[C++-sig] Re: C++ object from PyObject pointer
by David Abrahams other posts by this author
Feb 24 2003 10:03PM messages near this date
[C++-sig] Re: boost.python answer - thanks!
|
[C++-sig] Re : How to wrap this overloaded member function whose return type is reference ?
The following message is a courtesy copy of an article
that has been posted to gmane.comp.lib.boost.user as well.
"mghiggins <mghiggins@[...].com> " <mghiggins@[...].com> writes:
> Excuse my newbiness if this question is too dumb... :)
>
> I've built a python extension from a C++ class using boost - it all
> seems to work fine.
>
> However, now another C++ function is receiving a pointer to a PyObject
> that represents an instance of this "boosted" python class. How do I
> pick off a pointer to the underlying C++ object from the PyObject
> pointer?
Boost.Python questions to the c++-sig, please!
http://www.python.org/sigs/c++-sig/
Your answer:
void f(PyObject* p)
{
handle<> ph(borrowed(p));
MyObj* op = extract<MyObj*> (object(ph));
}
HTH,
Dave
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
_______________________________________________
C++-sig mailing list
C++-sig@[...].org
http://mail.python.org/mailman/listinfo/c++-sig
|