From: William S F. <ws...@fu...> - 2010-08-17 23:29:57
|
Arnleif Bjørstad wrote: > Hi > > > > Using MS Visual Studio 2008, I have set up a solution project like those > in Swig examples for C#. My test application loads the dll, but so far I > only can get the application to report its version number, that is > returning an integer. > > > > I understand that I need to do some extra work because SWIG cant know > what is input, output, or both input/output. > > > > One example is: > > > > short LC_OpenSos(const char *fil,short sModus,short sNyIdx,short > sVisStatus,LC_FILADM **ppFil, short *o_stat); > > > > It is the last 2 arguments that gives me trouble. They are both > out-parameters. > > > > LC_FILADM **ppFil (pointer to a struct) > > short *o_stat > > > > Reading about typemaps and looking into the typemaps.i file I have tried > to correctly wrap the pointer “o_stat”. > > In a preliminary test I did add a proxy function to the c++ program to > reduse the pointer **ppFil to *pFil and the interface file looks like this: > > > > /* File : Fyba.i */ > > %module FybaSharpTest > > > > %{ > > #include "fyba.h" > > #include "stdafx.h" > > #include "Prox.h" > > %} > > > > %include "fyba.h" > > %include "Prox.h" > > > > // %ignore LC_OpenSos(const char *fil,short sModus,short sNyIdx,short > sVisStatus,LC_FILADM **ppFil, short *o_stat); > > > > %include "typemaps.i" > > %apply short *INOUT { short *o_stat }; > > short LC_OpenSos2(const char *fil,short sModus,short sNyIdx,short > sVisStatus,LC_FILADM *ppFil, short *o_stat); > > > > > > > > I would appreciate if anyone could helpe me with good examples, wrapping > to C#. > > I have searched the internet, but cant finde much useful examples. > The short *o_stat should work given the code you have above. What is the problem? For the LC_FILADM**, take a look at http://www.swig.org/Doc2.0/Java.html#Java_struct_pointer_pointer and convert the typemaps for C# usage using the info in http://www.swig.org/Doc2.0/CSharp.html#CSharp_differences_java William |