[C++-sig] RE: passing Boost wrapped classes (refs and/or pointers) to/from Python and C++

Mike Dickheiser miked at sinistergames.com
Mon Jun 10 21:02:30 CEST 2002


I'm starting to feel a bit like Alice in Boostland ;)

I entered the world of boost through
http://www.boost.org/libs/python/doc/index.html, and read through all the
documentation available on that page (items 1 - 15 in the table of
contents). Nowehere in that documentation did I see discussion on how to
call a Python function from C++, and so I assumed that I had to use the
standard method of:

PyObject* pValue = PyObject_CallObject(pPythonFunc, pArgs);

What I wanted to know was how to pass/pack/put-in/convert a Vector3 into
pArgs (assuming Vector3 has been wrapped by Boost v1). I know how to put
integers, floats, strings and other basic types into "pArgs", but not custom
types like my Vector3. I also needed to know how to get a Vector3 out of
pValue, assuming that's what the called python function returns.

I looked into the usual Py_BuildValue stuff and tuple-packing, but still had
no clue, which led me to seek answers at the SIG.

Now I see in your response a reference to

boost::python::callback<ResultType>::call(arg1, arg2, arg3...);

This is something I haven't seen before at all in any of the documents at
the previously mentioned address, but looks a lot like what I need. Where
can I find the documentation that includes this? I'm assuming I can find v1
docs at the sourceforge.net address you gave, but if that's incorrect please
let me know.

Thanks again,
Mike










More information about the Cplusplus-sig mailing list