logo       

custom function/return type: msg#00118

programming.swig

Subject: custom function/return type

Hi

First I must say that SWIG really rocks, because... it does. :-)

I have a little question regarding the interface file: Is it possible to have a function returning a value of variable type? e.g. an integer at one time, and maybe a string another time.

I've tried looking around in the documentation about typemaps and such. However, it doesn't seem to be applicable to my conundrum, as the bottom line is that it is still a wrapping of a C function, which can only have one return type.

So I'm thinking is it possible to add a totally custom function, that will be included in the wrapped module, to the interface file? The thing is that I already have written such a function while I was trying to wrap my C++ classes without SWIG (it has the PyCFunction signature). Can this function be used in some way in the SWIG-wrapped module? That possibility would be the most simple one, although maybe not the nicest one.

I guess one alternative is to write specific C functions for all possible return types of the function and then add a python wrapper using %pythoncode, but I'd prefer it some other way.

Any hints on how this can be accomplished?


/André

_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise