From: Gibbs, S. <Sol...@sr...> - 2008-01-10 19:28:39
|
I'm sorry my suggestions didn't work out for you. I hoped that they would be enough to get you started and you'd be able to fill in the pieces I missed or got wrong.=20 > // From newsgroup > %typemap(in) struct** STRUCTIN ($&1_type tmp){ > //**** fixup **** > // $&1_type tmp defines a variable tmp with the type of=20 > pointer to $1 > // $input is the input of the typemap/wrapper function. > tmp =3D $input; >=20 > // $1 will be the arguement to the C code. > $1 =3D *tmp; > } > %apply struct** STRUCTIN {SwigSimpleStruct_t** here} >=20 > %include "SwigSimpleStruct.h" >=20 > In fact, it would appear that the typemap is never even=20 > applied. If it were, wouldn't the string '//**** fixup ****'=20 > be inserted somewhere inside SwigSimpleStruct_wrap.c? No string there. >=20 > So what's STRUCTIN? A special variable like INPUT and OUTPUT?=20 > Where does it come from? What is it? Is it documented=20 > anywhere? Does the typemap create it (my guess)?=20 The typemap directive creates a map that matches the fake type struct** with name STRUCTIN. It is totally specific to the code that's being written here. It has nothing to do with swig internals. > What's=20 > %apply do? Why do I have to apply to SwigSimpleStruct_t**.=20 > Why 'here', because the matching is syntactic on the C=20 > function declaration? What if I want this transformation applied > *only* for the C function SwigSimpleStructCreateHere()? How=20 > do I state that? The %apply directive tells swig to apply the STUCTIN map for type struct** to SwigSimpleStruct_t** parametres named "here". So, yes, it matches the C function declaration. You could define the typemap with the types for the C function directly too. My preference is to use the %apply directive; I think it makes the swig interface module easier to read by explicitly specifying which typemap is used. If you wanted the typemap applied only to that specific C function, I would start by moving away from importing the C header file into the swig module. Copy and paste the declarations. Then you can either rename the variable you want the typemap applied to to something unique or put the %apply directive just before the declaration it's to be applied to and put a %clear directive just after the declaration. http://swig.sourceforge.net/Doc1.3/Typemaps.html#Typemaps_nn48 =20 |