From: Anthony Geay Date: Mon, 2 Mar 2015 11:01:24 +0000 (+0100) Subject: Work in progress. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f0300897bee2b676b756cd7c6f69b9dfd99378f1;p=tools%2Fmedcoupling.git Work in progress. --- diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index 56087f7ee..4aefb7327 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -2176,6 +2176,47 @@ namespace ParaMEDMEM } // serialization + + static PyObject *__new__(PyObject *args) throw(INTERP_KERNEL::Exception) + { + static const char MSG[]="DataArrayDouble.__new__ : the args in input is expected to be a tuple of size 2 !"; + if(!PyTuple_Check(args)) + throw INTERP_KERNEL::Exception(MSG); + PyObject *globals(PyEval_GetGlobals());//borrowed + PyObject *builtins(PyDict_GetItemString(globals,"__builtins__"));//borrowed + PyObject *obj(PyObject_GetAttrString(builtins,"object")); + PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__")); + Py_DECREF(obj); + PyObject *instance(PyObject_CallObject(selfMeth,PyTuple_GetItem(args,0))); + Py_DECREF(selfMeth); + PyObject *initMeth(PyObject_GetAttrString(instance,"__init__")); + if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1))) + { //unserialization requested + PyObject *tmp1(PyInt_FromLong(0)); + PyObject *zeNumpyRepr(PyDict_GetItem(PyTuple_GetItem(args,1),tmp1));//borrowed + Py_DECREF(tmp1); + PyObject *tmp3(PyTuple_New(1)); + PyTuple_SetItem(tmp3,0,zeNumpyRepr); Py_XINCREF(zeNumpyRepr); + PyObject *tmp2(PyObject_CallObject(initMeth,tmp3)); + Py_DECREF(tmp2); + Py_DECREF(tmp3); + } + else + { + int sz(PyTuple_Size(args)); + PyObject *tmp3(PyTuple_New(sz-1)); + for(int i=0;i