I have the following situation: I am creating a python wrapping of a few functions in a library, for which I am at present using the -builtin option for the performance benefits it offers.
Because there is some lengthy and repetitive marshalling of inputs and outputs in these typemaps, I have separated out that marshalling into functions defined in fragments. In some of those (output) functions, I have a returned instance of a struct that has a corresponding SWIG wrapping, but which I need to directly convert to a Python object using SWIG_NewPointerObj (because I need to pass the Python wrapping of this struct to a call of the constructor of another object, and that constructor is defined only in Python).
It seems that the -builtin option does not play nicely with SWIG_NewPointerObj when the latter is called in a fragment, because when SWIGPYTHON_BUILTIN is defined, SWIG_NewPointerObj(ptr,type,flags) is defined to be a call to SWIG_Python_NewPointerObj(self,ptr,type,flags) (in all other cases the first argument is defined to be NULL rather than self). Inside of a fragment "self" is not defined, so the wrapper will not compile.
As far as I can tell, were SWIG_NewPointerObj called directly inside of a wrapped function, then "self" would be the first argument to the wrapped function, which is---I think---a pointer to the function itself? If that is not, then what does "self" point to in that case? Should I be trying to get some handle to that argument, and passing it on to my fragment function? If so, is there a special variable for that (in particular, I wasn't sure if that's what $self would be converted to) that I can access inside typemaps?
Irrespective of these questions, I guess I would also appreciate if some expert could explain what SWIG_NewPointerObj() is doing with its first argument; I am unfamiliar with the internals of the runtime type-checking system and couldn't easily tell from the source code why it needs it, but only when -builtin is specified. I think a better understanding of that would help me figure out what I can be using for that first argument.
Get latest updates about Open Source Projects, Conferences and News.