Revision 3 as of 2008-12-05 11:03:41

Clear message

From http://www.boost.org/doc/libs/1_37_0/libs/python/doc/v2/overloads.html

Few methods and functions have parameters by default.

To send this information to boost::python, you need to call theses instructions :

BOOST_PYTHON_FUNCTION_OVERLOADS( overloadsname , functionname , arg_minimum, arg_maximum ) BOOST_PYTHON_FUNCTION_OVERLOADS( overloadsname , classname::staticmethodname , arg_minimum, arg_maximum )

For global functions and for static methods.

BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS( overloadsname , classname::methodname, arg_minimum, arg_maximum )

For class methods.

Sample :

#include <boost/python/module.hpp> #include <boost/python/def.hpp> #include <boost/python/args.hpp> #include <boost/python/tuple.hpp> #include <boost/python/class.hpp> #include <boost/python/overloads.hpp> #include <boost/python/return_internal_reference.hpp>

using namespace boost::python;

tuple f(int x = 1, double y = 4.25, char const* z = "wow") {

}

BOOST_PYTHON_FUNCTION_OVERLOADS(f_overloads, f, 0, 3)

class X {

};

BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(X_returnsame_overloads, X::returnsame, 0, 1) BOOST_PYTHON_FUNCTION_OVERLOADS(X_returnsum_overloads, X::returnsum, 1, 2)

BOOST_PYTHON_MODULE(args_ext) {

}

Unable to edit the page? See the FrontPage for instructions.