[C++-sig] Wrapping an abstract interface
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Sat Feb 14 18:30:16 CET 2004
--- Andreas Kloeckner <ak at ixion.net> wrote:
> This boils down to this: Can I make it appear from Python as if a class
> has a method for which no member function in C++ actually exists (but
> maybe just a regular function)?
Definitely yes. With 1.31.0 you can do this even with constructors.
Methods:
Your free function must take the wrapped type as the first argument:
void addl_method(wrapped_t const& self);
class_<wrapped_t>("wrapped_t")
.def("addl_method", addl_method)
;
Constructors:
See boost/libs/python/test/injected.cpp
Ralf
__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html
More information about the Cplusplus-sig
mailing list