sharedfuncs.cpp
/* Attempts to locate an appropriate subclass of mx.Array 
   using the mltypes package. If for some reason this fails, 
   mx.Array is returned instead.
 */
Attempts to locate an appropriate subclass of mx.Array
using the mltypes package. If for some reason this fails,
mx.Array is returned instead.
Attempts to locate an appropriate subclass of mx . Array using the mltypes package . If for some reason this fails mx . Array is returned instead .
PyObject *Find_mltype_for(mxArray *mxobj) {
  #define GET_MX_ARRAY_CLASS PyObject_GetAttrString(mxmodule, "Array")
  PyObject *newclass, *mrolist, *util, *findtype;
  newclass = mrolist = util = findtype = NULL;
  mrolist = Calculate_matlab_mro(mxobj);
  if (!mrolist) {
    mexPrintf("failed to get mro list\n");
    PyErr_Clear();
    newclass = GET_MX_ARRAY_CLASS;
    goto findtypes_error;
  }
  util = PyImport_ImportModule("pymexutil");
  if (!util) {
    mexPrintf("failed to import pymexutil\n");
    PyErr_Clear();
    newclass = GET_MX_ARRAY_CLASS;
    goto findtypes_error;
  }
  findtype = PyObject_GetAttrString(util, "findtype");
  if (!findtype) {
    mexPrintf("failed to find pymexutil.findtype\n");
    PyErr_Clear();
    newclass = GET_MX_ARRAY_CLASS;
    goto findtypes_error;
  }
  mrolist = PyTuple_Pack(1, mrolist);
  newclass = PyObject_CallFunction(findtype, "O", mrolist);
  if (!newclass) {
    mexPrintf("failed to call _findtype\n");
    PyErr_Clear();
    newclass = GET_MX_ARRAY_CLASS;
    goto findtypes_error;
  }
  findtypes_error:
  Py_XDECREF(findtype);
  Py_XDECREF(mrolist);
  Py_XDECREF(util);
  return newclass;
}
PyObject * Find_mltype_for ( mxArray * mxobj ) { #define GET_MX_ARRAY_CLASS  PyObject_GetAttrString(mxmodule, "Array") PyObject * newclass , * mrolist , * util , * findtype ; newclass = mrolist = util = findtype = NULL ; mrolist = Calculate_matlab_mro ( mxobj ) ; if ( ! mrolist ) { mexPrintf ( " \n " ) ; PyErr_Clear ( ) ; newclass = GET_MX_ARRAY_CLASS ; goto findtypes_error ; } util = PyImport_ImportModule ( " " ) ; if ( ! util ) { mexPrintf ( " \n " ) ; PyErr_Clear ( ) ; newclass = GET_MX_ARRAY_CLASS ; goto findtypes_error ; } findtype = PyObject_GetAttrString ( util , " " ) ; if ( ! findtype ) { mexPrintf ( " \n " ) ; PyErr_Clear ( ) ; newclass = GET_MX_ARRAY_CLASS ; goto findtypes_error ; } mrolist = PyTuple_Pack ( 1 , mrolist ) ; newclass = PyObject_CallFunction ( findtype , " " , mrolist ) ; if ( ! newclass ) { mexPrintf ( " \n " ) ; PyErr_Clear ( ) ; newclass = GET_MX_ARRAY_CLASS ; goto findtypes_error ; } findtypes_error : Py_XDECREF ( findtype ) ; Py_XDECREF ( mrolist ) ; Py_XDECREF ( util ) ; return newclass ; }
Attempts to locate an appropriate subclass of mx.Array
using the mltypes package.
Attempts to locate an appropriate subclass of mx . Array using the mltypes package .
/* I'm not sure why we need *another* tuple around this, but apparently
     CallFunction kills the outermost tuple here */