Skip to content

Commit 604928a

Browse files
committed
new API changes
[SVN r15344]
1 parent 4a67625 commit 604928a

File tree

2 files changed

+50
-8
lines changed

2 files changed

+50
-8
lines changed

test/defaults.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,25 +158,25 @@ BOOST_PYTHON_MODULE_INIT(defaults_ext)
158158
.def("barfoo", (object(*)(int, char, std::string, double))0, bar_stubs())
159159
;
160160

161-
class_<Y>("Y", no_init)
161+
class_<Y>("Y", init<>("doc of Y init")) // this should work
162162
.def("get_state", &Y::get_state)
163163
;
164164

165165
class_<X>("X")
166166

167167
# if (!defined(BOOST_INTEL_CXX_VERSION) || BOOST_INTEL_CXX_VERSION > 600)
168-
.def(init<int, optional<char, std::string, double> >())
169-
.def(init<std::string, bool>())
168+
.def(init<int, optional<char, std::string, double> >("doc of init"))
169+
.def(init<std::string, bool>()[default_call_policies()]) // what's a good policy here?
170170
# else
171-
.def_init(args<int>())
172-
.def_init(args<int, char>())
173-
.def_init(args<int, char, std::string>())
174-
.def_init(args<int, char, std::string, double>())
171+
.def_init(args<int>(), "doc of init")
172+
.def_init(args<int, char>(), "doc of init")
173+
.def_init(args<int, char, std::string>(), "doc of init")
174+
.def_init(args<int, char, std::string, double>(), "doc of init")
175175
.def_init(args<std::string, bool>())
176176
# endif
177177
.def("get_state", &X::get_state)
178178
.def("bar", &X::bar, X_bar_stubs())
179-
.def("bar2", &X::bar2, X_bar_stubs2(), return_internal_reference<>())
179+
.def("bar2", &X::bar2, X_bar_stubs2("doc of X::bar2")[return_internal_reference<>()])
180180
.def("foo", (object(X::*)(std::string, bool) const)0, X_foo_2_stubs())
181181
.def("foo", (object(X::*)(int, bool) const)0, X_foo_2_stubs())
182182
.def("foo", (object(X::*)(list, list, bool) const)0, X_foo_3_stubs())

test/defaults.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,73 +3,115 @@
33
>>> from defaults_ext import *
44
>>> bar(1)
55
'int(1); char(D); string(default); double(0.0); '
6+
67
>>> bar(2, 'X')
78
'int(2); char(X); string(default); double(0.0); '
9+
810
>>> bar(3, 'Y', "Hello World")
911
'int(3); char(Y); string(Hello World); double(0.0); '
12+
1013
>>> bar(4, 'Z', "Hi There", 3.3)
1114
'int(4); char(Z); string(Hi There); double(3.3); '
15+
1216
>>> foo(1)
1317
'int(1); char(D); string(default); double(0.0); '
18+
1419
>>> foo(2, 'X')
1520
'int(2); char(X); string(default); double(0.0); '
21+
1622
>>> foo(3, 'Y', "Hello World")
1723
'int(3); char(Y); string(Hello World); double(0.0); '
24+
1825
>>> foo(4, 'Z', "Hi There", 3.3)
1926
'int(4); char(Z); string(Hi There); double(3.3); '
27+
2028
>>> x = X()
2129
>>> x.bar(1)
2230
'int(1); char(D); string(default); double(0.0); '
31+
2332
>>> x.bar(2, 'X')
2433
'int(2); char(X); string(default); double(0.0); '
34+
2535
>>> x.bar(3, 'Y', "Hello World")
2636
'int(3); char(Y); string(Hello World); double(0.0); '
37+
2738
>>> x.bar(4, 'Z', "Hi There", 3.3)
2839
'int(4); char(Z); string(Hi There); double(3.3); '
40+
2941
>>> x.foo(5)
3042
'int(5); bool(0); '
43+
3144
>>> x.foo(6, 0)
3245
'int(6); bool(0); '
46+
3347
>>> x.foo(7, 1)
3448
'int(7); bool(1); '
49+
3550
>>> x.foo("A")
3651
'string(A); bool(0); '
52+
3753
>>> x.foo("B", False)
3854
'string(B); bool(0); '
55+
3956
>>> x.foo("C", True)
4057
'string(C); bool(1); '
58+
4159
>>> x.foo([0,1,2], [2,3,4])
4260
'list([0, 1, 2]); list([2, 3, 4]); bool(0); '
61+
4362
>>> x.foo([0,1,2], [2,3,4], False)
4463
'list([0, 1, 2]); list([2, 3, 4]); bool(0); '
64+
4565
>>> x.foo([0,1,2], [2,3,4], True)
4666
'list([0, 1, 2]); list([2, 3, 4]); bool(1); '
67+
4768
>>> x = X(1)
4869
>>> x.get_state()
4970
'int(1); char(D); string(constructor); double(0.0); '
71+
5072
>>> x = X(1, 'X')
5173
>>> x.get_state()
5274
'int(1); char(X); string(constructor); double(0.0); '
75+
5376
>>> x = X(1, 'X', "Yabadabadoo")
5477
>>> x.get_state()
5578
'int(1); char(X); string(Yabadabadoo); double(0.0); '
79+
5680
>>> x = X(1, 'X', "Phoenix", 3.65)
5781
>>> x.get_state()
5882
'int(1); char(X); string(Phoenix); double(3.65); '
83+
5984
>>> x.bar2().get_state()
6085
'int(0); char(D); string(default); double(0.0); '
86+
6187
>>> x.bar2(1).get_state()
6288
'int(1); char(D); string(default); double(0.0); '
89+
6390
>>> x.bar2(1, 'K').get_state()
6491
'int(1); char(K); string(default); double(0.0); '
92+
6593
>>> x.bar2(1, 'K', "Kim").get_state()
6694
'int(1); char(K); string(Kim); double(0.0); '
95+
6796
>>> x.bar2(1, 'K', "Kim", 9.9).get_state()
6897
'int(1); char(K); string(Kim); double(9.9); '
98+
6999
>>> x = X("Phoenix", 1)
70100
>>> x.get_state()
71101
'Got exactly two arguments from constructor: string(Phoenix); bool(1); '
72102
103+
>>> def printdoc(x):
104+
... print x.__doc__
105+
106+
>>> printdoc(X.__init__)
107+
doc of init
108+
109+
>>> printdoc(Y.__init__)
110+
doc of Y init
111+
112+
>>> printdoc(X.bar2)
113+
doc of X::bar2
114+
73115
"""
74116
def run(args = None):
75117
import sys

0 commit comments

Comments
 (0)