|
From: Andrew M. <and...@db...> - 2007-09-25 15:35:03
|
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....
> > -----Original Message-----
> > I am using SWIG to wrap a closed-source third-party API. One of the
> > routines in the API returns a block of bytes read from a binary file.
In
> > C
> > the routine that does this returns a char* (and a length as well). I
> > have
> > written a little C wrapper around the API so that I can have a simple
> > header that can be SWIG'd. My routine also returns a char*. The
> > SWIG-generated code treats this as a string and uses the java String
> > type.
> > How do I make it use a byte array instead please?
Regards,
Andrew Marlow
----
There is an emerald here the size of a plover's egg!
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
---
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional EU corporate and regulatory disclosures.
|