From: vsr Date: Thu, 25 Nov 2010 13:17:04 +0000 (+0000) Subject: Merge from V5_1_main branch 24/11/2010 X-Git-Tag: V6_2_0a1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9fe06fc622b1fa6c61cd72dc6eb669672231e68a;p=tools%2Fyacsgen.git Merge from V5_1_main branch 24/11/2010 --- diff --git a/Examples/ast2/components.py b/Examples/ast2/components.py index 68fc30f..3a75703 100644 --- a/Examples/ast2/components.py +++ b/Examples/ast2/components.py @@ -29,7 +29,6 @@ execfile("../context.py") aster_root=os.path.join(aster_home,aster_version) fcompodir=os.path.join(os.getcwd(),"fcompo") -myasterdir=os.path.join(os.getcwd(),"myaster","bibpyt") install_prefix="./install" appli_dir="appli" 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/ast2/myaster/src/op0189.f b/Examples/ast2/myaster/src/op0189.f index 9c669bd..79bc96f 100644 --- a/Examples/ast2/myaster/src/op0189.f +++ b/Examples/ast2/myaster/src/op0189.f @@ -62,9 +62,9 @@ C COMMON/YACS/IFL include 'calcium.hf' real*8 tt,tp,t0,t1,ss,zz - real yr + real*4 yr CHARACTER*8 tch(2) - real tcp(2) + real*4 tcp(2) integer*4 tlo(3) write(6,*) '--> OP196 ' diff --git a/Examples/context.py b/Examples/context.py index 2b4fdb5..0d6ab8e 100644 --- a/Examples/context.py +++ b/Examples/context.py @@ -17,16 +17,18 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -import os +import os,sys +#sys.path.insert(0,"../..") KERNEL_ROOT_DIR=os.getenv("KERNEL_ROOT_DIR","/local/cchris/Salome/Install/KERNEL_V5") GUI_ROOT_DIR=os.getenv("GUI_ROOT_DIR","/local/cchris/Salome/Install/GUI_V5") -YACS_ROOT_DIR=os.getenv("YACS_ROOT_DIR","/local/cchris/Salome/Install/YACS_V5_1_main") +YACS_ROOT_DIR=os.getenv("YACS_ROOT_DIR","/local/cchris/Salome/Install/YACS_V5") context={'update':1, "makeflags":"", - "prerequisites":"/local/cchris/.packages.d/envSalome5", + "prerequisites":"/local/cchris/.packages.d/envSalome51main", "kernel":KERNEL_ROOT_DIR, + "gui":GUI_ROOT_DIR, } 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/cppgui1/components.py b/Examples/cppgui1/components.py new file mode 100644 index 0000000..0fc17ea --- /dev/null +++ b/Examples/cppgui1/components.py @@ -0,0 +1,126 @@ +# 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 +# + +#import context from .. +execfile("../context.py") + +import os +from module_generator import * + +idldefs=""" +#include "myinterface.idl" +""" + +compodefs=r""" + + +class A: public virtual POA_Idl_A +{ +public: + void createObject(::SALOMEDS::Study_ptr theStudy, const char* name){}; + + // Driver interface + virtual SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile){return 0;}; + virtual SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile){return 0;}; + virtual bool Load(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream, const char* theURL, bool isMultiFile){return 0;}; + virtual bool LoadASCII(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream, const char* theURL, bool isMultiFile){return 0;}; + virtual void Close(SALOMEDS::SComponent_ptr IORSComponent){}; + virtual char* ComponentDataType(){return "cppcompos";}; + virtual char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, const char* IORString, CORBA::Boolean isMultiFile, CORBA::Boolean isASCII){return 0;}; + virtual char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, const char* aLocalPersistentID, CORBA::Boolean isMultiFile, + CORBA::Boolean isASCII){return 0;}; + virtual bool CanPublishInStudy(CORBA::Object_ptr theIOR){return 0;}; + virtual SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,SALOMEDS::SObject_ptr theSObject,CORBA::Object_ptr theObject, + const char* theName){return 0;}; + virtual CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject){return 0;}; + virtual SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID){return 0;}; + virtual CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID){return 0;}; + virtual SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream, CORBA::Long theObjectID, SALOMEDS::SObject_ptr theObject){return 0;}; +}; + +""" + +compomethods=r""" + + Engines::TMPFile* DumpPython(CORBA::Object_ptr theStudy, + CORBA::Boolean isPublished, + CORBA::Boolean& isValidScript) + { + std::cerr << "je suis dans le dump:" << __LINE__ << std::endl; + SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy); + if(CORBA::is_nil(aStudy)) + return new Engines::TMPFile(0); + + SALOMEDS::SObject_var aSO = aStudy->FindComponent("cppcompos"); + if(CORBA::is_nil(aSO)) + return new Engines::TMPFile(0); + + std::string Script = "import cppcompos_ORB\n"; + Script += "import salome\n"; + Script += "compo = salome.lcc.FindOrLoadComponent('FactoryServer','cppcompos')\n"; + Script += "def RebuildData(theStudy):\n"; + Script += " compo.SetCurrentStudy(theStudy)\n"; + const char* aScript=Script.c_str(); + + char* aBuffer = new char[strlen(aScript)+1]; + strcpy(aBuffer, aScript); + CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer; + int aBufferSize = strlen(aBuffer)+1; + Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1); + isValidScript = true; + return aStreamFile._retn(); + } + + +""" + +body=""" +std::cerr << "a: " << a << std::endl; +std::cerr << "b: " << b << std::endl; +c=a+b; +std::cerr << "c: " << c << std::endl; +""" +c1=CPPComponent("cppcompos",services=[ + Service("s1",inport=[("a","double"),("b","double")], + outport=[("c","double")], + defs="//def1",body=body, + ), + ], + includes="-I/usr/include", + idls=["*.idl"], + interfacedefs=idldefs, + inheritedinterface="Idl_A", + compodefs=compodefs, + inheritedclass="A", + addedmethods=compomethods, + ) + +modul=Module("cppcompos",components=[c1],prefix="./install", + doc=["*.rst",], + gui=["cppcomposGUI.cxx","cppcomposGUI.h","demo.ui","*.png"], + ) + +g=Generator(modul,context) +g.generate() +g.bootstrap() +g.configure() +g.make() +g.install() +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}) + diff --git a/Examples/cppgui1/cppcompos.png b/Examples/cppgui1/cppcompos.png new file mode 100644 index 0000000..16a20c1 Binary files /dev/null and b/Examples/cppgui1/cppcompos.png differ diff --git a/Examples/cppgui1/cppcomposGUI.cxx b/Examples/cppgui1/cppcomposGUI.cxx new file mode 100644 index 0000000..47df890 --- /dev/null +++ b/Examples/cppgui1/cppcomposGUI.cxx @@ -0,0 +1,144 @@ +#include "cppcomposGUI.h" +#include +#include +#include +#include +#include +#include + +#include +#include CORBA_CLIENT_HEADER(cppcompos) +#include CORBA_CLIENT_HEADER(SALOMEDS) +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) + +// QT Includes +#include +#include + +// Export the module +extern "C" { + CAM_Module* createModule() + { + return new cppcomposGUI(); + } +} + +// Constructor +cppcomposGUI::cppcomposGUI() : + SalomeApp_Module( "cppcompos" ), // default name + LightApp_Module( "cppcompos" ) +{ +} + +static cppcompos_ORB::cppcompos_var engine; + +// Module's initialization +void cppcomposGUI::initialize( CAM_Application* app ) +{ + + SalomeApp_Module::initialize( app ); + + Engines::Component_var comp = dynamic_cast(app)->lcc()->FindOrLoad_Component( "FactoryServer","cppcompos" ); + engine = cppcompos_ORB::cppcompos::_narrow(comp); + + QWidget* aParent = application()->desktop(); + SUIT_ResourceMgr* aResourceMgr = app->resourceMgr(); + + // create actions + QPixmap aPixmap = aResourceMgr->loadPixmap( "cppcompos","exec.png" ); + createAction( 901, "Banner", QIcon( aPixmap ), "Banner", "Banner", 0, aParent, false, this, SLOT( OnGetBanner() ) ); + createAction( 902, "Designer", QIcon( aPixmap ), "Designer", "Designer", 0, aParent, false, this, SLOT( OnDesigner() ) ); + + // create menus + int aMenuId; + aMenuId = createMenu( "cppcompos", -1, -1, 30 ); + createMenu( 901, aMenuId, 10 ); + + // create toolbars + int aToolId = createTool ( "cppcompos" ); + createTool( 901, aToolId ); + createTool( 902, aToolId ); +} + +// Get compatible dockable windows. +void cppcomposGUI::windows( QMap& theMap ) const +{ + theMap.clear(); + theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea ); + theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea ); +} + +// Module's engine IOR +QString cppcomposGUI::engineIOR() const +{ + return "bidon"; +} + +// Module's activation +bool cppcomposGUI::activateModule( SUIT_Study* theStudy ) +{ + bool bOk = SalomeApp_Module::activateModule( theStudy ); + + setMenuShown( true ); + setToolShown( true ); + + SALOME_NamingService *aNamingService = SalomeApp_Application::namingService(); + CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager"); + SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject); + SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(theStudy->id()); + + SALOMEDS::SComponent_var aFather = aDSStudy->FindComponent("cppcompos"); + if (aFather->_is_nil()) + { + SALOMEDS::StudyBuilder_var aStudyBuilder = aDSStudy->NewBuilder(); + aFather = aStudyBuilder->NewComponent("cppcompos"); + SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aFather, "AttributeName"); + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue("cppcompos"); + aName->Destroy(); + aStudyBuilder->DefineComponentInstance(aFather, engine); + } + CORBA::Boolean valid; + engine->DumpPython(aDSStudy,1,valid); + + return bOk; +} + +// Module's deactivation +bool cppcomposGUI::deactivateModule( SUIT_Study* theStudy ) +{ + setMenuShown( false ); + setToolShown( false ); + + return SalomeApp_Module::deactivateModule( theStudy ); +} + +// Action slot +void cppcomposGUI::OnGetBanner() +{ + // Dialog to get the Name + bool ok = FALSE; + QString myName = QInputDialog::getText( getApp()->desktop(), "label", "name", QLineEdit::Normal, QString::null, &ok ); + + if ( ok && !myName.isEmpty()) + { + ::CORBA::Double c; + engine->s1(1.,2.,c); + std::cerr << c << std::endl; + QString banner = "Hello " + myName; + SUIT_MessageBox::information( getApp()->desktop(), "info", banner, "OK" ); + } +} + +// Action slot +void cppcomposGUI::OnDesigner() +{ + QWidget* wid= new MyDemo(getApp()->desktop()); + wid->show(); +} + +MyDemo::MyDemo(QWidget *parent) + :QDialog(parent) +{ + ui.setupUi(this); +} diff --git a/Examples/cppgui1/cppcomposGUI.h b/Examples/cppgui1/cppcomposGUI.h new file mode 100644 index 0000000..e722eb6 --- /dev/null +++ b/Examples/cppgui1/cppcomposGUI.h @@ -0,0 +1,39 @@ +#ifndef _cppcomposGUI_H_ +#define _cppcomposGUI_H_ + +#include +#include "ui_demo.h" + +class cppcomposGUI: public SalomeApp_Module +{ + Q_OBJECT + +public: + cppcomposGUI(); + void initialize( CAM_Application* ); + QString engineIOR() const; + virtual void windows( QMap& theMap ) const; + +public slots: + bool deactivateModule( SUIT_Study* ); + bool activateModule( SUIT_Study* ); + +protected slots: + void OnGetBanner(); + void OnDesigner(); + +}; + +class MyDemo: public QDialog +{ + Q_OBJECT + +public: + MyDemo(QWidget *parent = 0); + +private: + Ui::DemoDialog ui; + +}; + +#endif diff --git a/Examples/cppgui1/demo.ui b/Examples/cppgui1/demo.ui new file mode 100644 index 0000000..69e4ac0 --- /dev/null +++ b/Examples/cppgui1/demo.ui @@ -0,0 +1,146 @@ + + + + + DemoDialog + + + + 0 + 0 + 400 + 300 + + + + PyUIC4 Demo Dialog + + + + 9 + + + 6 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 0 + + + 6 + + + + + Add items + + + + + + + Clear list + + + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 131 + 31 + + + + + + + + OK + + + + + + + + + + + + okButton + clicked() + DemoDialog + accept() + + + 369 + 256 + + + 96 + 254 + + + + + button2 + clicked() + list + clear() + + + 92 + 112 + + + 279 + 123 + + + + + diff --git a/Examples/cppgui1/exec.png b/Examples/cppgui1/exec.png new file mode 100644 index 0000000..16a20c1 Binary files /dev/null and b/Examples/cppgui1/exec.png differ diff --git a/Examples/cppgui1/index.rst b/Examples/cppgui1/index.rst new file mode 100644 index 0000000..e5ebde0 --- /dev/null +++ b/Examples/cppgui1/index.rst @@ -0,0 +1,23 @@ +.. cppcompos documentation master file, created by + sphinx-quickstart on Sun Sep 19 16:20:14 2010. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to cppcompos's documentation! +======================================= + +Contents: + +.. toctree:: + :maxdepth: 2 + + using.rst + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/Examples/cppgui1/myinterface.idl b/Examples/cppgui1/myinterface.idl new file mode 100644 index 0000000..16207a9 --- /dev/null +++ b/Examples/cppgui1/myinterface.idl @@ -0,0 +1,8 @@ +#include "SALOMEDS.idl" +#include "SALOME_Exception.idl" + +interface Idl_A : SALOMEDS::Driver +{ + void createObject(in SALOMEDS::Study theStudy, in string name) raises (SALOME::SALOME_Exception); +}; + diff --git a/Examples/cppgui1/using.rst b/Examples/cppgui1/using.rst new file mode 100644 index 0000000..f28347d --- /dev/null +++ b/Examples/cppgui1/using.rst @@ -0,0 +1,17 @@ + +GUI components +=================== + +Object Browser +-------------- +The Object Browser is a reusable GUI component. + +The Object Browser is only used to publish the run of the schema as a whole. + + +.. centered:: **Object Browser tab** + +The Object Browser is in a tab, with tree_view + +Other +---------- 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/pygui1/README.txt b/Examples/pygui1/README.txt new file mode 100644 index 0000000..fb47288 --- /dev/null +++ b/Examples/pygui1/README.txt @@ -0,0 +1,19 @@ +A Python component dynamically loadable +=============================================== + +To build this example, modify the ../context.py file +to take into account your configuration. + +1- your prerequisite file +2- your KERNEL_ROOT_DIR + +Then set the environment (including PYTHONPATH for YACSGEN, ../.. from here and execute components.py :: + + source + python components.py + +You should get a SALOME module in source form (pycompos_SRC), its installation (install) and +a SALOME application (appli) composed of modules KERNEL, GUI, YACS and the new module pycompos. + +Launch SALOME : ./appli/runAppli -k +activate the pycompos module, look at the doc, activate commands, ... diff --git a/Examples/pygui1/components.py b/Examples/pygui1/components.py new file mode 100644 index 0000000..1ca7ac3 --- /dev/null +++ b/Examples/pygui1/components.py @@ -0,0 +1,118 @@ +# 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 +# + +import os + +#import context from .. +execfile("../context.py") + +from module_generator import * + +defs=""" +""" + +body=""" + c=a+b + d=a-b +""" + +idldefs=""" +#include "myinterface.idl" +""" + +compodefs=r""" +import SALOME_DriverPy +import traceback + +class A(SALOME_DriverPy.SALOME_DriverPy_i): + def __init__(self): + SALOME_DriverPy.SALOME_DriverPy_i.__init__(self,"pycompos") + return + + def createObject( self, study, name ): + "Create object. " + try: + print study,name + builder = study.NewBuilder() + father = study.FindComponent( "pycompos" ) + if father is None: + father = builder.NewComponent( "pycompos" ) + attr = builder.FindOrCreateAttribute( father, "AttributeName" ) + attr.SetValue( "pycompos" ) + + object = builder.NewObject( father ) + attr = builder.FindOrCreateAttribute( object, "AttributeName" ) + attr.SetValue( name ) + except: + traceback.print_exc() + + def DumpPython( self, study, isPublished ): + abuffer = [] + abuffer.append( "def RebuildData( theStudy ):" ) + names = [] + father = study.FindComponent( "pycompos" ) + if father: + iter = study.NewChildIterator( father ) + while iter.More(): + name = iter.Value().GetName() + if name: names.append( name ) + iter.Next() + pass + pass + if names: + abuffer += [ " from salome import lcc" ] + abuffer += [ " import pycompos_ORB" ] + abuffer += [ " " ] + abuffer += [ " compo = lcc.FindOrLoadComponent( 'FactoryServerPy', 'pycompos' )" ] + abuffer += [ " " ] + abuffer += [ " compo.createObject( theStudy, '%s' )" % name for name in names ] + pass + abuffer += [ " " ] + + return ("\n".join( abuffer ), 1) + +""" + +c1=PYComponent("pycompos",services=[ + Service("s1",inport=[("a","double"),("b","double")], + outport=[("c","double"),("d","double")], + defs=defs,body=body, + ), + ], + idls=["*.idl"], + interfacedefs=idldefs, + inheritedinterface="Idl_A", + compodefs=compodefs, + inheritedclass="A", + ) + +modul=Module("pycompos",components=[c1],prefix="./install", + doc=["*.rst","*.png"], + gui=["pycomposGUI.py","demo.ui","*.png"], + ) + +g=Generator(modul,context) +g.generate() +g.bootstrap() +g.configure() +g.make() +g.install() +g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}) + + diff --git a/Examples/pygui1/demo.ui b/Examples/pygui1/demo.ui new file mode 100644 index 0000000..69e4ac0 --- /dev/null +++ b/Examples/pygui1/demo.ui @@ -0,0 +1,146 @@ + + + + + DemoDialog + + + + 0 + 0 + 400 + 300 + + + + PyUIC4 Demo Dialog + + + + 9 + + + 6 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 0 + + + 6 + + + + + Add items + + + + + + + Clear list + + + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 131 + 31 + + + + + + + + OK + + + + + + + + + + + + okButton + clicked() + DemoDialog + accept() + + + 369 + 256 + + + 96 + 254 + + + + + button2 + clicked() + list + clear() + + + 92 + 112 + + + 279 + 123 + + + + + diff --git a/Examples/pygui1/exec.png b/Examples/pygui1/exec.png new file mode 100644 index 0000000..16a20c1 Binary files /dev/null and b/Examples/pygui1/exec.png differ diff --git a/Examples/pygui1/index.rst b/Examples/pygui1/index.rst new file mode 100644 index 0000000..ff84846 --- /dev/null +++ b/Examples/pygui1/index.rst @@ -0,0 +1,23 @@ +.. pycompos documentation master file, created by + sphinx-quickstart on Sun Sep 19 16:20:14 2010. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to pycompos's documentation! +======================================= + +Contents: + +.. toctree:: + :maxdepth: 2 + + using.rst + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/Examples/pygui1/myinterface.idl b/Examples/pygui1/myinterface.idl new file mode 100644 index 0000000..16207a9 --- /dev/null +++ b/Examples/pygui1/myinterface.idl @@ -0,0 +1,8 @@ +#include "SALOMEDS.idl" +#include "SALOME_Exception.idl" + +interface Idl_A : SALOMEDS::Driver +{ + void createObject(in SALOMEDS::Study theStudy, in string name) raises (SALOME::SALOME_Exception); +}; + diff --git a/Examples/pygui1/pycompos.png b/Examples/pygui1/pycompos.png new file mode 100644 index 0000000..16a20c1 Binary files /dev/null and b/Examples/pygui1/pycompos.png differ diff --git a/Examples/pygui1/pycomposGUI.py b/Examples/pygui1/pycomposGUI.py new file mode 100644 index 0000000..f57dd52 --- /dev/null +++ b/Examples/pygui1/pycomposGUI.py @@ -0,0 +1,125 @@ +import os + +from PyQt4.QtCore import * +from PyQt4.QtGui import * +from PyQt4.QtWebKit import * +from PyQt4 import QtCore, QtGui, uic + +import salome +import pycompos_ORB + +# Get SALOME PyQt interface +import SalomePyQt +sgPyQt = SalomePyQt.SalomePyQt() + +# Get SALOME Swig interface +import libSALOME_Swig +sg = libSALOME_Swig.SALOMEGUI_Swig() + +# object counter +__objectid__ = 0 + +### +# get active study ID +### +def _getStudyId(): + return sgPyQt.getStudyId() + +### +# get active study +### +def _getStudy(): + studyId = _getStudyId() + study = salome.myStudyManager.GetStudyByID( studyId ) + return study + +# called when module is initialized +# return map of popup windows to be used by the module +def windows(): + wm = {} + wm[SalomePyQt.WT_ObjectBrowser] = Qt.LeftDockWidgetArea + wm[SalomePyQt.WT_PyConsole] = Qt.BottomDockWidgetArea + return wm + +# called when module is initialized +# return list of 2d/3d views to be used ny the module +def views(): + return [] + +# called when module is activated +# returns True if activating is successfull and False otherwise +def activate(): + # create top-level menu + mid = sgPyQt.createMenu( "pycompos", -1, 90, sgPyQt.defaultMenuGroup() ) + # create toolbar + tid = sgPyQt.createTool( "pycompos" ) + # create actions and fill menu and toolbar with actions + a = sgPyQt.createAction( 941, "Hello", "Hello", "Show hello dialog box" ,"exec.png") + sgPyQt.createMenu( a, mid ) + sgPyQt.createTool( a, tid ) + a = sgPyQt.createAction( 942, "Hello2", "Hello2", "Show hello2 dialog box" ,"exec.png") + sgPyQt.createMenu( a, mid ) + sgPyQt.createTool( a, tid ) + a = sgPyQt.createAction( 943, "Create object", "Create object", "Create object","exec.png" ) + sgPyQt.createMenu( a, mid ) + sgPyQt.createTool( a, tid ) + + return True + +# called when module is deactivated +def deactivate(): + pass + +_engine=None +def getEngine(): + global _engine + if not _engine: + _engine= salome.lcc.FindOrLoadComponent( "FactoryServerPy", "pycompos" ) + return _engine + +### +# Create new object +### +def CreateObject(): + global __objectid__ + default_name = str( sgPyQt.stringSetting( "pycompos", "def_obj_name", "Object" ).trimmed() ) + # generate object name + __objectid__ = __objectid__ + 1 + name = "%s_%d" % ( default_name, __objectid__ ) + if not name: return + getEngine().createObject( _getStudy(), name ) + print getEngine().s1(4,5) + print getEngine().ComponentDataType() + sg.updateObjBrowser( True ) + +class DemoImpl(QtGui.QDialog): + def __init__(self, *args): + super(DemoImpl, self).__init__(*args) + + uic.loadUi(os.path.join(os.environ["pycompos_ROOT_DIR"],"share","salome","resources","pycompos","demo.ui"), self) + + @QtCore.pyqtSlot() + def on_button1_clicked(self): + for s in "This is a demo".split(" "): + self.list.addItem(s) + +# called when GUI action is activated +# action ID is passed as parameter +def OnGUIEvent( commandID ): + print "pycompos.OnGUIEvent(): command = %d" % commandID + if commandID==941: + widget=QMainWindow(sgPyQt.getDesktop()) + web = QWebView(widget) + page=os.path.join(os.environ["pycompos_ROOT_DIR"],"share","doc","salome","gui","pycompos","index.html") + web.load(QUrl(page)) + widget.setCentralWidget(web) + widget.show() + + elif commandID==942: + widget = DemoImpl(sgPyQt.getDesktop()) + widget.show() + + elif commandID==943: + CreateObject() + + diff --git a/Examples/pygui1/using.rst b/Examples/pygui1/using.rst new file mode 100644 index 0000000..8321bf3 --- /dev/null +++ b/Examples/pygui1/using.rst @@ -0,0 +1,20 @@ + +GUI components +=================== + +Object Browser +-------------- +The Object Browser is a reusable GUI component. + +The Object Browser is only used to publish the run of the schema as a whole. + + +.. centered:: **Object Browser tab** + +The Object Browser is in a tab, with tree_view + +Other +---------- +.. image:: exec.png + :align: center + diff --git a/Examples/pyth1/components.py b/Examples/pyth1/components.py index b7e2ee8..3677297 100644 --- a/Examples/pyth1/components.py +++ b/Examples/pyth1/components.py @@ -18,10 +18,10 @@ # import os -from module_generator import Generator,Module,Service,PYComponent #import context from .. execfile("../context.py") +from module_generator import Generator,Module,Service,PYComponent cwd=os.getcwd() 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/MANIFEST.in b/MANIFEST.in index 381adcb..7148ed7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -22,6 +22,10 @@ include Examples/makefile.inc include Examples/*/*.f include Examples/*/*.py include Examples/*/*.cxx +include Examples/*/*.h +include Examples/*/*.png +include Examples/*/*.ui +include Examples/*/*.rst include Examples/*/coupling.xml include Examples/*/Makefile include Examples/*/README.txt diff --git a/module_generator/__init__.py b/module_generator/__init__.py index 585afa1..e79531f 100644 --- a/module_generator/__init__.py +++ b/module_generator/__init__.py @@ -18,9 +18,9 @@ # """ - Package to generate SALOME modules with components - implemented in C++, Fortran or Python - that can use datastream ports +The python module module_generator defines classes which can be used to define a SALOME module, its components and +generates a SALOME source module, its installation and a SALOME application including this module and +other preexisting SALOME modules like GEOM, SMESH or others. """ from gener import Module, Service, Generator from fcompo import F77Component @@ -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/astcompo.py b/module_generator/astcompo.py index f124fbb..cb99fcf 100644 --- a/module_generator/astcompo.py +++ b/module_generator/astcompo.py @@ -36,6 +36,30 @@ from aster_tmpl import comm, make_etude, cexe, exeaster from aster_tmpl import container, component class ASTERComponent(Component): + """ + A :class:`ASTERComponent` instance represents an ASTER SALOME component (special component for Code_Aster that is a mix of + Fortran and Python code) with services given as a list of :class:`Service` instances with the parameter *services*. + + :param name: gives the name of the component. + :type name: str + :param services: the list of services (:class:`Service`) of the component. + :param kind: If it is given and has the value "exe", the component will be built as a standalone + component (executable or shell script). The default is to build the component as a dynamic library. + :param libs: gives all the libraries options to add when linking the generated component (-L...). + :param rlibs: gives all the runtime libraries options to add when linking the generated component (-R...). + :param exe_path: is only used when kind is "exe" and gives the path to the standalone component. + :param aster_dir: gives the Code_Aster installation directory. + :param python_path: If it is given (as a list of paths), all the paths are added to the python path (sys.path). + :param argv: is a list of strings that gives the command line parameters for Code_Aster. This parameter is only useful when + kind is "lib". + + For example, the following call defines a Code_Aster component named "mycompo" with one service s1 (it must have been defined before). + This standalone component takes some command line arguments:: + + >>> c1 = module_generator.ASTERComponent('mycompo', services=[s1,], kind="exe", + exe_path="launch.sh", + argv=["-memjeveux","4"]) + """ def __init__(self, name, services=None, libs="", rlibs="", aster_dir="", python_path=None, argv=None, kind="lib", exe_path=None): """initialise component attributes""" @@ -117,11 +141,15 @@ class ASTERComponent(Component): if self.kind == "lib": makefileItems["salomepython_PYTHON"]=[self.name+".py"] elif self.kind == "exe": - makefileItems["salomepython_PYTHON"]=[self.name+"_module.py",self.name+"_component.py","E_SUPERV.py"] + makefileItems["salomepython_PYTHON"]=[self.name+"_module.py",self.name+"_component.py"] + if self.version < (10,1,2): + makefileItems["salomepython_PYTHON"].append("E_SUPERV.py") makefileItems["dist_salomescript_SCRIPTS"]=[self.name+".exe"] makefileItems["salomeres_DATA"]=[self.name+"_config.txt"] elif self.kind == "cexe": - makefileItems["salomepython_PYTHON"]=[self.name+".py",self.name+"_container.py","E_SUPERV.py"] + makefileItems["salomepython_PYTHON"]=[self.name+".py",self.name+"_container.py"] + if self.version < (10,1,2): + makefileItems["salomepython_PYTHON"].append("E_SUPERV.py") makefileItems["dist_salomescript_SCRIPTS"]=[self.name+".exe"] makefileItems["salomeres_DATA"]=[self.name+"_config.txt"] return makefileItems @@ -130,18 +158,19 @@ class ASTERComponent(Component): def makeexepath(self, gen): """standalone component: generate files for calculation code""" - #copy and patch E_SUPERV.py - fil = open(os.path.join(self.aster_dir, "bibpyt", "Execution", "E_SUPERV.py")) - esuperv = fil.read() - fil.close() + fdict={} if self.version < (10,1,2): #patch to E_SUPERV.py + fil = open(os.path.join(self.aster_dir, "bibpyt", "Execution", "E_SUPERV.py")) + esuperv = fil.read() + fil.close() esuperv = re.sub("def Execute\(self\)", "def Execute(self, params)", esuperv) esuperv = re.sub("j=self.JdC", "self.jdc=j=self.JdC", esuperv) esuperv = re.sub("\*\*args", "context_ini=params, **args", esuperv) esuperv = re.sub("def main\(self\)", "def main(self,params={})", esuperv) esuperv = re.sub("return self.Execute\(\)", "return self.Execute(params)", esuperv) + fdict["E_SUPERV.py"]=esuperv #use a specific main program (modification of config.txt file) fil = open(os.path.join(self.aster_dir, "config.txt")) @@ -154,29 +183,27 @@ class ASTERComponent(Component): 'site-packages','salome','%s_component.py'%self.name) config = re.sub("Execution\/E_SUPERV.py", path, config) - fdict= { - "%s_component.py"%self.name:component.substitute(component=self.name), - "%s_config.txt" % self.name:config, - "E_SUPERV.py":esuperv, - } + fdict["%s_config.txt" % self.name] = config + fdict["%s_component.py" % self.name] = component.substitute(component=self.name) + return fdict def makecexepath(self, gen): """specific container: generate files""" - #copy and patch E_SUPERV.py - fil = open(os.path.join(self.aster_dir, "bibpyt", "Execution", "E_SUPERV.py")) - esuperv = fil.read() - fil.close() + fdict={} if self.version < (10,1,2): #patch to E_SUPERV.py + fil = open(os.path.join(self.aster_dir, "bibpyt", "Execution", "E_SUPERV.py")) + esuperv = fil.read() + fil.close() esuperv = re.sub("def Execute\(self\)", "def Execute(self, params)", esuperv) esuperv = re.sub("j=self.JdC", "self.jdc=j=self.JdC", esuperv) esuperv = re.sub("\*\*args", "context_ini=params, **args", esuperv) esuperv = re.sub("def main\(self\)", "def main(self,params={})", esuperv) esuperv = re.sub("return self.Execute\(\)", "return self.Execute(params)", esuperv) - + fdict["E_SUPERV.py"]=esuperv #use a specific main program fil = open(os.path.join(self.aster_dir, "config.txt")) @@ -188,11 +215,9 @@ class ASTERComponent(Component): 'site-packages','salome','%s_container.py' % self.name) config = re.sub("Execution\/E_SUPERV.py", path, config) - fdict= { - "%s_container.py" % self.name:container, - "%s_config.txt" % self.name:config, - "E_SUPERV.py":esuperv, - } + fdict["%s_container.py" % self.name] = container + fdict["%s_config.txt" % self.name] = config + return fdict def makeexeaster(self, gen): @@ -228,11 +253,11 @@ class ASTERComponent(Component): outparams = ",".join(params) rvars = ",".join(datas) - service = asterEXEService.substitute(component=self.name, - service=serv.name, + service = asterEXEService.substitute(component=self.name, + service=serv.name, inparams=inparams, - outparams=outparams, - body=serv.body, + outparams=outparams, + body=serv.body, dvars=dvars, rvars=rvars) streams = [] for name, typ, dep in serv.instream: @@ -248,11 +273,20 @@ class ASTERComponent(Component): services.append(service) inits.append(init) + if self.version < (10,1,2): + importesuperv="from E_SUPERV import SUPERV" + else: + importesuperv="""sys.path=["%s"]+sys.path +from Execution.E_SUPERV import SUPERV +""" % os.path.join(self.aster_dir, "bibpyt") + return asterEXECompo.substitute(component=self.name, module=gen.module.name, - servicesdef="\n".join(defs), - servicesimpl="\n".join(services), + servicesdef="\n".join(defs), + servicesimpl="\n".join(services), initservice='\n'.join(inits), - aster_dir=self.aster_dir) + aster_dir=self.aster_dir, + importesuperv=importesuperv, + ) def makecexeaster(self, gen): """specific container: generate SALOME component source""" @@ -286,11 +320,11 @@ class ASTERComponent(Component): outparams = ",".join(params) rvars = ",".join(datas) - service = asterCEXEService.substitute(component=self.name, - service=serv.name, + service = asterCEXEService.substitute(component=self.name, + service=serv.name, inparams=inparams, - outparams=outparams, - body=serv.body, + outparams=outparams, + body=serv.body, dvars=dvars, rvars=rvars) streams = [] for name, typ, dep in serv.instream: @@ -308,12 +342,21 @@ class ASTERComponent(Component): services.append(service) inits.append(init) + if self.version < (10,1,2): + importesuperv="from E_SUPERV import SUPERV" + else: + importesuperv="""sys.path=["%s"] +sys.path +from Execution.E_SUPERV import SUPERV +""" % os.path.join(self.aster_dir, "bibpyt") + return asterCEXECompo.substitute(component=self.name, module=gen.module.name, servicesdef="\n".join(defs), servicesimpl="\n".join(services), initservice='\n'.join(inits), - aster_dir=self.aster_dir) + aster_dir=self.aster_dir, + importesuperv=importesuperv, + ) def getImpl(self): if self.kind == "cexe": diff --git a/module_generator/aster_tmpl.py b/module_generator/aster_tmpl.py index b871375..80c255a 100644 --- a/module_generator/aster_tmpl.py +++ b/module_generator/aster_tmpl.py @@ -24,7 +24,7 @@ except: asterCompo=""" import sys,traceback,os -import ${module}__POA +import ${module}_ORB__POA import calcium import dsccalcium import SALOME @@ -48,11 +48,11 @@ except: ${servicesdef} #ENDDEF -class ${component}(${module}__POA.${component},dsccalcium.PyDSCComponent,SUPERV): +class ${component}(${module}_ORB__POA.${component},dsccalcium.PyDSCComponent,SUPERV): ''' To be identified as a SALOME component this Python class must have the same name as the component, inherit omniorb - class ${module}__POA.${component} and DSC class dsccalcium.PyDSCComponent + class ${module}_ORB__POA.${component} and DSC class dsccalcium.PyDSCComponent that implements DSC API. ''' def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ): @@ -78,12 +78,12 @@ asterCompo=Template(asterCompo) asterCEXECompo=""" import sys,traceback,os import string -import ${module}__POA +import ${module}_ORB__POA import calcium import dsccalcium import SALOME import linecache -from E_SUPERV import SUPERV +${importesuperv} try: import numpy @@ -97,11 +97,11 @@ ${servicesdef} class ExecutionError(Exception): '''General exception during execution''' -class ${component}(${module}__POA.${component},dsccalcium.PyDSCComponent,SUPERV): +class ${component}(${module}_ORB__POA.${component},dsccalcium.PyDSCComponent,SUPERV): ''' To be identified as a SALOME component this Python class must have the same name as the component, inherit omniorb - class ${module}__POA.${component} and DSC class dsccalcium.PyDSCComponent + class ${module}_ORB__POA.${component} and DSC class dsccalcium.PyDSCComponent that implements DSC API. ''' def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ): diff --git a/module_generator/cata_tmpl.py b/module_generator/cata_tmpl.py index e0258f5..c8feeff 100644 --- a/module_generator/cata_tmpl.py +++ b/module_generator/cata_tmpl.py @@ -31,10 +31,12 @@ idl=""" #include "DSC_Engines.idl" #include "SALOME_Exception.idl" #include "SALOME_PACOExtension.idl" +#include "SALOME_Component.idl" +#include "SALOME_Comm.idl" ${idldefs} -module ${module} +module ${module}_ORB { typedef sequence stringvec; typedef sequence dblevec; @@ -49,7 +51,7 @@ ${interfaces} idl=Template(idl) interface=""" - interface ${component}:Engines::Superv_Component + interface ${component}:${inheritedinterface} Engines::Superv_Component { ${services} }; @@ -94,22 +96,21 @@ xml_service = Template(xml_service) idlMakefile=""" include $$(top_srcdir)/adm_local/make_common_starter.am -BUILT_SOURCES = ${module}SK.cc ${PACO_BUILT_SOURCES} -IDL_FILES=${module}.idl +BUILT_SOURCES = ${module}SK.cc ${PACO_BUILT_SOURCES} ${other_sks} +IDL_FILES=${module}.idl ${other_idls} -lib_LTLIBRARIES = lib${module}.la +lib_LTLIBRARIES = libSalomeIDL${module}.la salomeidl_DATA = $$(IDL_FILES) ${PACO_salomeidl_DATA} -salomepython_DATA = ${module}_idl.py ${PACO_salomepython_DATA} -lib${module}_la_SOURCES = -nodist_lib${module}_la_SOURCES = ${module}SK.cc +libSalomeIDL${module}_la_SOURCES = +nodist_libSalomeIDL${module}_la_SOURCES = ${module}SK.cc ${other_sks} nodist_salomeinclude_HEADERS= ${module}.hh ${PACO_SALOMEINCLUDE_HEADERS} -lib${module}_la_CXXFLAGS = -I. $$(SALOME_INCLUDES) -lib${module}_la_LIBADD = $$(SALOME_IDL_LIBS) +libSalomeIDL${module}_la_CXXFLAGS = -I. $$(SALOME_INCLUDES) +libSalomeIDL${module}_la_LIBADD = $$(SALOME_IDL_LIBS) ########################################################## %SK.cc %.hh : %.idl -\t$$(OMNIORB_IDL) -bcxx $$(IDLCXXFLAGS) $$(OMNIORB_IDLCXXFLAGS) $$(IDL_INCLUDES) $$< +\t$$(OMNIORB_IDL) -bcxx $$(OMNIORB_IDLCXXFLAGS) $$(IDL_INCLUDES) $$< %_idl.py : %.idl -\t$$(OMNIORB_IDL) -bpython $$(IDL_INCLUDES) ${PACO_INCLUDES} $$< +\t$$(OMNIORB_IDL) $$(OMNIORB_IDLPYFLAGS) $$(IDL_INCLUDES) ${PACO_INCLUDES} $$< %PaCO.hxx %PaCO.cxx : %.idl %.xml \t$$(OMNIORB_IDL) -I@KERNEL_ROOT_DIR@/idl/salome -p@PACOPATH@/lib/python -bpaco -Wb$$(top_srcdir)/idl/$$*.xml,$$(srcdir):@PACOPATH@/idl:@KERNEL_ROOT_DIR@/idl/salome $$(top_srcdir)/idl/$$*.idl @@ -117,16 +118,15 @@ CLEANFILES = *.hh *SK.cc *.py *.hxx *.cxx EXTRA_DIST = $$(IDL_FILES) -clean-local: -\trm -rf ${module} ${module}__POA - -install-data-local: -\t$${mkinstalldirs} $$(DESTDIR)$$(salomepythondir) -\tcp -R ${module} ${module}__POA $$(DESTDIR)$$(salomepythondir) +install-data-local: $$(IDL_FILES) +\t$$(INSTALL) -d $$(DESTDIR)$$(salomepythondir) +\tls $$^ | while read file; do \\ +\t$$(OMNIORB_IDL) $$(OMNIORB_IDLPYFLAGS) $$(IDL_INCLUDES) -C$$(DESTDIR)$$(salomepythondir) $$$$file ; \\ +\tdone uninstall-local: -\trm -rf $$(DESTDIR)$$(salomepythondir)/${module} -\trm -rf $$(DESTDIR)$$(salomepythondir)/${module}__POA +\trm -rf $$(DESTDIR)$$(salomepythondir)/* + """ idlMakefile=Template(idlMakefile) diff --git a/module_generator/cpp_tmpl.py b/module_generator/cpp_tmpl.py index 4979bfa..eadcce2 100644 --- a/module_generator/cpp_tmpl.py +++ b/module_generator/cpp_tmpl.py @@ -235,7 +235,7 @@ extern "C" Engines::Container_var container = Engines::Container::_narrow(obj); ${component}_i * myEngine = new ${component}_i(orb, poa, container, instanceName.c_str(), "${component}"); pman->activate(); - obj=myEngine->_this(); + obj=myEngine->POA_${module}_ORB::${component}::_this(); Engines::Component_var component = Engines::Component::_narrow(obj); string component_registerName = containerName + "/" + instanceName; salomens->Register(component,component_registerName.c_str()); @@ -276,9 +276,8 @@ hxxCompo=""" ${compodefs} //ENDDEF -class ${component}_i: ${inheritedclass} - public virtual POA_${module}::${component}, - public virtual Superv_Component_i +class ${component}_i: public virtual POA_${module}_ORB::${component}, + ${inheritedclass} public virtual Superv_Component_i { public: ${component}_i(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, @@ -402,7 +401,7 @@ lib${component}Engine_la_SOURCES = ${component}.cxx ${sources} nodist_lib${component}Engine_la_SOURCES = lib${component}Engine_la_CXXFLAGS = -I$$(top_builddir)/idl $$(SALOME_INCLUDES) ${includes} lib${component}Engine_la_FFLAGS = $$(SALOME_INCLUDES) -fexceptions ${includes} -lib${component}Engine_la_LIBADD = ${libs} -L$$(top_builddir)/idl -l${module} $${SALOME_LIBS} $$(FLIBS) +lib${component}Engine_la_LIBADD = ${libs} -L$$(top_builddir)/idl -lSalomeIDL${module} $${SALOME_LIBS} $$(FLIBS) lib${component}Engine_la_LDFLAGS = ${rlibs} """ compoMakefile=Template(compoMakefile) @@ -412,7 +411,7 @@ lib${component}Exelib_la_SOURCES = ${component}.cxx nodist_lib${component}Exelib_la_SOURCES = lib${component}Exelib_la_CXXFLAGS = -I$$(top_builddir)/idl $$(SALOME_INCLUDES) ${includes} lib${component}Exelib_la_FFLAGS = $$(SALOME_INCLUDES) -fexceptions ${includes} -lib${component}Exelib_la_LIBADD = ${libs} -L$$(top_builddir)/idl -l${module} $${SALOME_LIBS} $$(FLIBS) +lib${component}Exelib_la_LIBADD = ${libs} -L$$(top_builddir)/idl -lSalomeIDL${module} $${SALOME_LIBS} $$(FLIBS) lib${component}Exelib_la_LDFLAGS = ${rlibs} """ compoEXEMakefile=Template(compoEXEMakefile) diff --git a/module_generator/cppcompo.py b/module_generator/cppcompo.py index eb6edea..3fef424 100644 --- a/module_generator/cppcompo.py +++ b/module_generator/cppcompo.py @@ -25,16 +25,50 @@ 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): - def __init__(self, name, services=None, libs="", rlibs="", includes="", - kind="lib", exe_path=None, sources=None, inheritedclass="", - compodefs=""): + """ + A :class:`CPPComponent` instance represents a C++ SALOME component with services given as a list of :class:`Service` + instances with the parameter *services*. + + :param name: gives the name of the component. + :type name: str + :param services: the list of services (:class:`Service`) of the component. + :param kind: If it is given and has the value "exe", the component will be built as a standalone + component (executable or shell script). The default is to build the component as a dynamic library. + :param libs: gives all the libraries options to add when linking the generated component (-L...). + :param rlibs: gives all the runtime libraries options to add when linking the generated component (-R...). + :param includes: gives all the include options to add when compiling the generated component (-I...). + :param sources: gives all the external source files to add in the compilation step (list of paths). + :param exe_path: is only used when kind is "exe" and gives the path to the standalone component. + :param compodefs: can be used to add extra definition code in the component for example when using a base class + to define the component class by deriving it (see *inheritedclass* parameter) + :param inheritedclass: can be used to define a base class for the component. The base class can be defined in external + source or with the *compodefs* parameter. The value of the *inheritedclass* parameter is the name of the base class. + :param idls: can be used to add extra idl CORBA interfaces to the component. This parameter must gives a list of idl file + names that are added into the generated module (idl directory) and compiled with the generated idl of the module. + :param interfacedefs: can be used to add idl definitions (or includes of idl files) into the generated idl of the module. + :param inheritedinterface: can be used to make the component inherit an extra idl interface that has been included through + the *idls* and *interfacedefs* parameters. See the cppgui1 example for how to use these last parameters. + :param addmethods: is a C++ specific parameter that can be used to redefine a component method (DumpPython for example). This + parameter is a string that must contain the definition and implementation code of the method. See the cppgui1 example + for how to use it. + + For example, the following call defines a standalone component named "mycompo" with one service s1 (it must have been defined before):: + + >>> c1 = module_generator.CPPComponent('mycompo', services=[s1,], kind="exe", + exe_path="./launch.sh") + """ + def __init__(self, name, services=None, libs="", rlibs="", includes="", kind="lib", + exe_path=None, sources=None, inheritedclass="", compodefs="", + idls=None,interfacedefs="",inheritedinterface="",addedmethods=""): self.exe_path = exe_path - Component.__init__(self, name, services, impl="CPP", libs=libs, - rlibs=rlibs, includes=includes, kind=kind, - sources=sources,inheritedclass=inheritedclass, - compodefs=compodefs) + Component.__init__(self, name, services, impl="CPP", libs=libs, rlibs=rlibs, + includes=includes, kind=kind, sources=sources, + inheritedclass=inheritedclass, compodefs=compodefs, idls=idls, + interfacedefs=interfacedefs, inheritedinterface=inheritedinterface, + addedmethods=addedmethods) def validate(self): """ validate component definition parameters""" @@ -98,9 +132,12 @@ 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) + + if self.addedmethods: + services.append(self.addedmethods) servicesdef = "\n".join(services) inheritedclass=self.inheritedclass diff --git a/module_generator/doc_tmpl.py b/module_generator/doc_tmpl.py new file mode 100644 index 0000000..e778e0f --- /dev/null +++ b/module_generator/doc_tmpl.py @@ -0,0 +1,259 @@ + +try: + from string import Template +except: + from compat import Template,set + +docmakefile=""" +include $(top_srcdir)/adm_local/make_common_starter.am + +salomedoc_DATA=html/index.html + +html/index.html: + make htm + +SPHINXOPTS = +SOURCEDIR = $(srcdir) +SPHINXBUILD = sphinx-build +PAPEROPT_a4 = -D latex_paper_size=a4 +ALLSPHINXOPTS = -d doctrees $(PAPEROPT_a4) $(SPHINXOPTS) $(SOURCEDIR) + +htm: + mkdir -p html doctrees + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) html + @echo + @echo "Build finished. The HTML pages are in html." + +install-data-local: + $(INSTALL) -d $(DESTDIR)$(salomedocdir) + cp -rf html/* $(DESTDIR)$(salomedocdir) ; + +uninstall-local: + chmod -R +w $(DESTDIR)$(salomedocdir) + rm -rf $(DESTDIR)$(salomedocdir)/* + +clean-local: + -rm -rf html latex doctrees + if test -d "html"; then rm -rf html ; fi + +""" + +docconf="""# -*- coding: utf-8 -*- +# +# ${module} documentation build configuration file, created by +# sphinx-quickstart on Sun Sep 19 16:20:14 2010. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = [] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'${module}' +copyright = u'2010' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '1' +# The full version, including alpha/beta/rc tags. +release = '1' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = '${module}doc' + + +# -- Options for LaTeX output -------------------------------------------------- + +# The paper size ('letter' or 'a4'). +#latex_paper_size = 'letter' + +# The font size ('10pt', '11pt' or '12pt'). +#latex_font_size = '10pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', '${module}.tex', u'${module} Documentation', + u'cc', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Additional stuff for the LaTeX preamble. +#latex_preamble = '' + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', '${module}', u'${module} Documentation', + [u'cc'], 1) +] +""" + +docconf=Template(docconf) diff --git a/module_generator/fcompo.py b/module_generator/fcompo.py index 55d2baf..c466fe3 100644 --- a/module_generator/fcompo.py +++ b/module_generator/fcompo.py @@ -29,6 +29,27 @@ else: f77Types = {"double":"double *", "long":"long *", "string":"const char *"} class F77Component(CPPComponent): + """ + A :class:`F77Component` instance represents a Fortran SALOME component with services given as a list of :class:`Service` + instances with the parameter *services*. + + :param name: gives the name of the component. + :type name: str + :param services: the list of services (:class:`Service`) of the component. + :param kind: If it is given and has the value "exe", the component will be built as a standalone + component (executable or shell script). The default is to build the component as a dynamic library. + :param libs: gives all the libraries options to add when linking the generated component (-L...). + :param rlibs: gives all the runtime libraries options to add when linking the generated component (-R...). + :param sources: gives all the external source files to add in the compilation step (list of paths). + :param exe_path: is only used when kind is "exe" and gives the path to the standalone component. + + For example, the following call defines a Fortran component named "mycompo" with one service s1 (it must have been defined before). + This component is implemented as a dynamic library linked with a user's library "mylib":: + + >>> c1 = module_generator.F77Component('mycompo', services=[s1,], + libs="-lmylib -Lmydir") + + """ def __init__(self, name, services=None, libs="", rlibs="", kind="lib", exe_path=None, sources=None): CPPComponent.__init__(self, name, services, libs=libs, rlibs=rlibs, diff --git a/module_generator/gener.py b/module_generator/gener.py index 704f2f0..4fc94e5 100644 --- a/module_generator/gener.py +++ b/module_generator/gener.py @@ -19,6 +19,7 @@ import os, shutil, glob, socket import traceback +import warnings try: from string import Template @@ -32,6 +33,7 @@ debug=0 from mod_tmpl import resMakefile, makecommon, configure, paco_configure from mod_tmpl import mainMakefile, autogen, application +from mod_tmpl import check_sphinx from cata_tmpl import catalog, interface, idl, idlMakefile, parallel_interface from cata_tmpl import xml, xml_interface, xml_service from cata_tmpl import idlMakefilePaCO_BUILT_SOURCES, idlMakefilePaCO_nodist_salomeinclude_HEADERS @@ -45,6 +47,8 @@ from salomemodules import salome_modules from yacstypes import corbaTypes, corbaOutTypes, moduleTypes, idlTypes, corba_in_type, corba_out_type from yacstypes import ValidTypes, PyValidTypes, calciumTypes, DatastreamParallelTypes from yacstypes import ValidImpl, ValidImplTypes, ValidStreamTypes, ValidParallelStreamTypes, ValidDependencies +from gui_tmpl import pyguimakefile, pysalomeapp, cppguimakefile, cppsalomeapp +from doc_tmpl import docmakefile, docconf def makedirs(namedir): """Create a new directory named namedir. If a directory already exists copy it to namedir.bak""" @@ -57,11 +61,42 @@ def makedirs(namedir): os.makedirs(namedir) class Module(object): - def __init__(self, name, components=None, prefix="",layout="multidir"): + """ + A :class:`Module` instance represents a SALOME module that contains components given as a list of + component instances (:class:`CPPComponent` or :class:`PYComponent` or :class:`F77Component` or :class:`ASTERComponent`) + with the parameter *components*. + + :param name: gives the name of the module. The SALOME source module + will be located in the directory. + :type name: str + :param components: gives the list of components of the module. + :param prefix: is the path of the installation directory. + :param layout: If given and has the value "monodir", all components + will be generated in a single directory. The default is to generate each component in its + own directory. + :param doc: can be used to add an online documentation to the module. It must be a list of file names (sources, images, ...) that will be + used to build a sphinx documentation (see http://sphinx.pocoo.org, for more information). If not given, the Makefile.am + and the conf.py (sphinx configuration) files are generated. In this case, the file name extension of source files must be .rst. + See small examples in Examples/pygui1 and Examples/cppgui1. + :param gui: can be used to add a GUI to the module. It must be a list of file names (sources, images, qt designer files, ...). + If not given, the Makefile.am and SalomeApp.xml are generated. All image files are put in the resources directory of the module. + The GUI can be implemented in C++ (file name extension '.cxx') or in Python (file name extension '.py'). + See small examples in Examples/pygui1 and Examples/cppgui1. + + For example, the following call defines a module named "mymodule" with 2 components c1 and c2 (they must have been + defined before) that will be installed in the "install" directory:: + + >>> m = module_generator.Module('mymodule', components=[c1,c2], + prefix="./install") + + """ + def __init__(self, name, components=None, prefix="",layout="multidir", doc=None, gui=None): self.name = name self.components = components or [] self.prefix = prefix or "%s_INSTALL" % name self.layout=layout + self.doc = doc + self.gui = gui try: self.validate() except Invalid,e: @@ -80,11 +115,16 @@ class Module(object): raise Invalid("%s is already defined as a component of the module" % compo.name) lcompo.add(compo.name) compo.validate() + if self.gui and self.layout != "multidir": + raise Invalid("A module with GUI can not be generated if layout is not multidir") + if self.doc and not self.gui: + warnings.warn("The documentation will be generated but it will not appear as an help doc, if your module has no GUI.") class Component(object): def __init__(self, name, services=None, impl="PY", libs="", rlibs="", includes="", kind="lib", sources=None, - inheritedclass="",compodefs=""): + inheritedclass="",compodefs="", + idls=None,interfacedefs="",inheritedinterface="",addedmethods=""): self.name = name self.impl = impl self.kind = kind @@ -95,6 +135,10 @@ class Component(object): self.sources = sources or [] self.inheritedclass=inheritedclass self.compodefs=compodefs + self.idls=idls + self.interfacedefs=interfacedefs + self.inheritedinterface=inheritedinterface + self.addedmethods=addedmethods def validate(self): if self.impl not in ValidImpl: @@ -119,11 +163,44 @@ class Component(object): return {} class Service(object): - def __init__(self, name, inport=None, outport=None, instream=None, - outstream=None, parallel_instream=None, parallel_outstream=None, body="", defs="", impl_type="sequential"): + """ + A :class:`Service` instance represents a component service with dataflow and datastream ports. + + :param name: gives the name of the service. + :type name: str + :param inport: gives the list of input dataflow ports. + :param outport: gives the list of output dataflow ports. An input or output dataflow port is defined + 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", + "CALCIUM_real", "CALCIUM_string", "CALCIUM_complex", "CALCIUM_logical", "CALCIUM_long". The mode can be "I" (iterative mode) + or "T" (temporal mode). + :param defs: gives the source code to insert in the definition section of the component. It can be C++ includes + or Python imports + :type defs: str + :param body: gives the source code to insert in the service call. It can be any C++ + or Python code that fits well in the body of the service method. + :type body: str + + For example, the following call defines a minimal Python service with one input dataflow port (name "a", type double) + and one input datastream port:: + + >>> s1 = module_generator.Service('myservice', inport=[("a","double"),], + instream=[("aa","CALCIUM_double","I")], + body="print a") + + + """ + 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 [] @@ -159,7 +236,7 @@ class Service(object): if name in lports: raise Invalid("%s is already defined as a stream port" % name) lports.add(name) - + for port in self.parallel_instream: name, typ = self.validateParallelStream(port) if name in lports: @@ -214,15 +291,31 @@ class Service(object): return name, typ class Generator(object): + """ + A :class:`Generator` instance take a :class:`Module` instance as its first parameter and can be used to generate the + SALOME source module, builds it, installs it and includes it in a SALOME application. + + :param module: gives the :class:`Module` instance that will be used for the generation. + :param context: If given , its content is used to specify the prerequisites + environment file (key *"prerequisites"*) and the SALOME KERNEL installation directory (key *"kernel"*). + :type context: dict + + For example, the following call creates a generator for the module m:: + + >>> g = module_generator.Generator(m,context) + """ def __init__(self, module, context=None): self.module = module self.context = context or {} self.kernel = self.context["kernel"] + self.gui = self.context.get("gui") self.makeflags = self.context.get("makeflags") self.aster = "" + if self.module.gui and not self.gui: + raise Invalid("To generate a module with GUI, you need to set the 'gui' parameter in the context dictionnary") def generate(self): - """generate SALOME module as described by module attribute""" + """Generate a SALOME source module""" module = self.module namedir = module.name+"_SRC" force = self.context.get("force") @@ -242,7 +335,7 @@ class Generator(object): makefile = "SUBDIRS=" makefileItems={"header":""" include $(top_srcdir)/adm_local/make_common_starter.am -AM_CFLAGS=$$(SALOME_INCLUDES) -fexceptions +AM_CFLAGS=$(SALOME_INCLUDES) -fexceptions """, "salomepython_PYTHON":[], "dist_salomescript_SCRIPTS":[], @@ -263,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) @@ -288,11 +381,22 @@ AM_CFLAGS=$$(SALOME_INCLUDES) -fexceptions makefileItems["salomeinclude_HEADERS"]=makefileItems["salomeinclude_HEADERS"]+mdict.get("salomeinclude_HEADERS",[]) makefileItems["body"]=makefileItems["body"]+mdict.get("body","")+'\n' + if module.gui: + GUIname=module.name+"GUI" + fdict=self.makeGui(namedir) + srcs[GUIname] = fdict + #for src/Makefile.am + makefile = makefile + " " + GUIname + if self.module.layout == "multidir": srcs["Makefile.am"] = makefile+'\n' else: srcs["Makefile.am"] = self.makeMakefile(makefileItems) + docsubdir="" + if module.doc: + docsubdir="doc" + #for catalog files catalogfile = "%sCatalog.xml" % module.name @@ -301,12 +405,16 @@ AM_CFLAGS=$$(SALOME_INCLUDES) -fexceptions for mod in self.used_modules: common_starter = common_starter + salome_modules[mod]["makefiledefs"] + '\n' + adm_local={"make_common_starter.am": common_starter, "check_aster.m4":check_aster} + if module.doc: + adm_local["check_sphinx.m4"]=check_sphinx + self.makeFiles({"autogen.sh":autogen, - "Makefile.am":mainMakefile, + "Makefile.am":mainMakefile.substitute(docsubdir=docsubdir), "README":"", "NEWS":"", "AUTHORS":"", "ChangeLog":"", "src":srcs, "resources":{"Makefile.am":resMakefile.substitute(module=module.name), catalogfile:self.makeCatalog()}, - "adm_local":{"make_common_starter.am": common_starter, "check_aster.m4":check_aster}, + "adm_local":adm_local, }, namedir) #add checks for modules in configure.ac @@ -319,43 +427,93 @@ AM_CFLAGS=$$(SALOME_INCLUDES) -fexceptions if self.module.layout=="multidir": for compo in module.components: configure_makefiles.append(" src/"+compo.name+"/Makefile") + + if module.gui: + configure_makefiles.append(" src/%sGUI/Makefile" % module.name) + if module.doc: + configure_makefiles.append(" doc/Makefile") + + other_check="" + other_summary="" + other_require="" + + if module.gui: + other_check=other_check + """CHECK_SALOME_GUI +CHECK_QT +""" + other_summary=other_summary+'''echo " SALOME GUI ............. : $SalomeGUI_ok" +echo " Qt ..................... : $qt_ok" +''' + other_require=other_require + """ + if test "x$SalomeGUI_ok" = "xno"; then + AC_MSG_ERROR([SALOME GUI is required],1) + fi + if test "x$qt_ok" = "xno"; then + AC_MSG_ERROR([Qt library is required],1) + fi +""" + if module.doc: + other_check=other_check+"CHECK_SPHINX\n" + other_summary=other_summary+'''echo " Sphinx ................. : $sphinx_ok"\n''' + other_require=other_require + """ + if test "x$sphinx_ok" = "xno"; then + AC_MSG_ERROR([Sphinx documentation generator is required],1) + fi +""" + + files={} #for idl files idlfile = "%s.idl" % module.name + paco_config="" + PACO_BUILT_SOURCES="" + PACO_SALOMEINCLUDE_HEADERS="" + PACO_INCLUDES="" + PACO_salomepython_DATA="" + PACO_salomeidl_DATA="" if paco: - xmlfile = "%s.xml" % module.name PACO_BUILT_SOURCES = idlMakefilePaCO_BUILT_SOURCES.substitute(module=module.name) PACO_SALOMEINCLUDE_HEADERS = idlMakefilePaCO_nodist_salomeinclude_HEADERS.substitute(module=module.name) PACO_salomepython_DATA = idlMakefilePACO_salomepython_DATA.substitute(module=module.name) PACO_salomeidl_DATA = idlMakefilePACO_salomeidl_DATA.substitute(module=module.name) PACO_INCLUDES = idlMakefilePACO_INCLUDES + paco_config=paco_configure + + files["configure.ac"]=configure.substitute(module=module.name.lower(), + makefiles='\n'.join(configure_makefiles), + paco_configure=paco_config, + modules=configure_modules, + other_check=other_check, + other_summary=other_summary, + other_require=other_require, + ) + + #if components have other idls + other_idls="" + other_sks="" + for compo in module.components: + if compo.idls: + for idl in compo.idls: + for fidl in glob.glob(idl): + other_idls=other_idls+os.path.basename(fidl) +" " + other_sks=other_sks+os.path.splitext(os.path.basename(fidl))[0]+"SK.cc " + + idlfiles={"Makefile.am": idlMakefile.substitute(module=module.name, + PACO_BUILT_SOURCES=PACO_BUILT_SOURCES, + PACO_SALOMEINCLUDE_HEADERS=PACO_SALOMEINCLUDE_HEADERS, + PACO_INCLUDES=PACO_INCLUDES, + PACO_salomepython_DATA=PACO_salomepython_DATA, + PACO_salomeidl_DATA=PACO_salomeidl_DATA, + other_idls=other_idls,other_sks=other_sks, + ), + idlfile : self.makeidl(), + } + if paco: + idlfiles["%s.xml" % module.name]=self.makexml() + + files["idl"]=idlfiles - self.makeFiles({"configure.ac":configure.substitute(module=module.name.lower(), - makefiles='\n'.join(configure_makefiles), - paco_configure=paco_configure, - modules=configure_modules), - "idl":{"Makefile.am":idlMakefile.substitute(module=module.name, - PACO_BUILT_SOURCES=PACO_BUILT_SOURCES, - PACO_SALOMEINCLUDE_HEADERS=PACO_SALOMEINCLUDE_HEADERS, - PACO_INCLUDES=PACO_INCLUDES, - PACO_salomepython_DATA=PACO_salomepython_DATA, - PACO_salomeidl_DATA=PACO_salomeidl_DATA), - idlfile:self.makeidl(), - xmlfile:self.makexml()}, - }, namedir) - else : - self.makeFiles({"configure.ac":configure.substitute(module=module.name.lower(), - makefiles='\n'.join(configure_makefiles), - paco_configure="", - modules=configure_modules), - "idl":{"Makefile.am":idlMakefile.substitute(module=module.name, - PACO_BUILT_SOURCES="", - PACO_SALOMEINCLUDE_HEADERS="", - PACO_INCLUDES="", - PACO_salomepython_DATA="", - PACO_salomeidl_DATA=""), - idlfile:self.makeidl()}, - }, namedir) + self.makeFiles(files,namedir) os.chmod(os.path.join(namedir, "autogen.sh"), 0777) #copy source files if any in created tree @@ -366,16 +524,117 @@ AM_CFLAGS=$$(SALOME_INCLUDES) -fexceptions else: shutil.copyfile(src, os.path.join(namedir, "src", os.path.basename(src))) - for m4file in ("check_Kernel.m4", "check_omniorb.m4", + if compo.idls: + #copy provided idl files in idl directory + for idl in compo.idls: + for fidl in glob.glob(idl): + shutil.copyfile(fidl, os.path.join(namedir, "idl", os.path.basename(fidl))) + + for m4file in ("check_Kernel.m4", "check_omniorb.m4", "ac_linker_options.m4", "ac_cxx_option.m4", - "python.m4", "enable_pthreads.m4", "check_f77.m4", + "python.m4", "enable_pthreads.m4", "check_f77.m4", "acx_pthread.m4", "check_boost.m4", "check_paco++.m4", "check_mpi.m4", "check_lam.m4", "check_openmpi.m4", "check_mpich.m4"): - shutil.copyfile(os.path.join(self.kernel, "salome_adm", "unix", "config_files", m4file), + shutil.copyfile(os.path.join(self.kernel, "salome_adm", "unix", "config_files", m4file), os.path.join(namedir, "adm_local", m4file)) + if self.module.gui: + for m4file in ("check_GUI.m4", "check_qt.m4", "check_opengl.m4"): + shutil.copyfile(os.path.join(self.gui, "adm_local", "unix", "config_files", m4file), + os.path.join(namedir, "adm_local", m4file)) + + self.makeDoc(namedir) return + def makeDoc(self,namedir): + if not self.module.doc: + return + rep=os.path.join(namedir,"doc") + os.makedirs(rep) + for docs in self.module.doc: + for doc in glob.glob(docs): + name = os.path.basename(doc) + shutil.copyfile(doc, os.path.join(rep, name)) + d={} + if not os.path.exists(os.path.join(namedir, "doc", "Makefile.am")): + #create a minimal makefile.am + d["Makefile.am"]=docmakefile + if not os.path.exists(os.path.join(namedir, "doc", "conf.py")): + #create a minimal conf.py + d["conf.py"]=docconf.substitute(module=self.module.name) + self.makeFiles(d,os.path.join(namedir,"doc")) + + def makeGui(self,namedir): + if not self.module.gui: + return + ispython=False + iscpp=False + #Force creation of intermediate directories + os.makedirs(os.path.join(namedir, "src", self.module.name+"GUI")) + + for srcs in self.module.gui: + for src in glob.glob(srcs): + shutil.copyfile(src, os.path.join(namedir, "src", self.module.name+"GUI", os.path.basename(src))) + if src[-3:]==".py":ispython=True + if src[-4:]==".cxx":iscpp=True + if ispython and iscpp: + raise Invalid("Module GUI must be pure python or pure C++ but not mixed") + if ispython: + return self.makePyGUI(namedir) + if iscpp: + return self.makeCPPGUI(namedir) + + def makePyGUI(self,namedir): + d={} + if not os.path.exists(os.path.join(namedir, "src", self.module.name+"GUI", "Makefile.am")): + #create a minimal makefile.am + sources=[] + other=[] + for srcs in self.module.gui: + for src in glob.glob(srcs): + if src[-3:]==".py": + sources.append(os.path.basename(src)) + else: + other.append(os.path.basename(src)) + makefile=pyguimakefile.substitute(sources=" ".join(sources),other_sources=" ".join(other)) + d["Makefile.am"]=makefile + + 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) + d["SalomeApp.xml"]=salomeapp + + return d + + def makeCPPGUI(self,namedir): + d={} + if not os.path.exists(os.path.join(namedir, "src", self.module.name+"GUI", "Makefile.am")): + #create a minimal makefile.am + sources=[] + other=[] + ui_files=[] + for srcs in self.module.gui: + for src in glob.glob(srcs): + if src[-4:]==".cxx": + sources.append(os.path.basename(src)) + elif src[-2:]==".h": + sources.append(os.path.basename(src)[:-2]+"_moc.cxx") + elif src[-3:]==".ui": + ui_files.append("ui_"+os.path.basename(src)[:-3]+".h") + else: + other.append(os.path.basename(src)) + + makefile=cppguimakefile.substitute(sources=" ".join(sources),other_sources=" ".join(other), + module=self.module.name, uisources= " ".join(ui_files)) + d["Makefile.am"]=makefile + + 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) + d["SalomeApp.xml"]=salomeapp + + return d + def makeMakefile(self,makefileItems): makefile="" if makefileItems.has_key("header"): @@ -418,6 +677,8 @@ AM_CFLAGS=$$(SALOME_INCLUDES) -fexceptions 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: @@ -454,7 +715,9 @@ AM_CFLAGS=$$(SALOME_INCLUDES) -fexceptions service = " void %s(" % serv.name service = service+",".join(params)+");" services.append(service) + interfaces.append(parallel_interface.substitute(component=compo.name, services="\n".join(services))) + else: services = [] for serv in compo.services: @@ -473,16 +736,32 @@ AM_CFLAGS=$$(SALOME_INCLUDES) -fexceptions 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) - interfaces.append(interface.substitute(component=compo.name, services="\n".join(services))) + + 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="" for mod in self.used_modules: idldefs = idldefs + salome_modules[mod]["idldefs"] + for compo in self.module.components: + if compo.interfacedefs: + idldefs = idldefs + compo.interfacedefs + return idl.substitute(module=self.module.name, interfaces='\n'.join(interfaces),idldefs=idldefs) # For PaCO++ @@ -516,44 +795,34 @@ AM_CFLAGS=$$(SALOME_INCLUDES) -fexceptions self.makeFiles(content, filename) def bootstrap(self): - """execute module autogen.sh script: execution of libtool, autoconf, automake""" + """Execute the first build step (bootstrap autotools with autogen.sh script) : execution of libtool, autoconf, automake""" ier = os.system("cd %s_SRC;sh autogen.sh" % self.module.name) if ier != 0: raise Invalid("bootstrap has ended in error") def configure(self): - """execute module configure script with installation prefix (prefix attribute of module)""" + """Execute the second build step (configure) with installation prefix as given by the prefix attribute of module""" prefix = self.module.prefix paco = self.context.get("paco") mpi = self.context.get("mpi") + args = (self.module.name, self.kernel, self.aster) + cmd = "cd %s_SRC;./configure --with-kernel=%s --with-aster=%s" % args + if self.gui: + cmd = cmd + " --with-gui=%s" % self.gui if prefix: prefix = os.path.abspath(prefix) - cmd = "cd %s_SRC;./configure --with-kernel=%s --with-aster=%s --prefix=%s" - if paco: - cmd += " --with-paco=%s" - if mpi: - cmd += " --with-mpi=%s" - ier = os.system(cmd % (self.module.name, self.kernel, self.aster, prefix, paco, mpi)) - else : - ier = os.system(cmd % (self.module.name, self.kernel, self.aster, prefix, paco)) - else : - ier = os.system(cmd % (self.module.name, self.kernel, self.aster, prefix)) - else: - cmd = "cd %s_SRC;./configure --with-kernel=%s --with-aster=%s" - if paco: - cmd += " --with-paco=%s" - if mpi: - cmd += " --with-mpi=%s" - ier = os.system(cmd % (self.module.name, self.kernel, self.aster, paco, mpi)) - else: - ier = os.system(cmd % (self.module.name, self.kernel, self.aster, paco)) - else: - ier = os.system(cmd % (self.module.name, self.kernel, self.aster)) + cmd = cmd + " --prefix=%s" % prefix + if paco: + cmd += " --with-paco=%s" % paco + if mpi: + cmd += " --with-mpi=%s" % mpi + + ier = os.system(cmd) if ier != 0: raise Invalid("configure has ended in error") def make(self): - """execute module Makefile : make""" + """Execute the third build step (compile and link) : make""" make_command = "make " if self.makeflags: make_command += self.makeflags @@ -562,14 +831,39 @@ AM_CFLAGS=$$(SALOME_INCLUDES) -fexceptions raise Invalid("make has ended in error") def install(self): - """install module: make install """ + """Execute the installation step : make install """ makedirs(self.module.prefix) ier = os.system("cd %s_SRC;make install" % self.module.name) if ier != 0: raise Invalid("install has ended in error") def make_appli(self, appliname, restrict=None, altmodules=None, resources=""): - """generate SALOME application""" + """ + Create a SALOME application containing the module and preexisting SALOME modules. + + :param appliname: is a string that gives the name of the application (directory path where the application + will be installed). + :type appliname: str + :param restrict: If given (a list of module names), only those SALOME modules will be included in the + application. The default is to include all modules that are located in the same directory as the KERNEL module and have + the same suffix (for example, if KERNEL directory is KERNEL_V5 and GEOM directory is GEOM_V5, GEOM module is automatically + included, except if restrict is used). + :param altmodules: can be used to add SALOME modules that cannot be managed with the precedent rule. This parameter + is a dict with a module name as the key and the installation path as the value. + :param resources: can be used to define an alternative resources catalog (path of the file). + + For example, the following calls create a SALOME application with external modules and resources catalog in "appli" directory:: + + >>> g=Generator(m,context) + >>> g.generate() + >>> g.bootstrap() + >>> g.configure() + >>> g.make() + >>> g.install() + >>> g.make_appli("appli", restrict=["KERNEL"], altmodules={"GUI":GUI_ROOT_DIR, "YACS":YACS_ROOT_DIR}, + resources="myresources.xml") + + """ makedirs(appliname) rootdir, kerdir = os.path.split(self.kernel) diff --git a/module_generator/gui_tmpl.py b/module_generator/gui_tmpl.py new file mode 100644 index 0000000..2cc897b --- /dev/null +++ b/module_generator/gui_tmpl.py @@ -0,0 +1,65 @@ +try: + from string import Template +except: + from compat import Template,set + +pyguimakefile=""" +include $$(top_srcdir)/adm_local/make_common_starter.am + +# Scripts to be installed +salomepython_PYTHON= ${sources} + +salomeres_DATA =SalomeApp.xml ${other_sources} +""" +pyguimakefile=Template(pyguimakefile) + + +pysalomeapp=""" + +
+ + + +
+
+ +
+
+""" +pysalomeapp=Template(pysalomeapp) + +cppguimakefile=""" +include $$(top_srcdir)/adm_local/make_common_starter.am + +BUILT_SOURCES=${uisources} + +lib_LTLIBRARIES= lib${module}.la +lib${module}_la_SOURCES = ${sources} +lib${module}_la_CPPFLAGS = $$(SALOME_INCLUDES) $$(GUI_CXXFLAGS) $$(QT_INCLUDES) -I$$(top_builddir)/idl +lib${module}_la_LIBADD = -L$$(top_builddir)/idl -lSalomeIDL${module} + +salomeres_DATA =SalomeApp.xml ${other_sources} + +# meta object implementation files generation (moc) +%_moc.cxx: %.h + $$(MOC) $$< -o $$@ + +# qt forms files generation (uic) +ui_%.h: %.ui + $$(UIC) -o $$@ $$< + +""" +cppguimakefile=Template(cppguimakefile) + +cppsalomeapp=""" + +
+ + +
+
+ +
+
+""" +cppsalomeapp=Template(cppsalomeapp) 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/mod_tmpl.py b/module_generator/mod_tmpl.py index 61f41e3..59bddf2 100644 --- a/module_generator/mod_tmpl.py +++ b/module_generator/mod_tmpl.py @@ -46,10 +46,11 @@ echo "Running libtoolize..." ; libtoolize --copy --force || exit 1 echo "Running automake..." ; automake --add-missing --copy || exit 1 """ -mainMakefile="""include $(top_srcdir)/adm_local/make_common_starter.am -SUBDIRS = idl resources src +mainMakefile="""include $$(top_srcdir)/adm_local/make_common_starter.am +SUBDIRS = idl resources src ${docsubdir} ACLOCAL_AMFLAGS = -I adm_local """ +mainMakefile=Template(mainMakefile) configure=""" AC_INIT(${module}, 1.0) @@ -80,6 +81,8 @@ AC_SUBST(MODULE_NAME) AC_CHECK_ASTER +${other_check} + echo echo echo @@ -89,7 +92,6 @@ echo "------------------------------------------------------------------------" echo echo "Configuration Options Summary:" echo -echo "Mandatory products:" echo " Threads ................ : $$threads_ok" echo " OmniOrb (CORBA) ........ : $$omniORB_ok" echo " OmniOrbpy (CORBA) ...... : $$omniORBpy_ok" @@ -99,6 +101,7 @@ echo " SALOME KERNEL .......... : $$Kernel_ok" echo " PaCO++ ................. : $$PaCO_ok" echo " MPI .................... : $$mpi_ok" echo " Code Aster ............. : $$Aster_ok" +${other_summary} echo echo "------------------------------------------------------------------------" echo @@ -118,6 +121,8 @@ fi if test "x$$Kernel_ok" = "xno"; then AC_MSG_ERROR([SALOME KERNEL is required],1) fi +${other_require} + ${paco_configure} AC_CONFIG_FILES([ @@ -160,7 +165,7 @@ admlocalm4dir = $(admlocaldir)/unix/config_files sharedpkgpythondir =$(pkgpythondir)/shared_modules # Documentation directory -docdir = $(datadir)/doc/salome +salomedocdir = $(prefix)/share/doc/salome/gui/${MODULE_NAME} IDL_INCLUDES = -I$(KERNEL_ROOT_DIR)/idl/salome KERNEL_LIBS= -L$(KERNEL_ROOT_DIR)/lib/salome -lSalomeContainer -lOpUtil -lSalomeDSCContainer -lSalomeDSCSuperv -lSalomeDatastream -lSalomeDSCSupervBasic -lCalciumC @@ -179,3 +184,42 @@ salomeres_DATA = $${DATA_INST} EXTRA_DIST = $${DATA_INST} """ resMakefile=Template(resMakefile) + +check_sphinx=""" +AC_DEFUN([CHECK_SPHINX],[ + +AC_CHECKING(for sphinx doc generator) + +sphinx_ok=yes +dnl where is sphinx ? +AC_PATH_PROG(SPHINX,sphinx-build) +if test "x$SPHINX" = "x" +then + AC_MSG_WARN(sphinx not found) + sphinx_ok=no +fi + +dnl Can I load ths sphinx module ? +dnl This code comes from the ax_python_module macro. +if test -z $PYTHON; +then + PYTHON="python" +fi +PYTHON_NAME=`basename $PYTHON` +AC_MSG_CHECKING($PYTHON_NAME module: sphinx) + $PYTHON -c "import sphinx" 2>/dev/null + if test $? -eq 0; + then + AC_MSG_RESULT(yes) + eval AS_TR_CPP(HAVE_PYMOD_sphinx)=yes + else + AC_MSG_RESULT(no) + eval AS_TR_CPP(HAVE_PYMOD_sphinx)=no + sphinx_ok=no + fi + +AM_CONDITIONAL(SPHINX_IS_OK, [test x"$sphinx_ok" = xyes]) + +]) +""" + diff --git a/module_generator/pycompo.py b/module_generator/pycompo.py index 411c936..3e6953d 100644 --- a/module_generator/pycompo.py +++ b/module_generator/pycompo.py @@ -35,13 +35,40 @@ def indent(text, prefix=' '): return join(lines, '\n') class PYComponent(Component): - def __init__(self, name, services=None, python_path=None, kind="lib", - sources=None, inheritedclass="", compodefs=""): + """ + A :class:`PYComponent` instance represents a Python SALOME component with services given as a list of :class:`Service` + instances with the parameter *services*. + + :param name: gives the name of the component. + :type name: str + :param services: the list of services (:class:`Service`) of the component. + :param kind: If it is given and has the value "exe", the component will be built as a standalone + component (python executable). The default is to build the component as a python module. + :param sources: gives all the external Python source files to add in the component directory (list of paths). + :param python_path: If it is given (as a list of paths), all the paths are added to the python path (sys.path). + :param compodefs: can be used to add extra definition code in the component for example when using a base class + to define the component class by deriving it (see *inheritedclass* parameter) + :param inheritedclass: can be used to define a base class for the component. The base class can be defined in external + source or with the *compodefs* parameter. The value of the *inheritedclass* parameter is the name of the base class. + :param idls: can be used to add extra idl CORBA interfaces. This parameter must gives a list of idl file names that are + added into the generated module (idl directory) and compiled with the generated idl of the module. + :param interfacedefs: can be used to add idl definitions (or includes of idl files) into the generated idl of the module. + :param inheritedinterface: can be used to make the component inherit an extra idl interface that has been included through + the *idls* and *interfacedefs* parameters. See the pygui1 example for how to use these last parameters. + + For example, the following call defines a Python component named "mycompo" with one service s1 (it must have been defined before):: + + >>> c1 = module_generator.PYComponent('mycompo', services=[s1,], + python_path="apath") + + """ + def __init__(self, name, services=None, kind="lib", sources=None, python_path=None, + compodefs="", inheritedclass="", idls=None, interfacedefs="", inheritedinterface=""): """initialise component attributes""" self.python_path = python_path or [] - Component.__init__(self, name, services, impl="PY", kind=kind, - sources=sources, inheritedclass=inheritedclass, - compodefs=compodefs) + Component.__init__(self, name, services, impl="PY", kind=kind, sources=sources, + inheritedclass=inheritedclass, compodefs=compodefs, + idls=idls,interfacedefs=interfacedefs,inheritedinterface=inheritedinterface) def validate(self): """validate component attributes""" diff --git a/module_generator/pyth_tmpl.py b/module_generator/pyth_tmpl.py index 4996d6d..e88595b 100644 --- a/module_generator/pyth_tmpl.py +++ b/module_generator/pyth_tmpl.py @@ -25,7 +25,7 @@ except: pyCompo=""" import sys,traceback,os sys.path=sys.path+[${python_path}] -import ${module}__POA +import ${module}_ORB__POA import calcium import dsccalcium import SALOME @@ -45,11 +45,11 @@ ${compodefs} ${servicesdef} #ENDDEF -class ${component}(${inheritedclass} ${module}__POA.${component},dsccalcium.PyDSCComponent): +class ${component}(${module}_ORB__POA.${component}, ${inheritedclass} dsccalcium.PyDSCComponent): ''' To be identified as a SALOME component this Python class must have the same name as the component, inherit omniorb - class ${module}__POA.${component} and DSC class dsccalcium.PyDSCComponent + class ${module}_ORB__POA.${component} and DSC class dsccalcium.PyDSCComponent that implements DSC API. ''' def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ): 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 125254e..8aa90f1 100644 --- a/module_generator/yacstypes.py +++ b/module_generator/yacstypes.py @@ -23,34 +23,49 @@ 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":"" } +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: - return corbaTypes[typ] % module + return corbaTypes[typ] % (module+"_ORB") else: return corbaTypes[typ] def corba_out_type(typ, module): if corbaOutTypes[typ].count("%s")>0: - return corbaOutTypes[typ] % module + return corbaOutTypes[typ] % (module+"_ORB") else: return corbaOutTypes[typ] +def corba_rtn_type(typ, module): + if corbaRtnTypes[typ].count("%s")>0: + return corbaRtnTypes[typ] % (module+"_ORB") + 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") diff --git a/setup.py b/setup.py index 7285caa..05622c9 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ from distutils.core import setup setup(name='YACSGEN', - version='6.1.0', + version='6.2.0', author='C. Caremoli', packages=['module_generator'], )