Hi,

I have the following code:

-------------------------------------------------------------------------------
#include <boost/python.hpp>
#include <iostream>

class Foo
{
public:
    Foo() {} ;
    static void doit(const char * message) {
        std::cout << "doing it statically: " << message << "\n";
    };
    void nonstatic_doit(const char *message) {
        std::cout << "doing it nonstatically: " << message << "\n";
    };
};

using namespace boost::python;

BOOST_PYTHON_MODULE(foo)
{
    class_<Foo>("Foo",init<>())
    .def("doit", &Foo::doit)
    .def("nonstatic_doit", &Foo::nonstatic_doit)
    ;
}
-------------------------------------------------------------------------------

When I try out my foo module, I see this:

In [1]: from foo import Foo

In [2]: f = Foo()

In [3]: f.nonstatic_doit("hello")
doing it nonstatically: hello

In [4]: f.doit("hello")
---------------------------------------------------------------------------
ArgumentError                             Traceback (most recent call last)

/home/amundson/work/synergia2-devel_1_0/build/synergia2/components/foundation/<ipython console> in <module>()

ArgumentError: Python argument types in
    Foo.doit(Foo, str)
did not match C++ signature:
    doit(char const*)


-------------------------------------------------------------------------------

How can I wrap doit?

Thanks,
Jim Amundson

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to