From: Mathieu M. <mat...@gm...> - 2008-12-11 12:37:57
|
On Thu, Dec 11, 2008 at 7:35 AM, Antti Karanta <ant...@na...> wrote: > > On Wed, 10 Dec 2008 12:21:06 +0200, Mathieu Malaterre > <mathieu.malaterre@xxxx> wrote: > >> I would like to wrap something like this in C#: >> >> const double *get6() >> { >> static const double bla[6] = {}; >> return bla; >> } >> >> I would like to tell the wrapped layer that this is an array of 6 >> elements (no more, no less). >> >> Could someone please point me to the documentation for this. All I can >> find is something related to python (not C#). > > Arrays are supported in swig svn head. If you want to use the current > release you have to make your own typemaps (or copy paste from svn head. > Note that the FIXED typemaps won't work on curren't swig release). > > See documentation about handling arrays > https://swig.svn.sourceforge.net/svnroot/swig/trunk/Doc/Manual/CSharp.html > and the typemaps > https://swig.svn.sourceforge.net/svnroot/swig/trunk/Lib/csharp/arrays_csharp.i > > There's support only for array parameters, though. If you need support > for array return values, I think you have to roll your own typemaps. > > Or, you can write a simple wrapper function that copies the content of > the returned array to a parameter array, e.g. > > void get6_helper( double* bla ) { > double originals = get6() ; > memcpy( bla, originals, 6 * sizeof( double ) ) ; > } > > and wrap that using the provided typemaps. The svnroot link did not work for me (HTML would not be rendered) instead I had to use: http://swig.svn.sourceforge.net/viewvc/swig/trunk/Doc/Manual/CSharp.html Anyway thanks for the link, but I still do not see how to remap the function parameter as a return arg in the C# later. I would like to use the get6() function in C# (for consistency in the different wrapped language): uint[] out = get6(); Thanks again ! -- Mathieu |