I am trying to use SWIG to create a C # computer for C ++ code, similar to the following:
class blah { ... public: float *getVarA() { return a; } private float *a; ... }
In my interface file, I use the following% apply:
%apply float OUTPUT[] { float *getVarA() }
This causes the C # shell to return float [], but the shell function does not know what float * a is. This causes a lot of errors:
Cannot implicitly convert type 'float[]' to 'System.IntPtr'
Wrapper function created:
public float[] getVarA() { IntPtr cPtr = SpectrumPINVOKE.blah_getVarA(swigCPtr); SWIGTYPE_p_float ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_float(cPtr, false); return ret; }
When using types without pointers, such as:
class blah { ... public: int getVarB() { return b; } private: int b; ... }
I get good
public int getVarB() { int ret = SpectrumPINVOKE.blah_getVarB(swigCPtr); return ret; }
I read the 2.0 documentation more than I would like, but somewhere I am missing something, and I cannot find it right now. Thanks.
source share