From: crouzet Date: Mon, 20 Jun 2011 15:18:49 +0000 (+0000) Subject: hxx2salome part : Management of parallel c++ component. X-Git-Tag: V5_1_6~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=83259483936a8fea47b5a5a48fdec7de20b2fca3;p=tools%2Fyacsgen.git hxx2salome part : Management of parallel c++ component. --- diff --git a/module_generator/gener.py b/module_generator/gener.py index 4fc94e5..bdf902e 100644 --- a/module_generator/gener.py +++ b/module_generator/gener.py @@ -601,7 +601,7 @@ echo " Qt ..................... : $qt_ok" if not os.path.exists(os.path.join(namedir, "src", self.module.name+"GUI", "SalomeApp.xml")): #create a minimal SalomeApp.xml - salomeapp=pysalomeapp.substitute(module=self.module.name) + salomeapp=pysalomeapp.substitute(module=self.module.name,lmodule=self.module.name.lower()) d["SalomeApp.xml"]=salomeapp return d @@ -621,6 +621,8 @@ echo " Qt ..................... : $qt_ok" sources.append(os.path.basename(src)[:-2]+"_moc.cxx") elif src[-3:]==".ui": ui_files.append("ui_"+os.path.basename(src)[:-3]+".h") + elif src[-3:]==".ts": + other.append(os.path.basename(src)[:-3]+".qm") else: other.append(os.path.basename(src)) @@ -630,7 +632,7 @@ echo " Qt ..................... : $qt_ok" if not os.path.exists(os.path.join(namedir, "src", self.module.name+"GUI", "SalomeApp.xml")): #create a minimal SalomeApp.xml - salomeapp=cppsalomeapp.substitute(module=self.module.name) + salomeapp=cppsalomeapp.substitute(module=self.module.name,lmodule=self.module.name.lower()) d["SalomeApp.xml"]=salomeapp return d @@ -701,6 +703,7 @@ echo " Qt ..................... : $qt_ok" """generate module IDL file source (CORBA interface)""" from pacocompo import PACOComponent interfaces = [] + idldefs="" for compo in self.module.components: if isinstance(compo, PACOComponent): services = [] @@ -741,11 +744,18 @@ echo " Qt ..................... : $qt_ok" services.append(service) from hxxcompo import HXX2SALOMEComponent - if isinstance(compo,HXX2SALOMEComponent): + from hxxparacompo import HXX2SALOMEParaComponent + if isinstance(compo,HXX2SALOMEComponent) or isinstance(compo,HXX2SALOMEParaComponent): from hxx_tmpl import interfaceidlhxx Inherited="" - if compo.use_medmem==True: - Inherited=", SALOME_MED::MED_Gen_Driver" + if isinstance(compo,HXX2SALOMEParaComponent): + Inherited="SALOME_MED::ParaMEDMEMComponent" + idldefs="""#include "ParaMEDMEMComponent.idl"\n""" + else: + if compo.use_medmem==True: + Inherited="Engines::Component,SALOME::MultiCommClass,SALOME_MED::MED_Gen_Driver" + else: + Inherited="Engines::Component" interfaces.append(interfaceidlhxx.substitute(component=compo.name,inherited=Inherited, services="\n".join(services))) else: inheritedinterface="" @@ -754,7 +764,6 @@ echo " Qt ..................... : $qt_ok" interfaces.append(interface.substitute(component=compo.name, services="\n".join(services),inheritedinterface=inheritedinterface)) #build idl includes for SALOME modules - idldefs="" for mod in self.used_modules: idldefs = idldefs + salome_modules[mod]["idldefs"] diff --git a/module_generator/gui_tmpl.py b/module_generator/gui_tmpl.py index 2cc897b..2a968bc 100644 --- a/module_generator/gui_tmpl.py +++ b/module_generator/gui_tmpl.py @@ -22,7 +22,7 @@ pysalomeapp="""
- +
""" @@ -48,6 +48,9 @@ salomeres_DATA =SalomeApp.xml ${other_sources} ui_%.h: %.ui $$(UIC) -o $$@ $$< +# translation (*.qm) files generation (lrelease) +%.qm: %.ts + $$(LRELEASE) $$< -qm $$@ """ cppguimakefile=Template(cppguimakefile) @@ -58,7 +61,7 @@ cppsalomeapp="""
- +
""" diff --git a/module_generator/hxx_awk.py b/module_generator/hxx_awk.py index 839f3ca..cc96e88 100644 --- a/module_generator/hxx_awk.py +++ b/module_generator/hxx_awk.py @@ -33,6 +33,8 @@ 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" +cpp2idl_mapping["const ParaMEDMEM::MEDCouplingFieldDouble&"]="in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface" +cpp2idl_mapping["ParaMEDMEM::MEDCouplingFieldDouble*&"]="out 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={} diff --git a/module_generator/hxx_tmpl.py b/module_generator/hxx_tmpl.py index 3e25a10..b66a39f 100644 --- a/module_generator/hxx_tmpl.py +++ b/module_generator/hxx_tmpl.py @@ -110,8 +110,7 @@ class ${component}; // forward declaration class ${component}_i: ${inheritedclass} public POA_${module}_ORB::${component}_Gen, - public Engines_Component_i, - public SALOMEMultiComm + public Engines_Component_i { public: @@ -178,7 +177,7 @@ lib${component}Engine_la_LIBADD = ${libs} -L$$(top_builddir)/idl -lSalomeIDL${ #, SALOME_MED::MED_Gen_Driver, SALOME::MultiCommClass interfaceidlhxx=""" - interface ${component}_Gen:Engines::Component,SALOME::MultiCommClass ${inherited} + interface ${component}_Gen: ${inherited} { ${services} }; diff --git a/module_generator/hxxcompo.py b/module_generator/hxxcompo.py index 1d551e7..2f0a42a 100644 --- a/module_generator/hxxcompo.py +++ b/module_generator/hxxcompo.py @@ -14,25 +14,38 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# See http://www.salome-platform.org/ +# or email : webmaster.salome@opencascade.com # """ - Module that generates SALOME c++ Component from a non SALOME c++ component (its header and its shares library) + Module that generates SALOME c++ Component from a non SALOME c++ component + (its header and its shares library) """ debug=1 import os +import string +import fnmatch +from tempfile import mkstemp 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 +from hxx_awk import parse01,parse1,parse2,parse3 +from hxx_awk import cpp2idl_mapping +# these tables contain the part of code which depends upon c++ types +from hxx_awk import cpp_impl_a,cpp_impl_b,cpp_impl_c +from hxx_awk import cpp2yacs_mapping +from tempfile import mkdtemp +from hxx_tmpl_gui import hxxgui_cxx, hxxgui_h, hxxgui_icon_ts +from hxx_tmpl_gui import hxxgui_message_en, hxxgui_message_fr +from hxx_tmpl_gui import hxxgui_config, hxxgui_xml_fr, hxxgui_xml_en + +# ------------------------------------------------------------------------------ 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)): @@ -40,23 +53,24 @@ class HXX2SALOMEComponent(Component): 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] + hxxfileful = search_file(hxxfile,cpp_path) + cpplibful = search_file(cpplib,cpp_path) + format_error = 'Error in HXX2SALOMEComponent : file %s ot found in %s' + assert len(hxxfileful) > 0, format_error % (hxxfile, cpp_path) + assert len(cpplibful) > 0, format_error % (cpplib, 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}' """ + 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 + # create temporary awk files for the parsing (fd01,p01n)=mkstemp() f01=os.fdopen(fd01,"w") f01.write(parse01) @@ -77,154 +91,207 @@ class HXX2SALOMEComponent(Component): 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 + # awk parsing of hxx files - + # result written in file parse_type_result + cmd2 = [ + "cat %s" % hxxfile, + "awk -f %s" % p01n, + "sed 's/virtual //g'", + "sed 's/MEDMEM_EXPORT//g'", + "sed 's/throw.*;/;/g'", + "awk -f %s" % p1n, + "awk -f %s" % p2n, + "awk -v class_name=%s -f %s" % (class_name, p3n) ] + cmd2 = ' | '.join(cmd2) + 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. + # 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 + # The service names are stored in list_of_services + # The information relative to a service (called service_name) is stored in + # the dictionnary service_definition[service_name] 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 + 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]={} + function_name=words[2] + # store the name of new service + list_of_services.append(function_name) + # create a dict to store informations relative to this service + 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 + # an argument type and argument name of the current service + if len(words) == 2: + current_service=list_of_services[-1] + current_service_dict=service_definition[current_service] typename=words[0] argname=words[1] - service_definition[list_of_services[-1]]["ports"].append( (argname,typename) ) # store in c++ order the arg names + # store in c++ order the arg names + current_service_dict["ports"].append( (argname,typename) ) # 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) ) + current_service_dict["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 + current_service_dict["outports"].append((argname, typename) ) + # + # For each service : + # - generate implementation of c++ servant + # - store it in service_definition[serv]["impl"] 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: + 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 there was no args + if s_argument_processing=="//\tArguments processing\n": + 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 return type is void, the call syntax is different + if rtn_type == "void" : + 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 : + # for auto_ptr argument, retrieve the raw pointer behind + post=".get()" + if argtype == "const MEDMEM::MESH&" or \ + argtype == "const MEDMEM::SUPPORT&" : + # we cannot create MESHClient on the stack + # (private constructor!), + # so we create it on the heap and dereference it + pre="*" + + post+="," # separator between arguments + s_call_cpp_function += " %s_%s%s" % ( pre,argname,post) + if s_call_cpp_function[-1]==',': + # get rid of trailing comma + s_call_cpp_function=s_call_cpp_function[0:-1] + + 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] + # the treatment of %(module) is postponed in makecxx() + # because we don't know here the module name + s_argument_postprocessing += \ + format % {"arg" : argname, "module" : "%(module)s" } + + # Part 3.b : In Argument Post-processing + for (argname,argtype) in service_definition[serv]["inports"]: + # not all in types require a treatment + if cpp_impl_c.has_key(argtype): + format=cpp_impl_c[argtype] + # id : treatment of %(module) is postponed in makecxx + s_argument_postprocessing += \ + format % {"arg" : argname, "module" : "%(module)s" } + + # Part 3.c : return processing + s_rtn_processing=cpp_impl_b[rtn_type] + + format_end_serv = "\tendService(\"%(class_name)s_i::%(serv_name)s\");" + format_end_serv += "\n\tEND_OF(\"%(class_name)s_i::%(serv_name)s\");\n" + s_rtn_processing += format_end_serv %\ + { "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 + # Create a list of Service objects (called services), + # and give it to Component constructor + # services=[] - from hxx_awk import cpp2yacs_mapping + self.use_medmem=False + self.use_medcoupling=False 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 + # 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": + for op in service_definition[serv]["inports"]: + inports.append([op[0], cpp2yacs_mapping[op[1]] ] ) + + outports = [] + for op in service_definition[serv]["outports"]: + outports.append([op[0], cpp2yacs_mapping[op[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 + # find out if component uses medmem types and/or medcoupling types + 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 + 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, @@ -240,7 +307,7 @@ class HXX2SALOMEComponent(Component): Inheritedclass="" self.inheritedconstructor="" if self.use_medmem: - Compodefs=""" + Compodefs=""" #include CORBA_CLIENT_HEADER(MED) #include CORBA_CLIENT_HEADER(MED_Gen) #include "FIELDClient.hxx" @@ -250,11 +317,11 @@ class HXX2SALOMEComponent(Component): #include "MEDMEM_FieldTemplate_i.hxx" #include "Med_Gen_Driver_i.hxx" """ - Inheritedclass="Med_Gen_Driver_i" - self.inheritedconstructor="Med_Gen_Driver_i(orb)," + Inheritedclass="Med_Gen_Driver_i, public SALOMEMultiComm" + self.inheritedconstructor="Med_Gen_Driver_i(orb)," if self.use_medcoupling: - Compodefs+=""" + Compodefs+=""" #include CORBA_CLIENT_HEADER(MEDCouplingCorbaServant) #include CORBA_CLIENT_HEADER(MED_Gen) #include "MEDCouplingFieldDoubleServant.hxx" @@ -271,10 +338,11 @@ class HXX2SALOMEComponent(Component): 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 + 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 @@ -283,6 +351,7 @@ class HXX2SALOMEComponent(Component): hxxfile:self.makehxx(gen) } +# ------------------------------------------------------------------------------ def getMakefileItems(self,gen): makefileItems={"header":""" include $(top_srcdir)/adm_local/make_common_starter.am @@ -296,12 +365,14 @@ include $(top_srcdir)/adm_local/make_common_starter.am 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 = " %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) @@ -310,10 +381,13 @@ include $(top_srcdir)/adm_local/make_common_starter.am 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) + 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 """ @@ -322,12 +396,85 @@ include $(top_srcdir)/adm_local/make_common_starter.am 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+"_ORB"} ) + print "CNC bug : ",serv.body + 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+"_ORB"} ) services.append(service) return cxxCompo.substitute(component=self.name, - inheritedconstructor=self.inheritedconstructor, + inheritedconstructor=self.inheritedconstructor, servicesdef="\n".join(defs), servicesimpl="\n".join(services)) +# ------------------------------------------------------------------------------ + def getGUIfilesTemplate(self): + """generate in a temporary directory files for a generic GUI, + and return a list with file names. + it is the responsability of the user to get rid + of the temporary directory when finished + """ + gui_cxx=hxxgui_cxx.substitute(component_name=self.name) + gui_h=hxxgui_h.substitute(component_name=self.name) + gui_icon_ts=hxxgui_icon_ts.substitute(component_name=self.name) + gui_message_en=hxxgui_message_en.substitute(component_name=self.name) + gui_message_fr=hxxgui_message_fr.substitute(component_name=self.name) + gui_config=hxxgui_config.substitute(component_name=self.name) + gui_xml_fr=hxxgui_xml_fr.substitute(component_name=self.name) + gui_xml_en=hxxgui_xml_en.substitute(component_name=self.name) + temp_dir=mkdtemp() + gui_cxx_file_name=os.path.join(temp_dir,self.name+"GUI.cxx") + gui_h_file_name=os.path.join(temp_dir,self.name+"GUI.h") + gui_icon_ts_file_name=os.path.join(temp_dir,self.name+"_icons.ts") + gui_message_en_file_name=os.path.join(temp_dir,self.name+"_msg_en.ts") + gui_message_fr_file_name=os.path.join(temp_dir,self.name+"_msg_fr.ts") + gui_config_file_name=os.path.join(temp_dir,"config") + gui_xml_fr_file_name=os.path.join(temp_dir,self.name+"_en.xml") + gui_xml_en_file_name=os.path.join(temp_dir,self.name+"_fr.xml") + + list_of_gui_names=[] + + gui_cxx_file=open(gui_cxx_file_name,"w") + gui_cxx_file.write(gui_cxx) + gui_cxx_file.close() + list_of_gui_names.append(gui_cxx_file_name) + + gui_h_file=open(gui_h_file_name,"w") + gui_h_file.write(gui_h) + gui_h_file.close() + list_of_gui_names.append(gui_h_file_name) + + gui_icon_ts_file=open(gui_icon_ts_file_name,"w") + gui_icon_ts_file.write(gui_icon_ts) + gui_icon_ts_file.close() + list_of_gui_names.append(gui_icon_ts_file_name) + + gui_message_en_file=open(gui_message_en_file_name,"w") + gui_message_en_file.write(gui_message_en) + gui_message_en_file.close() + list_of_gui_names.append(gui_message_en_file_name) + + gui_message_fr_file=open(gui_message_fr_file_name,"w") + gui_message_fr_file.write(gui_message_fr) + gui_message_fr_file.close() + list_of_gui_names.append(gui_message_fr_file_name) + + gui_config_file=open(gui_config_file_name,"w") + gui_config_file.write(gui_config) + gui_config_file.close() + list_of_gui_names.append(gui_config_file_name) + + gui_xml_fr_file=open(gui_xml_fr_file_name,"w") + gui_xml_fr_file.write(gui_xml_fr) + gui_xml_fr_file.close() + list_of_gui_names.append(gui_xml_fr_file_name) + + gui_xml_en_file=open(gui_xml_en_file_name,"w") + gui_xml_en_file.write(gui_xml_en) + gui_xml_en_file.close() + list_of_gui_names.append(gui_xml_en_file_name) + + + return list_of_gui_names diff --git a/module_generator/yacstypes.py b/module_generator/yacstypes.py index 8aa90f1..4ffa78d 100644 --- a/module_generator/yacstypes.py +++ b/module_generator/yacstypes.py @@ -116,6 +116,7 @@ add_type("SALOME_MED/SUPPORT", "SALOME_MED::SUPPORT_ptr", "SALOME_MED::SUPPORT_o 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/Matrix", "SALOME::Matrix_ptr", "SALOME::Matrix_out", "MED", "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/MPIMEDCouplingFieldDoubleCorbaInterface", "SALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface_ptr", "SALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface_out", "MED", "SALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface", "SALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface_ptr") add_type("SALOME_MED/MEDCouplingUMeshCorbaInterface", "SALOME_MED::MEDCouplingUMeshCorbaInterface_ptr", "SALOME_MED::MEDCouplingUMeshCorbaInterface_out", "MED", "SALOME_MED::MEDCouplingUMeshCorbaInterface", "SALOME_MED::MEDCouplingUMeshCorbaInterface_ptr") diff --git a/setup.py b/setup.py index d71293d..7e1778f 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,8 @@ from distutils.core import setup setup(name='YACSGEN', - version='5.1.5', + version='5.1.6', author='C. Caremoli', packages=['module_generator'], + scripts=['script/hxx2salome.py',] )