I am a bit perplexed on how to define the SWIG_Object type for the MATLAB module I am working on. I notice that Python defines it as "PyObject *" in "Lib/python/pytypemaps.swg". For MATLAB, that would correspond to "mxArray*".

But then I end up with problems with const-correctness for some of input typemaps., e.g. the following in Lib/typemaps/primtypes.swg:

%fragment(SWIG_AsVal_frag(bool),"header",fragment=SWIG_AsVal_frag(long)) {
SWIG_AsVal_dec(bool)(SWIG_Object obj, bool *val)
  long v;
  int res = SWIG_AsVal(long)(obj, val ? &v : 0);
  if (SWIG_IsOK(res)) {    
    if (val) *val = v ? true : false;
    return res;
  return SWIG_TypeError;

In MATLAB, the (MEX) entry point has the declaration: "void mexFunction(int resc, mxArray *resv[], int argc, const mxArray *argv[])", i.e. the input arguments (argv) are passed as arrays of pointers to constant mxArray structures. So I cannot use the above typemap for the input arguments. If I define SWIG_Object I end up with similar problems for the function outputs.

Did I misunderstand something or should I simply cast away the const qualifier of the input arguments?

Best regards!