Skip to content

Commit 5e8d775

Browse files
committed
Support for MinGW-2.0
[SVN r15719]
1 parent f4d4579 commit 5e8d775

File tree

12 files changed

+480
-1634
lines changed

12 files changed

+480
-1634
lines changed

include/boost/python/dict.hpp

Lines changed: 79 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -8,110 +8,126 @@
88

99
namespace boost { namespace python {
1010

11-
class dict : public object
11+
class dict;
12+
13+
namespace detail
1214
{
13-
public:
15+
struct BOOST_PYTHON_DECL dict_base : object
16+
{
17+
// D.clear() -> None. Remove all items from D.
18+
void clear();
19+
20+
// D.copy() -> a shallow copy of D
21+
dict copy();
22+
23+
// D.get(k[,d]) -> D[k] if D.has_key(k), else d. d defaults to None.
24+
object get(object_cref k) const;
25+
26+
object get(object_cref k, object_cref d) const;
27+
28+
// D.has_key(k) -> 1 if D has a key k, else 0
29+
bool has_key(object_cref k) const;
30+
31+
// D.items() -> list of D's (key, value) pairs, as 2-tuples
32+
list items() const;
33+
34+
// D.iteritems() -> an iterator over the (key, value) items of D
35+
object iteritems() const;
36+
37+
// D.iterkeys() -> an iterator over the keys of D
38+
object iterkeys() const;
39+
40+
// D.itervalues() -> an iterator over the values of D
41+
object itervalues() const;
42+
43+
// D.keys() -> list of D's keys
44+
list keys() const;
45+
46+
// D.popitem() -> (k, v), remove and return some (key, value) pair as a
47+
// 2-tuple; but raise KeyError if D is empty
48+
tuple popitem();
49+
50+
// D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if not D.has_key(k)
51+
object setdefault(object_cref k);
52+
53+
object setdefault(object_cref k, object_cref d);
54+
55+
// D.update(E) -> None. Update D from E: for k in E.keys(): D[k] = E[k]
56+
void update(object_cref E);
57+
58+
// D.values() -> list of D's values
59+
list values() const;
60+
61+
protected:
62+
// dict() -> new empty dictionary.
63+
// dict(mapping) -> new dictionary initialized from a mapping object's
64+
// (key, value) pairs.
65+
// dict(seq) -> new dictionary initialized as if via:
66+
dict_base(); // new dict
67+
explicit dict_base(object_cref data);
68+
69+
BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(dict_base, object)
70+
private:
71+
static detail::new_reference call(object const&);
72+
};
73+
}
74+
75+
class dict : public detail::dict_base
76+
{
77+
typedef detail::dict_base base;
78+
public:
1479
// dict() -> new empty dictionary.
1580
// dict(mapping) -> new dictionary initialized from a mapping object's
1681
// (key, value) pairs.
1782
// dict(seq) -> new dictionary initialized as if via:
18-
BOOST_PYTHON_DECL dict(); // new dict
19-
explicit BOOST_PYTHON_DECL dict(object_cref data);
83+
dict() {} // new dict
2084

2185
template <class T>
2286
explicit dict(T const& data)
23-
: object(dict::call(object(data)))
87+
: base(object(data))
2488
{
2589
}
2690

27-
// D.clear() -> None. Remove all items from D.
28-
BOOST_PYTHON_DECL void clear();
29-
30-
// D.copy() -> a shallow copy of D
31-
BOOST_PYTHON_DECL dict copy();
32-
33-
// D.get(k[,d]) -> D[k] if D.has_key(k), else d. d defaults to None.
34-
BOOST_PYTHON_DECL object get(object_cref k) const;
35-
3691
template<class T>
3792
object get(T const& k) const
3893
{
39-
return this->get(object(k));
94+
return base::get(object(k));
4095
}
4196

42-
BOOST_PYTHON_DECL object get(object_cref k, object_cref d) const;
43-
4497
template<class T1, class T2>
4598
object get(T1 const& k, T2 const& d) const
4699
{
47-
return this->get(object(k),object(d));
100+
return base::get(object(k),object(d));
48101
}
49-
50-
// D.has_key(k) -> 1 if D has a key k, else 0
51-
BOOST_PYTHON_DECL bool has_key(object_cref k) const;
52-
102+
53103
template<class T>
54104
bool has_key(T const& k) const
55105
{
56-
return this->has_key(object(k));
106+
return base::has_key(object(k));
57107
}
58-
59-
// D.items() -> list of D's (key, value) pairs, as 2-tuples
60-
BOOST_PYTHON_DECL list items() const;
61-
62-
// D.iteritems() -> an iterator over the (key, value) items of D
63-
BOOST_PYTHON_DECL object iteritems() const;
64-
65-
// D.iterkeys() -> an iterator over the keys of D
66-
BOOST_PYTHON_DECL object iterkeys() const;
67-
68-
// D.itervalues() -> an iterator over the values of D
69-
BOOST_PYTHON_DECL object itervalues() const;
70-
71-
// D.keys() -> list of D's keys
72-
BOOST_PYTHON_DECL list keys() const;
73-
74-
// D.popitem() -> (k, v), remove and return some (key, value) pair as a
75-
// 2-tuple; but raise KeyError if D is empty
76-
BOOST_PYTHON_DECL tuple popitem();
77-
78-
// D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if not D.has_key(k)
79-
BOOST_PYTHON_DECL object setdefault(object_cref k);
80-
108+
81109
template<class T>
82110
object setdefault(T const& k)
83111
{
84-
return this->setdefault(object(k));
112+
return base::setdefault(object(k));
85113
}
86-
87-
BOOST_PYTHON_DECL object setdefault(object_cref k, object_cref d);
88-
114+
89115
template<class T1, class T2>
90116
object setdefault(T1 const& k, T2 const& d)
91117
{
92-
return this->setdefault(object(k),object(d));
118+
return base::setdefault(object(k),object(d));
93119
}
94120

95-
// D.update(E) -> None. Update D from E: for k in E.keys(): D[k] = E[k]
96-
BOOST_PYTHON_DECL void update(object_cref E);
97-
98121
template<class T>
99122
void update(T const& E)
100123
{
101-
this->update(object(E));
124+
base::update(object(E));
102125
}
103126

104-
// D.values() -> list of D's values
105-
BOOST_PYTHON_DECL list values() const;
106-
107127
public: // implementation detail -- for internal use only
108-
BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(dict, object)
109-
110-
private:
111-
static BOOST_PYTHON_DECL detail::new_reference call(object const&);
128+
BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(dict, base)
112129
};
113130

114-
115131
//
116132
// Converter Specializations
117133
//

include/boost/python/list.hpp

Lines changed: 60 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,93 +11,116 @@
1111

1212
namespace boost { namespace python {
1313

14-
class list : public object
14+
namespace detail
1515
{
16+
struct BOOST_PYTHON_DECL list_base : object
17+
{
18+
void append(object_cref); // append object to end
19+
20+
long count(object_cref value) const; // return number of occurrences of value
21+
22+
void extend(object_cref sequence); // extend list by appending sequence elements
23+
24+
long index(object_cref value) const; // return index of first occurrence of value
25+
26+
void insert(int index, object_cref); // insert object before index
27+
void insert(object const& index, object_cref);
28+
29+
object pop(); // remove and return item at index (default last)
30+
object pop(long index);
31+
object pop(object const& index);
32+
33+
void remove(object_cref value); // remove first occurrence of value
34+
35+
void reverse(); // reverse *IN PLACE*
36+
37+
void sort(); // sort *IN PLACE*; if given, cmpfunc(x, y) -> -1, 0, 1
38+
void sort(object_cref cmpfunc);
39+
40+
41+
protected:
42+
list_base(); // new list
43+
explicit list_base(object_cref sequence); // new list initialized from sequence's items
44+
45+
BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(list_base, object)
46+
private:
47+
static detail::new_non_null_reference call(object const&);
48+
};
49+
}
50+
51+
class list : public detail::list_base
52+
{
53+
typedef detail::list_base base;
1654
public:
17-
BOOST_PYTHON_DECL list(); // new list
18-
explicit BOOST_PYTHON_DECL list(object_cref sequence); // new list initialized from sequence's items
55+
list() {} // new list
1956

2057
template <class T>
2158
explicit list(T const& sequence)
22-
: object(list::call(object(sequence)))
59+
: base(object(sequence))
2360
{
2461
}
2562

26-
BOOST_PYTHON_DECL void append(object_cref); // append object to end
27-
2863
template <class T>
2964
void append(T const& x)
3065
{
31-
this->append(object(x));
66+
base::append(object(x));
3267
}
3368

34-
BOOST_PYTHON_DECL long count(object_cref value) const; // return number of occurrences of value
35-
3669
template <class T>
3770
long count(T const& value) const
3871
{
39-
return this->count(object(value));
72+
return base::count(object(value));
4073
}
4174

42-
BOOST_PYTHON_DECL void extend(object_cref sequence); // extend list by appending sequence elements
43-
4475
template <class T>
4576
void extend(T const& x)
4677
{
47-
this->extend(object(x));
78+
base::extend(object(x));
4879
}
4980

50-
BOOST_PYTHON_DECL long index(object_cref value) const; // return index of first occurrence of value
51-
5281
template <class T>
5382
long index(T const& x) const
5483
{
55-
return this->index(object(x));
84+
return base::index(object(x));
5685
}
5786

58-
BOOST_PYTHON_DECL void insert(int index, object_cref); // insert object before index
59-
BOOST_PYTHON_DECL void insert(object const& index, object_cref);
60-
6187
template <class T>
6288
void insert(int index, T const& x) // insert object before index
6389
{
64-
this->insert(index, object(x));
90+
base::insert(index, object(x));
6591
}
6692

6793
template <class T>
6894
void insert(object const& index, T const& x) // insert object before index
6995
{
70-
this->insert(index, object(x));
96+
base::insert(index, object(x));
7197
}
72-
73-
BOOST_PYTHON_DECL object pop(); // remove and return item at index (default last)
74-
BOOST_PYTHON_DECL object pop(long index);
75-
BOOST_PYTHON_DECL object pop(object const& index);
7698

77-
BOOST_PYTHON_DECL void remove(object_cref value); // remove first occurrence of value
99+
object pop() { return base::pop(); }
100+
object pop(long index) { return base::pop(index); }
78101

79102
template <class T>
80-
void remove(T const& value)
103+
object pop(T const& index)
81104
{
82-
this->remove(object(value));
105+
return base::pop(object(index));
83106
}
84-
85-
BOOST_PYTHON_DECL void reverse(); // reverse *IN PLACE*
86107

87-
BOOST_PYTHON_DECL void sort(); // sort *IN PLACE*; if given, cmpfunc(x, y) -> -1, 0, 1
88-
BOOST_PYTHON_DECL void sort(object_cref cmpfunc);
108+
template <class T>
109+
void remove(T const& value)
110+
{
111+
base::remove(object(value));
112+
}
89113

114+
void sort() { base::sort(); }
115+
90116
template <class T>
91117
void sort(T const& value)
92118
{
93-
this->sort(object(value));
119+
base::sort(object(value));
94120
}
95121

96122
public: // implementation detail -- for internal use only
97-
BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(list, object)
98-
99-
private:
100-
static BOOST_PYTHON_DECL detail::new_non_null_reference call(object const&);
123+
BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(list, base)
101124
};
102125

103126
//

include/boost/python/long.hpp

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,43 @@
1111

1212
namespace boost { namespace python {
1313

14-
class long_ : public object
14+
namespace detail
1515
{
16+
struct BOOST_PYTHON_DECL long_base : object
17+
{
18+
protected:
19+
long_base(); // new long_
20+
explicit long_base(object_cref rhs);
21+
explicit long_base(object_cref rhs, object_cref base);
22+
23+
BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(long_base, object)
24+
25+
private:
26+
static detail::new_non_null_reference call(object const&);
27+
static detail::new_non_null_reference call(object const&, object const&);
28+
};
29+
}
30+
31+
class long_ : public detail::long_base
32+
{
33+
typedef detail::long_base base;
1634
public:
17-
BOOST_PYTHON_DECL long_(); // new long_
18-
explicit BOOST_PYTHON_DECL long_(object_cref rhs);
35+
long_() {} // new long_
1936

2037
template <class T>
2138
explicit long_(T const& rhs)
22-
: object(long_::call(object(rhs)))
39+
: base(object(rhs))
2340
{
2441
}
2542

26-
explicit BOOST_PYTHON_DECL long_(object_cref rhs, object_cref base);
27-
2843
template <class T, class U>
2944
explicit long_(T const& rhs, U const& base)
30-
: object(long_::call(object(rhs), object(base)))
45+
: base(object(rhs), object(base))
3146
{
3247
}
33-
public: // implementation detail -- for internal use only
34-
BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(long_, object)
3548

36-
private:
37-
static BOOST_PYTHON_DECL detail::new_non_null_reference call(object const&);
38-
static BOOST_PYTHON_DECL detail::new_non_null_reference call(object const&, object const&);
49+
public: // implementation detail -- for internal use only
50+
BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(long_, base)
3951
};
4052

4153
//

0 commit comments

Comments
 (0)