From 55e725d8ee7953c815fe716633f0b29e5a0cc73b Mon Sep 17 00:00:00 2001 From: caremoli Date: Fri, 22 Oct 2010 17:06:40 +0000 Subject: [PATCH] CCAR: merge HXX2SALOME development from V5_1_main branch into V5_1_5_BR branch --- Examples/ast2/coupling.xml | 309 ++++++++++--------- Examples/cpp1/coupling.xml | 134 +++++---- Examples/fort1/coupling.xml | 124 ++++---- Examples/hxx1/README | 23 ++ Examples/hxx1/component.py | 54 ++++ Examples/hxx1/cpp_component.tgz | Bin 0 -> 19844 bytes Examples/hxx1/test_compohxx.py | 129 ++++++++ Examples/pyth1/coupling.xml | 138 +++++---- module_generator/__init__.py | 1 + module_generator/cata_tmpl.py | 2 + module_generator/cppcompo.py | 3 +- module_generator/gener.py | 26 +- module_generator/hxx_awk.py | 477 ++++++++++++++++++++++++++++++ module_generator/hxx_tmpl.py | 189 ++++++++++++ module_generator/hxxcompo.py | 333 +++++++++++++++++++++ module_generator/salomemodules.py | 5 +- module_generator/yacstypes.py | 51 +++- 17 files changed, 1643 insertions(+), 355 deletions(-) create mode 100644 Examples/hxx1/README create mode 100644 Examples/hxx1/component.py create mode 100644 Examples/hxx1/cpp_component.tgz create mode 100644 Examples/hxx1/test_compohxx.py create mode 100644 module_generator/hxx_awk.py create mode 100644 module_generator/hxx_tmpl.py create mode 100644 module_generator/hxxcompo.py diff --git a/Examples/ast2/coupling.xml b/Examples/ast2/coupling.xml index 3625fc7..0a541cb 100644 --- a/Examples/ast2/coupling.xml +++ b/Examples/ast2/coupling.xml @@ -1,147 +1,164 @@ - - - - - - - - - - - 23 - - - - - caster - s1 - - - - - - - - - - - - - - - - - - - - cfort - s1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -node1ba -node2a - - -node1bb -node2b - - -node2ba -node1aa - - -node2bb -node1ab - - -node2bc -node1ac - - -node2bd -node1ad - - -node2be -node1ae - - -node2bf -node1af - - -node2bg -node1ag - - - - node1fort:8 - dataout f1 - - - node1d - node98 p1 - - - datainf1 - node2 a - - - - node1 a - 23 - - - node1 b - 23 - - - node1 c - hello - - - - node2 b - 23 - - - node2 c - hello - - - - node1 jdc - f.comm - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 23 + + + + caster + + s1 + + + + + + + + + + + + + + + + + + cfort + + s1 + + + + + + + + + + + + + + + + + + + + + + + + datain node2 + node1 node98 + node1 dataout + + datain f1 + node2 a + + + node1 fort:8 + dataout f1 + + + node1 d + node98 p1 + + + node1 ba + node2 a + + + node1 bb + node2 b + + + node2 ba + node1 aa + + + node2 bb + node1 ab + + + node2 bc + node1 ac + + + node2 bd + node1 ad + + + node2 be + node1 ae + + + node2 bf + node1 af + + + node2 bg + node1 ag + + + node1jdc + f.comm + + + node1a + 23 + + + node1b + 23 + + + node1c + hello + + + node2b + 23 + + + node2c + hello + + + + + + + - diff --git a/Examples/cpp1/coupling.xml b/Examples/cpp1/coupling.xml index 07b3a26..bf6dbfc 100644 --- a/Examples/cpp1/coupling.xml +++ b/Examples/cpp1/coupling.xml @@ -1,63 +1,73 @@ - - - - - - - - - - - - - - compo1 - s1 - - - - - - - - - - compo1 - s1 - - - - - - - - - - - node1ba - node2aa - - - node2ba - node1aa - - - - node1 a - 23 - - - node1 b - 53 - - - node2 a - 63 - - - node2 b - 73 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + compo1 + + s1 + + + + + + + + compo1 + + s1 + + + + + + + + node1 ba + node2 aa + + + node2 ba + node1 aa + + + node1a + 23 + + + node1b + 53 + + + node2a + 63 + + + node2b + 73 + + + + - diff --git a/Examples/fort1/coupling.xml b/Examples/fort1/coupling.xml index c3d4ef8..8c0e551 100644 --- a/Examples/fort1/coupling.xml +++ b/Examples/fort1/coupling.xml @@ -1,59 +1,67 @@ - - - - - - - - - - - - - - fcode1 - serv1 - - - - - - - - - fcode2 - serv1 - - - - - - - - - - - node1PARAM - node2PARAM - - - - node1 a - 23 - - - node1 b - 53 - - - node2 a - 63 - - - node2 b - 73 - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + fcode1 + + serv1 + + + + + + + fcode2 + + serv1 + + + + + + + node1 PARAM + node2 PARAM + + + node1a + 23 + + + node1b + 53 + + + node2a + 63 + + + node2b + 73 + + + + - diff --git a/Examples/hxx1/README b/Examples/hxx1/README new file mode 100644 index 0000000..2c5154f --- /dev/null +++ b/Examples/hxx1/README @@ -0,0 +1,23 @@ +to run this example, one has first to untar the cpp_component archive, compile it, +and install it in directory COMPONENTCPP_INSTALL + + tar xvfz cpp_component.tgz + mkdir COMPONENTCPP_INSTALL COMPONENTCPP_BUILD + cd COMPONENTCPP_SRC + ./build_configure + cd ../COMPONENTCPP_BUILD + ../COMPONENTCPP_SRC/configure --prefix=... + make + make install + + +Generate the components with : + + python component.py + + +Test them with + + appli/runAppli -u test_compohxx.py + + diff --git a/Examples/hxx1/component.py b/Examples/hxx1/component.py new file mode 100644 index 0000000..5008c41 --- /dev/null +++ b/Examples/hxx1/component.py @@ -0,0 +1,54 @@ +import os +from module_generator import Generator,Module,Service +from module_generator import CPPComponent,PYComponent,HXX2SALOMEComponent + +kernel_root_dir=os.environ["KERNEL_ROOT_DIR"] +gui_root_dir=os.environ["GUI_ROOT_DIR"] +yacs_root_dir=os.environ["YACS_ROOT_DIR"] +med_root_dir=os.environ["MED_ROOT_DIR"] +geom_root_dir=os.environ["GEOM_ROOT_DIR"] + +#import context from .. +execfile("../context.py") + +cwd=os.getcwd() +cpppath=os.path.join(cwd,"COMPONENTCPP_INSTALL") + + +# PUT HERE DEFINITIONS OF THE COMPONENTS AND THE SERVICES + + +os.environ["CALCULCPP_ROOT_DIR"]=cpppath +os.environ["MEDCALCCPP_ROOT_DIR"]=cpppath +os.environ["TESTMEDCPP_ROOT_DIR"]=cpppath +os.environ["ICOCOCPP_ROOT_DIR"]=cpppath +os.environ["TESTMEMCPP_ROOT_DIR"]=cpppath +c1=HXX2SALOMEComponent("CALCUL.hxx","libCALCULCXX.so" , cpppath ) +c2=HXX2SALOMEComponent("MEDCALC.hxx","libMEDCALCCXX.so" , cpppath ) +c3=HXX2SALOMEComponent("TESTMED.hxx","libTESTMEDCXX.so" , cpppath ) +c4=HXX2SALOMEComponent("ICOCO.hxx","libICOCOCXX.so" , cpppath ) +c5=HXX2SALOMEComponent("TESTMEM.hxx","libTESTMEMCXX.so" , cpppath ) + + +g=Generator(Module("hxxcompos",components=[c4,c1,c2,c3,c5],prefix="./install"),context) +g.generate() +g.bootstrap() +g.configure() +g.make() +g.install() +g.make_appli("appli", + restrict=["KERNEL","GUI","YACS"], + altmodules={"GUI":gui_root_dir, + "MED":med_root_dir, + "YACS":yacs_root_dir, + "GEOM":geom_root_dir}) +cppenv=""" export CALCULCPP_ROOT_DIR=%(cpppath)s +export MEDCALCCPP_ROOT_DIR=%(cpppath)s +export TESTMEDCPP_ROOT_DIR=%(cpppath)s +export ICOCOCPP_ROOT_DIR=%(cpppath)s +export TESTMEMCPP_ROOT_DIR=%(cpppath)s""" % {"cpppath" : cpppath} + +cppenvfile=open("appli/env.d/cppEnv.sh","w") +cppenvfile.write(cppenv) +cppenvfile.close() + diff --git a/Examples/hxx1/cpp_component.tgz b/Examples/hxx1/cpp_component.tgz new file mode 100644 index 0000000000000000000000000000000000000000..87432a041a678c7cc9db603c48871399290508ea GIT binary patch literal 19844 zcmV)CK*GNtiwFR1oxMx|1MFLQbK6F;&%eQ^m@rOA+9W0Fuq&3CDutpFz13BsdF%Do?lY=HNx)1`PanTN2JD}moS&TzPA~iC=cD08 zf8&dfe{I6`Y7+_g}!v(v|7d zO@#QuOXBQznXVldOauKX`1!;Jj_zy4}ttfCD)a~!9Cc6vBEIJ)RvOK%p7N1Nggp`|a{Qq*+o=f7|K z^7v7!wWnJf{Oj+JTAfzy+VOnx=&han&T%f!M*ZW#{%NoH>(N{L=exRay&(47pcC%Y z*Nw>1INV9)<8=ePIGU(wmdN)G=%{Gj7!`r;gP^TvB2-$dXez=t=BBR_y>8z8zU{@~ zTm@@aA7?7?M+FZ-JY6@`mvbcc@IE@zOloca(b-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P{DoP1)`i6_UBEK3m_Mg}r@yhCcuzli# zKXNt+?*9fV=}cg$dG0e)R6t?#odKOlf|?7zF!9iiz){=0eg+DX&fO`zH*&Se;8E=6 zK>E?=mmD01wiz}$cOZ(i`8qGMFiz`x7^b$>Y59?##!xBZv`G_rKMO31Kypv;zioZ@Tt@rsdA&)WtPlLIVcgGtv(mVKuR9X!J~}N1 v8*5_9SGHEXVRfyp)wQ}-*Xmkbt7~ - - - - - - - - - - - - compo2 - s1 - - - - - - - - - - - compo2 - s1 - - - - - - - - - - - - node1ba - node2aa - - - node2ba - node1aa - - - - node1 a - 23 - - - node1 b - 53 - - - node2 a - 63 - - - node2 b - 73 - - + + + + + + + + + + + + + + + + + + + + + + + + + + + compo2 + + s1 + + + + + + + + + compo2 + + s1 + + + + + + + + + node1 ba + node2 aa + + + node2 ba + node1 aa + + + node1a + 23 + + + node1b + 53 + + + node2a + 63 + + + node2b + 73 + + + + - diff --git a/module_generator/__init__.py b/module_generator/__init__.py index 650d35a..e79531f 100644 --- a/module_generator/__init__.py +++ b/module_generator/__init__.py @@ -28,3 +28,4 @@ from cppcompo import CPPComponent from pacocompo import PACOComponent from pycompo import PYComponent from astcompo import ASTERComponent +from hxxcompo import HXX2SALOMEComponent diff --git a/module_generator/cata_tmpl.py b/module_generator/cata_tmpl.py index d3c6f7f..c8feeff 100644 --- a/module_generator/cata_tmpl.py +++ b/module_generator/cata_tmpl.py @@ -31,6 +31,8 @@ idl=""" #include "DSC_Engines.idl" #include "SALOME_Exception.idl" #include "SALOME_PACOExtension.idl" +#include "SALOME_Component.idl" +#include "SALOME_Comm.idl" ${idldefs} diff --git a/module_generator/cppcompo.py b/module_generator/cppcompo.py index aec9c78..3fef424 100644 --- a/module_generator/cppcompo.py +++ b/module_generator/cppcompo.py @@ -25,6 +25,7 @@ import os from gener import Component, Invalid from cpp_tmpl import initService, cxxService, hxxCompo, cxxCompo from cpp_tmpl import exeCPP, compoEXEMakefile, compoMakefile +from yacstypes import corba_rtn_type class CPPComponent(Component): """ @@ -131,7 +132,7 @@ AM_CFLAGS=$(SALOME_INCLUDES) -fexceptions """ services = [] for serv in self.services: - service = " void %s(" % serv.name + service = " %s %s(" % (corba_rtn_type(serv.ret,gen.module.name),serv.name) service = service+gen.makeArgs(serv)+");" services.append(service) diff --git a/module_generator/gener.py b/module_generator/gener.py index 74153d9..4fc94e5 100644 --- a/module_generator/gener.py +++ b/module_generator/gener.py @@ -173,6 +173,7 @@ class Service(object): by a 2-tuple (port name, data type name). The list of supported basic data types is: "double", "long", "string", "dblevec", "stringvec", "intvec", "file" and "pyobj" only for Python services. Depending on the implementation language, it is also possible to use some types from SALOME modules (see :ref:`yacstypes`). + :param ret: gives the type of the return parameter :param instream: gives the list of input datastream ports. :param outstream: gives the list of output datastream ports. An input or output datastream port is defined by a 3-tuple (port name, data type name, mode name). The list of possible data types is: "CALCIUM_double", "CALCIUM_integer", @@ -194,11 +195,12 @@ class Service(object): """ - def __init__(self, name, inport=None, outport=None, instream=None, outstream=None, + def __init__(self, name, inport=None, outport=None, ret="void", instream=None, outstream=None, parallel_instream=None, parallel_outstream=None, defs="", body="", impl_type="sequential"): self.name = name self.inport = inport or [] self.outport = outport or [] + self.ret = ret self.instream = instream or [] self.outstream = outstream or [] self.parallel_instream = parallel_instream or [] @@ -354,7 +356,7 @@ AM_CFLAGS=$(SALOME_INCLUDES) -fexceptions modules = {} for compo in module.components: for serv in compo.services: - for name, typ in serv.inport + serv.outport: + for name, typ in serv.inport + serv.outport + [ ("return",serv.ret) ] : mod = moduleTypes[typ] if mod: get_dependent_modules(mod,modules) @@ -675,6 +677,8 @@ echo " Qt ..................... : $qt_ok" params = [] for name, typ in serv.outport: params.append(cataOutparam.substitute(name=name, type=typ)) + if serv.ret != "void" : + params.append(cataOutparam.substitute(name="return", type=serv.ret)) outparams = "\n".join(params) streams = [] for name, typ, dep in serv.instream: @@ -732,14 +736,22 @@ echo " Qt ..................... : $qt_ok" else: typ=idlTypes[typ] params.append("out %s %s" % (typ, name)) - service = " void %s(" % serv.name + service = " %s %s(" % (idlTypes[serv.ret],serv.name) service = service+",".join(params)+") raises (SALOME::SALOME_Exception);" services.append(service) - inheritedinterface="" - if compo.inheritedinterface: - inheritedinterface=compo.inheritedinterface+"," - interfaces.append(interface.substitute(component=compo.name, services="\n".join(services),inheritedinterface=inheritedinterface)) + from hxxcompo import HXX2SALOMEComponent + if isinstance(compo,HXX2SALOMEComponent): + from hxx_tmpl import interfaceidlhxx + Inherited="" + if compo.use_medmem==True: + Inherited=", SALOME_MED::MED_Gen_Driver" + interfaces.append(interfaceidlhxx.substitute(component=compo.name,inherited=Inherited, services="\n".join(services))) + else: + inheritedinterface="" + if compo.inheritedinterface: + inheritedinterface=compo.inheritedinterface+"," + interfaces.append(interface.substitute(component=compo.name, services="\n".join(services),inheritedinterface=inheritedinterface)) #build idl includes for SALOME modules idldefs="" diff --git a/module_generator/hxx_awk.py b/module_generator/hxx_awk.py new file mode 100644 index 0000000..839f3ca --- /dev/null +++ b/module_generator/hxx_awk.py @@ -0,0 +1,477 @@ +# only the first two characters of the map are actually used to find out in/out caracteristic +cpp2idl_mapping={} +cpp2idl_mapping["int"]="in long" +cpp2idl_mapping["bool"]="in boolean" +cpp2idl_mapping["double"]="in double" +cpp2idl_mapping["float"]="in float" +cpp2idl_mapping["long"]="in long" +cpp2idl_mapping["short"]="in short" +cpp2idl_mapping["unsigned"]="in unsigned long" +cpp2idl_mapping["const char*"]="in string" +cpp2idl_mapping["const std::string&"]="in string" +cpp2idl_mapping["int&"]="out long" +cpp2idl_mapping["bool&"]="out boolean" +cpp2idl_mapping["double&"]="out double" +cpp2idl_mapping["float&"]="out float" +cpp2idl_mapping["long&"]="out long" +cpp2idl_mapping["short&"]="out short" +cpp2idl_mapping["unsigned&"]="out unsigned long" +cpp2idl_mapping["std::string&"]="out string" +cpp2idl_mapping["const MEDMEM::MESH&"]="in SALOME_MED::MESH" +cpp2idl_mapping["const MEDMEM::MESH*"]="in SALOME_MED::MESH" +cpp2idl_mapping["const MEDMEM::SUPPORT&"]="in SALOME_MED::SUPPORT" +cpp2idl_mapping["const MEDMEM::SUPPORT*"]="in SALOME_MED::SUPPORT" +cpp2idl_mapping["const MEDMEM::FIELD*"]="in SALOME_MED::FIELDDOUBLE" +cpp2idl_mapping["const MEDMEM::FIELD&"]="in SALOME_MED::FIELDDOUBLE" +cpp2idl_mapping["MEDMEM::FIELD*&"]="out SALOME_MED::FIELDDOUBLE" +cpp2idl_mapping["const std::vector&"]="in %(module)s::dblevec" +cpp2idl_mapping["const std::vector >&"]="in SALOME::Matrix" +cpp2idl_mapping["std::vector*&"]="out %(module)s::dblevec" +cpp2idl_mapping["const MEDMEM::FIELD*"]="in SALOME_MED::FIELDINT" +cpp2idl_mapping["const MEDMEM::FIELD&"]="in SALOME_MED::FIELDINT" +cpp2idl_mapping["MEDMEM::FIELD*&"]="out SALOME_MED::FIELDINT" +cpp2idl_mapping["const std::vector&"]="in %(module)s::intvec" +cpp2idl_mapping["std::vector*&"]="out %(module)s::intvec" +cpp2idl_mapping["const ParaMEDMEM::MEDCouplingFieldDouble*"]="in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface" + +# ['stringvec', 'string', 'double', 'long', 'dblevec', 'file', 'intvec', 'dataref', 'GEOM_Object', 'SMESH_Mesh', 'SMESH_Hypothesis', 'SALOME_MED/MED', 'SALOME_MED/MESH', 'SALOME_MED/SUPPORT', 'SALOME_MED/FIELD', 'SALOME_MED/FIELDDOUBLE', 'SALOME_MED/FIELDINT'] +cpp2yacs_mapping={} +cpp2yacs_mapping["int"]="long" +cpp2yacs_mapping["bool"]="boolean" +cpp2yacs_mapping["double"]="double" +#cpp2yacs_mapping["float"]="in float" +cpp2yacs_mapping["long"]="long" +#cpp2yacs_mapping["short"]="in short" +#cpp2yacs_mapping["unsigned"]="in unsigned long" +cpp2yacs_mapping["const char*"]="string" +cpp2yacs_mapping["const std::string&"]="string" +cpp2yacs_mapping["int&"]="long" +cpp2yacs_mapping["bool&"]="boolean" +cpp2yacs_mapping["double&"]="double" +#cpp2yacs_mapping["float&"]="out float" +cpp2yacs_mapping["long&"]="long" +#cpp2yacs_mapping["short&"]="out short" +#cpp2yacs_mapping["unsigned&"]="out unsigned long" +cpp2yacs_mapping["std::string&"]="string" +cpp2yacs_mapping["const MEDMEM::MESH&"]="SALOME_MED/MESH" +cpp2yacs_mapping["const MEDMEM::MESH*"]="SALOME_MED/MESH" +cpp2yacs_mapping["const MEDMEM::SUPPORT&"]="SALOME_MED/SUPPORT" +cpp2yacs_mapping["const MEDMEM::SUPPORT*"]="SALOME_MED/SUPPORT" +cpp2yacs_mapping["const MEDMEM::FIELD*"]="SALOME_MED/FIELDDOUBLE" +cpp2yacs_mapping["const MEDMEM::FIELD&"]="SALOME_MED/FIELDDOUBLE" +cpp2yacs_mapping["MEDMEM::FIELD*&"]="SALOME_MED/FIELDDOUBLE" + +cpp2yacs_mapping["const std::vector&"]="dblevec" + +cpp2yacs_mapping["const std::vector >&"]="SALOME/Matrix" + +cpp2yacs_mapping["std::vector*&"]="dblevec" + +cpp2yacs_mapping["const MEDMEM::FIELD*"]="SALOME_MED/FIELDINT" +cpp2yacs_mapping["const MEDMEM::FIELD&"]="SALOME_MED/FIELDINT" +cpp2yacs_mapping["MEDMEM::FIELD*&"]="SALOME_MED/FIELDINT" +cpp2yacs_mapping["const std::vector&"]="intvec" +cpp2yacs_mapping["std::vector*&"]="intvec" + +cpp2yacs_mapping["void"]="void" +cpp2yacs_mapping["char*"]="string" +cpp2yacs_mapping["std::string"]="string" +cpp2yacs_mapping["MEDMEM::MESH&"]="SALOME_MED/MESH" +cpp2yacs_mapping["MEDMEM::MESH*"]="SALOME_MED/MESH" +cpp2yacs_mapping["MEDMEM::SUPPORT*"]="SALOME_MED/SUPPORT" +cpp2yacs_mapping["MEDMEM::FIELD*"]="SALOME_MED/FIELDDOUBLE" +cpp2yacs_mapping["MEDMEM::FIELD&"]="SALOME_MED/FIELDDOUBLE" +cpp2yacs_mapping["MEDMEM::FIELD*"]="SALOME_MED/FIELDINT" +cpp2yacs_mapping["MEDMEM::FIELD&"]="SALOME_MED/FIELDINT" + +cpp2yacs_mapping["std::vector*"]="dblevec" +cpp2yacs_mapping["std::vector*"]="intvec" + +cpp2yacs_mapping["std::vector >*"]="SALOME/Matrix" +cpp2yacs_mapping["std::vector"]="stringvec" +cpp2yacs_mapping["const ParaMEDMEM::MEDCouplingFieldDouble*"]="SALOME_MED/MEDCouplingFieldDoubleCorbaInterface" +cpp2yacs_mapping["const ParaMEDMEM::MEDCouplingFieldDouble&"]="SALOME_MED/MEDCouplingFieldDoubleCorbaInterface" +cpp2yacs_mapping["ParaMEDMEM::MEDCouplingFieldDouble*&"]="SALOME_MED/MEDCouplingFieldDoubleCorbaInterface" +cpp2yacs_mapping["ParaMEDMEM::MEDCouplingUMesh*"]="SALOME_MED/MEDCouplingUMeshCorbaInterface" +cpp2yacs_mapping["ParaMEDMEM::MEDCouplingFieldDouble*"]="SALOME_MED/MEDCouplingFieldDoubleCorbaInterface" +# table for c++ code generation : argument's processing +cpp_impl_a={} +cpp_impl_a["int"]="\tint _%(arg)s(%(arg)s);\n" +cpp_impl_a["bool"]="\tbool _%(arg)s(%(arg)s);\n" +cpp_impl_a["double"]="\tdouble _%(arg)s(%(arg)s);\n" +cpp_impl_a["float"]="\tfloat _%(arg)s(%(arg)s);\n" +cpp_impl_a["long"]="\tlong _%(arg)s(%(arg)s);\n" +cpp_impl_a["short"]="\tshort _%(arg)s(%(arg)s);\n" +cpp_impl_a["unsigned"]="\tunsigned _%(arg)s(%(arg)s);\n" +cpp_impl_a["const char*"]="\tconst char* _%(arg)s(%(arg)s);\n" +cpp_impl_a["const std::string&"]="\tconst std::string _%(arg)s(%(arg)s);\n" +cpp_impl_a["int&"]="\tint _%(arg)s;\n" +cpp_impl_a["bool&"]="\tbool _%(arg)s;\n" +cpp_impl_a["double&"]="\tdouble _%(arg)s;\n" +cpp_impl_a["float&"]="\tfloat _%(arg)s;\n" +cpp_impl_a["long&"]="\tlong _%(arg)s;\n" +cpp_impl_a["short&"]="\tshort _%(arg)s;\n" +cpp_impl_a["unsigned&"]="\tunsigned _%(arg)s;\n" +cpp_impl_a["std::string&"]="\tstd::string _%(arg)s;\n" +cpp_impl_a["const MEDMEM::MESH&"]="\tMEDMEM::MESHClient* _%(arg)s = new MEDMEM::MESHClient(%(arg)s);\n\t _%(arg)s->fillCopy();\n" # MESHClient cannot be created on the stack (private constructor), so we create it on the heap and dereference it later (in treatment 4) +cpp_impl_a["const MEDMEM::MESH*"]="\tMEDMEM::MESHClient* _%(arg)s = new MEDMEM::MESHClient(%(arg)s);\n\t _%(arg)s->fillCopy();\n" +cpp_impl_a["const MEDMEM::SUPPORT&"]="\tMEDMEM::SUPPORTClient* _%(arg)s = new MEDMEM::SUPPORTClient(%(arg)s);\n" # SUPPORTClient cannot be created on the stack (protected destructor), so we create it on the heap and dereference it later (in treatment 4) +cpp_impl_a["const MEDMEM::SUPPORT*"]="\tMEDMEM::SUPPORTClient* _%(arg)s = new MEDMEM::SUPPORTClient(%(arg)s);\n" +cpp_impl_a["MEDMEM::FIELD*&"]="\tMEDMEM::FIELD* _%(arg)s;\n" +cpp_impl_a["const MEDMEM::FIELD*"]="\tstd::auto_ptr > _%(arg)s ( new MEDMEM::FIELDClient(%(arg)s) );\n" +cpp_impl_a["const MEDMEM::FIELD&"]="\tMEDMEM::FIELDClient _%(arg)s(%(arg)s);\n" +cpp_impl_a["const std::vector&"]="\tlong _%(arg)s_size=%(arg)s.length();\n\tconst double *_%(arg)s_value = &%(arg)s[0];\n"\ + "\tstd::vector _%(arg)s(_%(arg)s_value,_%(arg)s_value+_%(arg)s_size);\n" +cpp_impl_a["std::vector*&"]="\tstd::vector* _%(arg)s;\n" +cpp_impl_a["const std::vector >&"]="\tMatrixClient _%(arg)s_client;\n\tint _%(arg)s_nbRow;\n\tint _%(arg)s_nbCol;\n"\ + "\tdouble* _%(arg)s_tab = _%(arg)s_client.getValue(%(arg)s,_%(arg)s_nbCol,_%(arg)s_nbRow);\n\tstd::vector > _%(arg)s(_%(arg)s_nbRow);\n"\ + "\tfor (int i=0; i!=_%(arg)s_nbRow; ++i)\n\t{\n\t _%(arg)s[i].resize(_%(arg)s_nbCol);\n"\ + "\t std::copy(_%(arg)s_tab+_%(arg)s_nbCol*i,_%(arg)s_tab+_%(arg)s_nbCol*(i+1), _%(arg)s[i].begin());\n\t}\n\tdelete [] _%(arg)s_tab;\n" +cpp_impl_a["MEDMEM::FIELD*&"]="\tMEDMEM::FIELD* _%(arg)s;\n" +cpp_impl_a["const MEDMEM::FIELD*"]="\tstd::auto_ptr > _%(arg)s ( new MEDMEM::FIELDClient(%(arg)s) );\n" +cpp_impl_a["const MEDMEM::FIELD&"]="\tMEDMEM::FIELDClient _%(arg)s(%(arg)s);\n" +cpp_impl_a["const std::vector&"]="\tlong _%(arg)s_size=%(arg)s.length();\n"\ + "\tstd::vector _%(arg)s(_%(arg)s_size);\n"\ + "\tfor (int i=0; i!=_%(arg)s_size; ++i)\n\t _%(arg)s[i]=%(arg)s[i];" +cpp_impl_a["std::vector*&"]="\tstd::vector* _%(arg)s;\n" +cpp_impl_a["const ParaMEDMEM::MEDCouplingFieldDouble*"]="\tParaMEDMEM::MEDCouplingFieldDouble* _%(arg)s=ParaMEDMEM::MEDCouplingFieldDoubleClient::New(%(arg)s);\n" +cpp_impl_a["const ParaMEDMEM::MEDCouplingFieldDouble&"]="\tParaMEDMEM::MEDCouplingFieldDouble* __%(arg)s=ParaMEDMEM::MEDCouplingFieldDoubleClient::New(%(arg)s);\n"\ + "\tParaMEDMEM::MEDCouplingFieldDouble& _%(arg)s=*__%(arg)s;\n" +cpp_impl_a["ParaMEDMEM::MEDCouplingFieldDouble*&"]="\tParaMEDMEM::MEDCouplingFieldDouble* _%(arg)s;\n" + + +# table for c++ code generation : returned value processing +cpp_impl_b={} +cpp_impl_b["void"]="" +cpp_impl_b["int"]="\tCORBA::Long _rtn_ior(_rtn_cpp);\n" +cpp_impl_b["bool"]="\tCORBA::Boolean _rtn_ior(_rtn_cpp);\n" +cpp_impl_b["double"]="\tCORBA::Double _rtn_ior(_rtn_cpp);\n" +cpp_impl_b["float"]="\tCORBA::Float _rtn_ior(_rtn_cpp);\n" +cpp_impl_b["long"]="\tCORBA::Long _rtn_ior(_rtn_cpp);\n" +cpp_impl_b["short"]="\tCORBA::Short _rtn_ior(_rtn_cpp);\n" +cpp_impl_b["unsigned"]="\tCORBA::ULong _rtn_ior(_rtn_cpp);\n" +cpp_impl_b["const char*"]="\tchar* _rtn_ior = CORBA::string_dup(_rtn_cpp);\n" +cpp_impl_b["char*"]="\tchar* _rtn_ior(_rtn_cpp);\n" +cpp_impl_b["std::string"]="""\tchar* _rtn_ior=CORBA::string_dup(_rtn_cpp.c_str());\n +\tstd::copy(_rtn_cpp.begin(),_rtn_cpp.end(),_rtn_ior);\n""" +cpp_impl_b["const MEDMEM::MESH&"]="""\tMEDMEM::MESH_i * _rtn_mesh_i = new MEDMEM::MESH_i(const_cast(&_rtn_cpp));\n +\tSALOME_MED::MESH_ptr _rtn_ior = _rtn_mesh_i->_this();\n""" +cpp_impl_b["MEDMEM::MESH&"]="\tMEDMEM::MESH_i * _rtn_mesh_i = new MEDMEM::MESH_i(&_rtn_cpp);\n\tSALOME_MED::MESH_ptr _rtn_ior = _rtn_mesh_i->_this();\n" +cpp_impl_b["MEDMEM::MESH*"]= "\tMEDMEM::MESH_i * _rtn_mesh_i = new MEDMEM::MESH_i(_rtn_cpp);\n\tSALOME_MED::MESH_ptr _rtn_ior = _rtn_mesh_i->_this();\n" +cpp_impl_b["const MEDMEM::MESH*"]="\tMEDMEM::MESH_i * _rtn_mesh_i = new MEDMEM::MESH_i(const_cast(_rtn_cpp));\n\tSALOME_MED::MESH_ptr _rtn_ior = _rtn_mesh_i->_this();\n" +cpp_impl_b["MEDMEM::SUPPORT*"]="\tMEDMEM::SUPPORT_i * _rtn_support_i = new MEDMEM::SUPPORT_i(_rtn_cpp);\n\tSALOME_MED::SUPPORT_ptr _rtn_ior = _rtn_support_i->_this();\n" +cpp_impl_b["const MEDMEM::FIELD*"]="""\tMEDMEM::FIELDTEMPLATE_I * _rtn_field_i = new MEDMEM::FIELDTEMPLATE_I(const_cast*>(_rtn_cpp),false);\n +\tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n""" +cpp_impl_b["MEDMEM::FIELD*"]="""\tMEDMEM::FIELDTEMPLATE_I * _rtn_field_i = new MEDMEM::FIELDTEMPLATE_I(_rtn_cpp,true);\n +\tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n""" +cpp_impl_b["MEDMEM::FIELD&"]="""\tMEDMEM::FIELDTEMPLATE_I * _rtn_field_i = new MEDMEM::FIELDTEMPLATE_I(&_rtn_cpp,false);\n +\tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n""" +cpp_impl_b["const MEDMEM::FIELD&"]="""\tMEDMEM::FIELDTEMPLATE_I * _rtn_field_i = new MEDMEM::FIELDTEMPLATE_I(const_cast*>(&_rtn_cpp),false);\n +\tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n""" +cpp_impl_b["std::vector*"]="""\t%(module)s::dblevec * _rtn_ior = new %(module)s::dblevec;\n +\tint _rtn_cpp_length=(*_rtn_cpp).size();\n +\t_rtn_ior->length(_rtn_cpp_length);\n +\tfor (int i=0; i<_rtn_cpp_length; ++i)\n\t (*_rtn_ior)[i] = (*_rtn_cpp)[i];\n""" +cpp_impl_b["std::vector >*"]="""\tint _rtn_cpp_i=(*_rtn_cpp).size();\n\tint _rtn_cpp_j=(*_rtn_cpp)[0].size();\n +\tdouble* _rtn_tab = new double[_rtn_cpp_i*_rtn_cpp_j];\n +\tfor (int i=0; i!=_rtn_cpp_i; ++i)\n\t std::copy((*_rtn_cpp)[i].begin(),(*_rtn_cpp)[i].end(),_rtn_tab+i*_rtn_cpp_j);\n +\tSALOME_Matrix_i* _rtn_matrix_i = new SALOME_Matrix_i(*this,_rtn_tab,_rtn_cpp_i,_rtn_cpp_j,true);\n +\tSALOME::Matrix_ptr _rtn_ior = _rtn_matrix_i->_this();\n\tdelete _rtn_cpp;\n""" +cpp_impl_b["const MEDMEM::FIELD*"]="\tMEDMEM::FIELDINT_i * _rtn_field_i = new MEDMEM::FIELDINT_i(const_cast*>(_rtn_cpp),false);\n\tSALOME_MED::FIELDINT_ptr _rtn_ior = _rtn_field_i->_this();\n" +cpp_impl_b["MEDMEM::FIELD*"]="\tMEDMEM::FIELDINT_i * _rtn_field_i = new MEDMEM::FIELDINT_i(_rtn_cpp,true);\n\tSALOME_MED::FIELDINT_ptr _rtn_ior = _rtn_field_i->_this();\n" +cpp_impl_b["MEDMEM::FIELD&"]="\tMEDMEM::FIELDINT_i * _rtn_field_i = new MEDMEM::FIELDINT_i(&_rtn_cpp,false);\n\tSALOME_MED::FIELDINT_ptr _rtn_ior = _rtn_field_i->_this();\n" +cpp_impl_b["const MEDMEM::FIELD&"]="\tMEDMEM::FIELDINT_i * _rtn_field_i = new MEDMEM::FIELDINT_i(const_cast*>(&_rtn_cpp),false);\n\tSALOME_MED::FIELDINT_ptr _rtn_ior = _rtn_field_i->_this();\n" +cpp_impl_b["std::vector*"]="""\t%(module)s::intvec * _rtn_ior = new %(module)s::intvec; +\tint _rtn_cpp_length=(*_rtn_cpp).size(); +\t_rtn_ior->length(_rtn_cpp_length); +\tfor (int i=0; i<_rtn_cpp_length; ++i)\n\t (*_rtn_ior)[i] = (*_rtn_cpp)[i];\n""" +cpp_impl_b["std::vector"]="""\t%(module)s::stringvec * _rtn_ior = new %(module)s::stringvec; +\tint _rtn_cpp_length=_rtn_cpp.size(); +\t_rtn_ior->length(_rtn_cpp_length); +\tfor (int i=0; i<_rtn_cpp_length; ++i) +\t (*_rtn_ior)[i] = _rtn_cpp[i].c_str();\n""" +cpp_impl_b["ParaMEDMEM::MEDCouplingFieldDouble*"]="""\tParaMEDMEM::MEDCouplingFieldDoubleServant * _rtn_field_i = new ParaMEDMEM::MEDCouplingFieldDoubleServant(_rtn_cpp); +\t_rtn_cpp->decrRef(); +\tSALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr _rtn_ior = _rtn_field_i->_this();\n""" +cpp_impl_b["ParaMEDMEM::MEDCouplingUMesh*"]="""\tParaMEDMEM::MEDCouplingUMeshServant * _rtn_mesh_i = new ParaMEDMEM::MEDCouplingUMeshServant(_rtn_cpp); +\t_rtn_cpp->decrRef(); +\tSALOME_MED::MEDCouplingUMeshCorbaInterface_ptr _rtn_ior = _rtn_mesh_i->_this();\n""" +# +# table for c++ code generation : out parameters processing and removeRef for reference counted objects +# +cpp_impl_c={} +cpp_impl_c["MEDMEM::FIELD*&"]="""\tMEDMEM::FIELDTEMPLATE_I * %(arg)s_ior = new MEDMEM::FIELDTEMPLATE_I(_%(arg)s, true);\n +\t%(arg)s = %(arg)s_ior->_this();\n""" +cpp_impl_c["MEDMEM::FIELD*&"]=""" \tMEDMEM::FIELDINT_i * %(arg)s_ior = new MEDMEM::FIELDINT_i(_%(arg)s, true);\n +\t%(arg)s = %(arg)s_ior->_this();\n""" +cpp_impl_c["std::vector*&"]="""\t%(arg)s = new %(module)s::dblevec;\n +\t%(arg)s->length((*_%(arg)s).size());\n +\tfor (int i=0; i<(*_%(arg)s).size(); ++i)\n\t (*%(arg)s)[i] = (*_%(arg)s)[i];\n""" +cpp_impl_c["std::vector*&"]="""\t%(arg)s = new %(module)s::intvec;\n +\t%(arg)s->length((*_%(arg)s).size());\n +\tfor (int i=0; i<(*_%(arg)s).size(); ++i)\n\t (*%(arg)s)[i] = (*_%(arg)s)[i];\n""" +cpp_impl_c["std::string&"]="\t%(arg)s = CORBA::string_dup(_%(arg)s.c_str());\n" +cpp_impl_c["int&"]="\t%(arg)s = _%(arg)s;\n" +cpp_impl_c["bool&"]="\t%(arg)s = _%(arg)s;\n" +cpp_impl_c["double&"]="\t%(arg)s = _%(arg)s;\n" +cpp_impl_c["float&"]="\t%(arg)s = _%(arg)s;\n" +cpp_impl_c["long&"]="\t%(arg)s = _%(arg)s;\n" +cpp_impl_c["short&"]="\t%(arg)s = _%(arg)s;\n" +cpp_impl_c["unsigned&"]="\t%(arg)s = _%(arg)s;\n" +cpp_impl_c["const MEDMEM::MESH&"]="\t_%(arg)s->removeReference();\n" +cpp_impl_c["const MEDMEM::MESH*"]="\t_%(arg)s->removeReference();\n" +cpp_impl_c["const MEDMEM::SUPPORT&"]="\t_%(arg)s->removeReference();\n" +cpp_impl_c["const MEDMEM::SUPPORT*"]="\t_%(arg)s->removeReference();\n" +cpp_impl_c["const ParaMEDMEM::MEDCouplingFieldDouble*"]="\t_%(arg)s->decrRef();\n" +cpp_impl_c["const ParaMEDMEM::MEDCouplingFieldDouble*"]="\t_%(arg)s->decrRef();\n" +cpp_impl_c["const ParaMEDMEM::MEDCouplingFieldDouble&"]="\t__%(arg)s->decrRef();\n" +cpp_impl_c["ParaMEDMEM::MEDCouplingFieldDouble*&"]="""\tParaMEDMEM::MEDCouplingFieldDoubleServant * %(arg)s_out=new ParaMEDMEM::MEDCouplingFieldDoubleServant(_%(arg)s); +\t_%(arg)s->decrRef(); +\t%(arg)s = %(arg)s_out->_this();\n""" + +# +# the following awk files (extracted from hxx2saloe) are used to parse hxx file +# +# +parse01=""" +# This awk program deletes C like comments '*/ ... /*' +# -- +# Copyright (C) CEA +# Author : Nicolas Crouzet (CEA) +# -- +{ + if (t = index($0, "/*")) { + if (t > 1) + tmp = substr($0, 1, t - 1) + else + tmp = "" + u = index(substr($0, t + 2), "*/") + while (u == 0) { + getline + t = -1 + u = index($0, "*/") + } + if (u <= length($0) - 2) + $0 = tmp substr($0, t + u + 3) + else + $0 = tmp + } + print $0 +} +""" +parse1=""" +# This awk program extract public functions of the class definition present in hxx interface +# -- +# Copyright (C) CEA +# Author : Nicolas Crouzet (CEA) +# -- + +BEGIN { public=0 } + +# we want to extract each function that is public and that does'nt contain +# the patterns : public, protected, private, // (comments), { and } +public == 1 && +$1 !~ /public/ && +$1 !~ /protected/ && +$1 !~ /private/ && +$1 !~ /\/\/*/ && +$1 !~ /{|}/ { + for (i=1; i<=NF; i++) + printf "%s ", $i +# change line if last field contains ";" -> one function per line in output + if ( $NF ~ /;/ ) + printf "\\n" +} + +$1 == "class" && $0 !~ /;/ {public=1} # we test matching against /;/ to get rid of forward declaration +$1 ~ /public/ {public=1} +$1 ~ /protected/ {public=0} +$1 ~ /private/ {public=0} +$1 ~ /}/ {public=0} +""" +parse2=""" +# suppress blanks between type and indirection or reference operators (* and &) +# -- +# Copyright (C) CEA +# Author : Nicolas Crouzet (CEA) +# -- +{ gsub(/[ \\t]+&/,"\\\\& ") + gsub(/[ \\t]+\*/,"* ") + print $0 } +""" +parse3=""" +# This awk program contains the type mapping tables - and the treatments +# -- +# Copyright (C) CEA, EDF +# Author : Nicolas Crouzet (CEA) +# -- +# for code generation +# +BEGIN { +# +# file name generation + class_i=class_name"_i" +# +# +# type mapping from c++ component to idl +# + idl_arg_type["int"]="in long" + idl_arg_type["bool"]="in boolean" + idl_arg_type["double"]="in double" + idl_arg_type["float"]="in float" + idl_arg_type["long"]="in long" + idl_arg_type["short"]="in short" +# idl_arg_type["unsigned"]="in unsigned long" + idl_arg_type["const char*"]="in string" + idl_arg_type["const std::string&"]="in string" + idl_arg_type["int&"]="out long" + idl_arg_type["bool&"]="out boolean" + idl_arg_type["double&"]="out double" + idl_arg_type["float&"]="out float" + idl_arg_type["long&"]="out long" + idl_arg_type["short&"]="out short" + idl_arg_type["unsigned&"]="out unsigned long" + idl_arg_type["std::string&"]="out string" + idl_arg_type["const MEDMEM::MESH&"]="in SALOME_MED::MESH" + idl_arg_type["const MEDMEM::MESH*"]="in SALOME_MED::MESH" + idl_arg_type["const MEDMEM::SUPPORT&"]="in SALOME_MED::SUPPORT" + idl_arg_type["const MEDMEM::SUPPORT*"]="in SALOME_MED::SUPPORT" + idl_arg_type["const MEDMEM::FIELD*"]="in SALOME_MED::FIELDDOUBLE" + idl_arg_type["const MEDMEM::FIELD&"]="in SALOME_MED::FIELDDOUBLE" + idl_arg_type["MEDMEM::FIELD*&"]="out SALOME_MED::FIELDDOUBLE" + idl_arg_type["const std::vector&"]="in SALOME::vectorOfDouble" + idl_arg_type["const std::vector >&"]="in SALOME::Matrix" + idl_arg_type["std::vector*&"]="out SALOME::vectorOfDouble" + idl_arg_type["const MEDMEM::FIELD*"]="in SALOME_MED::FIELDINT" + idl_arg_type["const MEDMEM::FIELD&"]="in SALOME_MED::FIELDINT" + idl_arg_type["MEDMEM::FIELD*&"]="out SALOME_MED::FIELDINT" + idl_arg_type["const std::vector&"]="in SALOME::vectorOfLong" + idl_arg_type["std::vector*&"]="out SALOME::vectorOfLong" + idl_arg_type["const ParaMEDMEM::MEDCouplingFieldDouble*"]="in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface" +# +# +# mapping for returned types +# + idl_rtn_type["void"]="void" + idl_rtn_type["int"]="long" + idl_rtn_type["bool"]="boolean" + idl_rtn_type["double"]="double" + idl_rtn_type["float"]="float" + idl_rtn_type["long"]="long" + idl_rtn_type["short"]="short" + idl_rtn_type["unsigned"]="unsigned long" + idl_rtn_type["const char*"]="string" + idl_rtn_type["char*"]="string" + idl_rtn_type["std::string"]="string" + idl_rtn_type["const MEDMEM::MESH&"]="SALOME_MED::MESH" + idl_rtn_type["MEDMEM::MESH&"]="SALOME_MED::MESH" + idl_rtn_type["MEDMEM::MESH*"]="SALOME_MED::MESH" + idl_rtn_type["const MEDMEM::MESH*"]="SALOME_MED::MESH" + idl_rtn_type["MEDMEM::SUPPORT*"]="SALOME_MED::SUPPORT" + idl_rtn_type["const MEDMEM::FIELD*"]="SALOME_MED::FIELDDOUBLE" + idl_rtn_type["MEDMEM::FIELD*"]="SALOME_MED::FIELDDOUBLE" + idl_rtn_type["MEDMEM::FIELD&"]="SALOME_MED::FIELDDOUBLE" + idl_rtn_type["const MEDMEM::FIELD&"]="SALOME_MED::FIELDDOUBLE" + idl_rtn_type["std::vector*"]="SALOME::vectorOfDouble" + idl_rtn_type["std::vector >*"]="SALOME::Matrix" + idl_rtn_type["const MEDMEM::FIELD*"]="SALOME_MED::FIELDINT" + idl_rtn_type["MEDMEM::FIELD*"]="SALOME_MED::FIELDINT" + idl_rtn_type["MEDMEM::FIELD&"]="SALOME_MED::FIELDINT" + idl_rtn_type["const MEDMEM::FIELD&"]="SALOME_MED::FIELDINT" + idl_rtn_type["std::vector*"]="SALOME::vectorOfLong" + idl_rtn_type["std::vector"]="StrSeq" + idl_rtn_type["ParaMEDMEM::MEDCouplingUMesh*"]="SALOME_MED::MEDCouplingUMeshCorbaInterface" + idl_rtn_type["ParaMEDMEM::MEDCouplingFieldDouble*"]="SALOME_MED::MEDCouplingFieldDoubleCorbaInterface" +# +# +# record sep is ");\\n" whith blanks all around, and optional "(" at the beginning + RS="[(]?[ \\t]*[)][ \\t]*(const)?[ \\t]*[;][ \\t]*[\\n]" + FS="[ \\t]*[(,][ \\t]*" # field sep is either "(" or "," surrounded by blanks +} + +# --------------------- treatment 1 ---------------------------------- +# +# extract from fields types, function name, and argument's names +# +{ + print "Function : ",$0 >> "parse_result" # print for debug + for (i=1; i<=NF; i++) { + print "\\t-> ",i," : ",$i >> "parse_result" + } + ok1=0;ok=1 + error_message="\\t The non compatible types are : " + # check if returned type ($1) is one of the accepted types (idl_rtn_type) + for (cpptype in idl_rtn_type) { + if ( substr($1,1,length(cpptype)) == cpptype ) { + # if compatible, store returned type and function name + type[1]=cpptype + name[1]=substr($1,length(cpptype)+1) + sub("^[ \\t]*","",name[1]) # get rid of leading blanks + ok1=1 + break + } + } + ok*=ok1 + if ( ! ok1) { + split($1,tab," ") + error_message=error_message sprintf("\\n\\t\\t-> %s (return type)",tab[1]) + } + # for each argument ($i), check if it is compatible (belongs to idl_arg_type) + for (i=2; i<=NF; i++) { + ok2=0 + split($i,tab,"=") # get rid of default value + item=tab[1] + sub("/[ \\t]*&[ \\t]*/", "&", item) # supress spaces around * and $ + sub("/[ \\t]**[ \\t]*/", "*", item) + for (cpptype in idl_arg_type) { + l = length(cpptype) + s0 = substr(item,1,l) # to discriminate between int and int&, ... + s1 = " " + if (length(item) > l) + s1 = substr(item, l+1, 1) + + if ( (s0 == cpptype) && (s1 == " ") ) { + # if compatible, store argument type and name + type[i]=cpptype + name[i]=substr(item,length(cpptype)+1) + sub("^[ \\t]*","",name[i]) # get rid of leading blanks + if ( length(name[i]) == 0 ) # automatic name if argument's name wasn't precised + name[i]=sprintf("_arg%d",i-1) + ok2=1 + break + } + } + ok*=ok2 # ok=0 if one of the type is not compatible + if ( ! ok2) { + error_message=error_message "\\n\\t\\t-> "item + } + } + + # print compatibility + if ( $0 !~ class_name ) { # constructor are not considered, but we don't print it + if ( ok == 0){ # if one of the c++ type is not compatible + printf " [KO] : %s",$0 + } + else + printf " [OK] : %s",$0 + + if ( $0 !~ /\(/ ) { + printf "(" # if there is no argument, parenthesis was suppressed, so we add it for printing + } + printf ");\\n" + if ( ok == 0){ #print the error message + printf "%s\\n\\n",error_message + } + } + if ( ok == 0) # pass to the next function if one of the c++ type is not compatible + next +} +# +# --------------------- treatment 1 bis ------------------------------ +{ + printf "Function;%s;%s\\n",type[1],name[1] > "parse_type_result" + for (i=2; i<=NF; i++) { + printf "%s;%s\\n",type[i],name[i] >> "parse_type_result" + } +} +""" diff --git a/module_generator/hxx_tmpl.py b/module_generator/hxx_tmpl.py new file mode 100644 index 0000000..0ca5507 --- /dev/null +++ b/module_generator/hxx_tmpl.py @@ -0,0 +1,189 @@ +# Copyright (C) 2009-2010 EDF R&D +# +# 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. +# +# 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 +# + +try: + from string import Template +except: + from compat import Template,set + +cxxCompo=""" +// this cxx file was generated by yacsgen +#include "${component}_i.hxx" +#include "${component}.hxx" +using namespace std; +#include +#include +#include "SenderFactory.hxx" +#include "MultiCommException.hxx" +#include "ReceiverFactory.hxx" +#include "SALOME_Matrix_i.hxx" +#include "MatrixClient.hxx" +#include "Utils_CorbaException.hxx" + +//DEFS +${servicesdef} +//ENDDEF + +//============================================================================= +/*! + * standard constructor + */ +//============================================================================= +${component}_i::${component}_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName),${inheritedconstructor}cppCompo_(new ${component}) +{ + MESSAGE("activate object"); + _thisObj = this ; + _id = _poa->activate_object(_thisObj); +} + +${component}_i::~${component}_i() +{ +} + +${servicesimpl} + +char* ${component}_i::ComponentDataType() +{ + return CORBA::string_dup("${component}"); +} + +Engines::Component_ptr ${component}_i::GetComponentInstance() +{ + return ${component}_Gen::_this(); +} + +extern "C" +{ + PortableServer::ObjectId * ${component}Engine_factory( + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) + { + MESSAGE("PortableServer::ObjectId * ${component}Engine_factory()"); + SCRUTE(interfaceName); + ${component}_i * my${component} + = new ${component}_i(orb, poa, contId, instanceName, interfaceName); + return my${component}->getId() ; + } +} +""" +cxxCompo=Template(cxxCompo) + +hxxCompo=""" +//this file was generated by yacsgen +#ifndef __${component}_hxx2salome__ +#define __${component}_hxx2salome__ + +#include +#include CORBA_SERVER_HEADER(${module}) +#include "SALOME_Component_i.hxx" +#include "SALOMEMultiComm.hxx" +#include // for std::auto_ptr +//COMPODEFS +${compodefs} +//ENDDEF + +class ${component}; // forward declaration + +class ${component}_i: ${inheritedclass} + public POA_${module}::${component}_Gen, + public Engines_Component_i, + public SALOMEMultiComm +{ + +public: + ${component}_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName); + virtual ~${component}_i(); + +${servicesdef} + +// (re)defined methods of Driver + virtual Engines::Component_ptr GetComponentInstance(); + char* ComponentDataType(); + +private: + std::auto_ptr<${component}> cppCompo_; + +}; + + +extern "C" + PortableServer::ObjectId * ${component}Engine_factory( + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName); + + +#endif +""" +hxxCompo=Template(hxxCompo) + +cxxService=""" +${ret} ${component}_i::${service}(${parameters}) throw (SALOME::SALOME_Exception) +{ + beginService("${component}_i::${service}"); + BEGIN_OF("${component}_i::${service}"); + try + { +${body} + } + catch (std::exception& ex) + { + THROW_SALOME_CORBA_EXCEPTION( ex.what(), SALOME::INTERNAL_ERROR ); + } +} +""" +cxxService=Template(cxxService) + + +compoMakefile=""" + +dist_lib${component}Engine_la_SOURCES = \ + ${component}_i.cxx + +lib${component}Engine_la_CXXFLAGS = -I$$(top_builddir)/idl $$(SALOME_INCLUDES) ${includes} +lib${component}Engine_la_LIBADD = ${libs} -L$$(top_builddir)/idl -l${module} $${SALOME_LIBS} $$(FLIBS) + + +""" + +#, SALOME_MED::MED_Gen_Driver, SALOME::MultiCommClass +interfaceidlhxx=""" + interface ${component}_Gen:Engines::Component,SALOME::MultiCommClass ${inherited} + { +${services} + }; +""" +interfaceidlhxx=Template(interfaceidlhxx) + + +compoMakefile=Template(compoMakefile) diff --git a/module_generator/hxxcompo.py b/module_generator/hxxcompo.py new file mode 100644 index 0000000..ff023ef --- /dev/null +++ b/module_generator/hxxcompo.py @@ -0,0 +1,333 @@ +# Copyright (C) 2009-2010 CEA DEN +# +# 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. +# +# 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 +# +""" + Module that generates SALOME c++ Component from a non SALOME c++ component (its header and its shares library) +""" + +debug=1 +import os +from gener import Component, Invalid +from hxx_tmpl import cxxService, hxxCompo, cxxCompo, compoMakefile +from module_generator import Service +import string +from tempfile import mkstemp +from yacstypes import corba_rtn_type,moduleTypes + +class HXX2SALOMEComponent(Component): + def __init__(self, hxxfile , cpplib , cpp_path ): + # search a file within a directory tree + import fnmatch + def search_file(pattern, root): + matches = [] + for path, dirs, files in os.walk(os.path.abspath(root)): + for filename in fnmatch.filter(files, pattern): + matches.append(os.path.join(path, filename)) + return matches + + hxxfileful=search_file(hxxfile,cpp_path) + cpplibful=search_file(cpplib,cpp_path) + assert len(hxxfileful) > 0 ,'Error in HXX2SALOMEComponent : file ' + hxxfile + ' not found in ' + cpp_path + assert len(cpplibful) > 0 ,'Error in HXX2SALOMEComponent : file ' + cpplib + ' not found in ' + cpp_path + hxxfile=hxxfileful[0] + cpplib=cpplibful[0] + + # grab name of c++ component + from hxx_awk import parse01,parse1,parse2,parse3 + cmd1="""awk '$1 == "class" && $0 !~ /;/ {print $2}' """ + hxxfile + """|awk -F: '{printf "%s",$1}' """ + f=os.popen(cmd1) + class_name=f.readlines()[0] + name=class_name + print "classname=",class_name + f.close() + + # create temporary awk files + (fd01,p01n)=mkstemp() + f01=os.fdopen(fd01,"w") + f01.write(parse01) + f01.close() + + (fd1,p1n)=mkstemp() + f1=os.fdopen(fd1,"w") + f1.write(parse1) + f1.close() + + (fd2,p2n)=mkstemp() + f2=os.fdopen(fd2,"w") + f2.write(parse2) + f2.close() + + (fd3,p3n)=mkstemp() + f3=os.fdopen(fd3,"w") + f3.write(parse3) + f3.close() + + # awk parsing of hxx files - result written in file parse_type_result + cmd2="cat " + hxxfile + " | awk -f " + p01n + """ | sed 's/virtual //g' | sed 's/MEDMEM_EXPORT//g' | sed 's/throw.*;/;/g' | awk -f """ + p1n + " | awk -f " + p2n + " | awk -v class_name=" + class_name + " -f " + p3n + os.system(cmd2) + os.remove(p01n) + os.remove(p1n) + os.remove(p2n) + os.remove(p3n) + + # Retrieve the information which was generated in the file parse_type_result. + # The structure of the file is : + # + # Function return_type function_name + # [arg1_type arg1_name] + # [arg2_type arg2_name] + # ... + # The information is stored in a list of dictionnaries (service_definition) + from hxx_awk import cpp2idl_mapping + list_of_services=[] + service_definition={} + result_parsing=open("parse_type_result","r") + for line in result_parsing.readlines(): + line=line[0:-1] # get rid of trailing \n + words = string.split(line,';') + + if len(words) >=3 and words[0] == "Function": # detect a new service + function_name=words[2] + list_of_services.append(function_name) + service_definition[function_name]={} + service_definition[function_name]["ret"]=words[1] # return type + service_definition[function_name]["inports"]=[] + service_definition[function_name]["outports"]=[] + service_definition[function_name]["ports"]=[] + service_definition[function_name]["impl"]=[] + + if len(words) == 2: # an argument type and argument name of a previous service + typename=words[0] + argname=words[1] + service_definition[list_of_services[-1]]["ports"].append( (argname,typename) ) # store in c++ order the arg names + + # separate in from out parameters + inout=cpp2idl_mapping[typename][0:2] + assert inout=="in" or inout=="ou",'Error in table cpp2idl_mapping' + if inout == "in": + service_definition[list_of_services[-1]]["inports"].append( (argname,typename) ) + else: + service_definition[list_of_services[-1]]["outports"].append( (argname,typename) ) + + # generate implementation of c++ servant + from hxx_awk import cpp_impl_a,cpp_impl_b,cpp_impl_c # these tables contain the part of code which depends upon c++ types + for serv in list_of_services: + if debug: + print "service : ",serv + print " inports -> ",service_definition[serv]["inports"] + print " outports -> ",service_definition[serv]["outports"] + print " return -> ",service_definition[serv]["ret"] + + + # Part 1 : Argument pre-processing + s_argument_processing="//\tArguments processing\n" + for (argname,argtype) in service_definition[serv]["inports"] + service_definition[serv]["outports"]: + format=cpp_impl_a[argtype] + s_argument_processing += format % {"arg" : argname } + if s_argument_processing=="//\tArguments processing\n": # if there was no args + s_argument_processing="" + + + # Part 2 : Call to the underlying c++ function + s_call_cpp_function="//\tCall cpp component\n\t" + rtn_type=service_definition[serv]["ret"] + if rtn_type == "void" : # if return type is void, the call syntax is different + s_call_cpp_function += "cppCompo_->%s(" % serv + else: + s_call_cpp_function += "%s _rtn_cpp = cppCompo_->%s(" % (rtn_type ,serv ) + + for (argname,argtype) in service_definition[serv]["ports"]: + # special treatment for some arguments + post="" + pre="" + if string.find(cpp_impl_a[argtype],"auto_ptr" ) != -1 : + post=".get()" # for auto_ptr argument, retrieve the raw pointer behind + if argtype == "const MEDMEM::MESH&" or argtype == "const MEDMEM::SUPPORT&" : + pre="*" # we cannot create MESHClient on the stack (private constructor), so we create it on the heap and dereference it + post+="," # separator between arguments + s_call_cpp_function += " %s_%s%s" % ( pre,argname,post) + if s_call_cpp_function[-1]==',': + s_call_cpp_function=s_call_cpp_function[0:-1] # get rid of trailing comma + s_call_cpp_function=s_call_cpp_function+');\n' + + # Part 3.a : Out Argument Post-processing + s_argument_postprocessing="//\tPost-processing & return\n" + for (argname,argtype) in service_definition[serv]["outports"]: + format=cpp_impl_c[argtype] + s_argument_postprocessing += format % {"arg" : argname, "module" : "%(module)s" } # the treatment of %(module) is postponed in makecxx() + # because we don't know here the module name + # Part 3.b : In Argument Post-processing + for (argname,argtype) in service_definition[serv]["inports"]: + if cpp_impl_c.has_key(argtype): # not all in types require a treatment + format=cpp_impl_c[argtype] + s_argument_postprocessing += format % {"arg" : argname, "module" : "%(module)s" } # id : treatment of %(module) is postponed in makecxx + + # Part 3.c : return processing + s_rtn_processing=cpp_impl_b[rtn_type] + s_rtn_processing += "\tendService(\"%(class_name)s_i::%(serv_name)s\");\n\tEND_OF(\"%(class_name)s_i::%(serv_name)s\");\n" % { "serv_name" : serv, "class_name" : class_name } + if rtn_type != "void": + s_rtn_processing += "\treturn _rtn_ior;" + + service_definition[serv]["impl"] = s_argument_processing + s_call_cpp_function + s_argument_postprocessing + s_rtn_processing + if debug: + print "implementation :\n",service_definition[serv]["impl"] + + # + # Create a list of services, and give it to Component constructor + services=[] + from hxx_awk import cpp2yacs_mapping + for serv in list_of_services: + # for inports and outports, Service class expects a list of tuples, each tuple containing the name and the yacs type of the port + # thus we need to convert c++ types to yacs types (we use for that the cpp2yacs_mapping table + inports=[] + for i in range( len(service_definition[serv]["inports"]) ): + inports.append( [service_definition[serv]["inports"][i][0], cpp2yacs_mapping[service_definition[serv]["inports"][i][1]] ] ) + outports=[] + for i in range( len(service_definition[serv]["outports"]) ): + outports.append( [service_definition[serv]["outports"][i][0], cpp2yacs_mapping[service_definition[serv]["outports"][i][1]] ] ) + + Return="void" + if service_definition[serv]["ret"] != "void": + Return=cpp2yacs_mapping[service_definition[serv]["ret"]] + + # find out if component uses medmem types and/or medcoupling types + self.use_medmem=False + self.use_medcoupling=False + for (argname,argtype) in inports + outports + [("return",Return)]: + if moduleTypes[argtype]=="MED": + if argtype.count("Coupling")>0: + self.use_medcoupling=True + else: + self.use_medmem=True + break + + code=service_definition[serv]["impl"] + if debug: + print "service : ",serv + print " inports -> ",service_definition[serv]["inports"] + print " converted inports -> ",inports + print " outports -> ",service_definition[serv]["outports"] + print " converted outports -> ",outports + print " Return -> ",service_definition[serv]["ret"] + print " converted Return -> ",Return + + services.append(Service(serv, + inport=inports, + outport=outports, + ret=Return, + defs="", + body=code, + ) ) + + Includes="-I${"+name+"CPP_ROOT_DIR}/include" + Libs="-L${"+name+"CPP_ROOT_DIR}/lib -l"+name+"CXX" + Compodefs="" + Inheritedclass="" + self.inheritedconstructor="" + if self.use_medmem: + Compodefs=""" +#include CORBA_CLIENT_HEADER(MED) +#include CORBA_CLIENT_HEADER(MED_Gen) +#include "FIELDClient.hxx" +#include "MESHClient.hxx" +#include "MEDMEM_Support_i.hxx" +#include "MEDMEM_Mesh_i.hxx" +#include "MEDMEM_FieldTemplate_i.hxx" +#include "Med_Gen_Driver_i.hxx" +""" + Inheritedclass="Med_Gen_Driver_i" + self.inheritedconstructor="Med_Gen_Driver_i(orb)," + + if self.use_medcoupling: + Compodefs+=""" +#include CORBA_CLIENT_HEADER(MEDCouplingCorbaServant) +#include CORBA_CLIENT_HEADER(MED_Gen) +#include "MEDCouplingFieldDoubleServant.hxx" +#include "MEDCouplingUMeshServant.hxx" +#include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingUMesh.hxx" +#include "MEDCouplingUMeshClient.hxx" +#include "MEDCouplingFieldDouble.hxx" +#include "MEDCouplingFieldDoubleClient.hxx" +""" + + Component.__init__(self, name, services, impl="CPP", libs=Libs, + rlibs="", includes=Includes, kind="lib", + sources=None,inheritedclass=Inheritedclass, + compodefs=Compodefs) + + def makeCompo(self, gen): + """generate files for C++ component + + return a dict where key is the file name and value is the content of the file + """ + cxxfile = "%s_i.cxx" % self.name + hxxfile = "%s_i.hxx" % self.name + return {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), + cxxfile:self.makecxx(gen), + hxxfile:self.makehxx(gen) + } + + def getMakefileItems(self,gen): + makefileItems={"header":""" +include $(top_srcdir)/adm_local/make_common_starter.am + +"""} + makefileItems["lib_LTLIBRARIES"]=["lib"+self.name+"Engine.la"] + makefileItems["salomeinclude_HEADERS"]=["%s_i.hxx" % self.name] + makefileItems["body"]=compoMakefile.substitute(module=gen.module.name, + component=self.name, + libs=self.libs, + includes=self.includes) + return makefileItems + + def makehxx(self, gen): + """return a string that is the content of .hxx file + """ + services = [] + for serv in self.services: + service = " %s %s(" % (corba_rtn_type(serv.ret,gen.module.name),serv.name) + service = service+gen.makeArgs(serv)+") throw (SALOME::SALOME_Exception);" + services.append(service) + servicesdef = "\n".join(services) + + inheritedclass=self.inheritedclass + if self.inheritedclass: + inheritedclass= " public virtual " + self.inheritedclass + "," + + return hxxCompo.substitute(component=self.name, module=gen.module.name, + servicesdef=servicesdef, inheritedclass=inheritedclass, + compodefs=self.compodefs) + + def makecxx(self, gen, exe=0): + """return a string that is the content of .cxx file + """ + services = [] + inits = [] + defs = [] + for serv in self.services: + defs.append(serv.defs) + service = cxxService.substitute(component=self.name, service=serv.name,ret=corba_rtn_type(serv.ret,gen.module.name), + parameters=gen.makeArgs(serv), + body=serv.body % {"module":gen.module.name} ) + services.append(service) + return cxxCompo.substitute(component=self.name, + inheritedconstructor=self.inheritedconstructor, + servicesdef="\n".join(defs), + servicesimpl="\n".join(services)) + diff --git a/module_generator/salomemodules.py b/module_generator/salomemodules.py index c296765..bddf0f9 100644 --- a/module_generator/salomemodules.py +++ b/module_generator/salomemodules.py @@ -51,13 +51,14 @@ salome_modules["GEOM"]={"idldefs" : idldefs, "makefiledefs" : makefiledefs, "con idldefs=""" #include "MED_Gen.idl" #include "MED.idl" +#include "MEDCouplingCorbaServant.idl" """ makefiledefs=""" #module MED MED_IDL_INCLUDES = -I$(MED_ROOT_DIR)/idl/salome -MED_INCLUDES= -I$(MED_ROOT_DIR)/include/salome +MED_INCLUDES= -I${MED2HOME}/include -I${MED_ROOT_DIR}/include/salome -I${HDF5HOME}/include MED_IDL_LIBS= -L$(MED_ROOT_DIR)/lib/salome -lSalomeIDLMED -MED_LIBS= -L$(MED_ROOT_DIR)/lib/salome +MED_LIBS= -L${MED2HOME}/lib -lmed -L${HDF5HOME}/lib -lhdf5 -L${MED_ROOT_DIR}/lib/salome -lSalomeIDLMED -lMEDClientcmodule -lmedcouplingcorba -lmedcouplingclient SALOME_LIBS += ${MED_LIBS} SALOME_IDL_LIBS += ${MED_IDL_LIBS} SALOME_INCLUDES += ${MED_INCLUDES} diff --git a/module_generator/yacstypes.py b/module_generator/yacstypes.py index f82b6b0..07e33d9 100644 --- a/module_generator/yacstypes.py +++ b/module_generator/yacstypes.py @@ -23,17 +23,26 @@ corbaTypes = {"double":"CORBA::Double", "long":"CORBA::Long", "string":"const char*", "dblevec":"const %s::dblevec&", "stringvec":"const %s::stringvec&", "intvec":"const %s::intvec&", - "file":None + "file":None, "boolean":"CORBA::Boolean", "void":"void" } corbaOutTypes = {"double":"CORBA::Double&", "long":"CORBA::Long&", "string":"CORBA::String_out", "dblevec":"%s::dblevec_out", "stringvec":"%s::stringvec_out", "intvec":"%s::intvec_out", - "file":None + "file":None, "boolean":"CORBA::Boolean_out", "void":None } -moduleTypes = {"double":"", "long":"", "string":"", "dblevec":"", "stringvec":"", "intvec":"", "file":"" , "pyobj":"" } +moduleTypes = {"double":"", "long":"", "string":"", "dblevec":"", "stringvec":"", "intvec":"", "file":"", "pyobj":"", "boolean":"", "void":"" } + +idlTypes = {"double":"double", "long":"long", "string":"string", "dblevec":"dblevec", "stringvec":"stringvec", "intvec":"intvec", + "file":"", "boolean":"boolean", "void":"void" } + +corbaRtnTypes = {"double":"CORBA::Double", "long":"CORBA::Long", + "string":"char*", "dblevec":"%s::dblevec*", + "stringvec":"%s::stringvec*", "intvec":"%s::intvec*", + "file":None, "boolean":"CORBA::Boolean", "void":"void" + } + -idlTypes = {"double":"double", "long":"long", "string":"string", "dblevec":"dblevec", "stringvec":"stringvec", "intvec":"intvec", "file":"" } def corba_in_type(typ, module): if corbaTypes[typ].count("%s")>0: @@ -47,10 +56,16 @@ def corba_out_type(typ, module): else: return corbaOutTypes[typ] +def corba_rtn_type(typ, module): + if corbaRtnTypes[typ].count("%s")>0: + return corbaRtnTypes[typ] % module + else: + return corbaRtnTypes[typ] + ValidTypes = corbaTypes.keys() PyValidTypes = ValidTypes+["pyobj"] -def add_type(typename, corbaType, corbaOutType, module, idltype): +def add_type(typename, corbaType, corbaOutType, module, idltype, corbaRtnType): """ add a data type YACS from other module than KERNEL to the list of available types :param typename: YACS data type name @@ -63,9 +78,12 @@ def add_type(typename, corbaType, corbaOutType, module, idltype): :type module: string :param idltype: representation for CORBA idl :type idltype: string + :param corbaRtnType: representation for C++ CORBA return parameter + :type corbaRtnType: string """ corbaTypes[typename] = corbaType corbaOutTypes[typename] = corbaOutType + corbaRtnTypes[typename] = corbaRtnType moduleTypes[typename] = module idlTypes[typename] = idltype ValidTypes.append(typename) @@ -88,13 +106,16 @@ ValidStreamTypes = calciumTypes.keys() ValidParallelStreamTypes = DatastreamParallelTypes.keys() ValidDependencies = ("I", "T") -add_type("dataref", "const Engines::dataref&", "Engines::dataref_out", "", "dataref") -add_type("GEOM_Object", "GEOM::GEOM_Object_ptr", "GEOM::GEOM_Object_out", "GEOM", "GEOM::GEOM_Object") -add_type("SMESH_Mesh", "SMESH::SMESH_Mesh_ptr", "SMESH::SMESH_Mesh_out", "SMESH", "SMESH::SMESH_Mesh") -add_type("SMESH_Hypothesis", "SMESH::SMESH_Hypothesis_ptr", "SMESH::SMESH_Hypothesis_out", "SMESH", "SMESH::SMESH_Hypothesis") -add_type("SALOME_MED/MED", "SALOME_MED::MED_ptr", "SALOME_MED::MED_out", "MED", "SALOME_MED::MED") -add_type("SALOME_MED/MESH", "SALOME_MED::MESH_ptr", "SALOME_MED::MESH_out", "MED", "SALOME_MED::MESH") -add_type("SALOME_MED/SUPPORT", "SALOME_MED::SUPPORT_ptr", "SALOME_MED::SUPPORT_out", "MED", "SALOME_MED::SUPPORT") -add_type("SALOME_MED/FIELD", "SALOME_MED::FIELD_ptr", "SALOME_MED::FIELD_out", "MED", "SALOME_MED::FIELD") -add_type("SALOME_MED/FIELDDOUBLE", "SALOME_MED::FIELDDOUBLE_ptr", "SALOME_MED::FIELDDOUBLE_out", "MED", "SALOME_MED::FIELDDOUBLE") -add_type("SALOME_MED/FIELDINT", "SALOME_MED::FIELDINT_ptr", "SALOME_MED::FIELDINT_out", "MED", "SALOME_MED::FIELDINT") +add_type("dataref", "const Engines::dataref&", "Engines::dataref_out", "", "dataref","Engines::dataref*") +add_type("GEOM_Object", "GEOM::GEOM_Object_ptr", "GEOM::GEOM_Object_out", "GEOM", "GEOM::GEOM_Object","GEOM::GEOM_Object_ptr") +add_type("SMESH_Mesh", "SMESH::SMESH_Mesh_ptr", "SMESH::SMESH_Mesh_out", "SMESH", "SMESH::SMESH_Mesh","SMESH::SMESH_Mesh_ptr") +add_type("SMESH_Hypothesis", "SMESH::SMESH_Hypothesis_ptr", "SMESH::SMESH_Hypothesis_out", "SMESH", "SMESH::SMESH_Hypothesis", "SMESH::SMESH_Hypothesis_ptr") +add_type("SALOME_MED/MED", "SALOME_MED::MED_ptr", "SALOME_MED::MED_out", "MED", "SALOME_MED::MED", "SALOME_MED::MED_ptr") +add_type("SALOME_MED/MESH", "SALOME_MED::MESH_ptr", "SALOME_MED::MESH_out", "MED", "SALOME_MED::MESH", "SALOME_MED::MESH_ptr") +add_type("SALOME_MED/SUPPORT", "SALOME_MED::SUPPORT_ptr", "SALOME_MED::SUPPORT_out", "MED", "SALOME_MED::SUPPORT", "SALOME_MED::SUPPORT_ptr") +add_type("SALOME_MED/FIELD", "SALOME_MED::FIELD_ptr", "SALOME_MED::FIELD_out", "MED", "SALOME_MED::FIELD", "SALOME_MED::FIELD_ptr") +add_type("SALOME_MED/FIELDDOUBLE", "SALOME_MED::FIELDDOUBLE_ptr", "SALOME_MED::FIELDDOUBLE_out", "MED", "SALOME_MED::FIELDDOUBLE", "SALOME_MED::FIELDDOUBLE_ptr") +add_type("SALOME_MED/FIELDINT", "SALOME_MED::FIELDINT_ptr", "SALOME_MED::FIELDINT_out", "MED", "SALOME_MED::FIELDINT", "SALOME_MED::FIELDINT_ptr") +add_type("SALOME/Matrix", "SALOME::Matrix_ptr", "SALOME::Matrix_out", "", "SALOME::Matrix", "SALOME::Matrix_ptr") +add_type("SALOME_MED/MEDCouplingFieldDoubleCorbaInterface", "SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr", "SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_out", "MED", "SALOME_MED::MEDCouplingFieldDoubleCorbaInterface", "SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr") +add_type("SALOME_MED/MEDCouplingUMeshCorbaInterface", "SALOME_MED::MEDCouplingUMeshCorbaInterface_ptr", "SALOME_MED::MEDCouplingUMeshCorbaInterface_out", "MED", "SALOME_MED::MEDCouplingUMeshCorbaInterface", "SALOME_MED::MEDCouplingUMeshCorbaInterface_ptr") -- 2.39.2