std::copy(elts.begin(),elts.end(),d0->getPointer());
std::copy(eltsIndex.begin(),eltsIndex.end(),d1->getPointer());
PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- d0->incrRef();
- d1->incrRef();
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
return ret;
}
std::copy(elts.begin(),elts.end(),d0->getPointer());
std::copy(eltsIndex.begin(),eltsIndex.end(),d1->getPointer());
PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- d0->incrRef();
- d1->incrRef();
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
return ret;
}
MEDCouplingAutoRefCountObjectPtr<DataArrayByte> ret=DataArrayByte::New();
std::vector<int> tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,nbOfCompo);
ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
- ret->incrRef();
- return ret;
+ return ret.retn();
}
else
throw INTERP_KERNEL::Exception(msg);
int tmpp1=-1;
std::vector<int> tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,tmpp1);
ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
- ret->incrRef();
- return ret;
+ return ret.retn();
}
}
else
int tmpp1=-1,tmpp2=-1;
std::vector<int> tmp=fillArrayWithPyListInt2(elt0,tmpp1,tmpp2);
ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
- ret->incrRef();
- return ret;
+ return ret.retn();
}
}
else if(PyInt_Check(elt0))
throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive number of components !");
MEDCouplingAutoRefCountObjectPtr<DataArrayByte> ret=DataArrayByte::New();
ret->alloc(nbOfTuples1,nbOfCompo);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
else
throw INTERP_KERNEL::Exception(msg);
{//DataArrayByte.New(5)
MEDCouplingAutoRefCountObjectPtr<DataArrayByte> ret=DataArrayByte::New();
ret->alloc(nbOfTuples1,1);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
}
else
static DataArrayAsciiChar *New(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) throw(INTERP_KERNEL::Exception)
{
- const char *msg="ParaMEDMEM::DataArrayAsciiChar::New : Available API are : \n-DataArrayAsciiChar.New()\n--DataArrayAsciiChar.New([1,3,4])\n-DataArrayAsciiChar.New([1,3,4],3)\n-DataArrayAsciiChar.New([1,3,4,5],2,2)\n-DataArrayAsciiChar.New(5)\n-DataArrayAsciiChar.New(5,2) !";
+ const char *msg="ParaMEDMEM::DataArrayAsciiChar::New : Available API are : \n-DataArrayAsciiChar.New()\n-DataArrayAsciiChar.New([1,3,4])\n-DataArrayAsciiChar.New([\"abc\",\"de\",\"fghi\"])\n-DataArrayAsciiChar.New([\"abc\",\"de\",\"fghi\"],\"t\")\n-DataArrayAsciiChar.New([1,3,4],3)\n-DataArrayAsciiChar.New([1,3,4,5],2,2)\n-DataArrayAsciiChar.New(5)\n-DataArrayAsciiChar.New(5,2) !";
if(PyList_Check(elt0) || PyTuple_Check(elt0))
{
if(nbOfTuples)
MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> ret=DataArrayAsciiChar::New();
std::vector<int> tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,nbOfCompo);
ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
- ret->incrRef();
- return ret;
+ return ret.retn();
}
else
throw INTERP_KERNEL::Exception(msg);
int tmpp1=-1;
std::vector<int> tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,tmpp1);
ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
- ret->incrRef();
- return ret;
+ return ret.retn();
}
}
+ else if(PyString_Check(nbOfTuples))
+ {
+ if(PyString_Size(nbOfTuples)!=1)
+ throw INTERP_KERNEL::Exception(msg);
+ //DataArrayAsciiChar.New(["abc","de","fghi"],"t")
+ std::vector<std::string> tmp;
+ if(fillStringVector(elt0,tmp))
+ return DataArrayAsciiChar::New(tmp,PyString_AsString(nbOfTuples)[0]);
+ else
+ throw INTERP_KERNEL::Exception(msg);
+ }
else
throw INTERP_KERNEL::Exception(msg);
}
else
- {// DataArrayAsciiChar.New([1,3,4])
- MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> ret=DataArrayAsciiChar::New();
- int tmpp1=-1,tmpp2=-1;
- std::vector<int> tmp=fillArrayWithPyListInt2(elt0,tmpp1,tmpp2);
- ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
- ret->incrRef();
- return ret;
+ {
+ std::vector<std::string> tmmp;
+ if(fillStringVector(elt0,tmmp))
+ //DataArrayAsciiChar.New(["abc","de","fghi"])
+ return DataArrayAsciiChar::New(tmmp,' ');
+ else
+ {
+ // DataArrayAsciiChar.New([1,3,4])
+ MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> ret=DataArrayAsciiChar::New();
+ int tmpp1=-1,tmpp2=-1;
+ std::vector<int> tmp=fillArrayWithPyListInt2(elt0,tmpp1,tmpp2);
+ ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
+ return ret.retn();
+ }
}
}
else if(PyInt_Check(elt0))
throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive number of components !");
MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> ret=DataArrayAsciiChar::New();
ret->alloc(nbOfTuples1,nbOfCompo);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
else
throw INTERP_KERNEL::Exception(msg);
{//DataArrayAsciiChar.New(5)
MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> ret=DataArrayAsciiChar::New();
ret->alloc(nbOfTuples1,1);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
}
else
DataArrayAsciiChar(PyObject *elt0, PyObject *nbOfTuples=0, PyObject *nbOfComp=0) throw(INTERP_KERNEL::Exception)
{
- return ParaMEDMEM_DataArrayAsciiChar_New__SWIG_1(elt0,nbOfTuples,nbOfComp);
+ return ParaMEDMEM_DataArrayAsciiChar_New__SWIG_3(elt0,nbOfTuples,nbOfComp);
}
DataArrayAsciiCharIterator *__iter__() throw(INTERP_KERNEL::Exception)
throw INTERP_KERNEL::Exception("DataArrayAsciiChar::search : only strings in input supported !");
}
- PyObject *getTuple(int tupleId) throw(INTERP_KERNEL::Exception)
+ PyObject *getTuple(int tupleId) const throw(INTERP_KERNEL::Exception)
{
int sz=self->getNumberOfComponents();
INTERP_KERNEL::AutoPtr<char> tmp=new char[sz+1]; tmp[sz]='\0';
return ParaMEDMEM_DataArrayAsciiChar_presenceOfTuple(self,obj);
}
}
+
+ PyObject *__getitem__(PyObject *obj) const throw(INTERP_KERNEL::Exception)
+ {
+ int sw,iTypppArr;
+ std::vector<int> stdvecTyyppArr;
+ std::pair<int, std::pair<int,int> > sTyyppArr;
+ ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+ convertObjToPossibleCpp2(obj,self->getNumberOfTuples(),sw,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
+ switch(sw)
+ {
+ case 1:
+ return ParaMEDMEM_DataArrayAsciiChar_getTuple(self,iTypppArr);
+ case 2:
+ return convertDataArrayChar(self->selectByTupleIdSafe(&stdvecTyyppArr[0],&stdvecTyyppArr[0]+stdvecTyyppArr.size()), SWIG_POINTER_OWN | 0 );
+ case 3:
+ return convertDataArrayChar(self->selectByTupleId2(sTyyppArr.first,sTyyppArr.second.first,sTyyppArr.second.second), SWIG_POINTER_OWN | 0 );
+ case 4:
+ return convertDataArrayChar(self->selectByTupleIdSafe(daIntTyypp->begin(),daIntTyypp->end()), SWIG_POINTER_OWN | 0 );
+ default:
+ throw INTERP_KERNEL::Exception("DataArrayAsciiChar::__getitem__ : supporting int, list of int, tuple of int, DataArrayInt and slice in input !");
+ }
+ }
+
+ DataArrayAsciiChar *__setitem__(PyObject *obj, PyObject *value) throw(INTERP_KERNEL::Exception)
+ {
+ static const char msg[]="DataArrayAsciiChar::__setitem__ : supporting int, list of int, tuple of int, DataArrayInt and slice in input, and 4 types accepted in value : string, list or tuple of strings having same size, not null DataArrayChar instance.";
+ int sw1,iTypppArr;
+ std::vector<int> stdvecTyyppArr;
+ std::pair<int, std::pair<int,int> > sTyyppArr;
+ ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+ int nbOfCompo=self->getNumberOfTuples();
+ convertObjToPossibleCpp2(obj,nbOfCompo,sw1,iTypppArr,stdvecTyyppArr,sTyyppArr,daIntTyypp);
+ int sw2;
+ char vc; std::string sc; std::vector<std::string> vsc; DataArrayChar *dacc=0;
+ convertObjToPossibleCpp6(value,sw2,vc,sc,vsc,dacc);
+ switch(sw1)
+ {
+ case 1:
+ {//obj int
+ switch(sw2)
+ {//value char
+ case 1:
+ {
+ self->setPartOfValuesSimple3(vc,&iTypppArr,&iTypppArr+1,0,nbOfCompo,1);
+ return self;
+ }
+ //value string
+ case 2:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> tmp=DataArrayAsciiChar::New(sc);
+ self->setPartOfValues3(tmp,&iTypppArr,&iTypppArr+1,0,nbOfCompo,1,false);
+ return self;
+ }
+ //value vector<string>
+ case 3:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> tmp=DataArrayAsciiChar::New(vsc,' ');
+ self->setPartOfValues3(tmp,&iTypppArr,&iTypppArr+1,0,nbOfCompo,1,false);
+ return self;
+ }
+ //value DataArrayChar
+ case 4:
+ {
+ self->setPartOfValues3(dacc,&iTypppArr,&iTypppArr+1,0,nbOfCompo,1,false);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ case 2:
+ {//obj list-tuple[int]
+ switch(sw2)
+ {
+ {//value char
+ case 1:
+ {
+ self->setPartOfValuesSimple3(vc,&stdvecTyyppArr[0],&stdvecTyyppArr[0]+stdvecTyyppArr.size(),0,nbOfCompo,1);
+ return self;
+ }
+ //value string
+ case 2:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> tmp=DataArrayAsciiChar::New(sc);
+ self->setPartOfValues3(tmp,&stdvecTyyppArr[0],&stdvecTyyppArr[0]+stdvecTyyppArr.size(),0,nbOfCompo,1,false);
+ return self;
+ }
+ //value vector<string>
+ case 3:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> tmp=DataArrayAsciiChar::New(vsc,' ');
+ self->setPartOfValues3(tmp,&stdvecTyyppArr[0],&stdvecTyyppArr[0]+stdvecTyyppArr.size(),0,nbOfCompo,1,false);
+ return self;
+ }
+ //value DataArrayChar
+ case 4:
+ {
+ self->setPartOfValues3(dacc,&stdvecTyyppArr[0],&stdvecTyyppArr[0]+stdvecTyyppArr.size(),0,nbOfCompo,1,false);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ }
+ case 3:
+ {//slice
+ switch(sw2)
+ {
+ {//value char
+ case 1:
+ {
+ self->setPartOfValuesSimple1(vc,sTyyppArr.first,sTyyppArr.second.first,sTyyppArr.second.second,0,nbOfCompo,1);
+ return self;
+ }
+ //value string
+ case 2:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> tmp=DataArrayAsciiChar::New(sc);
+ self->setPartOfValues1(tmp,sTyyppArr.first,sTyyppArr.second.first,sTyyppArr.second.second,0,nbOfCompo,1,false);
+ return self;
+ }
+ //value vector<string>
+ case 3:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> tmp=DataArrayAsciiChar::New(vsc,' ');
+ self->setPartOfValues1(tmp,sTyyppArr.first,sTyyppArr.second.first,sTyyppArr.second.second,0,nbOfCompo,1,false);
+ return self;
+ }
+ //value DataArrayChar
+ case 4:
+ {
+ self->setPartOfValues1(dacc,sTyyppArr.first,sTyyppArr.second.first,sTyyppArr.second.second,0,nbOfCompo,1,false);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ }
+ case 4:
+ {//DataArrayInt
+ switch(sw2)
+ {
+ {//value char
+ case 1:
+ {
+ self->setPartOfValuesSimple3(vc,daIntTyypp->begin(),daIntTyypp->end(),0,nbOfCompo,1);
+ return self;
+ }
+ //value string
+ case 2:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> tmp=DataArrayAsciiChar::New(sc);
+ self->setPartOfValues3(tmp,daIntTyypp->begin(),daIntTyypp->end(),0,nbOfCompo,1,false);
+ return self;
+ }
+ //value vector<string>
+ case 3:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayAsciiChar> tmp=DataArrayAsciiChar::New(vsc,' ');
+ self->setPartOfValues3(tmp,daIntTyypp->begin(),daIntTyypp->end(),0,nbOfCompo,1,false);
+ return self;
+ }
+ //value DataArrayChar
+ case 4:
+ {
+ self->setPartOfValues3(dacc,daIntTyypp->begin(),daIntTyypp->end(),0,nbOfCompo,1,false);
+ return self;
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
+ }
+ default:
+ throw INTERP_KERNEL::Exception(msg);
+ }
+ }
}
%extend ParaMEDMEM::MEDCouplingFieldDiscretization
MEDCouplingUMesh *mOut=self->emulateMEDMEMBDC(nM1LevMesh,d0,d1,d2,d3,d4,dd5);
PyObject *ret=PyTuple_New(7);
PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(mOut),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr((DataArrayInt *)d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr((DataArrayInt *)d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d0.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(d1.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
PyTuple_SetItem(ret,3,SWIG_NewPointerObj(SWIG_as_voidptr(d2),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
PyTuple_SetItem(ret,4,SWIG_NewPointerObj(SWIG_as_voidptr(d3),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
PyTuple_SetItem(ret,5,SWIG_NewPointerObj(SWIG_as_voidptr(d4),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
PyTuple_SetItem(ret,6,SWIG_NewPointerObj(SWIG_as_voidptr(dd5),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- d0->incrRef();
- d1->incrRef();
return ret;
}
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d1=DataArrayInt::New();
self->getReverseNodalConnectivity(d0,d1);
PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- d0->incrRef();
- d1->incrRef();
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(d0.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(d1.retn()),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
return ret;
}
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
std::vector<double> tmp=fillArrayWithPyListDbl2(elt0,nbOfTuples1,nbOfCompo);
ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
- ret->incrRef();
- return ret;
+ return ret.retn();
}
else
throw INTERP_KERNEL::Exception(msg);
int tmpp1=-1;
std::vector<double> tmp=fillArrayWithPyListDbl2(elt0,nbOfTuples1,tmpp1);
ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
- ret->incrRef();
- return ret;
+ return ret.retn();
}
}
else
int tmpp1=-1,tmpp2=-1;
std::vector<double> tmp=fillArrayWithPyListDbl2(elt0,tmpp1,tmpp2);
ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
- ret->incrRef();
- return ret;
+ return ret.retn();
}
}
else if(PyInt_Check(elt0))
throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !");
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
ret->alloc(nbOfTuples1,nbOfCompo);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
else
throw INTERP_KERNEL::Exception(msg);
{//DataArrayDouble.New(5)
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
ret->alloc(nbOfTuples1,1);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
}
else
{
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
ret->applyLin(1.,val);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
case 2:
{
{
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
ret->applyLin(1.,val);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
case 3:
{
{
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
ret->applyLin(1.,-val);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
case 2:
{
{
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
ret->applyLin(-1.,val);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
case 3:
{
{
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
ret->applyLin(val,0.);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
case 2:
{
{
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
ret->applyLin(val,0.);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
case 3:
{
throw INTERP_KERNEL::Exception("DataArrayDouble::__div__ : trying to divide by zero !");
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
ret->applyLin(1/val,0.);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
case 2:
{
{
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=self->deepCpy();
ret->applyInv(val);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
case 3:
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
std::vector<int> tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,nbOfCompo);
ret->alloc(nbOfTuples1,nbOfCompo); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
- ret->incrRef();
- return ret;
+ return ret.retn();
}
else
throw INTERP_KERNEL::Exception(msg);
int tmpp1=-1;
std::vector<int> tmp=fillArrayWithPyListInt2(elt0,nbOfTuples1,tmpp1);
ret->alloc(nbOfTuples1,tmpp1); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
- ret->incrRef();
- return ret;
+ return ret.retn();
}
}
else
int tmpp1=-1,tmpp2=-1;
std::vector<int> tmp=fillArrayWithPyListInt2(elt0,tmpp1,tmpp2);
ret->alloc(tmpp1,tmpp2); std::copy(tmp.begin(),tmp.end(),ret->getPointer());
- ret->incrRef();
- return ret;
+ return ret.retn();
}
}
else if(PyInt_Check(elt0))
throw INTERP_KERNEL::Exception("DataArrayInt::New : should be a positive number of components !");
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
ret->alloc(nbOfTuples1,nbOfCompo);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
else
throw INTERP_KERNEL::Exception(msg);
{//DataArrayInt.New(5)
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
ret->alloc(nbOfTuples1,1);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
}
else
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
ret->applyLin(1,val);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
case 2:
{
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
ret->applyLin(1,val);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
case 2:
{
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
ret->applyLin(1,-val);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
case 2:
{
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
ret->applyLin(-1,val);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
case 2:
{
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
ret->applyLin(val,0);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
case 2:
{
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
ret->applyLin(val,0);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
case 2:
{
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
ret->applyDivideBy(val);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
case 2:
{
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
ret->applyInv(val);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
case 2:
{
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
ret->applyModulus(val);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
case 2:
{
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=self->deepCpy();
ret->applyRModulus(val);
- ret->incrRef();
- return ret;
+ return ret.retn();
}
case 2:
{
return ret;
}
+static bool fillStringVector(PyObject *pyLi, std::vector<std::string>& vec) throw(INTERP_KERNEL::Exception)
+{
+ if(PyList_Check(pyLi))
+ {
+ Py_ssize_t sz=PyList_Size(pyLi);
+ vec.resize(sz);
+ for(int i=0;i<sz;i++)
+ {
+ PyObject *o=PyList_GetItem(pyLi,i);
+ if(PyString_Check(o))
+ vec[i]=PyString_AsString(o);
+ else
+ return false;
+ }
+ return true;
+ }
+ else if(PyTuple_Check(pyLi))
+ {
+ Py_ssize_t sz=PyTuple_Size(pyLi);
+ vec.resize(sz);
+ for(int i=0;i<sz;i++)
+ {
+ PyObject *o=PyTuple_GetItem(pyLi,i);
+ if(PyString_Check(o))
+ vec[i]=PyString_AsString(o);
+ else
+ return false;
+ }
+ return true;
+ }
+ else
+ return false;
+}
+
static PyObject *convertDblArrToPyList(const double *ptr, int size) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=PyList_New(size);
* if python int -> cpp int sw=1
* if python list[int] -> cpp vector<int> sw=2
* if python tuple[int] -> cpp vector<int> sw=2
- * if python slicp -> cpp pair sw=3
- * if python DataArrayInt -> cpp DataArrayInt sw=4
+ * if python slicp -> cpp pair sw=3 (begin,end,step)
+ * if python DataArrayInt -> cpp DataArrayInt sw=4 . The returned pointer cannot be the null pointer ! If null an exception is thrown.
*
* switch between (int,vector<int>,DataArrayInt)
*/
sw=4;
return ;
}
- status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayIntTuple,0|0);;
+ status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayIntTuple,0|0);
if(SWIG_IsOK(status))
{
ParaMEDMEM::DataArrayIntTuple *tmp=reinterpret_cast< ParaMEDMEM::DataArrayIntTuple * >(argp);
throw INTERP_KERNEL::Exception(msg);
}
+/*!
+ * if python int -> cpp int sw=1
+ * if python tuple[int] -> cpp vector<int> sw=2
+ * if python list[int] -> cpp vector<int> sw=2
+ * if python slice -> cpp pair sw=3
+ * if python DataArrayIntTuple -> cpp DataArrayIntTuple sw=4 . WARNING The returned pointer can be the null pointer !
+ */
static void convertObjToPossibleCpp22(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector<int>& stdvecTyypp, std::pair<int, std::pair<int,int> >& p, ParaMEDMEM::DataArrayIntTuple *& daIntTyypp) throw(INTERP_KERNEL::Exception)
{
sw=-1;
sw=4;
}
+/*!
+ * if python string with size one -> cpp char sw=1
+ * if python string with size different from one -> cpp string sw=2
+ * if python tuple[string] or list[string] -> vector<string> sw=3
+ * if python not null pointer of DataArrayChar -> cpp DataArrayChar sw=4
+ * switch between (int,string,vector<string>,DataArrayChar)
+ */
+static void convertObjToPossibleCpp6(PyObject *value, int& sw, char& cTyp, std::string& sType, std::vector<std::string>& vsType, ParaMEDMEM::DataArrayChar *& dacType) throw(INTERP_KERNEL::Exception)
+{
+ const char *msg="4 types accepted : string, list or tuple of strings having same size, not null DataArrayChar instance.";
+ sw=-1;
+ if(PyString_Check(value))
+ {
+ const char *pt=PyString_AsString(value);
+ Py_ssize_t sz=PyString_Size(value);
+ if(sz==1)
+ {
+ cTyp=pt[0];
+ sw=1;
+ return;
+ }
+ else
+ {
+ sType=pt;
+ sw=2;
+ return;
+ }
+ }
+ if(PyTuple_Check(value))
+ {
+ int size=PyTuple_Size(value);
+ vsType.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyTuple_GetItem(value,i);
+ if(PyString_Check(o))
+ vsType[i]=PyString_AsString(o);
+ else
+ {
+ std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not a string ! only tuples of strings accepted !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=3;
+ return;
+ }
+ if(PyList_Check(value))
+ {
+ int size=PyList_Size(value);
+ vsType.resize(size);
+ for(int i=0;i<size;i++)
+ {
+ PyObject *o=PyList_GetItem(value,i);
+ if(PyString_Check(o))
+ vsType[i]=PyString_AsString(o);
+ else
+ {
+ std::ostringstream oss; oss << "List as been detected but element #" << i << " is not string ! only lists of strings accepted !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ sw=3;
+ return;
+ }
+ void *argp;
+ int status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayChar,0|0);
+ if(SWIG_IsOK(status))
+ {
+ dacType=reinterpret_cast< ParaMEDMEM::DataArrayChar * >(argp);
+ if(!dacType)
+ {
+ std::ostringstream oss; oss << msg << " Instance in null !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ sw=4;
+ return ;
+ }
+ throw INTERP_KERNEL::Exception(msg);
+}
+
/*!
* if value int -> cpp it sw=1
* if value list[int] -> vt sw=2