]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Fix calcium in python3.
authorOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Fri, 27 Jul 2018 08:43:13 +0000 (10:43 +0200)
committerOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Fri, 27 Jul 2018 08:43:13 +0000 (10:43 +0200)
src/DSC/DSC_Python/CMakeLists.txt
src/DSC/DSC_Python/calcium.i
src/Utils/CMakeLists.txt
src/Utils/capsulethunk.h [deleted file]

index 697747d88f265a09906194b9309d43ecdb3031e6..eb5369a43e18d67c2769c0c766ed5f0345cdb640 100755 (executable)
@@ -31,6 +31,7 @@ INCLUDE_DIRECTORIES(
   ${NUMPY_INCLUDE_DIR}
   ${PTHREAD_INCLUDE_DIR}
   ${Boost_INCLUDE_DIRS}
+  ${OMNIORBPY_INCLUDE_DIR}
   ${PROJECT_BINARY_DIR}/salome_adm
   ${PROJECT_SOURCE_DIR}/src/DSC/DSC_User
   ${PROJECT_SOURCE_DIR}/src/DSC/DSC_User/Datastream
index 586cd8defdd6bc4a78a95135c6c8db65de76c9dd..618ccaa2515ad8ea8559c82ed3e6fe0b10395a27 100644 (file)
 #include <Salome_file_i.hxx>
 #include <omniORB4/CORBA.h>
 
-//--- from omniORBpy.h (not present on Debian Sarge packages)
-
-struct omniORBpyAPI {
-
-  PyObject* (*cxxObjRefToPyObjRef)(const CORBA::Object_ptr cxx_obj,
-           CORBA::Boolean hold_lock);
-  // Convert a C++ object reference to a Python object reference.
-  // If <hold_lock> is true, caller holds the Python interpreter lock.
-
-  CORBA::Object_ptr (*pyObjRefToCxxObjRef)(PyObject* py_obj,
-             CORBA::Boolean hold_lock);
-  // Convert a Python object reference to a C++ object reference.
-  // Raises BAD_PARAM if the Python object is not an object reference.
-  // If <hold_lock> is true, caller holds the Python interpreter lock.
-
-  PyObject* (*handleCxxSystemException)(const CORBA::SystemException& ex);
-  // Sets the Python exception state to reflect the given C++ system
-  // exception. Always returns NULL. The caller must hold the Python
-  // interpreter lock.
-};
-
-  omniORBpyAPI* api;
-  PyObject* dsc ;
-
+#include <Python.h>
+#include <omniORBpy.h>
+omniORBpyAPI* api=0;
+PyObject* dsc ;
 
 %}
 
 %init
 %{
-#include <capsulethunk.h>
   // init section
 #ifdef WITH_NUMPY
   import_array()
@@ -80,7 +59,7 @@ struct omniORBpyAPI {
     return NULL;
   }
   PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API");
-  api = (omniORBpyAPI*)PyCapsule_New(pyapi,NULL,NULL);
+  api = (omniORBpyAPI*)PyCapsule_GetPointer(pyapi,"_omnipy.API");
   Py_DECREF(pyapi);
 
   PyObject* engines = PyImport_ImportModule("Engines");
index ec38d52d2005b15263099187dcb2a4317f14e6bc..689b32e1aed258d34ddd9c56fcdaa752d1a9413d 100755 (executable)
@@ -79,4 +79,3 @@ ADD_LIBRARY(OpUtil ${OpUtil_SOURCES})
 TARGET_LINK_LIBRARIES(OpUtil ${COMMON_LIBS})
 INSTALL(TARGETS OpUtil EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
 INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
-INSTALL(FILES capsulethunk.h DESTINATION ${SALOME_INSTALL_HEADERS})
diff --git a/src/Utils/capsulethunk.h b/src/Utils/capsulethunk.h
deleted file mode 100644 (file)
index 6b20564..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-#ifndef __CAPSULETHUNK_H
-#define __CAPSULETHUNK_H
-
-#if (    (PY_VERSION_HEX <  0x02070000) \
-     || ((PY_VERSION_HEX >= 0x03000000) \
-      && (PY_VERSION_HEX <  0x03010000)) )
-
-#define __PyCapsule_GetField(capsule, field, default_value) \
-    ( PyCapsule_CheckExact(capsule) \
-        ? (((PyCObject *)capsule)->field) \
-        : (default_value) \
-    ) \
-
-#define __PyCapsule_SetField(capsule, field, value) \
-    ( PyCapsule_CheckExact(capsule) \
-        ? (((PyCObject *)capsule)->field = value), 1 \
-        : 0 \
-    ) \
-
-
-#define PyCapsule_Type PyCObject_Type
-
-#define PyCapsule_CheckExact(capsule) (PyCObject_Check(capsule))
-#define PyCapsule_IsValid(capsule, name) (PyCObject_Check(capsule))
-
-
-#define PyCapsule_New(pointer, name, destructor) \
-    (PyCObject_FromVoidPtr(pointer, destructor))
-
-
-#define PyCapsule_GetPointer(capsule, name) \
-    (PyCObject_AsVoidPtr(capsule))
-
-/* Don't call PyCObject_SetPointer here, it fails if there's a destructor */
-#define PyCapsule_SetPointer(capsule, pointer) \
-    __PyCapsule_SetField(capsule, cobject, pointer)
-
-
-#define PyCapsule_GetDestructor(capsule) \
-    __PyCapsule_GetField(capsule, destructor)
-
-#define PyCapsule_SetDestructor(capsule, dtor) \
-    __PyCapsule_SetField(capsule, destructor, dtor)
-
-
-/*
- * Sorry, there's simply no place
- * to store a Capsule "name" in a CObject.
- */
-#define PyCapsule_GetName(capsule) NULL
-
-static int
-PyCapsule_SetName(PyObject *capsule, const char *unused)
-{
-    unused = unused;
-    PyErr_SetString(PyExc_NotImplementedError,
-        "can't use PyCapsule_SetName with CObjects");
-    return 1;
-}
-
-
-
-#define PyCapsule_GetContext(capsule) \
-    __PyCapsule_GetField(capsule, descr)
-
-#define PyCapsule_SetContext(capsule, context) \
-    __PyCapsule_SetField(capsule, descr, context)
-
-
-static void *
-PyCapsule_Import(const char *name, int no_block)
-{
-    PyObject *object = NULL;
-    void *return_value = NULL;
-    char *trace;
-    size_t name_length = (strlen(name) + 1) * sizeof(char);
-    char *name_dup = (char *)PyMem_MALLOC(name_length);
-
-    if (!name_dup) {
-        return NULL;
-    }
-
-    memcpy(name_dup, name, name_length);
-
-    trace = name_dup;
-    while (trace) {
-        char *dot = strchr(trace, '.');
-        if (dot) {
-            *dot++ = '\0';
-        }
-
-        if (object == NULL) {
-            if (no_block) {
-                object = PyImport_ImportModuleNoBlock(trace);
-            } else {
-                object = PyImport_ImportModule(trace);
-                if (!object) {
-                    PyErr_Format(PyExc_ImportError,
-                        "PyCapsule_Import could not "
-                        "import module \"%s\"", trace);
-                }
-            }
-        } else {
-            PyObject *object2 = PyObject_GetAttrString(object, trace);
-            Py_DECREF(object);
-            object = object2;
-        }
-        if (!object) {
-            goto EXIT;
-        }
-
-        trace = dot;
-    }
-
-    if (PyCObject_Check(object)) {
-        PyCObject *cobject = (PyCObject *)object;
-        return_value = cobject->cobject;
-    } else {
-        PyErr_Format(PyExc_AttributeError,
-            "PyCapsule_Import \"%s\" is not valid",
-            name);
-    }
-
-EXIT:
-    Py_XDECREF(object);
-    if (name_dup) {
-        PyMem_FREE(name_dup);
-    }
-    return return_value;
-}
-
-#endif /* #if PY_VERSION_HEX < 0x02070000 */
-
-#endif /* __CAPSULETHUNK_H */