Hi David,

The C# struct I have written is called TypeData (it was an error when I wrote the mail).

Now, my code is in namespaces, as you suggested and I have added an %ignore clause for CTypeData. As well, I have updated cs_struct(X,Y) for %cs_struct(X,Y). But I still have problems and generated code is not as I expected.

This is my interface file at this moment:


/* File : dexlib.i */
%module dexlib

%{
#include "dexlib.h"
%}

%include <wchar.i>
%include cs_struct.i

%cs_struct(DEXLIB::CTypeData, TypeData);

%nspace DEXLIB::DEX;
%nspace DEXLIB::GraphPool;
%nspace DEXLIB::Session;
%nspace DEXLIB::Graph;
%nspace DEXLIB::DbGraph;
%nspace DEXLIB::RGraph;
%nspace DEXLIB::ObjectType;

%ignore DEXLIB::DbGraph::DbGraph (Session *sess);
%ignore DEXLIB::CTypeData;

/* Let's just grab the original header file here */
%include "dexlib.h"


All classes are defined into the DEXLIB namespace.


Although there is an ignore clause for CTypeData, it is still generated as a native handler class and Graph (at C# code) updates an instance of this class

  public bool GetTypeData(int type, DEXLIB.CTypeData tdata) {
    bool ret = dexlibPINVOKE.DEXLIB_Graph_GetTypeData(swigCPtr, type, DEXLIB.CTypeData.getCPtr(tdata));
    if (dexlibPINVOKE.SWIGPendingException.Pending) throw dexlibPINVOKE.SWIGPendingException.Retrieve();
    return ret;
  }


Firstly, I do not understand why %ignore DEXLIB::CTypeData is not working (although it works for the other ignore clause I have).

Finally, cs_struct seems is not working (I have also tested using %cs_struct(DEXLIB::CTypeData, DEXLIB.TypeData) or cs_struct(CTypeData, TypeData) and they do not work).

Thanks,
Sergio


On Mar 30, 2011, at 7:16 PM, David Piepgrass wrote:

Oh, I see the problem. Or at least the main problem. The macro is called %cs_struct, not cs_struct. Add a %.
 
%include "cs_struct.i"
cs_struct(CTypeData, TypeData);