From: Anthony Geay Date: Tue, 3 Mar 2015 15:47:13 +0000 (+0100) Subject: Full OK for DataArrayDouble. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3de2bab1332491eacef4de0d72b1db43356fb1f4;p=tools%2Fmedcoupling.git Full OK for DataArrayDouble. --- diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index 577c576ce..2091a046e 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -20,6 +20,9 @@ %include "MEDCouplingCommon.i" %pythoncode %{ +def ParaMEDMEMDataArrayDoublenew(cls,*args): + import _MEDCoupling + return _MEDCoupling.DataArrayDouble____new___(cls,args) def ParaMEDMEMDataArrayDoubleIadd(self,*args): import _MEDCoupling return _MEDCoupling.DataArrayDouble____iadd___(self, self, *args) diff --git a/src/MEDCoupling_Swig/MEDCouplingFinalize.i b/src/MEDCoupling_Swig/MEDCouplingFinalize.i index 26097c097..7d6bafb8b 100644 --- a/src/MEDCoupling_Swig/MEDCouplingFinalize.i +++ b/src/MEDCoupling_Swig/MEDCouplingFinalize.i @@ -18,6 +18,7 @@ // %pythoncode %{ +DataArrayDouble.__new__=classmethod(ParaMEDMEMDataArrayDoublenew) DataArrayDouble.__iadd__=ParaMEDMEMDataArrayDoubleIadd DataArrayDouble.__isub__=ParaMEDMEMDataArrayDoubleIsub DataArrayDouble.__imul__=ParaMEDMEMDataArrayDoubleImul @@ -51,6 +52,7 @@ DataArrayIntTuple.__imod__=ParaMEDMEMDataArrayIntTupleImod DenseMatrix.__iadd__=ParaMEDMEMDenseMatrixIadd DenseMatrix.__isub__=ParaMEDMEMDenseMatrixIsub +del ParaMEDMEMDataArrayDoublenew del ParaMEDMEMDataArrayDoubleIadd del ParaMEDMEMDataArrayDoubleIsub del ParaMEDMEMDataArrayDoubleImul diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index d7ec98b1d..561ecb820 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -2176,51 +2176,38 @@ namespace ParaMEDMEM } // serialization - - static PyObject *__new__(PyObject *args) throw(INTERP_KERNEL::Exception) + static PyObject *___new___(PyObject *cls, 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 *builtinsd(PyModule_GetDict(builtins));//borrowed PyObject *builtinsd(PyEval_GetBuiltins());//borrowed PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed - //PyObject *obj(PyObject_GetAttrString(builtins,"object")); PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__")); - //Py_DECREF(obj); - ///// + // PyObject *tmp0(PyTuple_New(1)); - PyTuple_SetItem(tmp0,0,PyTuple_GetItem(args,0)); Py_DECREF(PyTuple_GetItem(args,0)); + PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls); PyObject *instance(PyObject_CallObject(selfMeth,tmp0)); Py_DECREF(tmp0); - ///// 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