// Copyright David Abrahams 2002. Permission to copy, use, // modify, sell and distribute this software is granted provided this // copyright notice appears in all copies. This software is provided // "as is" without express or implied warranty, and with no claim as // to its suitability for any purpose. #include #include #include #if defined(_AIX) && defined(__EDG_VERSION__) && __EDG_VERSION__ < 245 # include // works around a KCC intermediate code generation bug #endif using namespace boost::python; using namespace std; /////////////////////////////////////////////////////////////////////////////// std::string foo(int a, char b = 'D', std::string c = "default", double d = 0.0) { std::stringstream stream; stream << "int(" << a << "); "; stream << "char(" << b << "); "; stream << "string(" << c << "); "; stream << "double(" << d << "); "; return stream.str(); } BOOST_PYTHON_FUNCTION_GEN(foo_stubs, foo, 1, 4) /////////////////////////////////////////////////////////////////////////////// struct X { std::string bar(int a, char b = 'D', std::string c = "default", double d = 0.0) const { std::stringstream stream; stream << "int(" << a << "); "; stream << "char(" << b << "); "; stream << "string(" << c << "); "; stream << "double(" << d << "); "; return stream.str(); } }; BOOST_PYTHON_MEMBER_FUNCTION_GEN(X_bar_stubs, bar, 1, 4) /////////////////////////////////////////////////////////////////////////////// BOOST_PYTHON_MODULE_INIT(defaults_ext) { module m("defaults_ext"); m.def(foo_stubs(), signature()); class_ xc("X"); m.add(xc); xc.def_init(); xc.def(X_bar_stubs(), signature()); } #include "module_tail.cpp"