return reinterpret_cast< MEDCoupling::DataArray * >(aBasePtrVS);
}
-static PyObject *NewMethWrapCallInitOnlyIfEmptyDictInInput(PyObject *cls, PyObject *args, const char *clsName)
-{
- if(!PyTuple_Check(args))
- {
- std::ostringstream oss; oss << clsName << ".__new__ : the args in input is expected to be a tuple !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- PyObject *builtinsd(PyEval_GetBuiltins());//borrowed
- PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed
- PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__"));
- //
- PyObject *tmp0(PyTuple_New(1));
- PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls);
- PyObject *instance(PyObject_CallObject(selfMeth,tmp0));
- Py_DECREF(tmp0);
- Py_DECREF(selfMeth);
- if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==0 )
- {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ !
- PyObject *initMeth(PyObject_GetAttrString(instance,"__init__"));
- PyObject *tmp3(PyTuple_New(0));
- PyObject *tmp2(PyObject_CallObject(initMeth,tmp3));
- Py_XDECREF(tmp2);
- Py_DECREF(tmp3);
- Py_DECREF(initMeth);
- }
- return instance;
-}
-
-template<class T>
-static PyObject *NewMethWrapCallInitOnlyIfDictWithSingleEltInInputGeneral(PyObject *cls, PyObject *args, const char *clsName)
-{
- if(!PyTuple_Check(args))
- {
- std::ostringstream oss; oss << clsName << ".__new__ : the args in input is expected to be a tuple !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- PyObject *builtinsd(PyEval_GetBuiltins());//borrowed
- PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed
- PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__"));
- //
- PyObject *tmp0(PyTuple_New(1));
- PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls);
- PyObject *instance(PyObject_CallObject(selfMeth,tmp0));
- Py_DECREF(tmp0);
- Py_DECREF(selfMeth);
- if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==1 )
- {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ !
- PyObject *initMeth(PyObject_GetAttrString(instance,"__init__"));
- PyObject *zeNumpyRepr(0);
- {
- PyObject *tmp1(PyInt_FromLong(0));
- zeNumpyRepr=PyDict_GetItem(PyTuple_GetItem(args,1),tmp1);//borrowed
- Py_DECREF(tmp1);
- }
- if(!zeNumpyRepr)
- {
- std::ostringstream oss; oss << clsName << ".__new__ : the args in input is expected to be a tuple !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- T tt;
- {
- PyObject *tmp3(0);
- try
- {
- tmp3=tt(zeNumpyRepr);
- }
- catch(INTERP_KERNEL::Exception& e)
- {
- std::ostringstream oss; oss << clsName << ".__new__ : Invalid type in input " << " : " << e.what();
- throw INTERP_KERNEL::Exception(oss.str());
- }
- {
- PyObject *tmp2(PyObject_CallObject(initMeth,tmp3));
- Py_XDECREF(tmp2);
- }
- Py_DECREF(tmp3);
- }
- Py_DECREF(initMeth);
- }
- return instance;
-}
-
-struct SinglePyObjToBePutInATuple
-{
- PyObject *operator()(PyObject *zeNumpyRepr)
- {
- PyObject *tmp3(PyTuple_New(1));
- PyTuple_SetItem(tmp3,0,zeNumpyRepr); Py_XINCREF(zeNumpyRepr);
- return tmp3;
- }
-};
-
-struct SinglePyObjExpectToBeAListOfSz2
-{
- PyObject *operator()(PyObject *uniqueElt)
- {
- if(!PyTuple_Check(uniqueElt) || PyTuple_Size(uniqueElt)!=2)
- throw INTERP_KERNEL::Exception("Not a tuple of size 2 !");
- Py_XINCREF(uniqueElt);
- return uniqueElt;
- }
-};
-
-static PyObject *NewMethWrapCallInitOnlyIfDictWithSingleEltInInput(PyObject *cls, PyObject *args, const char *clsName)
-{
- return NewMethWrapCallInitOnlyIfDictWithSingleEltInInputGeneral<SinglePyObjToBePutInATuple>(cls,args,clsName);
-}
-
static PyObject *convertPartDefinition(MEDCoupling::PartDefinition *pd, int owner)
{
PyObject *ret=0;