Re: wrapping c void* as c# IntPtr not generating proper code
William S Fulton <[email protected]>
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CANGqftCKx_sA+xw-T+RGW+dQ8suQ6Kds=sxaVAqOWNDcYrSZBg@mail.gmail.com> |
Hi Carlos I've added the missing typemaps so this works in future releases. You can simply add them into your own interface file for now. See https://github.com/swig/swig/commit/bfddc50a6a38193acabaf8d895c5e472718a9a4d# . William On Wed, 8 Apr 2020 at 10:10, Carlos Frederico Biscaya <[email protected]> wrote: > Hi all, > > So I know that using > %apply void *VOID_INT_PTR { void * } > > is intended to wrap my void* parameters and return values as IntPtr > instead of a generic SWIG SWIGTYPE_p_void. > > It works for functions, as described in the SWIG user manual. But if I do > something like this: > > struct simpleVoid { > void * myVoidMember; > }; > > the resulting code will not compile, because the generated wrapper for > myVoidMember looks like this: > > public global::System.IntPtr myVoidMember { > set { > SwigExperimentWrapperPINVOKE.simpleVoid_myVoidMember_set(swigCPtr, > value); > } > get { > global::System.IntPtr cPtr = > SwigExperimentWrapperPINVOKE.simpleVoid_myVoidMember_get(swigCPtr); > SWIGTYPE_p_void ret = (cPtr == global::System.IntPtr.Zero) ? null : > new SWIGTYPE_p_void(cPtr, false); > return ret; > } > } > > The problem is, that the getter uses SWIGTYPE_p_void as type for ret > instead of System.IntPtr, which will then produce a build failure, because > there is no implicit way of converting it to System.IntrPtr when returning. > > What can I do to fix this behaviour? If you guys have any ideas, please, > please tell. > > Br, > Fred > > _______________________________________________ > Swig-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/swig-user > _______________________________________________ Swig-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/swig-user