[prev in list] [next in list] [prev in thread] [next in thread]
List: python-cpp-sig
Subject: [C++-sig] Re: C++ object from PyObject pointer
From: c++-sig () python ! org (David Abrahams)
Date: 2003-02-24 22:03:23
Message-ID: uptphgwus.fsf () boost-consulting ! com
[Download RAW message or body]
The following message is a courtesy copy of an article
that has been posted to gmane.comp.lib.boost.user as well.
"mghiggins <mghiggins@yahoo.com>" <mghiggins@yahoo.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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic