[C++-sig] How to create and return a new instance of a Python Exported C++ class.
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Fri May 23 22:56:42 CEST 2003
--- pj <pjdurai at hotmail.com> wrote:
> class BB
> {
> GetMeAA ( )
> {
> // When called from python this needs to create and return a
> Python-AA object.
> }
> };
>
>
> How would I write this member function, and how would I export it ?
> I suspect I am missing something rudimentary. But no clue yet to what.
Unless I am missing something: it is all automatic. Just make your member
function complete:
AA GetMeAA() { return AA(); }
Then
class_<BB>("BB", ...)
.def("GetMeAA", &BB::GetMeAA)
;
Boost.Python generates all the wrapping/unwrapping code for you. You don't have
to think about it unless you are dealing with raw pointers or want to avoid
using AA's copy constructor.
Ralf
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
More information about the Cplusplus-sig
mailing list