From: Leonid Z. <lz...@il...> - 2009-07-15 16:45:00
|
Hi, I'm attempting to use SWIG to allow me to easily call C++ native code from C# managed code. I had a problem with getting SWIG to generate the correct method signatures when I try to pass an array of user-defined objects as a parameter. Here's the basic setup: cppcode.hpp - class A { private: double *values; int values_len; public: void setValues(double *data, int data_len); }; class B { private: A *objects; int objects_len; public: void setObjects(A *data, int data_len); }; cppcode.i - %include "arrays_csharp.i"; %module CPPCode %{ #include "cppcode.hpp" $}; %csmethodmodifiers A::setValues "public unsafe"; %apply double FIXED[] {double *data}; class A { public: void setValues(double *data, int data_len); }; %csmethodmodifiers B::setObjects "public unsafe"; %apply A FIXED[] {A *data}; class B { public: void setObjects(A *data, int data_len); }; What happens when I run SWIG on this is that the C# class definition for A is generated correctly, with setValues taking an array of doubles; however, the C# class definition for B is not generated correctly - A *data in setObjects becomes a single instance of type A, not an array. Is there any way for me to force SWIG to generate the correct method signature? -- Best Regards, Leonid Zamdborg Institute for Genomic Biology University of Illinois at Urbana-Champaign |