Salome HOME
Windows compatibility.
authorrnv <rnv@opencascade.com>
Fri, 31 Mar 2017 07:15:27 +0000 (10:15 +0300)
committerrnv <rnv@opencascade.com>
Fri, 31 Mar 2017 07:15:27 +0000 (10:15 +0300)
src/py2yacs/CMakeLists.txt
src/py2yacs/Test/Py2yacsTest.cxx
src/py2yacs/py2yacs.cxx
src/py2yacs/py2yacs.hxx
src/runtime/TypeConversions.hxx
src/runtime/VisitorSalomeSaveState.cxx

index d5c4ce3bac494195677a779483e753a7be724393..8e32b7c4eeb26f7033853e3139c79d9f196f9de7 100644 (file)
@@ -28,6 +28,7 @@ INCLUDE_DIRECTORIES(
 
 ADD_DEFINITIONS(
   ${PYTHON_DEFINITIONS}
+  ${OMNIORB_DEFINITIONS}
   )
 
 IF(SALOME_BUILD_TESTS)
index 8572bd3ffe19dcba9910b550212e5d6b94fcec8b..1ba389d23b18e777beec3e4e1b1048f261bd1049 100644 (file)
@@ -156,7 +156,7 @@ void Py2yacsTest::t3()
                          "  print b\n"
                          "  print c\n";
   const char* input_ports[] = {"a", "b", "c"};
-  const char* output_ports[] = {};
+  const char** output_ports;
   verifyCorrectPycode(code_py, "f1", 3, input_ports, 0, output_ports);
 }
 
@@ -166,7 +166,7 @@ void Py2yacsTest::t4()
                          "  print 'toto'\n"
                          "  return\n";
   const char* input_ports[] = {"a", "b", "c"};
-  const char* output_ports[] = {};
+  const char** output_ports;
   verifyCorrectPycode(code_py, "f1", 0, input_ports, 0, output_ports);
 }
 
