You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2019/02/25 18:40:20 UTC

[qpid-proton] 03/06: PROTON-1992: [Python] move build dependencies to Proton-C Core - Remove all swig bound APIs that are only in libqpid-proton - Link Python extension lib to libqpid-proton-core

This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit e4aec3a53759e2caf3a5ba22efbc1aff5c662685
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Wed Oct 10 15:48:42 2018 -0400

    PROTON-1992: [Python] move build dependencies to Proton-C Core
    - Remove all swig bound APIs that are only in libqpid-proton
    - Link Python extension lib to libqpid-proton-core
---
 CMakeLists.txt             |  5 +--
 c/include/proton/cproton.i |  8 -----
 python/CMakeLists.txt      |  2 +-
 python/cproton.i           | 76 ++--------------------------------------------
 ruby/CMakeLists.txt        |  2 +-
 5 files changed, 7 insertions(+), 86 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 83c24e8..c4f06ae 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -338,8 +338,9 @@ if(SWIG_FOUND)
 
   # All swig modules should include ${PROTON_HEADERS} in SWIG_MODULE_<name>_EXTRA_DEPS
   file(GLOB PROTON_HEADERS "${CMAKE_SOURCE_DIR}/c/include/proton/*.h")
-  # All swig modules should include ${BINDING_DEPS} in swig_link_libraries
-  set (BINDING_DEPS qpid-proton)
+  # All swig modules should include ${BINDING_DEPS} or ${BINDING_DEPS_FULL} in swig_link_libraries
+  set (BINDING_DEPS qpid-proton-core)
+  set (BINDING_DEPS_FULL qpid-proton)
 
   # Add a block here to detect the prerequisites to build each language binding:
   #
diff --git a/c/include/proton/cproton.i b/c/include/proton/cproton.i
index c642438..e0cfc0b 100644
--- a/c/include/proton/cproton.i
+++ b/c/include/proton/cproton.i
@@ -920,8 +920,6 @@ typedef unsigned long int uintptr_t;
 
 %include "proton/sasl.h"
 
-%include "proton/selectable.h"
-
 %include "proton/ssl.h"
 
 %ignore pn_decode_atoms;
@@ -951,9 +949,6 @@ typedef unsigned long int uintptr_t;
   pn_link_t *pn_cast_pn_link(void *x) { return (pn_link_t *) x; }
   pn_delivery_t *pn_cast_pn_delivery(void *x) { return (pn_delivery_t *) x; }
   pn_transport_t *pn_cast_pn_transport(void *x) { return (pn_transport_t *) x; }
-  pn_reactor_t *pn_cast_pn_reactor(void *x) { return (pn_reactor_t *) x; }
-  pn_task_t *pn_cast_pn_task(void *x) { return (pn_task_t *) x; }
-  pn_selectable_t *pn_cast_pn_selectable(void *x) { return (pn_selectable_t *) x; }
 %}
 
 /* Connection driver */
@@ -967,7 +962,4 @@ typedef unsigned long int uintptr_t;
 %ignore pn_connection_driver_vlogf;
 %include "proton/connection_driver.h"
 
-
-%include "proton/reactor.h"
-%include "proton/handlers.h"
 %include "proton/cid.h"
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index a02c401..cd9c2c7 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -190,7 +190,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/README.rst.in
 set (py_src "${CMAKE_CURRENT_SOURCE_DIR}")
 set (py_bin "${CMAKE_CURRENT_BINARY_DIR}")
 set (py_dll "$<TARGET_FILE_DIR:_cproton>")
-set (py_bld "$<TARGET_FILE_DIR:qpid-proton>") # For windows
+set (py_bld "$<TARGET_FILE_DIR:qpid-proton-core>") # For windows
 set (py_tests "${py_src}/tests")
 
 set (py_path ${CMAKE_BINARY_DIR}/c/tools ${py_bld} $ENV{PATH})
diff --git a/python/cproton.i b/python/cproton.i
index 276eace..0dcc2ce 100644
--- a/python/cproton.i
+++ b/python/cproton.i
@@ -23,14 +23,11 @@
 #include <winsock2.h>
 #endif
 #include <proton/engine.h>
-#include <proton/url.h>
 #include <proton/message.h>
 #include <proton/object.h>
 #include <proton/sasl.h>
 #include <proton/messenger.h>
 #include <proton/ssl.h>
