Re: return a struct by reference without creating a handler wrapper class
2011-04-04 20:45:03 GMT
xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
In what way doesn’t it work? I haven’t actually tried %cs_struct(void*, IntPtr), but I do use %cs_struct(HWND, IntPtr), %cs_struct(HBITMAP, IntPtr), etc.
It is correct that there is no “ref” on TypeData using %cs_class. TypeData is supposed to be a class, so it is already passed by reference. “ref TypeData” would correspond to CTypeData** in C++.
Hi David,
I prefer this approach about wrapping free, but cs_struct(void *, IntPtr) neither cs_struct(void *, System.IntPtr) didn't work. Have you tried them?
On the other side, together with the cs_struct module, you give a cs_class module to be used with a C# class instead of a C# struct. I have been testing it but I think there is an error:
- Using cs_struct, resulting wrapper function is as follows:
[DllImport("dexlib", EntryPoint="CSharp_dex_Graph_TypeData")]
public static extern bool dex_Graph_GetTypeData(HandleRef, jarg1, int jarg2, ref edu.upc.dama.dex.TypeData jarg3);
- But using cs_class, resulting wrapper function is:
[DllImport("dexlib", EntryPoint="CSharp_dex_Graph_TypeData")]
public static extern bool dex_Graph_GetTypeData(HandleRef, jarg1, int jarg2, edu.upc.dama.dex.TypeData jarg3);
Note the difference is there is no "ref" modifier in the third argument when using cs_class. Is this an error of the cs_class module?
Thanks,
Sergio
On Apr 2, 2011, at 1:24 AM, David Piepgrass wrote:
Well, you could also allocate the string with malloc() and wrap free() with SWIG:
%cs_struct(void*, IntPtr)
void free(void* ptr);
From: Sergio Gómez Villamor [mailto:sgomez <at> ac.upc.edu]
Sent: Friday, April 01, 2011 11:39 AM
To: David Piepgrass
Cc: swig-user <at> lists.sourceforge.net
Subject: Re: [Swig-user] return a struct by reference without creating a handler wrapper class
OK, I will try this although I don't like it very much because if I have to allocate the string using SysAllocString, that means the allocation of the string will depend on the target language I'm compiling to.
Anyway, I will try this next week (it's my time to leave).
Thanks very much,
Sergio
------------------------------------------------------------------------------ Xperia(TM) PLAY It's a major breakthrough. An authentic gaming smartphone on the nation's most reliable network. And it wants your games. http://p.sf.net/sfu/verizon-sfdev
_______________________________________________ Swig-user mailing list Swig-user <at> lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/swig-user
RSS Feed