wrapping c void* as c# IntPtr not generating proper code

Carlos Frederico Biscaya <[email protected]>
Newsgroups gmane.comp.programming.swig
Message-ID <CANWOLaaD3D1EJOb9sY74Tpc6dCS6JDk=XFwvNB0ZUuThtWA1Lw@mail.gmail.com>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.