Salome HOME
updated copyright message
[tools/yacsgen.git] / module_generator / yacstypes.py
1 # Copyright (C) 2009-2023  EDF
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 ###########################################################
21 #             Types definitions                           #
22 ###########################################################
23 corbaTypes = {"double":"CORBA::Double", "long":"CORBA::Long",
24               "string":"const char*", "dblevec":"const %s::dblevec&",
25               "stringvec":"const %s::stringvec&", "intvec":"const %s::intvec&",
26               "file":None, "boolean":"CORBA::Boolean", "void":"void"
27              }
28
29 corbaOutTypes = {"double":"CORBA::Double&", "long":"CORBA::Long&",
30                  "string":"CORBA::String_out", "dblevec":"%s::dblevec_out",
31                  "stringvec":"%s::stringvec_out", "intvec":"%s::intvec_out",
32                  "file":None, "boolean":"CORBA::Boolean_out", "void":None
33                 }
34 moduleTypes = {"double":"", "long":"", "string":"", "dblevec":"", "stringvec":"", "intvec":"", "file":"", "pyobj":"", "boolean":"", "void":"" }
35
36 idlTypes = {"double":"double", "long":"long", "string":"string", "dblevec":"dblevec", "stringvec":"stringvec", "intvec":"intvec", 
37             "file":"", "boolean":"boolean", "void":"void" }
38
39 corbaRtnTypes = {"double":"CORBA::Double", "long":"CORBA::Long",
40                  "string":"char*", "dblevec":"%s::dblevec*",
41                  "stringvec":"%s::stringvec*", "intvec":"%s::intvec*",
42                  "file":None, "boolean":"CORBA::Boolean", "void":"void"
43                 }
44
45
46
47 def corba_in_type(typ, module):
48   if corbaTypes[typ].count("%s")>0:
49     return corbaTypes[typ] % (module+"_ORB")
50   else:
51     return corbaTypes[typ]
52
53 def corba_out_type(typ, module):
54   if corbaOutTypes[typ].count("%s")>0:
55     return corbaOutTypes[typ] % (module+"_ORB")
56   else:
57     return corbaOutTypes[typ]
58
59 def corba_rtn_type(typ, module):
60   if corbaRtnTypes[typ].count("%s")>0:
61     return corbaRtnTypes[typ] % (module+"_ORB")
62   else:
63     return corbaRtnTypes[typ]
64
65 ValidTypes = list(corbaTypes.keys())
66 PyValidTypes = ValidTypes+["pyobj"]
67
68 def add_type(typename, corbaType=None, corbaOutType=None, module="", idltype=None, corbaRtnType=None):
69   """ add a data type YACS from other module than KERNEL to the list of available types
70
71        :param typename: YACS data type name
72        :type typename: string
73        :param corbaType: representation for C++ CORBA in parameter
74        :type corbaType: string
75        :param corbaOutType: representation for C++ CORBA out parameter
76        :type corbaOutType: string
77        :param module: name of the module that defines the data type (GEOM for GEOM_Object)
78        :type module: string
79        :param idltype: representation for CORBA idl
80        :type idltype: string
81        :param corbaRtnType: representation for C++ CORBA return parameter
82        :type corbaRtnType: string
83   """
84   corbaTypes[typename] = corbaType or "const "+typename.replace("/","::")+"&"
85   corbaOutTypes[typename] = corbaOutType or typename.replace("/","::")+"_out"
86   corbaRtnTypes[typename] = corbaRtnType or typename.replace("/","::")+"*"
87   moduleTypes[typename] = module
88   idlTypes[typename] = idltype or typename.replace("/","::")
89   ValidTypes.append(typename)
90   PyValidTypes.append(typename)
91
92 calciumTypes = {"CALCIUM_double":"CALCIUM_double",
93                 "CALCIUM_integer":"CALCIUM_integer",
94                 "CALCIUM_real":"CALCIUM_real",
95                 "CALCIUM_string":"CALCIUM_string",
96                 "CALCIUM_complex":"CALCIUM_complex",
97                 "CALCIUM_logical":"CALCIUM_logical",
98                 "CALCIUM_long":"CALCIUM_long",
99                }
100
101 DatastreamParallelTypes = {"Param_Double_Port":"Param_Double_Port"}
102
103 ValidImpl = ("CPP", "PY", "F77", "ASTER", "PACO")
104 ValidImplTypes = ("sequential", "parallel")
105 ValidStreamTypes = list(calciumTypes.keys())
106 ValidParallelStreamTypes = list(DatastreamParallelTypes.keys())
107 ValidDependencies = ("I", "T")
108
109 #Add KERNEL YACS types : YACS name, c++ corba arg in, c++ corba arg out,defining module, repr corba idl, c++ corba return
110 add_type("dataref", "const Engines::dataref&", "Engines::dataref_out", "", "dataref","Engines::dataref*")
111 add_type("SALOME_TYPES/Parameter")
112 add_type("SALOME_TYPES/ParameterList", "const SALOME_TYPES::ParameterList&", "SALOME_TYPES::ParameterList_out", "", "SALOME_TYPES::ParameterList","SALOME_TYPES::ParameterList*")
113 add_type("SALOME_TYPES/VarList", "const SALOME_TYPES::VarList&", "SALOME_TYPES::VarList_out", "", "SALOME_TYPES::VarList","SALOME_TYPES::VarList*")
114 add_type("SALOME_TYPES/Variable", "const SALOME_TYPES::Variable&", "SALOME_TYPES::Variable_out", "", "SALOME_TYPES::Variable","SALOME_TYPES::Variable*")
115 add_type("SALOME_TYPES/VariableSequence", "const SALOME_TYPES::VariableSequence&", "SALOME_TYPES::VariableSequence_out", "", "SALOME_TYPES::VariableSequence","SALOME_TYPES::VariableSequence*")
116 add_type("SALOME_TYPES/StateSequence", "const SALOME_TYPES::StateSequence&", "SALOME_TYPES::StateSequence_out", "", "SALOME_TYPES::StateSequence","SALOME_TYPES::StateSequence*")
117 add_type("SALOME_TYPES/TimeSequence", "const SALOME_TYPES::TimeSequence&", "SALOME_TYPES::TimeSequence_out", "", "SALOME_TYPES::TimeSequence","SALOME_TYPES::TimeSequence*")
118 add_type("SALOME_TYPES/ParametricInput", "const SALOME_TYPES::ParametricInput&", "SALOME_TYPES::ParametricInput_out", "", "SALOME_TYPES::ParametricInput","SALOME_TYPES::ParametricInput*")
119 add_type("SALOME_TYPES/ParametricOutput", "const SALOME_TYPES::ParametricOutput&", "SALOME_TYPES::ParametricOutput_out", "", "SALOME_TYPES::ParametricOutput","SALOME_TYPES::ParametricOutput*")
120
121 #Add GEOM YACS types
122 add_type("GEOM_Object", "GEOM::GEOM_Object_ptr", "GEOM::GEOM_Object_out", "GEOM", "GEOM::GEOM_Object","GEOM::GEOM_Object_ptr")
123
124 #Add SMESH YACS types
125 add_type("SMESH_Mesh", "SMESH::SMESH_Mesh_ptr", "SMESH::SMESH_Mesh_out", "SMESH", "SMESH::SMESH_Mesh","SMESH::SMESH_Mesh_ptr")
126 add_type("SMESH_Hypothesis", "SMESH::SMESH_Hypothesis_ptr", "SMESH::SMESH_Hypothesis_out", "SMESH", "SMESH::SMESH_Hypothesis", "SMESH::SMESH_Hypothesis_ptr")
127
128 #Add MED YACS types
129 add_type("SALOME_MED/MED", "SALOME_MED::MED_ptr", "SALOME_MED::MED_out", "MED", "SALOME_MED::MED", "SALOME_MED::MED_ptr")
130 add_type("SALOME_MED/MESH", "SALOME_MED::MESH_ptr", "SALOME_MED::MESH_out", "MED", "SALOME_MED::MESH", "SALOME_MED::MESH_ptr")
131 add_type("SALOME_MED/SUPPORT", "SALOME_MED::SUPPORT_ptr", "SALOME_MED::SUPPORT_out", "MED", "SALOME_MED::SUPPORT", "SALOME_MED::SUPPORT_ptr")
132 add_type("SALOME_MED/FIELD", "SALOME_MED::FIELD_ptr", "SALOME_MED::FIELD_out", "MED", "SALOME_MED::FIELD", "SALOME_MED::FIELD_ptr")
133 add_type("SALOME_MED/FIELDDOUBLE", "SALOME_MED::FIELDDOUBLE_ptr", "SALOME_MED::FIELDDOUBLE_out", "MED", "SALOME_MED::FIELDDOUBLE", "SALOME_MED::FIELDDOUBLE_ptr")
134 add_type("SALOME_MED/FIELDINT", "SALOME_MED::FIELDINT_ptr", "SALOME_MED::FIELDINT_out", "MED", "SALOME_MED::FIELDINT", "SALOME_MED::FIELDINT_ptr")
135 add_type("SALOME/Matrix", "SALOME::Matrix_ptr", "SALOME::Matrix_out", "MED", "SALOME::Matrix", "SALOME::Matrix_ptr")
136 add_type("SALOME_MED/MEDCouplingFieldDoubleCorbaInterface", "SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr", "SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_out", "MED", "SALOME_MED::MEDCouplingFieldDoubleCorbaInterface", "SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr")
137 add_type("SALOME_MED/MPIMEDCouplingFieldDoubleCorbaInterface", "SALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface_ptr", "SALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface_out", "MED", "SALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface", "SALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface_ptr")
138 add_type("SALOME_MED/MEDCouplingUMeshCorbaInterface", "SALOME_MED::MEDCouplingUMeshCorbaInterface_ptr", "SALOME_MED::MEDCouplingUMeshCorbaInterface_out", "MED", "SALOME_MED::MEDCouplingUMeshCorbaInterface", "SALOME_MED::MEDCouplingUMeshCorbaInterface_ptr")
139 add_type("SALOME_MED/DataArrayDoubleCorbaInterface", "SALOME_MED::DataArrayDoubleCorbaInterface_ptr", "SALOME_MED::DataArrayDoubleCorbaInterface_out", "MED", "SALOME_MED::DataArrayDoubleCorbaInterface", "SALOME_MED::DataArrayDoubleCorbaInterface_ptr")