[C++-sig] Re: creating an instance of a class_<> object in c++ and exporting it to python
dique
chezdique at yahoo.com
Tue Aug 17 04:26:20 CEST 2004
I think my sample code illustrates exactly what you want. Perhaps you should compile and run it?
The reason that I use ObjectWrap as the HeldType is because you can't do object(a) for a raw
pointer 'a', but you can do object(objectWrapOfA) where objectWrapOfA = ObjectWrap(a).
By the way, your code should work if you make a few changes.
>
> PythonTypeA.def("A", &A::dummy);
>
should be PythonTypeA.def("dummy", &A::dummy);
> object python_object_a = (*PythonTypeAPtr)(2); // <<<<<<==========
remove the above line
>
> python_object_a = py_get_existing();
>
Just need to do this:
object python_object_a = py_get_existing();
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail
More information about the Cplusplus-sig
mailing list