Salome HOME
spns #32755 : TopIIVolMesh: move back to master branch
[tools/sat_salome.git] / products / patches / yacsgen_hxx.patch
1 diff --git a/module_generator/hxx_tmpl.py b/module_generator/hxx_tmpl.py
2 index 48b7552..328b345 100644
3 --- a/module_generator/hxx_tmpl.py
4 +++ b/module_generator/hxx_tmpl.py
5 @@ -25,7 +25,7 @@ except:
6  cxxCompo="""
7  // this cxx file was generated by yacsgen
8  #include "${component}_i.hxx"
9 -#include "${component}.hxx"
10 +#include "${hxxfile}"
11  using namespace std;
12  #include <string>
13  #include <vector>
14 diff --git a/module_generator/hxx_tmpl_gui.py b/module_generator/hxx_tmpl_gui.py
15 index cc5eff8..fae982f 100644
16 --- a/module_generator/hxx_tmpl_gui.py
17 +++ b/module_generator/hxx_tmpl_gui.py
18 @@ -58,10 +58,10 @@ ${component_name}GUI::${component_name}GUI() :
19  }
20  
21  // Gets a reference to the module's engine
22 -${component_name}_ORB::${component_name}_Gen_ptr ${component_name}GUI::Init${component_name}Gen( SalomeApp_Application* app )
23 +${module_name}_ORB::${component_name}_Gen_ptr ${component_name}GUI::Init${component_name}Gen( SalomeApp_Application* app )
24  {
25    Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer",COMPONENT_NAME );
26 -  ${component_name}_ORB::${component_name}_Gen_ptr clr = ${component_name}_ORB::${component_name}_Gen::_narrow(comp);
27 +  ${module_name}_ORB::${component_name}_Gen_ptr clr = ${module_name}_ORB::${component_name}_Gen::_narrow(comp);
28    ASSERT(!CORBA::is_nil(clr));
29    return clr;
30  }
31 @@ -149,7 +149,7 @@ void ${component_name}GUI::OnMyNewItem()
32  void ${component_name}GUI::OnCallAction()
33  {
34    // Create a ${component_name} component
35 -  ${component_name}_ORB::${component_name}_Gen_ptr ${component_name}gen = ${component_name}GUI::Init${component_name}Gen( getApp() );
36 +  ${module_name}_ORB::${component_name}_Gen_ptr ${component_name}gen = ${component_name}GUI::Init${component_name}Gen( getApp() );
37    
38    // Do the job...
39    //
40 @@ -256,7 +256,7 @@ hxxgui_h="""
41  #include <SalomeApp_Module.h>
42  
43  #include <SALOMEconfig.h>
44 -#include CORBA_CLIENT_HEADER(${component_name})
45 +#include CORBA_CLIENT_HEADER(${module_name})
46  
47  class SalomeApp_Application;
48  class ${component_name}GUI: public SalomeApp_Module
49 @@ -270,7 +270,7 @@ public:
50    QString engineIOR() const;
51    void    windows( QMap<int, int>& ) const;
52  
53 -  static ${component_name}_ORB::${component_name}_Gen_ptr Init${component_name}Gen( SalomeApp_Application* );
54 +  static ${module_name}_ORB::${component_name}_Gen_ptr Init${component_name}Gen( SalomeApp_Application* );
55  
56    virtual void                createPreferences();
57    virtual void                preferencesChanged( const QString&, const QString& );
58 diff --git a/module_generator/hxxcompo.py b/module_generator/hxxcompo.py
59 index 46d2f13..b042ad7 100644
60 --- a/module_generator/hxxcompo.py
61 +++ b/module_generator/hxxcompo.py
62 @@ -54,11 +54,15 @@ class HXX2SALOMEComponent(Component):
63                   matches.append(os.path.join(path, filename))
64          return matches
65  
66 +    assert cpplib[:3]=='lib' and cpplib[-3:]=='.so',\
67 +           'Error, library name %s does not conform to lib<name>.so pattern' 
68 +    cpplibname=cpplib[3:-3]
69      hxxfileful = search_file(hxxfile,cpp_path)
70      cpplibful = search_file(cpplib,cpp_path)
71      format_error = 'Error in HXX2SALOMEComponent : file %s not found in %s'
72      assert len(hxxfileful) > 0, format_error %  (hxxfile, cpp_path)
73      assert len(cpplibful) > 0, format_error % (cpplib, cpp_path)
74 +    self.hxxfile=hxxfile  # store it for cxxCompo template
75      hxxfile = hxxfileful[0]
76      cpplib = cpplibful[0]
77  
78 @@ -304,8 +308,8 @@ class HXX2SALOMEComponent(Component):
79             body=code,
80             ) )
81  
82 -    Includes = os.path.join(cpp_path, "include")
83 -    Libs = [ Library( name=name+"CXX", path=os.path.join(cpp_path, "lib"))]
84 +    Includes = os.path.dirname(hxxfile)
85 +    Libs = [ Library( name=cpplibname, path=os.path.dirname(cpplib))]
86      Compodefs=""
87      Inheritedclass=""
88      self.inheritedconstructor=""
89 @@ -438,28 +442,30 @@ class HXX2SALOMEComponent(Component):
90                             parameters=gen.makeArgs(serv),
91                             body=serv.body % {"module":gen.module.name+"_ORB"} )
92        services.append(service)
93 -    return cxxCompo.substitute(component=self.name, 
94 +    return cxxCompo.substitute(component=self.name, hxxfile=self.hxxfile, 
95                                 inheritedconstructor=self.inheritedconstructor,
96                                 servicesdef="\n".join(defs),
97                                 servicesimpl="\n".join(services))
98  
99  # ------------------------------------------------------------------------------
100 -  def getGUIfilesTemplate(self):
101 +  def getGUIfilesTemplate(self, module_name):
102        """generate in a temporary directory files for a generic GUI, 
103           and return a list with file names.
104           it is the responsability of the user to get rid 
105           of the temporary directory when finished
106        """
107 -      gui_cxx=hxxgui_cxx.substitute(component_name=self.name)
108 -      gui_h=hxxgui_h.substitute(component_name=self.name)
109 +      gui_cxx=hxxgui_cxx.substitute(component_name=self.name, 
110 +                                    module_name=module_name)
111 +      gui_h=hxxgui_h.substitute(component_name=self.name, 
112 +                                module_name=module_name)
113        gui_icon_ts=hxxgui_icon_ts.substitute(component_name=self.name)
114        gui_message_en=hxxgui_message_en.substitute(component_name=self.name)
115        gui_message_fr=hxxgui_message_fr.substitute(component_name=self.name)
116        gui_config=hxxgui_config.substitute(component_name=self.name)
117        gui_xml_fr=hxxgui_xml_fr.substitute(component_name=self.name)
118        gui_xml_en=hxxgui_xml_en.substitute(component_name=self.name)
119 -      gui_salomeapp_gen=cppsalomeapp.substitute(module=self.name,
120 -                                                lmodule=self.name.lower(),
121 +      gui_salomeapp_gen=cppsalomeapp.substitute(module=module_name,
122 +                                                lmodule=module_name.lower(),
123                                                  version="V0")
124        # for a salome component generated by hxx2salome from a c++ component, 
125        # the documentation points at the c++ component documentation
126 diff --git a/module_generator/hxxparacompo.py b/module_generator/hxxparacompo.py
127 index b093761..80aae50 100644
128 --- a/module_generator/hxxparacompo.py
129 +++ b/module_generator/hxxparacompo.py
130 @@ -355,7 +355,7 @@ void *th_%(serv_name)s(void *s)
131          self.thread_func_decl.append(service_definition[serv]["thread_func_decl"])
132          self.thread_str_decl.append(service_definition[serv]["thread_str_decl"])
133  #    Includes="-I${"+name+"CPP_ROOT_DIR}/include"
134 -    Includes = os.path.join(cpp_path, "include")
135 +    Includes = os.path.dirname(hxxfileful)
136  #    Libs="-L${"+name+"CPP_ROOT_DIR}/lib -l"+cpplibname
137  #    Libs=[cpplibname+" PATH "+ os.path.join(cpp_path, "lib") ]
138      Libs = [ Library( name=cpplibname, path=os.path.join(cpp_path, "lib"))]
139 diff --git a/script/hxx2salome.py b/script/hxx2salome.py
140 index 053e697..7c28d82 100755
141 --- a/script/hxx2salome.py
142 +++ b/script/hxx2salome.py
143 @@ -146,7 +146,7 @@ def hxx2salome(cppdir,
144      # if a graphical user interface is required,
145      # ask HXX2SALOMEComponent to generate template files
146      if do_gui:
147 -        gui_files=salome_compo.getGUIfilesTemplate()
148 +        gui_files=salome_compo.getGUIfilesTemplate(salome_compo.name)
149          g=Generator(Module(salome_compo.name,components=[salome_compo],
150              prefix=module_root_dir,
151              gui=gui_files),