ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> cpp-sig
cpp-sig
[C++-sig] How do I wrap a static member function?
by James Amundson other posts by this author
Oct 30 2009 2:47PM messages near this date
Re: [C++-sig] cannot find -lboost_python after upgrade to Ubuntu 9.10 | Re: [C++-sig] How do I wrap a static member function?
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@[...].org
http://mail.python.org/mailman/listinfo/cplusplus-sig
Thread:
James Amundson
Ravi
James Amundson

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved