You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by mc...@apache.org on 2012/11/29 22:15:46 UTC

svn commit: r1415383 - in /qpid/proton/trunk/proton-c/bindings: CMakeLists.txt perl/ perl/CMakeLists.txt perl/ChangeLog perl/perl.i

Author: mcpierce
Date: Thu Nov 29 21:15:45 2012
New Revision: 1415383

URL: http://svn.apache.org/viewvc?rev=1415383&view=rev
Log:
PROTON-92: Adds Perl language bindings to Proton.

This change takes the basic Proton C APIs and makes them available as
APIs witin the cproton_perl namespace.

Added:
    qpid/proton/trunk/proton-c/bindings/perl/
    qpid/proton/trunk/proton-c/bindings/perl/CMakeLists.txt
      - copied, changed from r1415142, qpid/proton/trunk/proton-c/bindings/CMakeLists.txt
    qpid/proton/trunk/proton-c/bindings/perl/ChangeLog
    qpid/proton/trunk/proton-c/bindings/perl/perl.i
Modified:
    qpid/proton/trunk/proton-c/bindings/CMakeLists.txt

Modified: qpid/proton/trunk/proton-c/bindings/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/CMakeLists.txt?rev=1415383&r1=1415382&r2=1415383&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/CMakeLists.txt (original)
+++ qpid/proton/trunk/proton-c/bindings/CMakeLists.txt Thu Nov 29 21:15:45 2012
@@ -43,3 +43,8 @@ if (PHP_CONFIG_EXE)
     add_subdirectory(php)
   endif (PHP_EXE)
 endif (PHP_CONFIG_EXE)
+
+include(FindPerlLibs)
+if (PERLLIBS_FOUND)
+  add_subdirectory(perl)
+endif (PERLLIBS_FOUND)

Copied: qpid/proton/trunk/proton-c/bindings/perl/CMakeLists.txt (from r1415142, qpid/proton/trunk/proton-c/bindings/CMakeLists.txt)
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/perl/CMakeLists.txt?p2=qpid/proton/trunk/proton-c/bindings/perl/CMakeLists.txt&p1=qpid/proton/trunk/proton-c/bindings/CMakeLists.txt&r1=1415142&r2=1415383&rev=1415383&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/CMakeLists.txt (original)
+++ qpid/proton/trunk/proton-c/bindings/perl/CMakeLists.txt Thu Nov 29 21:15:45 2012
@@ -17,29 +17,18 @@
 # under the License.
 #
 
-include(UseSWIG)
+include_directories("${PERL_INCLUDE_PATH}")
 
-set (BINDING_DEPS qpid-proton)
+# Need to pass in the same compiler flags used to build Perl itself
+execute_process(COMMAND perl -MConfig -e "print \$Config{ccflags}"
+                OUTPUT_VARIABLE PERLCFLAGS)
+set (CMAKE_C_FLAGS ${PERLCFLAGS})
 
-# Build wrapper for Python:
-find_package (PythonLibs)
-if (PYTHONLIBS_FOUND)
-  add_subdirectory(python)
-endif (PYTHONLIBS_FOUND)
+swig_add_module(cproton_perl perl perl.i)
+swig_link_libraries(cproton_perl ${BINDING_DEPS} ${PERL_LIBRARY})
 
-# Build wrapper for Ruby:
-find_package(Ruby)
-if (RUBY_FOUND)
-  add_subdirectory(ruby)
-endif (RUBY_FOUND)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cproton_perl.so
+              ${CMAKE_CURRENT_BINARY_DIR}/cproton_perl.pm
+        DESTINATION ${PERL_ARCHLIB}
+        COMPONENT Perl)
 
-# Build wrapper for PHP
-# For now, assume PHP support if the 'php-config' tool is present.
-# @todo: allow user to specify which php-config if multiple PHP sources installed!
-find_program(PHP_CONFIG_EXE php-config)
-if (PHP_CONFIG_EXE)
-  find_program(PHP_EXE php)
-  if (PHP_EXE)
-    add_subdirectory(php)
-  endif (PHP_EXE)
-endif (PHP_CONFIG_EXE)

Added: qpid/proton/trunk/proton-c/bindings/perl/ChangeLog
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/perl/ChangeLog?rev=1415383&view=auto
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/perl/ChangeLog (added)
+++ qpid/proton/trunk/proton-c/bindings/perl/ChangeLog Thu Nov 29 21:15:45 2012
@@ -0,0 +1,2 @@
+version 0.2: (TBA)
+	* First implementation of the stable APIs on top of swig.

