|
From: William S F. <ws...@fu...> - 2007-09-25 22:11:07
|
Andrew Marlow wrote:
> swi...@li... wrote on 25/09/2007 15:24:10:
>> "Navnidhi Sharma" <Nav...@us...> wrote on 25/09/2007
>> 15:04:52:
>>
>>> Use vector of chars in your wrapper.
>> My C wrapper does return a vector of chars. The return type is char*.
>
> I am part of the way there now. I found out that if I say:
>
> %include "various.i"
> %apply (char* BYTE) {char*data};
>
> it does use byte[] instead of String.
> However, I am still missing a piece of the puzzle. I also found that when
> I say getData() to get the byte[] data the length member is set to some
> infeasible value, probably uninitialised. I can't say I am suprised
> because I can't see how SWIG is supposed to know how big this array is. I
> know because there is another variable in the C API that tells me. But how
> do I use this to tell SWIG? It's a mystery to me....
>
The char *BYTE typemaps in various.i are input only typemaps. If you
want to marshal char * with byte[], then you need to add the missing
typemaps for marshalling return types, namely javaout and out. You can
get some ideas for this from arrays_java.i.
William
|