[C++-sig] Manipulating arguments with CallPolicies::precall?
Arve Knudsen
aknuds-1 at broadpark.no
Sun Jan 25 19:39:12 CET 2004
Hi
I want to wrap a native C Python object in a C++ object that takes care of
constructing and destructing it properly (there isn't any way to specify
custom allocation/deallocation routines are there?). However, I would like
to send this object directly to the associated routines (its part of an
existing Python extension). I haven't found any direct support for this
kind of thing within boost::python, since everything seems strongly tied
to the contained type (my wrapping C++ class). But, I figured it might be
possible to manipulate the Python argument tuple within
CallPolicies::precall?
So I experimented a little and it seems I am able to change the first
argument to point to the contained C object, instead of it's wrapper. But,
when the function (which takes a pointer to one such C object) receives
the object something is not right. A member which was initialized to zero
(verified within caller.hpp), now contains some other number. I suppose
some conversion magic goes wrong? I've tried to figure out what's going on
myself, but gdb tends to die on me in the process (no pun intended). It'd
be great if someone could enlighten me as to why this won't work (fingers
crossed), or perhaps present a better solution :)
Btw, I'm getting lots of warnings building boost::python from CVS (this is
on Linux with GCC 3.3.2 and Python 2.3), because of this:
/usr/include/python2.3/pyconfig.h:847:1: warning: "_POSIX_C_SOURCE"
redefined. Is Python 2.3 to blame? I dont think I ever saw this warning
with boost 1.30.2, though.
Thanks
Arve Knudsen
More information about the Cplusplus-sig
mailing list