From: caremoli Date: Fri, 22 Oct 2010 17:06:40 +0000 (+0000) Subject: CCAR: merge HXX2SALOME development from V5_1_main branch into V5_1_5_BR branch X-Git-Tag: V5_1_5rc1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=55e725d8ee7953c815fe716633f0b29e5a0cc73b;p=tools%2Fyacsgen.git CCAR: merge HXX2SALOME development from V5_1_main branch into V5_1_5_BR branch --- 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 0000000..87432a0 Binary files /dev/null and b/Examples/hxx1/cpp_component.tgz differ diff --git a/Examples/hxx1/test_compohxx.py b/Examples/hxx1/test_compohxx.py new file mode 100644 index 0000000..9d84a6a --- /dev/null +++ b/Examples/hxx1/test_compohxx.py @@ -0,0 +1,129 @@ +#============================================================================== +# File : CALCUL_test.py +# Created : +# Author : +# Project : SALOME +# Copyright : CEA 2005 +#============================================================================== +# +# Test du composant CALCUL +# +import SALOME +import salome +salome.salome_init() +print "Test du composant CALCUL généré généré par hxx2salome" +import hxxcompos +myCalc = salome.lcc.FindOrLoadComponent("FactoryServer", "CALCUL") +print "10+15 = ",myCalc.add(10,15) +print "10x15 = ",myCalc.mul(10,15) +#print "6! = ",myCalc.fact(6) +res1,res2 = myCalc.sqr2(12.0) +print "12*12 = ",res1," ",res2 +j=1 +i1,i2,i3 = myCalc.return_3_int(j) +assert (i1 == j+1),'Erreur dans la fonction return_3_int' +assert (i2 == j+2),'Erreur dans la fonction return_3_int' +assert (i3 == j+3),'Erreur dans la fonction return_3_int' +print 'return_3_int : ',j,' ',i1,' ',i2,' ',i3 +print "True && True = ",myCalc.And(True,True) +print "True && False = ",myCalc.And(True,False) +print "True || False = ",myCalc.Or(True,False) +from math import fabs +assert (fabs(res1-144.0)<1.0e-6 ), 'Erreur dans la fonction myCalc.sqr2 : 12*12 = '+str(res1) +assert ( myCalc.And(True,True)==True ) , 'Erreur dans la fonction And(True,True)' +assert ( myCalc.And(True,False)==False ) , 'Erreur dans la fonction And(True,False)' +assert ( myCalc.Or(True,False)==True ) , 'Erreur dans la fonction Or(True,False)' +print "Fin test hxx2salome/001/A1" +# +# +myTestMed = salome.lcc.FindOrLoadComponent("FactoryServerTM", "TESTMED") +myMedCalc = salome.lcc.FindOrLoadComponent("FactoryServerMC", "MEDCALC") +# +banner = myTestMed.getBanner() +print "Banner = ",banner +assert banner == "Hello" , 'erreur dans la fonction getBanner() : mauvaise valeur' +# +print "Creation et tests des supports :" +supportName=myTestMed.getSupportName(myTestMed.getSupport()) +print "Support name : ",supportName +assert supportName == "XsupportX" +# +from libMEDClient import FIELDDOUBLEClient +f_loc=FIELDDOUBLEClient(myTestMed.getVolume(myTestMed.getSupport())) +assert f_loc.getNumberOfValues() == 16 , 'created field has incorrect size' +from math import fabs +assert fabs(f_loc.norm2()-6.39444)<1.0e-5 , 'created field has incorrect norm 2' +# +myTestMed.affiche_fieldT(myTestMed.getVolume(myTestMed.getSupport())) +myTestMed.printSupportEntity(myTestMed.getSupport()) +myMedCalc.printSupport(myTestMed.getSupport()) +myMedCalc.printSupport(myTestMed.getPartialSupport()) +f_part=FIELDDOUBLEClient(myTestMed.getVolume(myTestMed.getPartialSupport())) +assert f_part.getNumberOfValues() == 3, 'created field on partial support has incorrect size' +assert fabs(f_part.norm2()-1.15470)<1.0e-5 , 'created field on partial support has incorrect norm 2' +print "Fin test hxx2salome/003/A1" +# +banner = myTestMed.getBanner() +print "Banner = ",banner +assert banner == "Hello" , 'erreur dans la fonction getBanner() : mauvaise valeur' +# +theMesh= myTestMed.getMesh() +theField = myTestMed.getField() +(theField1,theField2) = myTestMed.create2DoubleField() +myTestMed.affiche_fieldT(theField1) +mynorm=myTestMed.getNormMax(theField) +from math import fabs +assert fabs(mynorm-3.0)<1.0e-10 , 'created field has incorrect norm 1' +print "Norm of the Field : " , mynorm + +field1 = myTestMed.getConstFieldDouble( 3.0 , "field1" ) +myTestMed.affiche_fieldT(field1) +print "Creation tableau :" +size=12 +myTab = myTestMed.createDoubleTab(size) +myTabInt = myTestMed.createIntVector(size) +myTestMed.printDoubleTab(myTab) +print "Create a matrix" +myTestMed.printMatrix(myTestMed.createMatrix(size,size)) +print "Fin test hxx2salome/002/A1" + +# +# test of exception mechanism +from SALOME_MED import SUPPORT, MED_NODE, FIELDDOUBLE +test_exception=False +f_cell = myTestMed.getField() +f_node = myTestMed.getFieldOnNode() +try: + f_wrong=myMedCalc.add(f_cell,f_node) +except SALOME.SALOME_Exception, ex: + test_exception=True + print "wrong addition was correctly catched" + print "Exception is : ",ex + +assert test_exception, 'Error in the exception management : the wrong MED addition was not correctly catched' +print "Fin test hxx2salome/003/A2" + +myCoco = salome.lcc.FindOrLoadComponent("FactoryServerI", "ICOCO") +# +liste_champs = myCoco.getInputFieldsNames() +nb_champs=len(liste_champs) +print "Nombre de champs = ",nb_champs +assert nb_champs == 2 , 'erreur dans le nombre de champs, different de 2!' +# +print "Champ 1 (SourceField) : ",liste_champs[0] +print "Champ 2 (TargetField) : ",liste_champs[1] +assert liste_champs[0] == "SourceField", 'erreur dans le nom du champ 1' +assert liste_champs[1] == "TargetField", 'erreur dans le nom du champ 2' +# +print "Fin test hxx2salome/ICOCO/A1" +myCoco1 = salome.lcc.FindOrLoadComponent("FactoryServerI1", "ICOCO") +myCoco2 = salome.lcc.FindOrLoadComponent("FactoryServerI2", "ICOCO") +# +myCoco1.initialize() +m=myCoco1.getInputFieldTemplate("TargetField") +#myCoco1.solve() to test with 5.1.5 +#f=myCoco1.getOutputField("SourceField") +#myCoco2.printField(f) +# +print "##################################" +print "Fin test hxx2salome/ICOCO/A2" diff --git a/Examples/pyth1/coupling.xml b/Examples/pyth1/coupling.xml index cd9b441..7c95f94 100644 --- a/Examples/pyth1/coupling.xml +++ b/Examples/pyth1/coupling.xml @@ -1,65 +1,75 @@ - - - - - - - - - - - - - - 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")