X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FDSC%2FDSC_Python%2Fcalcium.i;h=424dd6a4a9dc0a1ab758f291456645fbeb0c23b4;hb=82668fe5e4d077072402d253497f96d4c53391f9;hp=768cb438c2c5c6a751ce36f891507dccfa40dbf1;hpb=7d2fe213bdf5bf962ce11e253020c9d3e0bc1cce;p=modules%2Fkernel.git diff --git a/src/DSC/DSC_Python/calcium.i b/src/DSC/DSC_Python/calcium.i index 768cb438c..424dd6a4a 100644 --- a/src/DSC/DSC_Python/calcium.i +++ b/src/DSC/DSC_Python/calcium.i @@ -1,24 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + %define DOCSTRING "CALCIUM python wrapping : Superv_Component class " @@ -28,6 +26,8 @@ %feature("autodoc", "1"); +%include cstring.i + %{ //C++ Includes #include @@ -118,6 +118,19 @@ typedef PyArrayObject ArrayObject; #define array_size(a,i) (((PyArrayObject *)a)->dimensions[i]) #define array_is_contiguous(a) (PyArray_ISCONTIGUOUS(a)) +const char* pytype_string(PyObject*); +const char* typecode_string(int); +int type_match(int, int); +int require_size(PyArrayObject*, int*, int); +int require_dimensions_n(PyArrayObject*, int*, int); +int require_dimensions(PyArrayObject*, int); +int require_contiguous(PyArrayObject*); +PyArrayObject* make_contiguous(PyArrayObject*, int*, int, int); +PyArrayObject* obj_to_array_no_conversion(PyObject*, int); +PyArrayObject* obj_to_array_allow_conversion(PyObject*, int, int*); +PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject*, int, int*); +PyArrayObject* obj_to_array_contiguous_allow_conversion(PyObject*, int, int*); + /* Given a PyObject, return a string describing its type. */ const char* pytype_string(PyObject* py_obj) { @@ -133,7 +146,7 @@ const char* pytype_string(PyObject* py_obj) { if (PyModule_Check( py_obj)) return "module" ; if (PyInstance_Check(py_obj)) return "instance" ; - return "unkown type"; + return "unknown type"; } /* @@ -181,7 +194,7 @@ const char* typecode_string(int typecode) { "unsigned short","int","unsigned int","long","unsigned long", "longlong","unsigned longlong", "float","double","long double","complex float","complex double","complex long double", - "object","string","unicode","void","ntypes","notype","char","unkown"}; + "object","string","unicode","void","ntypes","notype","char","unknown"}; return type_names[typecode]; } @@ -400,8 +413,9 @@ typedef PyObject ArrayObject; %include "carrays.i" -%array_class(int, intArray); -%array_class(float, floatArray); +%array_class(int, intArray); +%array_class(long, longArray); +%array_class(float, floatArray); %array_class(double, doubleArray); /* special struct to handle string arrays */ @@ -410,6 +424,7 @@ struct stringArray { stringArray(int nelements,int size=0) { nelem=nelements; + size=size; data= new char*[nelements]; for(int i=0;istrides[0]; for(int i=0;idata + i* array->strides[0]; + { + $1[i]=(char*) malloc(sizeof(char)*(array->strides[0]+1)); + strncpy($1[i],(char*) array->data + i* array->strides[0],array->strides[0]); + *($1[i]+array->strides[0])='\0'; + } %#else SWIG_exception(SWIG_TypeError, "string array expected"); %#endif @@ -513,12 +545,23 @@ TYPEMAP_IN3(double, PyArray_DOUBLE) else { $1=sarray->data; + $2=sarray->size; } } -%typemap(freearg) char** eval { - if (array$argnum) free($1); - if (is_new_object$argnum && array$argnum) Py_DECREF(array$argnum); +%typemap(freearg) (char** eval,int strSize) { +%#ifdef WITH_NUMPY + if (array$argnum) + { + for(int i=0;istrides[0]; for(int i=0;idata+i*temp->strides[0]; + { + $1[i]=(char*) temp->data+i*temp->strides[0]; + memset($1[i],0,temp->strides[0]); //numpy strings must be completed with 0 up to elsize + } %#else temp = NULL; SWIG_exception(SWIG_TypeError, "string array expected"); @@ -590,10 +639,13 @@ TYPEMAP_INPLACE3(double, PyArray_DOUBLE) else { $1=sarray->data; + $2=sarray->size; } } -%typemap(freearg) char** lval { +%typemap(freearg) (char** lval,int strSize) { +%#ifdef WITH_NUMPY if (temp$argnum) free($1); +%#endif } /* End of typemap for array of strings on input/output */ @@ -636,13 +688,16 @@ CORBAPTR(PortableServer::POA) %typemap(out) Ports::Port_ptr { $result = api->cxxObjRefToPyObjRef($1, 1); - //All output Ports::Port_ptr variables are duplicated by security. Need to release them for python . Explanation ?? + //All output Ports::Port_ptr variables are duplicated by security. Need to release them for python. CORBA::release($1); } %typemap(out) Ports::PortProperties_ptr, Engines::Salome_file_ptr { $result = api->cxxObjRefToPyObjRef($1, 1); + //the _ptr is duplicated by the routine called. + //Need to release it for Python because the call to cxxObjRefToPyObjRef has created another ref with a count of 1 + CORBA::release($1); } %typemap(out) Engines::DSC::uses_port * @@ -801,6 +856,7 @@ class PySupervCompo:public Superv_Component_i CORBA::Boolean is_connected(const char* port_name) throw (Engines::DSC::PortNotDefined); // End of DSC interface for python components + static void setTimeOut(); %extend @@ -825,22 +881,35 @@ extern "C" void create_calcium_port(Superv_Component_i* compo,char* name,char* t %ignore CPMESSAGE; %include "calciumP.h" -int cp_cd(Superv_Component_i *component,char *name); +%cstring_bounded_output(char *instanceName, 1024); + +int cp_cd(Superv_Component_i *component,char *instanceName); int cp_een(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,int *eval); int cp_edb(Superv_Component_i *component,int dep,double t,int n,char *nom,int nval,double *eval); int cp_ere(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,float *eval); +int cp_erd(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,float *eval); int cp_ecp(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,float *ecpval); int cp_elo(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,int *eval); int cp_ech(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,char** eval,int strSize); +int cp_elg(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,long *eval); +int cp_eln(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,long *eval); int cp_len(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,int *lval); int cp_ldb(Superv_Component_i *component,int dep,double *ti,double *tf,int *niter,char *nom,int nmax,int *nval,double *lval); int cp_lre(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,float *lval); +int cp_lrd(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,float *lval); int cp_lcp(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,float *lcpval); int cp_llo(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,int *lval); int cp_lch(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,char** lval,int strSize); +int cp_llg(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,long *lval); +int cp_lln(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,long *lval); + +int cp_fini(Superv_Component_i *component,char *nom, int n); +int cp_fint(Superv_Component_i *component,char *nom, float t); +int cp_effi(Superv_Component_i *component,char *nom, int n); +int cp_efft(Superv_Component_i *component,char *nom, float t); int cp_fin(Superv_Component_i *component,int cp_end);