Looks perfect, thanks much. On Tue, Jan 12, 2010 at 2:01 PM, troy d. straszheim <t...@resophonic.com>wrote:
> Charles Solar wrote: > >> Well I want to define the overloads myself anyway, I just do not know how >> to properly setup the small wrapper that will work. In the doc it tells you >> how to make flat function wrappers, but nothing on member function wrappers. >> I am unsure how I am supposed to handle the this pointer, for example. >> So idealy what I would like to know is what the macro does so I can >> manually write out the wrappers myself. >> >> And I have tried using Py++, it does not handle the default argument, it >> just puts the call in there and python still requires the param to be there. >> >> > Personally I hate that overload-wrapping macro thing. Here's one way to do > it: > > struct T > { > void bar(int i) { cout << "bar(" << i << ")\n"; } > void bar() { cout << "bar\n"; } > }; > > // > // use 'self' for 'this' for the sake of pythonicism > // > void bar_int (T* self, int i) { self->bar(i); } > void bar_void(T* self) { self->bar(); } > > BOOST_PYTHON_MODULE(foop) > { > class_<T>("T") > .def("bar", bar_int) > .def("bar", bar_void) > ; > } > > -t > > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig@python.org > http://mail.python.org/mailman/listinfo/cplusplus-sig >
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig