From: William S F. <ws...@fu...> - 2010-04-19 21:15:01
|
Tyler Sample wrote: > Okay, I've realized that a typemap specifically for handling that kind of > array has to be defined, because "arrays_csharp.i" only handles primitive > types. I've done this: > CSHARP_ARRAYS(MyHandle, MyHandle) > > > Very pretty results, but none of the example code or documentation I've seen > suggests this as a possibility, This is just invoking some typemaps via the CSHARP_ARRAYS preprocessor macro which was designed for primitive types. If it works for MyHandle, whatever that is, then feel free to use it. All you are doing is creating some typemaps that may or may not work for your type - this is for you to debug/decide. Documentation enhancements always welcome ;) William > and the "typemaps.i" file specifically > disallows doing a similar thing with pointers by #undef'ing the macros, so > I've no doubt doomed myself to a lifetime of heap corruption? > > -------------------------------------------------- > From: "Tyler Sample" <tyl...@gm...> > Sent: Wednesday, April 14, 2010 1:52 PM > To: "William S Fulton" <ws...@fu...>; > <swi...@li...> > Subject: Re: [Swig-user] Keeping an opaque type opaque > >> So, I've done this >> %include "typemaps.i" >> %include "arrays_csharp.i" >> %typemap(cstype) MyHandle "MyHandle"; >> %apply SWIGTYPE_p_void INOUT[] {MyHandle *pHandle}; >> >> I have a .cs file I add to what SWIG generates that just has a: >> using MyHandle = SWIGTYPE_p_void; >> If I could also tell SWIG this, that would be great. It's confusing to me >> that SWIG doesn't generate something like this automatically, or that it >> seems to be difficult to tell it to, based on the C++ typedef existing. >> >> The problem is I can't get the %apply directive above to work to handle an >> array of instances, no matter how I specify the type on either side. >> void*, MyHandle, SWIGTYPE_p_void all fail with warning 453: No typemaps >> are defined. >> >> Ideally, I'd like the generated .cs code to say "MyHandle[]", but I'm not >> sure that's possible since clearly SWIG doesn't know what a .cs MyHandle >> is. >> >> -------------------------------------------------- >> From: "William S Fulton" <ws...@fu...> >> Sent: Tuesday, April 13, 2010 12:13 PM >> To: "Tyler Sample" <tyl...@gm...> >> Cc: <swi...@li...> >> Subject: Re: [Swig-user] Keeping an opaque type opaque >> >>> Tyler Sample wrote: >>>> Apologies for the 2nd post, but on re-reading this I should clarify one >>>> thing: I am aware that SWIG by default treats pointers as opaque. My >>>> concern is giving the type a name without changing this. >>> In Java and C# SWIGTYPE_p_void type wrapper class cannot be renamed. What >>> you can do is use a different name in the cstype typemap, such as, >>> VoidType, then write your own VoidType class. The type name is >>> effectively hidden for the scripting languages so this shouldn't be an >>> issue. >>> >>> William > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Swig-user mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swig-user > |