Salome HOME
AutoGIL.hxx has been factorized to KERNEL PythonCppUtils.hxx
[modules/yacs.git] / src / runtime_swig / SALOMERuntime.i
index 4aab32a826056ecd1b4d6aadf0cce1a19a3d62f5..b9c782df6da401654d21f9cb6e1e3888dcf5ed1e 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006-2016  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2021  CEA/DEN, 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
@@ -66,6 +66,7 @@
 #include "PyStdout.hxx"
 #include "ExecutorSwig.hxx"
 #include <sstream>
+#include "Catalog.hxx"
 %}
 
 // ----------------------------------------------------------------------------
   Py_DECREF(pyapi);
 %}
 
+%{
+static PyObject *convertContainer2(YACS::ENGINE::Container *cont, int owner=0)
+{
+  if(!cont)
+    return SWIG_NewPointerObj((void*)cont,SWIGTYPE_p_YACS__ENGINE__Container, owner);
+  if(dynamic_cast<YACS::ENGINE::SalomeHPContainer *>(cont))
+    {
+      return SWIG_NewPointerObj((void*)dynamic_cast<YACS::ENGINE::SalomeHPContainer *>(cont),SWIGTYPE_p_YACS__ENGINE__SalomeHPContainer, owner);
+    }
+  if(dynamic_cast<YACS::ENGINE::SalomeContainer *>(cont))
+    {
+      return SWIG_NewPointerObj((void*)dynamic_cast<YACS::ENGINE::SalomeContainer *>(cont),SWIGTYPE_p_YACS__ENGINE__SalomeContainer, owner);
+    }
+  return SWIG_NewPointerObj((void*)cont,SWIGTYPE_p_YACS__ENGINE__Container, owner);
+}
+%}
+
 // ----------------------------------------------------------------------------
 
 #ifdef SWIGPYTHON
@@ -210,4 +228,22 @@ namespace YACS
 // becomes a real derived class, this will have to be changed.
 %rename(OptimizerAlgSync) YACS::ENGINE::PyOptimizerAlgBase;
 %rename(OptimizerAlgASync) YACS::ENGINE::PyOptimizerAlgASync;
+
 %include "PyOptimizerAlg.hxx"
+
+%newobject YACS::ENGINE::RuntimeSALOME::createAnyPyObject;
+
+%extend YACS::ENGINE::RuntimeSALOME
+{
+  PyObject *createContainer(const std::string& kind="")
+  {
+    YACS::ENGINE::Container *ret(self->createContainer(kind));
+    return convertContainer2(ret,SWIG_POINTER_OWN | 0);
+  }
+
+  Any* createAnyPyObject(PyObject * pyobj)
+  {
+    return convertPyObjectNeutral(self->getBuiltinCatalog()->_typeMap["pyobj"],
+                                  pyobj);
+  }
+}