Added: qpid/proton/trunk/proton-c/bindings/perl/perl.i
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/perl/perl.i?rev=1415383&view=auto
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/perl/perl.i (added)
+++ qpid/proton/trunk/proton-c/bindings/perl/perl.i Thu Nov 29 21:15:45 2012
@@ -0,0 +1,124 @@
+%module cproton_perl
+
+%{
+#include <proton/engine.h>
+#include <proton/message.h>
+#include <proton/sasl.h>
+#include <proton/driver.h>
+#include <proton/messenger.h>
+#include <proton/ssl.h>
+%}
+
+typedef unsigned int size_t;
+typedef signed int ssize_t;
+typedef unsigned char uint8_t;
+typedef unsigned int uint32_t;
+typedef unsigned long int uint64_t;
+typedef int int32_t;
+
+%include <cstring.i>
+
+%cstring_output_withsize(char *OUTPUT, size_t *OUTPUT_SIZE)
+%cstring_output_allocate_size(char **ALLOC_OUTPUT, size_t *ALLOC_SIZE, free(*$1));
+
+int pn_message_load(pn_message_t *msg, char *STRING, size_t LENGTH);
+%ignore pn_message_load;
+
+int pn_message_load_data(pn_message_t *msg, char *STRING, size_t LENGTH);
+%ignore pn_message_load_data;
+
+int pn_message_load_text(pn_message_t *msg, char *STRING, size_t LENGTH);
+%ignore pn_message_load_text;
+
+int pn_message_load_amqp(pn_message_t *msg, char *STRING, size_t LENGTH);
+%ignore pn_message_load_amqp;
+
+int pn_message_load_json(pn_message_t *msg, char *STRING, size_t LENGTH);
+%ignore pn_message_load_json;
+
+int pn_message_encode(pn_message_t *msg, char *OUTPUT, size_t *OUTPUT_SIZE);
+%ignore pn_message_encode;
+
+int pn_message_save(pn_message_t *msg, char *OUTPUT, size_t *OUTPUT_SIZE);
+%ignore pn_message_save;
+
+int pn_message_save_data(pn_message_t *msg, char *OUTPUT, size_t *OUTPUT_SIZE);
+%ignore pn_message_save_data;
+
+int pn_message_save_text(pn_message_t *msg, char *OUTPUT, size_t *OUTPUT_SIZE);
+%ignore pn_message_save_text;
+
+int pn_message_save_amqp(pn_message_t *msg, char *OUTPUT, size_t *OUTPUT_SIZE);
+%ignore pn_message_save_amqp;
+
+int pn_message_save_json(pn_message_t *msg, char *OUTPUT, size_t *OUTPUT_SIZE);
+%ignore pn_message_save_json;
+
+ssize_t pn_link_send(pn_link_t *transport, char *STRING, size_t LENGTH);
+%ignore pn_link_send;
+
+%rename(pn_link_recv) wrap_pn_link_recv;
+%inline %{
+  int wrap_pn_link_recv(pn_link_t *link, char *OUTPUT, size_t *OUTPUT_SIZE) {
+    ssize_t sz = pn_link_recv(link, OUTPUT, *OUTPUT_SIZE);
+    if (sz >= 0) {
+      *OUTPUT_SIZE = sz;
+    } else {
+      *OUTPUT_SIZE = 0;
+    }
+    return sz;
+  }
+%}
+%ignore pn_link_recv;
+
+ssize_t pn_transport_input(pn_transport_t *transport, char *STRING, size_t LENGTH);
+%ignore pn_transport_input;
+
+%rename(pn_transport_output) wrap_pn_transport_output;
+%inline %{
+  int wrap_pn_transport_output(pn_transport_t *transport, char *OUTPUT, size_t *OUTPUT_SIZE) {
+    ssize_t sz = pn_transport_output(transport, OUTPUT, *OUTPUT_SIZE);
+    if (sz >= 0) {
+      *OUTPUT_SIZE = sz;
+    } else {
+      *OUTPUT_SIZE = 0;
+    }
+    return sz;
+  }
+%}
+%ignore pn_transport_output;
+
+%rename(pn_delivery) wrap_pn_delivery;
+%inline %{
+  pn_delivery_t *wrap_pn_delivery(pn_link_t *link, char *STRING, size_t LENGTH) {
+    return pn_delivery(link, pn_dtag(STRING, LENGTH));
+  }
+%}
+%ignore pn_delivery;
+
+%rename(pn_delivery_tag) wrap_pn_delivery_tag;
+%inline %{
+  void wrap_pn_delivery_tag(pn_delivery_t *delivery, char **ALLOC_OUTPUT, size_t *ALLOC_SIZE) {
+    pn_delivery_tag_t tag = pn_delivery_tag(delivery);
+    *ALLOC_OUTPUT = malloc(tag.size);
+    *ALLOC_SIZE = tag.size;
+    memcpy(*ALLOC_OUTPUT, tag.bytes, tag.size);
+  }
+%}
+%ignore pn_delivery_tag;
+
+%rename(pn_message_data) wrap_pn_message_data;
+%inline %{
+  int wrap_pn_message_data(char *STRING, size_t LENGTH, char *OUTPUT, size_t *OUTPUT_SIZE) {
+    ssize_t sz = pn_message_data(OUTPUT, *OUTPUT_SIZE, STRING, LENGTH);
+    if (sz >= 0) {
+      *OUTPUT_SIZE = sz;
+    } else {
+      *OUTPUT_SIZE = 0;
+    }
+    return sz;
+  }
+%}
+%ignore pn_message_data;
+
+%include "proton/cproton.i"



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