From 6b96eca21bd358f48bf2d3ca54c218b04bf38958 Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Mon, 16 Sep 2002 03:01:35 +0000 Subject: [PATCH] Moved to python_v2_API_restructure branch [SVN r15354] --- test/Jamfile | 93 ---------------------------------- test/back_reference.cpp | 4 +- test/bienstman3.cpp | 2 +- test/bienstman4.cpp | 2 +- test/bienstman5.cpp | 2 +- test/callbacks.cpp | 4 +- test/cltree.cpp | 8 +-- test/data_members.cpp | 4 +- test/defaults.cpp | 16 ++---- test/docstring.cpp | 15 +++--- test/extract.cpp | 2 +- test/implicit.cpp | 2 +- test/list.cpp | 2 +- test/m1.cpp | 18 +++---- test/multi_arg_constructor.cpp | 2 +- test/nested.cpp | 4 +- test/operators.cpp | 4 +- test/pickle1.cpp | 2 +- test/pickle2.cpp | 2 +- test/pickle3.cpp | 2 +- test/test_pointer_adoption.cpp | 24 ++++----- test/virtual_functions.cpp | 6 +-- 22 files changed, 60 insertions(+), 160 deletions(-) diff --git a/test/Jamfile b/test/Jamfile index 511408e8..4ab9516d 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -54,98 +54,5 @@ rule bpl-test ( name ? : files * ) boost-python-runtest $(name) : $(py) $(modules) ; } -bpl-test enum ; -bpl-test minimal ; -bpl-test docstring ; -bpl-test exception_translator ; -bpl-test pearu1 : test_cltree.py cltree.cpp ; -bpl-test try : newtest.py m1.cpp m2.cpp ; -bpl-test builtin_converters : test_builtin_converters.py test_builtin_converters.cpp ; -bpl-test test_pointer_adoption ; -bpl-test operators ; -bpl-test callbacks ; bpl-test defaults ; -bpl-test object ; -bpl-test list ; -bpl-test long ; -bpl-test dict ; -bpl-test tuple ; -bpl-test str ; - -bpl-test virtual_functions ; -bpl-test back_reference ; -bpl-test implicit ; -bpl-test data_members ; - -bpl-test bienstman1 ; -bpl-test bienstman2 ; -bpl-test bienstman3 ; -bpl-test multi_arg_constructor ; -bpl-test iterator : iterator.py iterator.cpp input_iterator.cpp ; - -bpl-test extract ; - -bpl-test pickle1 ; -bpl-test pickle2 ; -bpl-test pickle3 ; - -bpl-test nested ; - -if $(TEST_BIENSTMAN_NON_BUGS) -{ - bpl-test bienstman4 ; - bpl-test bienstman5 ; -} - -# --- unit tests of library components --- - -local UNIT_TEST_PROPERTIES = - [ difference $(PYTHON_PROPERTIES) : BOOST_PYTHON_DYNAMIC_LIB ] BOOST_PYTHON_STATIC_LIB ; - -run indirect_traits_test.cpp ; -run destroy_test.cpp ; -run pointer_type_id_test.cpp ../../test/build/test_exec_monitor : : : $(UNIT_TEST_PROPERTIES) ; -run member_function_cast.cpp ; -run bases.cpp ; -run if_else.cpp ; -run pointee.cpp ; -run result.cpp ; - -compile string_literal.cpp ; -compile borrowed.cpp : $(UNIT_TEST_PROPERTIES) ; -compile object_manager.cpp : $(UNIT_TEST_PROPERTIES) ; - -run upcast.cpp ../../test/build/test_exec_monitor - : # command-line args - : # input files - : $(UNIT_TEST_PROPERTIES) - ; - -run select_holder.cpp ../../test/build/test_exec_monitor - : # command-line args - : # input files - : $(UNIT_TEST_PROPERTIES) - ; - - -run select_from_python_test.cpp ../src/converter/type_id.cpp ../../test/build/test_exec_monitor - : # command-line args - : # input files - : $(UNIT_TEST_PROPERTIES) - ; - -run select_arg_to_python_test.cpp ../src/converter/type_id.cpp ../../test/build/test_exec_monitor - : # command-line args - : # input files - : $(UNIT_TEST_PROPERTIES) - ; - -if $(TEST_EXPECTED_FAILURES) -{ - compile-fail ./raw_pyobject_fail1.cpp : $(PYTHON_PROPERTIES) ; - compile-fail ./raw_pyobject_fail2.cpp : $(PYTHON_PROPERTIES) ; - compile-fail ./object_fail1.cpp : $(PYTHON_PROPERTIES) ; -} - - diff --git a/test/back_reference.cpp b/test/back_reference.cpp index 73990640..d5ae5ece 100644 --- a/test/back_reference.cpp +++ b/test/back_reference.cpp @@ -93,12 +93,12 @@ BOOST_PYTHON_MODULE_INIT(back_reference_ext) def("copy_Z", copy_Z, return_value_policy()); def("x_instances", &X::count); - class_("Y", args()) + class_("Y", init()) .def("value", &Y::value) .def("set", &Y::set) ; - class_ >("Z", args()) + class_ >("Z", init()) .def("value", &Z::value) .def("set", &Z::set) ; diff --git a/test/bienstman3.cpp b/test/bienstman3.cpp index f1dc212d..22c7638e 100644 --- a/test/bienstman3.cpp +++ b/test/bienstman3.cpp @@ -17,6 +17,6 @@ BOOST_PYTHON_MODULE_INIT(bienstman3_ext) using namespace boost::python; class_("V", no_init); - class_("B", args()); + class_("B", init()); } diff --git a/test/bienstman4.cpp b/test/bienstman4.cpp index 324af85a..ee510f2d 100644 --- a/test/bienstman4.cpp +++ b/test/bienstman4.cpp @@ -30,7 +30,7 @@ BOOST_PYTHON_MODULE_INIT(bienstman4_ext) class_("T1") ; - class_("Term", args()) + class_("Term", init()) ; Type1 t1; diff --git a/test/bienstman5.cpp b/test/bienstman5.cpp index 007d12a9..75fbd8da 100644 --- a/test/bienstman5.cpp +++ b/test/bienstman5.cpp @@ -17,7 +17,7 @@ BOOST_PYTHON_MODULE_INIT(bienstman5_ext) { using namespace boost::python; - class_("M", args const&>()) + class_("M", init const&>()) ; } diff --git a/test/callbacks.cpp b/test/callbacks.cpp index 700c190a..763dcda8 100644 --- a/test/callbacks.cpp +++ b/test/callbacks.cpp @@ -137,8 +137,8 @@ BOOST_PYTHON_MODULE_INIT(callbacks_ext) def("apply_to_string_literal", apply_to_string_literal); - class_("X", args()) - .def_init(args()) + class_("X", init()) + .def(init()) .def("value", &X::value) .def("set", &X::set) ; diff --git a/test/cltree.cpp b/test/cltree.cpp index f7ea9eeb..8eb1f7f6 100755 --- a/test/cltree.cpp +++ b/test/cltree.cpp @@ -32,20 +32,20 @@ public: class symbol_wrapper: public symbol { public: - symbol_wrapper(PyObject* self): symbol() { - name = "cltree.wrapped_symbol"; + symbol_wrapper(PyObject* self): symbol() { + name = "cltree.wrapped_symbol"; } }; class variable_wrapper: public variable { public: - variable_wrapper(PyObject* self): variable() { + variable_wrapper(PyObject* self): variable() { name = "cltree.wrapped_variable"; } // This constructor is introduced only because cannot use // boost::noncopyable, see below. - variable_wrapper(PyObject* self,variable v): variable(v) {} + variable_wrapper(PyObject* self,variable v): variable(v) {} }; diff --git a/test/data_members.cpp b/test/data_members.cpp index 99459dff..7a05d359 100644 --- a/test/data_members.cpp +++ b/test/data_members.cpp @@ -22,14 +22,14 @@ double get_fair_value(X const& x) { return x.value(); } BOOST_PYTHON_MODULE_INIT(data_members_ext) { - class_("X", args()) + class_("X", init()) .def("value", &X::value) .def("set", &X::set) .def_readonly("x", &X::x) .add_property("fair_value", &get_fair_value) ; - class_("Y", args()) + class_("Y", init()) .def("value", &Y::value) .def("set", &Y::set) .def_readwrite("x", &Y::x) diff --git a/test/defaults.cpp b/test/defaults.cpp index 0f552666..41341e72 100644 --- a/test/defaults.cpp +++ b/test/defaults.cpp @@ -158,25 +158,17 @@ BOOST_PYTHON_MODULE_INIT(defaults_ext) .def("barfoo", (object(*)(int, char, std::string, double))0, bar_stubs()) ; - class_("Y", no_init) + class_("Y", init<>("doc of Y init")) // this should work .def("get_state", &Y::get_state) ; class_("X") -# if (!defined(BOOST_INTEL_CXX_VERSION) || BOOST_INTEL_CXX_VERSION > 600) - .def(init >()) - .def(init()) -# else - .def_init(args()) - .def_init(args()) - .def_init(args()) - .def_init(args()) - .def_init(args()) -# endif + .def(init >("doc of init")) + .def(init()[default_call_policies()]) // what's a good policy here? .def("get_state", &X::get_state) .def("bar", &X::bar, X_bar_stubs()) - .def("bar2", &X::bar2, X_bar_stubs2(), return_internal_reference<>()) + .def("bar2", &X::bar2, X_bar_stubs2("doc of X::bar2")[return_internal_reference<>()]) .def("foo", (object(X::*)(std::string, bool) const)0, X_foo_2_stubs()) .def("foo", (object(X::*)(int, bool) const)0, X_foo_2_stubs()) .def("foo", (object(X::*)(list, list, bool) const)0, X_foo_3_stubs()) diff --git a/test/docstring.cpp b/test/docstring.cpp index 01bacfba..417a6635 100644 --- a/test/docstring.cpp +++ b/test/docstring.cpp @@ -36,23 +36,24 @@ BOOST_PYTHON_MODULE_INIT(docstring_ext) "A simple test module for documentation strings\n" "Exercised by docstring.py" ; - + class_("X", "A simple class wrapper around a C++ int\n" "includes some error-checking" - - , args(), - "this is the __init__ function\n" - "its documentation has two lines." + + , init( + "this is the __init__ function\n" + "its documentation has two lines." + ) ) .def("value", &X::value, "gets the value of the object") ; - + def("create", create, return_value_policy(), "creates a new X object"); - + def("fact", fact, "compute the factorial"); } diff --git a/test/extract.cpp b/test/extract.cpp index 17640f2f..749f265a 100644 --- a/test/extract.cpp +++ b/test/extract.cpp @@ -124,7 +124,7 @@ BOOST_PYTHON_MODULE_INIT(extract_ext) ; object x_class( - class_("X", args()) + class_("X", init()) .def( "__repr__", x_rep)); // Instantiate an X object through the Python interface diff --git a/test/implicit.cpp b/test/implicit.cpp index cbf34027..2637f5ca 100644 --- a/test/implicit.cpp +++ b/test/implicit.cpp @@ -27,7 +27,7 @@ BOOST_PYTHON_MODULE_INIT(implicit_ext) def("x_value", x_value); def("make_x", make_x); - class_("X", args()) + class_("X", init()) .def("value", &X::value) .def("set", &X::set) ; diff --git a/test/list.cpp b/test/list.cpp index b3bce4a2..83ea063b 100644 --- a/test/list.cpp +++ b/test/list.cpp @@ -138,7 +138,7 @@ BOOST_PYTHON_MODULE_INIT(list_ext) def("exercise", exercise); - class_("X", args()) + class_("X", init()) .def( "__repr__", x_rep) ; } diff --git a/test/m1.cpp b/test/m1.cpp index f09e4a93..56ff4c19 100644 --- a/test/m1.cpp +++ b/test/m1.cpp @@ -96,7 +96,7 @@ PyObject* new_simple() // // Declare some wrappers/unwrappers to test the low-level conversion -// mechanism. +// mechanism. // using boost::python::to_python_converter; @@ -200,7 +200,7 @@ BOOST_PYTHON_MODULE_INIT(m1) { using namespace boost::python; using boost::shared_ptr; - + simple_to_python(); lvalue_from_pytype(); @@ -208,14 +208,14 @@ BOOST_PYTHON_MODULE_INIT(m1) lvalue_from_pytype< #if !defined(BOOST_MSVC) || BOOST_MSVC > 1300 // doesn't support non-type member pointer parameters extract_member -#else +#else extract_simple_object -#endif +#endif , &SimpleType >(); lvalue_from_pytype,&SimpleType>(); - + def("new_noddy", new_noddy); def("new_simple", new_simple); @@ -226,7 +226,7 @@ BOOST_PYTHON_MODULE_INIT(m1) def("f_const_ptr", f_const_ptr); def("f2", f2); - + // Expose g() def("g", g , return_value_policy() ); @@ -249,7 +249,7 @@ BOOST_PYTHON_MODULE_INIT(m1) class_, shared_ptr >("B") .def("name", &B::name) ; - + class_, shared_ptr >("C") .def("name", &C::name) ; @@ -259,8 +259,8 @@ BOOST_PYTHON_MODULE_INIT(m1) ; class_("complicated", - args()) - .def_init(args()) + init()) + .def(init()) .def("get_n", &complicated::get_n) ; } diff --git a/test/multi_arg_constructor.cpp b/test/multi_arg_constructor.cpp index 43e8bfb1..24bc4d9a 100644 --- a/test/multi_arg_constructor.cpp +++ b/test/multi_arg_constructor.cpp @@ -17,7 +17,7 @@ BOOST_PYTHON_MODULE_INIT(multi_arg_constructor_ext) class_ >( "A" - , args() + , init() ) ; diff --git a/test/nested.cpp b/test/nested.cpp index 9bc5be32..8cbe3d79 100644 --- a/test/nested.cpp +++ b/test/nested.cpp @@ -34,12 +34,12 @@ BOOST_PYTHON_MODULE_INIT(nested_ext) // Establish X as the current scope. scope x_class( - class_("X", args()) + class_("X", init()) .def(str(self)) ); // Y will now be defined in the current scope - class_("Y", args()) + class_("Y", init()) .def(str(self)) ; } diff --git a/test/operators.cpp b/test/operators.cpp index e21b5509..dc2313df 100755 --- a/test/operators.cpp +++ b/test/operators.cpp @@ -59,7 +59,7 @@ std::ostream& operator<<(std::ostream& s, X const& x) BOOST_PYTHON_MODULE_INIT(operators_ext) { - class_("X", args()) + class_("X", init()) .def("value", &X::value) .def(self - self) .def(self - int()) @@ -77,7 +77,7 @@ BOOST_PYTHON_MODULE_INIT(operators_ext) .def(pow(int(),self)) ; - class_ >("Z", args()) + class_ >("Z", init()) .def(int_(self)) .def(float_(self)) .def(complex_(self)) diff --git a/test/pickle1.cpp b/test/pickle1.cpp index e1397d60..1f9e5139 100644 --- a/test/pickle1.cpp +++ b/test/pickle1.cpp @@ -48,7 +48,7 @@ namespace { BOOST_PYTHON_MODULE_INIT(pickle1_ext) { using namespace boost::python; - class_("world", args()) + class_("world", init()) .def("greet", &world::greet) .def_pickle(world_pickle_suite()) ; diff --git a/test/pickle2.cpp b/test/pickle2.cpp index 984d6380..b8aacbd7 100644 --- a/test/pickle2.cpp +++ b/test/pickle2.cpp @@ -90,7 +90,7 @@ namespace { // Avoid cluttering the global namespace. BOOST_PYTHON_MODULE_INIT(pickle2_ext) { boost::python::class_( - "world", boost::python::args()) + "world", boost::python::init()) .def("greet", &world::greet) .def("get_secret_number", &world::get_secret_number) .def("set_secret_number", &world::set_secret_number) diff --git a/test/pickle3.cpp b/test/pickle3.cpp index 8911b24c..5fae9e6c 100644 --- a/test/pickle3.cpp +++ b/test/pickle3.cpp @@ -98,7 +98,7 @@ namespace { // Avoid cluttering the global namespace. BOOST_PYTHON_MODULE_INIT(pickle3_ext) { boost::python::class_( - "world", boost::python::args()) + "world", boost::python::init()) .def("greet", &world::greet) .def("get_secret_number", &world::get_secret_number) .def("set_secret_number", &world::set_secret_number) diff --git a/test/test_pointer_adoption.cpp b/test/test_pointer_adoption.cpp index b04e3496..90b39ea7 100644 --- a/test/test_pointer_adoption.cpp +++ b/test/test_pointer_adoption.cpp @@ -26,7 +26,7 @@ struct inner { this->s = new_s; } - + std::string s; }; @@ -42,7 +42,7 @@ struct A : Base { ++a_instances; } - + ~A() { --a_instances; @@ -65,7 +65,7 @@ struct B { B() : x(0) {} B(A* x_) : x(x_) {} - + inner const* adopt(A* x) { this->x = x; return &x->get_inner(); } std::string a_content() @@ -96,29 +96,29 @@ BOOST_PYTHON_MODULE_INIT(test_pointer_adoption_ext) def("create", create, return_value_policy()); def("as_A", as_A, return_internal_reference<>()); - + class_("Base") ; - - class_ >(no_init) + + class_ >("A", no_init) .def("content", &A::content) .def("get_inner", &A::get_inner, return_internal_reference<>()) ; - - class_(no_init) + + class_("inner", no_init) .def("change", &inner::change) ; - + class_("B") - .def_init(args(), with_custodian_and_ward_postcall<1,2>()) - + .def(init()[with_custodian_and_ward_postcall<1,2>()]) + .def("adopt", &B::adopt // Adopt returns a pointer referring to a subobject of its 2nd argument (1st being "self") , return_internal_reference<2 // Meanwhile, self holds a reference to the 2nd argument. , with_custodian_and_ward<1,2> >() ) - + .def("a_content", &B::a_content) ; } diff --git a/test/virtual_functions.cpp b/test/virtual_functions.cpp index 73d47dc5..f0bfd787 100644 --- a/test/virtual_functions.cpp +++ b/test/virtual_functions.cpp @@ -89,7 +89,7 @@ int X::counter; BOOST_PYTHON_MODULE_INIT(virtual_functions_ext) { - class_("concrete", args()) + class_("concrete", init()) .def("value", &concrete::value) .def("set", &concrete::set) .def("call_f", &concrete::call_f) @@ -97,14 +97,14 @@ BOOST_PYTHON_MODULE_INIT(virtual_functions_ext) ; class_ - >("abstract", args()) + >("abstract", init()) .def("value", &abstract::value) .def("call_f", &abstract::call_f) .def("set", &abstract::set) ; - class_("Y", args()) + class_("Y", init()) .def("value", &Y::value) .def("set", &Y::set) ;