On 1/25/2013 3:17 AM, oukrid nabil wrote:

Hello everybody,


I am currently facing a problem to wrap a function which prototype is as follows:

extern int SPOTDecryptFN(               /* Description */
       char* sModeleFN,                            /*:INPUT: Name of the model*/
       unsigned char ucKey[V_KEYLEN],   /*:INPUT: Key */
       char*** pasTabChainesFN,                 /*:OUTPUT: each line of the model */
       int*  iNbLgnRemplies,                       /*:OUTPUT: Number of lines of the array *pasTabChainesFN which are filled */
       char  c512ErrorMsg[512]                  /*:OUTPUT: Error message   */ );


Actually, I want to return in python the three outputs of the function, but I have some difficulties to return the "pasTabChainesFN" argument.

I tried to use a [typemap(out) char***] method in the interface file, but it didn'r work.


Thanks for your help,

Hello, Nabil.

The typemaps are only going to work on values that are visibly returned/provided in the exchange.  That would work if the 'char ***' were the return type of the function SPOTDecryptFN(), but it is returning an int.

For function arguments, you have to do something a bit more complicated and actually declare them as outputs to be processed.  Have a look at the "argout" type of typemap in the SWIG docs (should be somewhere near the 10.5.7 entry).  You'll need something like:

    %typemap(argout) char***
pasTabChainesFN {
        // convert char*** to something the target language understands
        ...
    }

(Just an unrelated observation:  if the first two arguments to
SPOTDecryptFN() are input-only, the really should be prefaced with "const" to indicate that.)