From: ageay Date: Wed, 6 Mar 2013 15:40:42 +0000 (+0000) Subject: Swig of DataArray*::pushBackValsSilent X-Git-Tag: V6_main_FINAL~321 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6e797f5777b5802f14f3a742d4179053507e1e36;p=tools%2Fmedcoupling.git Swig of DataArray*::pushBackValsSilent --- diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 179790356..920bcbb06 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -903,6 +903,14 @@ namespace ParaMEDMEM %extend ParaMEDMEM::DataArrayInt { + void pushBackValsSilent(PyObject *li) throw(INTERP_KERNEL::Exception) + { + int szArr,sw,iTypppArr; + std::vector stdvecTyyppArr; + const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr); + self->pushBackValsSilent(tmp,tmp+szArr); + } + PyObject *getDifferentValues() const throw(INTERP_KERNEL::Exception) { std::set ret=self->getDifferentValues(); @@ -2954,6 +2962,18 @@ namespace ParaMEDMEM return ParaMEDMEM_DataArrayDouble_New__SWIG_1(elt0,nbOfTuples,elt2); } + void pushBackValsSilent(PyObject *li) throw(INTERP_KERNEL::Exception) + { + double val; + DataArrayDouble *a; + DataArrayDoubleTuple *aa; + std::vector bb; + int sw,nbTuples=-1; + const char msg[]="Python wrap of DataArrayDouble::pushBackValsSilent : "; + const double *tmp=convertObjToPossibleCpp5_Safe2(li,sw,val,a,aa,bb,msg,1,true,nbTuples); + self->pushBackValsSilent(tmp,tmp+nbTuples); + } + std::string __str__() const { return self->repr(); diff --git a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i index faac75832..9aad039d6 100644 --- a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i +++ b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i @@ -1454,7 +1454,7 @@ static const double *convertObjToPossibleCpp5_Safe2(PyObject *value, int& sw, do throw INTERP_KERNEL::Exception(oss.str().c_str()); } else - return 0; + { nbTuples=0; return 0; } } } status=SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDoubleTuple,0|0); @@ -1462,15 +1462,28 @@ static const double *convertObjToPossibleCpp5_Safe2(PyObject *value, int& sw, do { e=reinterpret_cast< ParaMEDMEM::DataArrayDoubleTuple * >(argp); sw=3; - if(e->getNumberOfCompo()==nbCompExpected) + if(e) { - nbTuples=1; - return e->getConstPointer(); + if(e->getNumberOfCompo()==nbCompExpected) + { + nbTuples=1; + return e->getConstPointer(); + } + else + { + std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } } else { - std::ostringstream oss; oss << msg << "nb of components expected to be " << nbCompExpected << " , and input DataArrayDoubleTuple has " << e->getNumberOfCompo() << " components !"; - throw INTERP_KERNEL::Exception(oss.str().c_str()); + if(throwIfNullPt) + { + std::ostringstream oss; oss << msg << " null pointer not accepted!"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + else + { nbTuples=0; return 0; } } } throw INTERP_KERNEL::Exception("4 types accepted : integer, double, DataArrayDouble, DataArrayDoubleTuple");