From: Mathieu M. <mat...@gm...> - 2009-03-20 08:17:17
|
On Fri, Mar 20, 2009 at 8:13 AM, William S Fulton <ws...@fu...> wrote: > Mathieu Malaterre wrote: >> >> Hi there, >> >> I am trying to access c++ object from a C# layer that was wrapped by >> a 3rd party tool (not swig AFAIK). Looking at the hierarchy of class I >> could find the top level object to be (C# layer): >> >> public class WrappedObject : IDisposable >> { >> ... >> public HandleRef GetCppThis(); >> protected void SetCppThis(IntPtr rawCppThis, bool >> callDisposalMethod, bool strong); >> } >> >> >> My understanding is that the C++ pointer (just a guess) is just a >> call away: GetCppThis(). >> >> So what I would like to do with swig is be able to wrap a function >> that takes as input a 'HandleRef'. Then in the body of my c++ function >> I should be able to manipulate the C++ object directly. >> >> My first attempt was this: >> >> >> http://gdcm.svn.sourceforge.net/viewvc/gdcm/Sandbox/KitwareMummy/swig_kitwaremummy.i?view=markup >> >> but I do not understand how I can use the generated >> swig_kitwaremummyPINVOKE class: >> >> >> http://gdcm.svn.sourceforge.net/viewvc/gdcm/Sandbox/KitwareMummy/runme.cs?view=markup&sortby=date >> >> It keeps on telling me that this class does not have the proper >> access level (translated from french error message). >> >> What am i missing to be able to call this 'func' function > > The PINVOKE class is an internal workings class and you should be calling > swig_kitwaremummy.func( img.GetCppThis() ) instead. I see you have commented > that out, I could not figure out how to make the SWIGTYPE_p_void (my void* ptr) be a HandleRef... so the simpliest work around I found is to use directly the PINVOKE class directly :) > but that is what you need. If you really want to give the PINVOKE > class public access, use > > %pragma(csharp) imclassclassmodifiers="public class" Cool, that compiles ! Thanks, -- Mathieu |