index 9e364400699b47b667279c26cc18a6d0488b4ce7..2ad047d4e31f0898a8c63e7313eb37ce57184f9f 100644 (file)
@@ -75,7 +75,7 @@ static
 std::string copyList(PyObject *pyList, std::list<std::string>& cppList)
 {
   std::string error;
-  if(not PyList_Check(pyList))
+  if(!PyList_Check(pyList))
   {
     error = "Not a python list.\n";
     //throw Py2yacsException("Not a python list.");
@@ -86,7 +86,7 @@ std::string copyList(PyObject *pyList, std::list<std::string>& cppList)
     for(int i=0; i<n; i++)
     {
       PyObject *elem = PyList_GetItem(pyList,i);
-      if(not PyString_Check(elem))
+      if(!PyString_Check(elem))
       {
         std::stringstream message;
         message << "List element number " << i << " is not a string.\n";
@@ -158,7 +158,7 @@ PyObject* checkAndGetAttribute(PyObject *p,
                                std::string& error)
 {
   PyObject *pAttribute = PyObject_GetAttrString(p, attribute);
-  if(not pAttribute)
+  if(!pAttribute)
   {
     error += "Attribute '";
     error += attribute;
@@ -184,7 +184,7 @@ void Py2yacs::load(const std::string& python_code)
     pModule = PyImport_Import(pValue);
     Py_DECREF(pValue);
 
-    if (not pModule)
+    if (!pModule)
     {
       errorMessage  = getPyErrorText();
       errorMessage += "\nFailed to load ";
@@ -203,11 +203,11 @@ void Py2yacs::load(const std::string& python_code)
         
         pValue = PyObject_CallObject(pFunc, pArgs);
         Py_DECREF(pArgs);
-        if (not pValue)
+        if (!pValue)
             errorMessage = getPyErrorText();
         else
         {
-          if (not PyTuple_Check(pValue))
+          if (!PyTuple_Check(pValue))
           {
             errorMessage += "Parsing function should return a tuple of two string lists.\n";
           }
@@ -217,7 +217,7 @@ void Py2yacs::load(const std::string& python_code)
             errorMessage += "Parsing function should return two string lists.\n";
           }
           PyObject *pyList = PyTuple_GetItem(pValue, 0);
-          if(not PyList_Check(pyList))
+          if(!PyList_Check(pyList))
           {
             errorMessage += "The first returned value of the parsing function"
                             " should be a python list.\n";
@@ -232,7 +232,7 @@ void Py2yacs::load(const std::string& python_code)
               
               if(pAttribute = checkAndGetAttribute(fpy, "name", errorMessage))
               {
-                if(not PyString_Check(pAttribute))
+                if(!PyString_Check(pAttribute))
                 {
                   errorMessage += "Attribute 'name' should be a string.\n";
                   Py_DECREF(pAttribute);
@@ -282,7 +282,7 @@ void Py2yacs::load(const std::string& python_code)
       Py_DECREF(pModule);
     }
     
-    if(not errorMessage.empty())
+    if(!errorMessage.empty())
       throw Py2yacsException(errorMessage);
     // Py_Finalize();
 }
@@ -297,7 +297,7 @@ void Py2yacs::save(const std::string& file_path,
 
 YACS::ENGINE::Proc* Py2yacs::createProc(const std::string& python_function)const
 {
-  if(not _global_errors.empty())
+  if(!_global_errors.empty())
   {
     std::string error_message = "The python script contains errors.\n";
     std::list<std::string>::const_iterator it;
@@ -308,7 +308,7 @@ YACS::ENGINE::Proc* Py2yacs::createProc(const std::string& python_function)const
   
   // find function properties
   std::list<FunctionProperties>::const_iterator fn_prop = _functions.begin();
-  while(fn_prop != _functions.end() and fn_prop->_name != python_function)
+  while(fn_prop != _functions.end() && fn_prop->_name != python_function)
     fn_prop++;
   
   if(fn_prop == _functions.end())
@@ -316,7 +316,7 @@ YACS::ENGINE::Proc* Py2yacs::createProc(const std::string& python_function)const
     throw Py2yacsException(std::string("Function not found: ")+python_function);
   }
   
-  if(not fn_prop->_errors.empty())
+  if(!fn_prop->_errors.empty())
   {
     std::string error_message = "Function contains errors.\n";
     std::list<std::string>::const_iterator it;
@@ -334,7 +334,7 @@ YACS::ENGINE::Proc* Py2yacs::createProc(const std::string& python_function)const
       it!=fn_prop->_output_ports.end();
       it++)
   {
-    if (not first)
+    if (!first)
       fn_call << ",";
     first = false;
     fn_call << *it;
@@ -345,7 +345,7 @@ YACS::ENGINE::Proc* Py2yacs::createProc(const std::string& python_function)const
       it != fn_prop->_input_ports.end();
       it++)
   {
-    if (not first)
+    if (!first)
       fn_call << ",";
     first = false;
     fn_call << *it;
index b0ca9c40924cc9b82f4d8df9dd8e22d4f2f9092e..ee052cdf31e8d86102538d43b4dd7686059e84da 100644 (file)
 #ifndef _PY2YACS_H_
 #define _PY2YACS_H_
 
+#ifdef WIN32
+#  if defined py2yacslib_EXPORTS
+#    define PY2YACSLIB_EXPORT __declspec( dllexport )
+#  else
+#    define PY2YACSLIB_EXPORT __declspec( dllimport )
+#  endif
+#else
+#  define PY2YACSLIB_EXPORT
+#endif
+
+
 #include <string>
 #include <list>
 #include <exception>
 
-class Py2yacsException: std::exception
+class PY2YACSLIB_EXPORT Py2yacsException: std::exception
 {
   public:
     Py2yacsException(const std::string& what);
@@ -41,7 +52,7 @@ namespace YACS
   };
 };
 
-struct FunctionProperties
+struct PY2YACSLIB_EXPORT FunctionProperties
 {
   public:
     std::string _name;
@@ -55,7 +66,7 @@ struct FunctionProperties
  *  This class converts a string containing a python script to a yacs schema
  *  containing a python script node.
  */
-class Py2yacs
+class PY2YACSLIB_EXPORT Py2yacs
 {
   public:
     Py2yacs();
index cd3a330a1d5eab5ba36b1bf29b5e8d9861b455b1..fe030312dd1994036b2b8e44f726008924926073 100644 (file)
@@ -44,45 +44,47 @@ namespace YACS
     class TypeCode;
     class Any;
 
-    CORBA::TypeCode_ptr getCorbaTC(const TypeCode *t);
+    YACSRUNTIMESALOME_EXPORT CORBA::TypeCode_ptr getCorbaTC(const TypeCode *t);
 
-    int isAdaptableCorbaPyObject(const TypeCode * t1, const TypeCode * t2);
-    int isAdaptableCorbaNeutral(const TypeCode * t1, const TypeCode * t2);
-    int isAdaptableCorbaCorba(const TypeCode * t1, const TypeCode * t2);
+    YACSRUNTIMESALOME_EXPORT int isAdaptableCorbaPyObject(const TypeCode * t1, const TypeCode * t2);
+    YACSRUNTIMESALOME_EXPORT int isAdaptableCorbaNeutral(const TypeCode * t1, const TypeCode * t2);
+    YACSRUNTIMESALOME_EXPORT int isAdaptableCorbaCorba(const TypeCode * t1, const TypeCode * t2);
 
-    int isAdaptableNeutralCorba(const TypeCode * t1, const TypeCode * t2);
-    int isAdaptableNeutralNeutral(const TypeCode * t1, const TypeCode * t2);
-    int isAdaptableNeutralXml(const TypeCode * t1, const TypeCode * t2);
-    int isAdaptableNeutralPyObject(const TypeCode * t1, const TypeCode * t2);
+    YACSRUNTIMESALOME_EXPORT int isAdaptableNeutralCorba(const TypeCode * t1, const TypeCode * t2);
+    YACSRUNTIMESALOME_EXPORT int isAdaptableNeutralNeutral(const TypeCode * t1, const TypeCode * t2);
+    YACSRUNTIMESALOME_EXPORT int isAdaptableNeutralXml(const TypeCode * t1, const TypeCode * t2);
+    YACSRUNTIMESALOME_EXPORT int isAdaptableNeutralPyObject(const TypeCode * t1, const TypeCode * t2);
 
-    int isAdaptablePyObjectPyObject(const TypeCode * t1, const TypeCode * t2);
-    int isAdaptablePyObjectCorba(const TypeCode * t1, const TypeCode * t2);
-    int isAdaptablePyObjectNeutral(const TypeCode * t1, const TypeCode * t2);
+    YACSRUNTIMESALOME_EXPORT int isAdaptablePyObjectPyObject(const TypeCode * t1, const TypeCode * t2);
+    YACSRUNTIMESALOME_EXPORT int isAdaptablePyObjectCorba(const TypeCode * t1, const TypeCode * t2);
+    YACSRUNTIMESALOME_EXPORT int isAdaptablePyObjectNeutral(const TypeCode * t1, const TypeCode * t2);
 
-    int isAdaptableXmlNeutral(const TypeCode *t1,const TypeCode *t2);
-    int isAdaptableXmlCorba(const TypeCode *t1, const TypeCode *t2);
+    YACSRUNTIMESALOME_EXPORT int isAdaptableXmlNeutral(const TypeCode *t1,const TypeCode *t2);
+    YACSRUNTIMESALOME_EXPORT int isAdaptableXmlCorba(const TypeCode *t1, const TypeCode *t2);
 
-    PyObject *convertCorbaPyObject(const TypeCode * t,CORBA::Any* ob);
-    CORBA::Any *convertCorbaCorba(const TypeCode * t,CORBA::Any* ob);
-    YACS::ENGINE::Any *convertCorbaNeutral(const TypeCode *t,CORBA::Any* ob);
-    std::string convertCorbaXml(const TypeCode * t,CORBA::Any* ob);
+    YACSRUNTIMESALOME_EXPORT PyObject *convertCorbaPyObject(const TypeCode * t,CORBA::Any* ob);
+    YACSRUNTIMESALOME_EXPORT PyObject *convertCorbaPyObject(const TypeCode * t,CORBA::Any* ob);
+    YACSRUNTIMESALOME_EXPORT PyObject *convertCorbaPyObject(const TypeCode * t,CORBA::Any* ob);
+    YACSRUNTIMESALOME_EXPORT CORBA::Any *convertCorbaCorba(const TypeCode * t,CORBA::Any* ob);
+    YACSRUNTIMESALOME_EXPORT YACS::ENGINE::Any *convertCorbaNeutral(const TypeCode *t,CORBA::Any* ob);
+    YACSRUNTIMESALOME_EXPORT std::string convertCorbaXml(const TypeCode * t,CORBA::Any* ob);
 
-    CORBA::Any *convertPyObjectCorba(const TypeCode *t,PyObject *ob);
+    YACSRUNTIMESALOME_EXPORT CORBA::Any *convertPyObjectCorba(const TypeCode *t,PyObject *ob);
     YACSRUNTIMESALOME_EXPORT std::string convertPyObjectXml(const TypeCode * t,PyObject* ob);
-    YACS::ENGINE::Any *convertPyObjectNeutral(const TypeCode *t,PyObject* ob);
-    PyObject* convertPyObjectPyObject(const TypeCode *t,PyObject *ob);
-    std::string convertPyObjectToString(PyObject* ob);
-    bool checkPyObject(const TypeCode *t,PyObject* ob);
-
-    PyObject *convertXmlPyObject(const TypeCode * t,xmlDocPtr doc,xmlNodePtr cur );
-    PyObject *convertXmlStrPyObject(const TypeCode * t,std::string data );
-    CORBA::Any *convertXmlCorba(const TypeCode * t,xmlDocPtr doc,xmlNodePtr cur );
-    YACS::ENGINE::Any *convertXmlNeutral(const TypeCode * t,xmlDocPtr doc,xmlNodePtr cur );
-
-    PyObject *convertNeutralPyObject(const TypeCode * t,YACS::ENGINE::Any* ob);
-    std::string convertNeutralXml(const TypeCode * t,YACS::ENGINE::Any* ob);
-    CORBA::Any *convertNeutralCorba(const TypeCode *t,YACS::ENGINE::Any *ob);
-    YACS::ENGINE::Any *convertNeutralNeutral(const TypeCode *t, YACS::ENGINE::Any* ob);
+    YACSRUNTIMESALOME_EXPORT YACS::ENGINE::Any *convertPyObjectNeutral(const TypeCode *t,PyObject* ob);
+    YACSRUNTIMESALOME_EXPORT PyObject* convertPyObjectPyObject(const TypeCode *t,PyObject *ob);
+    YACSRUNTIMESALOME_EXPORT std::string convertPyObjectToString(PyObject* ob);
+    YACSRUNTIMESALOME_EXPORT bool checkPyObject(const TypeCode *t,PyObject* ob);
+
+    YACSRUNTIMESALOME_EXPORT PyObject *convertXmlPyObject(const TypeCode * t,xmlDocPtr doc,xmlNodePtr cur );
+    YACSRUNTIMESALOME_EXPORT PyObject *convertXmlStrPyObject(const TypeCode * t,std::string data );
+    YACSRUNTIMESALOME_EXPORT CORBA::Any *convertXmlCorba(const TypeCode * t,xmlDocPtr doc,xmlNodePtr cur );
+    YACSRUNTIMESALOME_EXPORT YACS::ENGINE::Any *convertXmlNeutral(const TypeCode * t,xmlDocPtr doc,xmlNodePtr cur );
+
+    YACSRUNTIMESALOME_EXPORT PyObject *convertNeutralPyObject(const TypeCode * t,YACS::ENGINE::Any* ob);
+    YACSRUNTIMESALOME_EXPORT std::string convertNeutralXml(const TypeCode * t,YACS::ENGINE::Any* ob);
+    YACSRUNTIMESALOME_EXPORT CORBA::Any *convertNeutralCorba(const TypeCode *t,YACS::ENGINE::Any *ob);
+    YACSRUNTIMESALOME_EXPORT YACS::ENGINE::Any *convertNeutralNeutral(const TypeCode *t, YACS::ENGINE::Any* ob);
   }
 
 }
index b0957cf9363b98110f6b10a018f122096e03eeba..e6b3d7e2f0d7874c9e56ff54d3e5f4e50e42db02 100644 (file)
@@ -68,14 +68,14 @@ void VisitorSalomeSaveState::visitForEachLoop(ForEachLoop *node)
   }
   
   StatesForNode state = node->getState();
-  if(YACS::LOADED == state or
-    YACS::ACTIVATED == state or
-    YACS::SUSPENDED == state or
-    YACS::EXECFAILED == state or
-    YACS::PAUSE == state or
-    YACS::TORECONNECT == state or
-    YACS::INTERNALERR == state or
-    YACS::FAILED == state or
+  if(YACS::LOADED == state ||
+    YACS::ACTIVATED == state ||
+    YACS::SUSPENDED == state ||
+    YACS::EXECFAILED == state ||
+    YACS::PAUSE == state ||
+    YACS::TORECONNECT == state ||
+    YACS::INTERNALERR == state ||
+    YACS::FAILED == state ||
     YACS::ERROR == state)
   {
     ForEachLoopPassedData* processedData = node->getProcessedData();