]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Work in progress.
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 2 Mar 2015 11:01:24 +0000 (12:01 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 2 Mar 2015 11:01:24 +0000 (12:01 +0100)
src/MEDCoupling_Swig/MEDCouplingMemArray.i

index 56087f7ee060dfe621cb74a3742e5a70ecfe97d8..4aefb73275043eacf8e73aa3bc725e150347187c 100644 (file)
@@ -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<sz-1;i++)
+              {
+                PyObject *tmp0(PyTuple_GetItem(args,i+1)); Py_XINCREF(tmp0);
+                PyTuple_SetItem(tmp3,i,tmp0);
+              }
+            PyObject *tmp2(PyObject_CallObject(initMeth,tmp3));
+            Py_DECREF(tmp2);
+            Py_DECREF(tmp3);
+          }
+        Py_DECREF(initMeth);
+        return instance;
+      }
 
       PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception)
       {