-#include <proton/reactor.h>
-#include <proton/handlers.h>
 
 /*
 NOTE: According to ccache-swig man page: "Known problems are using
@@ -315,7 +312,7 @@ int pn_ssl_get_cert_fingerprint(pn_ssl_t *ssl, char *OUTPUT, size_t MAX_OUTPUT_S
 
 %immutable PN_PYREF;
 %inline %{
-  extern const pn_class_t *PN_PYREF;
+  extern const pn_class_t PN_PYREF[];
 
   #define CID_pn_pyref CID_pn_void
   #define pn_pyref_new NULL
@@ -348,8 +345,7 @@ int pn_ssl_get_cert_fingerprint(pn_ssl_t *ssl, char *OUTPUT, size_t MAX_OUTPUT_S
     return PN_PYREF;
   }
 
-  const pn_class_t PNI_PYREF = PN_METACLASS(pn_pyref);
-  const pn_class_t *PN_PYREF = &PNI_PYREF;
+  const pn_class_t PN_PYREF[] = {PN_METACLASS(pn_pyref)};
 
   void *pn_py2void(PyObject *object) {
     return object;
@@ -371,74 +367,6 @@ int pn_ssl_get_cert_fingerprint(pn_ssl_t *ssl, char *OUTPUT, size_t MAX_OUTPUT_S
     return pn_void2py(object);
   }
 
-  typedef struct {
-    PyObject *handler;
-    PyObject *dispatch;
-    PyObject *exception;
-  } pni_pyh_t;
-
-  static pni_pyh_t *pni_pyh(pn_handler_t *handler) {
-    return (pni_pyh_t *) pn_handler_mem(handler);
-  }
-
-  static void pni_pyh_finalize(pn_handler_t *handler) {
-    pni_pyh_t *pyh = pni_pyh(handler);
-    SWIG_PYTHON_THREAD_BEGIN_BLOCK;
-    Py_DECREF(pyh->handler);
-    Py_DECREF(pyh->dispatch);
-    Py_DECREF(pyh->exception);
-    SWIG_PYTHON_THREAD_END_BLOCK;
-  }
-
-  static void pni_pydispatch(pn_handler_t *handler, pn_event_t *event, pn_event_type_t type) {
-    pni_pyh_t *pyh = pni_pyh(handler);
-    SWIG_PYTHON_THREAD_BEGIN_BLOCK;
-    PyObject *arg = SWIG_NewPointerObj(event, SWIGTYPE_p_pn_event_t, 0);
-    PyObject *pytype = PyInt_FromLong(type);
-    PyObject *result = PyObject_CallMethodObjArgs(pyh->handler, pyh->dispatch, arg, pytype, NULL);
-    if (!result) {
-      PyObject *exc, *val, *tb;
-      PyErr_Fetch(&exc, &val, &tb);
-      PyErr_NormalizeException(&exc, &val, &tb);
-      if (!val) {
-        val = Py_None;
-        Py_INCREF(val);
-      }
-      if (!tb) {
-        tb = Py_None;
-        Py_INCREF(tb);
-      }
-      {
-        PyObject *result2 = PyObject_CallMethodObjArgs(pyh->handler, pyh->exception, exc, val, tb, NULL);
-        if (!result2) {
-          PyErr_PrintEx(true);
-        }
-        Py_XDECREF(result2);
-      }
-      Py_XDECREF(exc);
-      Py_XDECREF(val);
-      Py_XDECREF(tb);
-    }
-    Py_XDECREF(arg);
-    Py_XDECREF(pytype);
-    Py_XDECREF(result);
-    SWIG_PYTHON_THREAD_END_BLOCK;
-  }
-
-  pn_handler_t *pn_pyhandler(PyObject *handler) {
-    pn_handler_t *chandler = pn_handler_new(pni_pydispatch, sizeof(pni_pyh_t), pni_pyh_finalize);
-    pni_pyh_t *phy = pni_pyh(chandler);
-    phy->handler = handler;
-    {
-      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
-      phy->dispatch = PyString_FromString("dispatch");
-      phy->exception = PyString_FromString("exception");
-      Py_INCREF(phy->handler);
-      SWIG_PYTHON_THREAD_END_BLOCK;
-    }
-    return chandler;
-  }
-
   void pn_pytracer(pn_transport_t *transport, const char *message) {
     PyObject *pytracer = (PyObject *) pn_record_get(pn_transport_attachments(transport), PNI_PYTRACER);
     SWIG_PYTHON_THREAD_BEGIN_BLOCK;
diff --git a/ruby/CMakeLists.txt b/ruby/CMakeLists.txt
index 9accbe2..9d4bd7a 100644
--- a/ruby/CMakeLists.txt
+++ b/ruby/CMakeLists.txt
@@ -35,7 +35,7 @@ set(SWIG_OUTFILE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
 include_directories(${PN_C_INCLUDE_DIR} ${RUBY_INCLUDE_PATH})
 
 swig_add_library(cproton-ruby LANGUAGE ruby SOURCES cproton.i)
-swig_link_libraries(cproton-ruby ${BINDING_DEPS} ${RUBY_LIBRARY})
+swig_link_libraries(cproton-ruby ${BINDING_DEPS_FULL} ${RUBY_LIBRARY})
 
 # Set version-dependent compile flags
 if (RUBY_VERSION VERSION_LESS 1.9.0)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org