You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by fa...@apache.org on 2014/09/06 13:23:14 UTC
svn commit: r1622849 [4/9] - in
/qpid/proton/branches/fadams-javascript-binding: ./ contrib/
contrib/proton-hawtdispatch/ contrib/proton-hawtdispatch/src/
contrib/proton-hawtdispatch/src/main/
contrib/proton-hawtdispatch/src/main/java/ contrib/proton-h...
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/CMakeLists.txt?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/CMakeLists.txt (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/CMakeLists.txt Sat Sep 6 11:23:10 2014
@@ -16,41 +16,38 @@
# specific language governing permissions and limitations
# under the License.
#
+
+# NB For python the SWIG module name must have the same name as the
+# input .i file for CMake to generate the correct dependencies
+
set(CMAKE_SWIG_FLAGS "-threads")
include_directories (${PYTHON_INCLUDE_PATH})
if (BUILD_WITH_CXX)
- SET_SOURCE_FILES_PROPERTIES(python.i PROPERTIES CPLUSPLUS ON)
+ SET_SOURCE_FILES_PROPERTIES(cproton.i PROPERTIES CPLUSPLUS ON)
endif (BUILD_WITH_CXX)
-swig_add_module(cproton python python.i)
+
+list(APPEND SWIG_MODULE_cproton_EXTRA_DEPS
+ ${CMAKE_SOURCE_DIR}/proton-c/include/proton/cproton.i
+)
+
+swig_add_module(cproton python cproton.i)
swig_link_libraries(cproton ${BINDING_DEPS} ${PYTHON_LIBRARIES})
-set_target_properties(_cproton
+set_target_properties(${SWIG_MODULE_cproton_REAL_NAME}
PROPERTIES
LINK_FLAGS "${CATCH_UNDEFINED}")
find_package(PythonInterp REQUIRED)
-if (CHECK_SYSINSTALL_PYTHON)
- execute_process(COMMAND ${PYTHON_EXECUTABLE}
- -c "from distutils.sysconfig import get_python_lib; print get_python_lib(True)"
- OUTPUT_VARIABLE PYTHON_SITEARCH_PACKAGES_DEFAULT
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-else ()
- set (PYTHON_SITEARCH_PACKAGES_DEFAULT ${BINDINGS_DIR}/python)
-endif ()
-
-if (NOT PYTHON_SITEARCH_PACKAGES)
- set (PYTHON_SITEARCH_PACKAGES ${PYTHON_SITEARCH_PACKAGES_DEFAULT})
-endif()
-
-install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m py_compile cproton.py
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")
-install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -O -m py_compile cproton.py
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")
-install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m py_compile proton.py
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})")
-install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -O -m py_compile proton.py
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})")
+# configure the files needed for generating Pypi packages. Packages
+# can be generated by running "python setup.py" from the build
+# directory.
+get_filename_component(PN_SWIG_PYTHON_C_WRAPPER
+ ${swig_generated_file_fullname} NAME)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/proton.py
+ ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in
+ ${CMAKE_CURRENT_BINARY_DIR}/setup.py @ONLY)
find_program(EPYDOC_EXE epydoc)
mark_as_advanced (EPYDOC_EXE)
@@ -66,14 +63,37 @@ if (EPYDOC_EXE)
${OPTIONAL_ARG})
endif (EPYDOC_EXE)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cproton.py
- ${CMAKE_CURRENT_BINARY_DIR}/cproton.pyc
- ${CMAKE_CURRENT_BINARY_DIR}/cproton.pyo
- ${CMAKE_CURRENT_SOURCE_DIR}/proton.py
- ${CMAKE_CURRENT_SOURCE_DIR}/proton.pyc
- ${CMAKE_CURRENT_SOURCE_DIR}/proton.pyo
- DESTINATION ${PYTHON_SITEARCH_PACKAGES}
- COMPONENT Python)
-install(TARGETS _cproton
- DESTINATION ${PYTHON_SITEARCH_PACKAGES}
- COMPONENT Python)
+if (CHECK_SYSINSTALL_PYTHON)
+ # use the python-native install paths:
+
+ install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} setup.py sdist
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")
+ install(CODE "execute_process(COMMAND
+ ${PYTHON_EXECUTABLE} setup.py --proton-install-prefix ${CMAKE_INSTALL_PREFIX} install
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")
+
+else ()
+ # install the bindings using the CMAKE path variables:
+ set (PYTHON_SITEARCH_PACKAGES ${BINDINGS_DIR}/python)
+
+ install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m py_compile cproton.py
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")
+ install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -O -m py_compile cproton.py
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})")
+ install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m py_compile proton.py
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})")
+ install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -O -m py_compile proton.py
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})")
+
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cproton.py
+ ${CMAKE_CURRENT_BINARY_DIR}/cproton.pyc
+ ${CMAKE_CURRENT_BINARY_DIR}/cproton.pyo
+ ${CMAKE_CURRENT_SOURCE_DIR}/proton.py
+ ${CMAKE_CURRENT_SOURCE_DIR}/proton.pyc
+ ${CMAKE_CURRENT_SOURCE_DIR}/proton.pyo
+ DESTINATION ${PYTHON_SITEARCH_PACKAGES}
+ COMPONENT Python)
+ install(TARGETS ${SWIG_MODULE_cproton_REAL_NAME}
+ DESTINATION ${PYTHON_SITEARCH_PACKAGES}
+ COMPONENT Python)
+endif()
Added: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/cproton.i
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/cproton.i?rev=1622849&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/cproton.i (added)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/cproton.i Sat Sep 6 11:23:10 2014
@@ -0,0 +1,379 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+%module cproton
+%{
+/* Includes the header in the wrapper code */
+#if defined(_WIN32) && ! defined(__CYGWIN__)
+#include <winsock2.h>
+#endif
+#include <proton/engine.h>
+#include <proton/message.h>
+#include <proton/sasl.h>
+#include <proton/driver.h>
+#include <proton/driver_extras.h>
+#include <proton/messenger.h>
+#include <proton/ssl.h>
+%}
+
+%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));
+%cstring_output_maxsize(char *OUTPUT, size_t MAX_OUTPUT_SIZE)
+
+// These are not used/needed in the python binding
+%ignore pn_message_get_id;
+%ignore pn_message_set_id;
+%ignore pn_message_get_correlation_id;
+%ignore pn_message_set_correlation_id;
+
+%typemap(in) pn_bytes_t {
+ if ($input == Py_None) {
+ $1.start = NULL;
+ $1.size = 0;
+ } else {
+ $1.start = PyString_AsString($input);
+ if (!$1.start) {
+ return NULL;
+ }
+ $1.size = PyString_Size($input);
+ }
+}
+
+%typemap(out) pn_bytes_t {
+ $result = PyString_FromStringAndSize($1.start, $1.size);
+}
+
+%typemap(out) pn_delivery_tag_t {
+ $result = PyString_FromStringAndSize($1.bytes, $1.size);
+}
+
+%typemap(in) pn_uuid_t {
+ memset($1.bytes, 0, 16);
+ if ($input == Py_None) {
+ ; // Already zeroed out
+ } else {
+ const char* b = PyString_AsString($input);
+ if (b) {
+ memmove($1.bytes, b, (PyString_Size($input) < 16 ? PyString_Size($input) : 16));
+ } else {
+ return NULL;
+ }
+ }
+}
+
+%typemap(out) pn_uuid_t {
+ $result = PyString_FromStringAndSize($1.bytes, 16);
+}
+
+%apply pn_uuid_t { pn_decimal128_t };
+
+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_push(pn_transport_t *transport, char *STRING, size_t LENGTH);
+%ignore pn_transport_push;
+
+%rename(pn_transport_peek) wrap_pn_transport_peek;
+%inline %{
+ int wrap_pn_transport_peek(pn_transport_t *transport, char *OUTPUT, size_t *OUTPUT_SIZE) {
+ ssize_t sz = pn_transport_peek(transport, OUTPUT, *OUTPUT_SIZE);
+ if (sz >= 0) {
+ *OUTPUT_SIZE = sz;
+ } else {
+ *OUTPUT_SIZE = 0;
+ }
+ return sz;
+ }
+%}
+%ignore pn_transport_peek;
+
+%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 = (char *) 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;
+
+%rename(pn_listener_set_context) wrap_pn_listener_set_context;
+%inline {
+ void wrap_pn_listener_set_context(pn_listener_t *l, PyObject *context) {
+ // don't incref context: we 'borrow' the reference - prevents
+ // reference loops. Should be safe as the Python object must
+ // outlive the C object.
+ pn_listener_set_context(l, context);
+ }
+}
+%ignore pn_listener_set_context;
+
+%rename(pn_listener_context) wrap_pn_listener_context;
+%inline {
+ PyObject *wrap_pn_listener_context(pn_listener_t *l) {
+ PyObject *result = (PyObject *) pn_listener_context(l);
+ // incref the returned context, as the caller expects this
+ if (result) {
+ Py_INCREF(result);
+ return result;
+ } else {
+ Py_RETURN_NONE;
+ }
+ }
+}
+%ignore pn_listener_context;
+
+%rename(pn_connector_set_context) wrap_pn_connector_set_context;
+%inline {
+ void wrap_pn_connector_set_context(pn_connector_t *c, PyObject *context) {
+ // don't incref context: we 'borrow' the reference - prevents
+ // reference loops. Should be safe as the Python object must
+ // outlive the C object.
+ pn_connector_set_context(c, context);
+ }
+}
+%ignore pn_connector_set_context;
+
+%rename(pn_connector_context) wrap_pn_connector_context;
+%inline {
+ PyObject *wrap_pn_connector_context(pn_connector_t *c) {
+ PyObject *result = (PyObject *) pn_connector_context(c);
+ // incref the returned context, as the caller expects this
+ if (result) {
+ Py_INCREF(result);
+ return result;
+ } else {
+ Py_RETURN_NONE;
+ }
+ }
+}
+%ignore pn_connector_context;
+
+%rename(pn_connection_get_context) wrap_pn_connection_get_context;
+%inline {
+ PyObject *wrap_pn_connection_get_context(pn_connection_t *c) {
+ PyObject *result = (PyObject *) pn_connection_get_context(c);
+ // incref the returned context, as the caller expects this
+ if (result) {
+ Py_INCREF(result);
+ return result;
+ } else {
+ Py_RETURN_NONE;
+ }
+ }
+}
+%ignore pn_connection_get_context;
+
+%rename(pn_connection_set_context) wrap_pn_connection_set_context;
+%inline {
+ void wrap_pn_connection_set_context(pn_connection_t *c, PyObject *context) {
+ // don't incref context: we 'borrow' the reference
+ pn_connection_set_context(c, context);
+ }
+}
+%ignore pn_connection_set_context;
+
+%rename(pn_session_get_context) wrap_pn_session_get_context;
+%inline {
+ PyObject *wrap_pn_session_get_context(pn_session_t *s) {
+ PyObject *result = (PyObject *) pn_session_get_context(s);
+ // incref the returned context, as the caller expects this
+ if (result) {
+ Py_INCREF(result);
+ return result;
+ } else {
+ Py_RETURN_NONE;
+ }
+ }
+}
+%ignore pn_session_get_context;
+
+%rename(pn_session_set_context) wrap_pn_session_set_context;
+%inline {
+ void wrap_pn_session_set_context(pn_session_t *s, PyObject *context) {
+ // don't incref context: we 'borrow' the reference
+ pn_session_set_context(s, context);
+ }
+}
+%ignore pn_session_set_context;
+
+%rename(pn_link_get_context) wrap_pn_link_get_context;
+%inline {
+ PyObject *wrap_pn_link_get_context(pn_link_t *l) {
+ PyObject *result = (PyObject *) pn_link_get_context(l);
+ // incref the returned context, as the caller expects this
+ if (result) {
+ Py_INCREF(result);
+ return result;
+ } else {
+ Py_RETURN_NONE;
+ }
+ }
+}
+%ignore pn_link_get_context;
+
+%rename(pn_link_set_context) wrap_pn_link_set_context;
+%inline {
+ void wrap_pn_link_set_context(pn_link_t *l, PyObject *context) {
+ // don't incref context: we 'borrow' the reference
+ pn_link_set_context(l, context);
+ }
+}
+%ignore pn_link_set_context;
+
+%rename(pn_delivery_get_context) wrap_pn_delivery_get_context;
+%inline {
+ PyObject *wrap_pn_delivery_get_context(pn_delivery_t *d) {
+ PyObject *result = (PyObject *) pn_delivery_get_context(d);
+ // incref the returned context, as the caller expects this
+ if (result) {
+ Py_INCREF(result);
+ return result;
+ } else {
+ Py_RETURN_NONE;
+ }
+ }
+}
+%ignore pn_delivery_get_context;
+
+%rename(pn_delivery_set_context) wrap_pn_delivery_set_context;
+%inline {
+ void wrap_pn_delivery_set_context(pn_delivery_t *d, PyObject *context) {
+ // don't incref context: we 'borrow' the reference
+ pn_delivery_set_context(d, context);
+ }
+}
+%ignore pn_delivery_set_context;
+
+ssize_t pn_data_decode(pn_data_t *data, char *STRING, size_t LENGTH);
+%ignore pn_data_decode;
+
+%rename(pn_data_encode) wrap_pn_data_encode;
+%inline %{
+ int wrap_pn_data_encode(pn_data_t *data, char *OUTPUT, size_t *OUTPUT_SIZE) {
+ ssize_t sz = pn_data_encode(data, OUTPUT, *OUTPUT_SIZE);
+ if (sz >= 0) {
+ *OUTPUT_SIZE = sz;
+ } else {
+ *OUTPUT_SIZE = 0;
+ }
+ return sz;
+ }
+%}
+%ignore pn_data_encode;
+
+%rename(pn_sasl_recv) wrap_pn_sasl_recv;
+%inline %{
+ int wrap_pn_sasl_recv(pn_sasl_t *sasl, char *OUTPUT, size_t *OUTPUT_SIZE) {
+ ssize_t sz = pn_sasl_recv(sasl, OUTPUT, *OUTPUT_SIZE);
+ if (sz >= 0) {
+ *OUTPUT_SIZE = sz;
+ } else {
+ *OUTPUT_SIZE = 0;
+ }
+ return sz;
+ }
+%}
+%ignore pn_sasl_recv;
+
+int pn_data_format(pn_data_t *data, char *OUTPUT, size_t *OUTPUT_SIZE);
+%ignore pn_data_format;
+
+bool pn_ssl_get_cipher_name(pn_ssl_t *ssl, char *OUTPUT, size_t MAX_OUTPUT_SIZE);
+%ignore pn_ssl_get_cipher_name;
+
+bool pn_ssl_get_protocol_name(pn_ssl_t *ssl, char *OUTPUT, size_t MAX_OUTPUT_SIZE);
+%ignore pn_ssl_get_protocol_name;
+
+int pn_ssl_get_peer_hostname(pn_ssl_t *ssl, char *OUTPUT, size_t *OUTPUT_SIZE);
+%ignore pn_ssl_get_peer_hostname;
+
+
+%include "proton/cproton.i"
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/proton.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/proton.py?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/proton.py (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/proton.py Sat Sep 6 11:23:10 2014
@@ -464,6 +464,7 @@ first message.
sub_impl = pn_messenger_subscribe(self._mng, source)
if not sub_impl:
self._check(pn_error_code(pn_messenger_error(self._mng)))
+ raise MessengerException("Cannot subscribe to %s"%source)
return Subscription(sub_impl)
def put(self, message):
@@ -760,8 +761,7 @@ first message.
return None
class Message(object):
- """
- The L{Message} class is a mutable holder of message content.
+ """The L{Message} class is a mutable holder of message content.
@ivar instructions: delivery instructions for the message
@type instructions: dict
@@ -780,7 +780,10 @@ class Message(object):
DEFAULT_PRIORITY = PN_DEFAULT_PRIORITY
- def __init__(self):
+ def __init__(self, **kwargs):
+ """
+ @param kwargs: Message property name/value pairs to initialise the Message
+ """
self._msg = pn_message()
self._id = Data(pn_message_id(self._msg))
self._correlation_id = Data(pn_message_correlation_id(self._msg))
@@ -788,6 +791,9 @@ class Message(object):
self.annotations = None
self.properties = None
self.body = None
+ for k,v in kwargs.iteritems():
+ getattr(self, k) # Raise exception if it's not a valid attribute.
+ setattr(self, k, v)
def __del__(self):
if hasattr(self, "_msg"):
@@ -860,7 +866,14 @@ class Message(object):
def _set_inferred(self, value):
self._check(pn_message_set_inferred(self._msg, bool(value)))
- inferred = property(_is_inferred, _set_inferred)
+ inferred = property(_is_inferred, _set_inferred,"""
+The inferred flag for a message indicates how the message content
+is encoded into AMQP sections. If inferred is true then binary and
+list values in the body of the message will be encoded as AMQP DATA
+and AMQP SEQUENCE sections, respectively. If inferred is false,
+then all values in the body of the message will be encoded as AMQP
+VALUE sections regardless of their type.
+""")
def _is_durable(self):
return pn_message_is_durable(self._msg)
@@ -2165,6 +2178,16 @@ class Endpoint(object):
def __init__(self):
self.condition = None
+ self._release_invoked = False
+
+ def _release(self):
+ """Release the underlying C Engine resource."""
+ if not self._release_invoked:
+ for c in self._children:
+ c._release()
+ self._free_resource()
+ self.connection._releasing(self)
+ self._release_invoked = True
def _update_cond(self):
obj2cond(self.condition, self._get_cond_impl())
@@ -2256,13 +2279,32 @@ class Connection(Endpoint):
def __del__(self):
if hasattr(self, "_conn") and self._conn:
- # pn_connection_free will release all child sessions in the C Engine, so
- # free all child python Sessions to avoid dangling references
- if hasattr(self, "_sessions") and self._sessions:
- for s in self._sessions:
- s._release()
- pn_connection_set_context(self._conn, None)
- pn_connection_free(self._conn)
+ self._release()
+
+ def free(self):
+ self._release()
+
+ @property
+ def _children(self):
+ return self._sessions
+
+ @property
+ def connection(self):
+ return self
+
+ def _free_resource(self):
+ pn_connection_free(self._conn)
+
+ def _released(self):
+ self._conn = None
+
+ def _releasing(self, child):
+ coll = getattr(self, "_collector", None)
+ if coll: coll = coll()
+ if coll:
+ coll._contexts.add(child)
+ else:
+ child._released()
def _check(self, err):
if err < 0:
@@ -2282,9 +2324,7 @@ class Connection(Endpoint):
pn_connection_collect(self._conn, None)
else:
pn_connection_collect(self._conn, collector._impl)
- # XXX: we can't let coll go out of scope or the connection will be
- # pointing to garbage
- self._collector = collector
+ self._collector = weakref.ref(collector)
def _get_container(self):
return pn_connection_get_container(self._conn)
@@ -2376,16 +2416,15 @@ class Session(Endpoint):
self._links = set()
self.connection._sessions.add(self)
- def _release(self):
- """Release the underlying C Engine resource."""
- if self._ssn:
- # pn_session_free will release all child links in the C Engine, so free
- # all child python Links to avoid dangling references
- for l in self._links:
- l._release()
- pn_session_set_context(self._ssn, None)
- pn_session_free(self._ssn)
- self._ssn = None
+ @property
+ def _children(self):
+ return self._links
+
+ def _free_resource(self):
+ pn_session_free(self._ssn)
+
+ def _released(self):
+ self._ssn = None
def free(self):
"""Release the Session, freeing its resources.
@@ -2477,16 +2516,15 @@ class Link(Endpoint):
self._deliveries = set()
self.session._links.add(self)
- def _release(self):
- """Release the underlying C Engine resource."""
- if self._link:
- # pn_link_free will settle all child deliveries in the C Engine, so free
- # all child python deliveries to avoid dangling references
- for d in self._deliveries:
- d._release()
- pn_link_set_context(self._link, None)
- pn_link_free(self._link)
- self._link = None
+ @property
+ def _children(self):
+ return self._deliveries
+
+ def _free_resource(self):
+ pn_link_free(self._link)
+
+ def _released(self):
+ self._link = None
def free(self):
"""Release the Link, freeing its resources"""
@@ -2536,6 +2574,10 @@ class Link(Endpoint):
def session(self):
return Session._wrap_session(pn_link_session(self._link))
+ @property
+ def connection(self):
+ return self.session.connection
+
def delivery(self, tag):
return Delivery._wrap_delivery(pn_delivery(self._link, tag))
@@ -2719,13 +2761,38 @@ class Receiver(Link):
def draining(self):
return pn_link_draining(self._link)
+class NamedInt(int):
+
+ values = {}
+
+ def __new__(cls, i, name):
+ ni = super(NamedInt, cls).__new__(cls, i)
+ cls.values[i] = ni
+ return ni
+
+ def __init__(self, i, name):
+ self.name = name
+
+ def __repr__(self):
+ return self.name
+
+ def __str__(self):
+ return self.name
+
+ @classmethod
+ def get(cls, i):
+ return cls.values.get(i, i)
+
+class DispositionType(NamedInt):
+ values = {}
+
class Disposition(object):
- RECEIVED = PN_RECEIVED
- ACCEPTED = PN_ACCEPTED
- REJECTED = PN_REJECTED
- RELEASED = PN_RELEASED
- MODIFIED = PN_MODIFIED
+ RECEIVED = DispositionType(PN_RECEIVED, "RECEIVED")
+ ACCEPTED = DispositionType(PN_ACCEPTED, "ACCEPTED")
+ REJECTED = DispositionType(PN_REJECTED, "REJECTED")
+ RELEASED = DispositionType(PN_RELEASED, "RELEASED")
+ MODIFIED = DispositionType(PN_MODIFIED, "MODIFIED")
def __init__(self, impl, local):
self._impl = impl
@@ -2736,7 +2803,7 @@ class Disposition(object):
@property
def type(self):
- return pn_disposition_type(self._impl)
+ return DispositionType.get(pn_disposition_type(self._impl))
def _get_section_number(self):
return pn_disposition_get_section_number(self._impl)
@@ -2824,12 +2891,13 @@ class Delivery(object):
self.remote = Disposition(pn_delivery_remote(self._dlv), False)
self.link._deliveries.add(self)
+ def __del__(self):
+ pn_delivery_set_context(self._dlv, None)
+
def _release(self):
"""Release the underlying C Engine resource."""
if self._dlv:
- pn_delivery_set_context(self._dlv, None)
pn_delivery_settle(self._dlv)
- self._dlv = None
@property
def tag(self):
@@ -2863,11 +2931,11 @@ class Delivery(object):
@property
def local_state(self):
- return pn_delivery_local_state(self._dlv)
+ return DispositionType.get(pn_delivery_local_state(self._dlv))
@property
def remote_state(self):
- return pn_delivery_remote_state(self._dlv)
+ return DispositionType.get(pn_delivery_remote_state(self._dlv))
@property
def settled(self):
@@ -2891,6 +2959,7 @@ class TransportException(ProtonException
class Transport(object):
+ TRACE_OFF = PN_TRACE_OFF
TRACE_DRV = PN_TRACE_DRV
TRACE_FRM = PN_TRACE_FRM
TRACE_RAW = PN_TRACE_RAW
@@ -2955,7 +3024,9 @@ class Transport(object):
return self._check(c)
def push(self, bytes):
- self._check(pn_transport_push(self._trans, bytes))
+ n = self._check(pn_transport_push(self._trans, bytes))
+ if n != len(bytes):
+ raise OverflowError("unable to process all bytes")
def close_tail(self):
self._check(pn_transport_close_tail(self._trans))
@@ -2981,26 +3052,9 @@ class Transport(object):
def close_head(self):
self._check(pn_transport_close_head(self._trans))
- def output(self, size):
- p = self.pending()
- if p < 0:
- return None
- else:
- out = self.peek(min(size, p))
- self.pop(len(out))
- return out
-
- def input(self, bytes):
- if not bytes:
- self.close_tail()
- return None
- else:
- c = self.capacity()
- if (c < 0):
- return None
- trimmed = bytes[:c]
- self.push(trimmed)
- return len(trimmed)
+ @property
+ def closed(self):
+ return pn_transport_closed(self._trans)
# AMQP 1.0 max-frame-size
def _get_max_frame_size(self):
@@ -3078,6 +3132,7 @@ class SASL(object):
OK = PN_SASL_OK
AUTH = PN_SASL_AUTH
+ SKIPPED = PN_SASL_SKIPPED
def __new__(cls, transport):
"""Enforce a singleton SASL object per Transport"""
@@ -3103,6 +3158,9 @@ class SASL(object):
def server(self):
pn_sasl_server(self._sasl)
+ def allow_skip(self, allow):
+ pn_sasl_allow_skip(self._sasl, allow)
+
def plain(self, user, password):
pn_sasl_plain(self._sasl, user, password)
@@ -3265,6 +3323,7 @@ class Collector:
def __init__(self):
self._impl = pn_collector()
+ self._contexts = set()
def peek(self):
event = pn_collector_peek(self._impl)
@@ -3285,6 +3344,9 @@ class Collector:
transport=tp)
def pop(self):
+ ev = self.peek()
+ if ev is not None:
+ ev._popped(self)
pn_collector_pop(self._impl)
def __del__(self):
@@ -3292,15 +3354,34 @@ class Collector:
class Event:
- CATEGORY_PROTOCOL = PN_EVENT_CATEGORY_PROTOCOL
-
- CONNECTION_LOCAL_STATE = PN_CONNECTION_LOCAL_STATE
- CONNECTION_REMOTE_STATE = PN_CONNECTION_REMOTE_STATE
- SESSION_LOCAL_STATE = PN_SESSION_LOCAL_STATE
- SESSION_REMOTE_STATE = PN_SESSION_REMOTE_STATE
- LINK_LOCAL_STATE = PN_LINK_LOCAL_STATE
- LINK_REMOTE_STATE = PN_LINK_REMOTE_STATE
+ CATEGORY_CONNECTION = PN_EVENT_CATEGORY_CONNECTION
+ CATEGORY_SESSION = PN_EVENT_CATEGORY_SESSION
+ CATEGORY_LINK = PN_EVENT_CATEGORY_LINK
+ CATEGORY_DELIVERY = PN_EVENT_CATEGORY_DELIVERY
+ CATEGORY_TRANSPORT = PN_EVENT_CATEGORY_TRANSPORT
+
+ CONNECTION_INIT = PN_CONNECTION_INIT
+ CONNECTION_OPEN = PN_CONNECTION_OPEN
+ CONNECTION_CLOSE = PN_CONNECTION_CLOSE
+ CONNECTION_REMOTE_OPEN = PN_CONNECTION_REMOTE_OPEN
+ CONNECTION_REMOTE_CLOSE = PN_CONNECTION_REMOTE_CLOSE
+ CONNECTION_FINAL = PN_CONNECTION_FINAL
+
+ SESSION_INIT = PN_SESSION_INIT
+ SESSION_OPEN = PN_SESSION_OPEN
+ SESSION_CLOSE = PN_SESSION_CLOSE
+ SESSION_REMOTE_OPEN = PN_SESSION_REMOTE_OPEN
+ SESSION_REMOTE_CLOSE = PN_SESSION_REMOTE_CLOSE
+ SESSION_FINAL = PN_SESSION_FINAL
+
+ LINK_INIT = PN_LINK_INIT
+ LINK_OPEN = PN_LINK_OPEN
+ LINK_CLOSE = PN_LINK_CLOSE
+ LINK_REMOTE_OPEN = PN_LINK_REMOTE_OPEN
+ LINK_REMOTE_CLOSE = PN_LINK_REMOTE_CLOSE
LINK_FLOW = PN_LINK_FLOW
+ LINK_FINAL = PN_LINK_FINAL
+
DELIVERY = PN_DELIVERY
TRANSPORT = PN_TRANSPORT
@@ -3314,6 +3395,19 @@ class Event:
self.delivery = delivery
self.transport = transport
+ def _popped(self, collector):
+ if self.type == Event.LINK_FINAL:
+ ctx = self.link
+ elif self.type == Event.SESSION_FINAL:
+ ctx = self.session
+ elif self.type == Event.CONNECTION_FINAL:
+ ctx = self.connection
+ else:
+ return
+
+ collector._contexts.remove(ctx)
+ ctx._released()
+
def __repr__(self):
objects = [self.connection, self.session, self.link, self.delivery,
self.transport]
@@ -3544,6 +3638,8 @@ __all__ = [
"Messenger",
"MessengerException",
"ProtonException",
+ "PN_VERSION_MAJOR",
+ "PN_VERSION_MINOR",
"Receiver",
"SASL",
"Sender",
Added: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/setup.py.in
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/setup.py.in?rev=1622849&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/setup.py.in (added)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/setup.py.in Sat Sep 6 11:23:10 2014
@@ -0,0 +1,107 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+from distutils.core import setup, Extension
+import logging
+import os
+import sys
+
+_c_module = '@SWIG_MODULE_cproton_REAL_NAME@'
+_src_file = '@PN_SWIG_PYTHON_C_WRAPPER@'
+_version = '@PN_VERSION@'
+_release = 0
+
+if "--proton-install-prefix" in sys.argv:
+ # special option used only if the python headers and library have been
+ # installed to a non-standard directory. This can be done during 'make
+ # install' from the proton build tree by using the cmake option
+ # -DCMAKE_INSTALL_PREFIX. The location of the headers and library must be
+ # specified so we can build the binding's C extension.
+ i = sys.argv.index("--proton-install-prefix") + 1
+ if i >= len(sys.argv):
+ raise ValueError("--proton-install-prefix requires a path parameter.")
+ _prefix = sys.argv[i]
+ # remove the proton arguments to they don't conflict with setup.py's other
+ # command arguments:
+ del sys.argv[i]
+ sys.argv.remove("--proton-install-prefix")
+ _destdir = os.environ.get("DESTDIR", "")
+ if _destdir and os.path.isabs(_prefix):
+ # DESTDIR may be used on unix systems to put the entire install tree
+ # under a particular directory. However, if _prefix is an absolute
+ # path, os.path.join will discard DESTDIR, so strip off the leading
+ # separator
+ _prefix = _prefix.lstrip(os.path.sep)
+
+ _inc_dir = os.path.join(_destdir,
+ _prefix,
+ '@INCLUDE_INSTALL_DIR@')
+ _lib_dir = os.path.join(_destdir,
+ _prefix,
+ '@LIB_INSTALL_DIR@')
+
+ swig_ext = Extension(_c_module, [_src_file],
+ libraries=['qpid-proton'],
+ include_dirs=[_inc_dir],
+ library_dirs=[_lib_dir])
+else:
+ swig_ext = Extension(_c_module, [_src_file],
+ libraries=['qpid-proton'])
+
+_help_description = """Before you can build or install these bindings, you must
+first install version @PN_VERSION@ of the Proton development library
+(libqpid-proton) and its C header files. These files must be available in order
+to build this packages' C-based extension.
+
+Packages for the Proton development library may be provided by your system's
+distribution. For example, the qpid-proton-c-devel RPM is available for
+Centos/RHEL via EPEL. A libqpid-proton2-dev deb file is available for Ubuntu
+via the Apache Qpid PPA (ppa:qpid/released).
+
+If your distribution does not make these packages available, you can download
+the Proton sources directly from the Apache Qpid project:
+
+ http://qpid.apache.org
+
+This package is compatible with the @PN_VERSION@ release of the Proton
+development library.
+
+If you need additional help, see http://qpid.apache.org/discussion.html
+"""
+
+_long_description = """This package contains the Python bindings for the Apache
+QPID Proton library.\n%s""" % _help_description
+
+try:
+ setup(name="python-qpid-proton",
+ version="%s-%d" % (_version, _release),
+ author="Apache Qpid",
+ author_email="dev@qpid.apache.org",
+ py_modules=["proton", "cproton"],
+ url="http://qpid.apache.org/",
+ description="Python bindings for the Proton library",
+ long_description=_long_description,
+ license="Apache Software License",
+ classifiers=["License :: OSI Approved :: Apache Software License",
+ "Intended Audience :: Developers",
+ "Programming Language :: Python"],
+ ext_modules=[swig_ext])
+except:
+ logging.error("setup failed!\n%s", _help_description)
+ raise
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/CMakeLists.txt?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/CMakeLists.txt (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/CMakeLists.txt Sat Sep 6 11:23:10 2014
@@ -20,7 +20,9 @@
if (NOT DEFAULT_RUBY_TESTING)
message(FATAL_ERROR "Ruby bindings cannot be tested while missing dependencies")
endif (NOT DEFAULT_RUBY_TESTING)
-
+list(APPEND SWIG_MODULE_cproton-ruby_EXTRA_DEPS
+ ${CMAKE_SOURCE_DIR}/proton-c/include/proton/cproton.i
+)
include_directories (${RUBY_INCLUDE_PATH})
swig_add_module(cproton-ruby ruby ruby.i)
swig_link_libraries(cproton-ruby ${BINDING_DEPS} ${RUBY_LIBRARY})
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton.rb
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton.rb?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton.rb (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton.rb Sat Sep 6 11:23:10 2014
@@ -20,6 +20,7 @@
require "cproton"
require "date"
+require "qpid_proton/version"
require "qpid_proton/described"
require "qpid_proton/mapping"
require "qpid_proton/array"
Added: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/version.rb
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/version.rb?rev=1622849&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/version.rb (added)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/version.rb Sat Sep 6 11:23:10 2014
@@ -0,0 +1,29 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+module Qpid
+
+ module Proton
+
+ PN_VERSION_MAJOR = Cproton::PN_VERSION_MAJOR
+ PN_VERSION_MINOR = Cproton::PN_VERSION_MINOR
+
+ end
+
+end
Propchange: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/version.rb
------------------------------------------------------------------------------
svn:eol-style = native
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/qpid_proton.gemspec
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/qpid_proton.gemspec?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/qpid_proton.gemspec (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/qpid_proton.gemspec Sat Sep 6 11:23:10 2014
@@ -8,6 +8,7 @@ system "swig -ruby -I../../include -o ex
Gem::Specification.new do |s|
s.name = "qpid_proton"
s.version = "0.3"
+ s.licenses = ['Apache-2.0']
s.platform = Gem::Platform::RUBY
s.authors = ["Darryl L. Pierce"]
s.email = ["proton@qpid.apache.org"]
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/ruby.i
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/ruby.i?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/ruby.i (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/ruby.i Sat Sep 6 11:23:10 2014
@@ -344,5 +344,4 @@ bool pn_ssl_get_cipher_name(pn_ssl_t *ss
bool pn_ssl_get_protocol_name(pn_ssl_t *ssl, char *OUTPUT, size_t MAX_OUTPUT_SIZE);
%ignore pn_ssl_get_protocol_name;
-
%include "proton/cproton.i"
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/docs/man/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/docs/man/CMakeLists.txt?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/docs/man/CMakeLists.txt (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/docs/man/CMakeLists.txt Sat Sep 6 11:23:10 2014
@@ -17,6 +17,6 @@
# under the License.
#
-INSTALL (FILES proton.1
+INSTALL (FILES proton.1 proton-dump.1
DESTINATION ${MAN_INSTALL_DIR}/man1)
Added: qpid/proton/branches/fadams-javascript-binding/proton-c/docs/man/proton-dump.1
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/docs/man/proton-dump.1?rev=1622849&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/docs/man/proton-dump.1 (added)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/docs/man/proton-dump.1 Sat Sep 6 11:23:10 2014
@@ -0,0 +1,19 @@
+.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.44.1.
+.TH USAGE: "1" "August 2014" "Usage: proton-dump [FILE1] [FILEn] ..." "User Commands"
+.SH NAME
+proton-dump - display the contents of an AMQP dump file containing frame data
+.SH SYNOPSIS
+.B proton-dump
+[\fIFILE1\fR] [\fIFILEn\fR] ...
+.SH DESCRIPTION
+Displays the content of an AMQP dump file containing frame data.
+.TP
+[FILEn]
+Dump file to be displayed.
+.PP
+Displays the content of an AMQP dump file containing frame data.
+.TP
+[FILEn]
+Dump file to be displayed.
+.SH "SEE ALSO"
+proton(1)
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/buffer.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/buffer.h?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/buffer.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/buffer.h Sat Sep 6 11:23:10 2014
@@ -29,6 +29,11 @@
extern "C" {
#endif
+typedef struct {
+ size_t size;
+ char *start;
+} pn_buffer_memory_t;
+
typedef struct pn_buffer_t pn_buffer_t;
PN_EXTERN pn_buffer_t *pn_buffer(size_t capacity);
@@ -44,6 +49,7 @@ PN_EXTERN int pn_buffer_trim(pn_buffer_t
PN_EXTERN void pn_buffer_clear(pn_buffer_t *buf);
PN_EXTERN int pn_buffer_defrag(pn_buffer_t *buf);
PN_EXTERN pn_bytes_t pn_buffer_bytes(pn_buffer_t *buf);
+PN_EXTERN pn_buffer_memory_t pn_buffer_memory(pn_buffer_t *buf);
PN_EXTERN int pn_buffer_print(pn_buffer_t *buf);
#ifdef __cplusplus
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/cproton.i
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/cproton.i?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/cproton.i (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/cproton.i Sat Sep 6 11:23:10 2014
@@ -30,6 +30,26 @@ typedef long long int int64_t;
/* Parse these interface header files to generate APIs for script languages */
%include "proton/import_export.h"
+
+%ignore _PROTON_VERSION_H;
+%include "proton/version.h"
+
+/* We cannot safely just wrap pn_bytes_t but each language binding must have a typemap for it - presumably to a string type */
+%ignore pn_bytes_t;
+
+/* There is no need to wrap pn_class_t aa it is an internal implementation detail and cannot be used outside the library */
+%ignore pn_class_t;
+
+/* Ignore C APIs related to pn_atom_t - they can all be achieved with pn_data_t */
+%ignore pn_atom_t;
+%ignore pn_atom_t_u; /* Seem to need this even though its nested in pn_atom_t */
+%ignore pn_data_get_atom;
+%ignore pn_data_put_atom;
+
+%ignore pn_delivery_tag_t;
+%ignore pn_decimal128_t;
+%ignore pn_uuid_t;
+
%include "proton/types.h"
%ignore pn_string_vformat;
%ignore pn_string_vaddf;
@@ -60,7 +80,7 @@ typedef long long int int64_t;
%aggregate_check(int, check_sasl_outcome,
PN_SASL_NONE, PN_SASL_OK, PN_SASL_AUTH,
- PN_SASL_SYS, PN_SASL_PERM, PN_SASL_TEMP);
+ PN_SASL_SYS, PN_SASL_PERM, PN_SASL_TEMP, PN_SASL_SKIPPED);
%aggregate_check(int, check_sasl_state,
PN_SASL_CONF, PN_SASL_IDLE, PN_SASL_STEP,
@@ -982,6 +1002,12 @@ typedef long long int int64_t;
sasl != NULL;
}
+%contract pn_sasl_allow_skip(pn_sasl_t *sasl, bool allow)
+{
+ require:
+ sasl != NULL;
+}
+
%contract pn_sasl_plain(pn_sasl_t *sasl, const char *username, const char *password)
{
require:
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/event.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/event.h?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/event.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/event.h Sat Sep 6 11:23:10 2014
@@ -81,8 +81,12 @@ typedef struct pn_event_t pn_event_t;
*/
typedef enum {
PN_EVENT_CATEGORY_NONE = 0,
- PN_EVENT_CATEGORY_PROTOCOL = 0x00010000,
- PN_EVENT_CATEGORY_COUNT = 2
+ PN_EVENT_CATEGORY_CONNECTION = 0x00010000,
+ PN_EVENT_CATEGORY_SESSION = 0x00020000,
+ PN_EVENT_CATEGORY_LINK = 0x00030000,
+ PN_EVENT_CATEGORY_DELIVERY = 0x00040000,
+ PN_EVENT_CATEGORY_TRANSPORT = 0x00050000,
+ PN_EVENT_CATEGORY_COUNT = 6
} pn_event_category_t;
/**
@@ -94,45 +98,137 @@ typedef enum {
* ever be generated.
*/
PN_EVENT_NONE = 0,
+
+ /**
+ * The connection has been created. This is the first event that
+ * will ever be issued for a connection. Events of this type point
+ * to the relevant connection.
+ */
+ PN_CONNECTION_INIT = PN_EVENT_CATEGORY_CONNECTION + 1,
+
+ /**
+ * The local connection endpoint has been closed. Events of this
+ * type point to the relevant connection.
+ */
+ PN_CONNECTION_OPEN = PN_EVENT_CATEGORY_CONNECTION + 2,
+
+ /**
+ * The remote endpoint has opened the connection. Events of this
+ * type point to the relevant connection.
+ */
+ PN_CONNECTION_REMOTE_OPEN = PN_EVENT_CATEGORY_CONNECTION + 3,
+
+ /**
+ * The local connection endpoint has been closed. Events of this
+ * type point to the relevant connection.
+ */
+ PN_CONNECTION_CLOSE = PN_EVENT_CATEGORY_CONNECTION + 4,
+
+ /**
+ * The remote endpoint has closed the connection. Events of this
+ * type point to the relevant connection.
+ */
+ PN_CONNECTION_REMOTE_CLOSE = PN_EVENT_CATEGORY_CONNECTION + 5,
+
+ /**
+ * The connection has been freed and any outstanding processing has
+ * been completed. This is the final event that will ever be issued
+ * for a connection.
+ */
+ PN_CONNECTION_FINAL = PN_EVENT_CATEGORY_CONNECTION + 6,
+
/**
- * The endpoint state flags for a connection have changed. Events of
- * this type point to the relevant connection as well as its
- * associated transport.
- */
- PN_CONNECTION_REMOTE_STATE = PN_EVENT_CATEGORY_PROTOCOL+1,
- PN_CONNECTION_LOCAL_STATE = PN_EVENT_CATEGORY_PROTOCOL+2,
- /**
- * The endpoint state flags for a session have changed. Events of
- * this type point to the relevant session as well as its associated
- * connection and transport.
- */
- PN_SESSION_REMOTE_STATE = PN_EVENT_CATEGORY_PROTOCOL+3,
- PN_SESSION_LOCAL_STATE = PN_EVENT_CATEGORY_PROTOCOL+4,
- /**
- * The endpoint state flags for a link have changed. Events of this
- * type point to the relevant link as well as its associated
- * session, connection, and transport.
+ * The session has been created. This is the first event that will
+ * ever be issued for a session.
*/
- PN_LINK_REMOTE_STATE = PN_EVENT_CATEGORY_PROTOCOL+5,
- PN_LINK_LOCAL_STATE = PN_EVENT_CATEGORY_PROTOCOL+6,
+ PN_SESSION_INIT = PN_EVENT_CATEGORY_SESSION + 1,
+
+ /**
+ * The local session endpoint has been opened. Events of this type
+ * point ot the relevant session.
+ */
+ PN_SESSION_OPEN = PN_EVENT_CATEGORY_SESSION + 2,
+
+ /**
+ * The remote endpoint has opened the session. Events of this type
+ * point to the relevant session.
+ */
+ PN_SESSION_REMOTE_OPEN = PN_EVENT_CATEGORY_SESSION + 3,
+
+ /**
+ * The local session endpoint has been closed. Events of this type
+ * point ot the relevant session.
+ */
+ PN_SESSION_CLOSE = PN_EVENT_CATEGORY_SESSION + 4,
+
+ /**
+ * The remote endpoint has closed the session. Events of this type
+ * point to the relevant session.
+ */
+ PN_SESSION_REMOTE_CLOSE = PN_EVENT_CATEGORY_SESSION + 5,
+
+ /**
+ * The session has been freed and any outstanding processing has
+ * been completed. This is the final event that will ever be issued
+ * for a session.
+ */
+ PN_SESSION_FINAL = PN_EVENT_CATEGORY_SESSION + 6,
+
+ /**
+ * The link has been created. This is the first event that will ever
+ * be issued for a link.
+ */
+ PN_LINK_INIT = PN_EVENT_CATEGORY_LINK + 1,
+
+ /**
+ * The local link endpoint has been opened. Events of this type
+ * point ot the relevant link.
+ */
+ PN_LINK_OPEN = PN_EVENT_CATEGORY_LINK + 2,
+
+ /**
+ * The remote endpoint has opened the link. Events of this type
+ * point to the relevant link.
+ */
+ PN_LINK_REMOTE_OPEN = PN_EVENT_CATEGORY_LINK + 3,
+
+ /**
+ * The local link endpoint has been closed. Events of this type
+ * point ot the relevant link.
+ */
+ PN_LINK_CLOSE = PN_EVENT_CATEGORY_LINK + 4,
+
+ /**
+ * The remote endpoint has closed the link. Events of this type
+ * point to the relevant link.
+ */
+ PN_LINK_REMOTE_CLOSE = PN_EVENT_CATEGORY_LINK + 5,
+
/**
* The flow control state for a link has changed. Events of this
- * type point to the relevant link along with its associated
- * session, connection, and transport.
+ * type point to the relevant link.
+ */
+ PN_LINK_FLOW = PN_EVENT_CATEGORY_LINK + 6,
+
+ /**
+ * The link has been freed and any outstanding processing has been
+ * completed. This is the final event that will ever be issued for a
+ * link. Events of this type point to the relevant link.
*/
- PN_LINK_FLOW = PN_EVENT_CATEGORY_PROTOCOL+7,
+ PN_LINK_FINAL = PN_EVENT_CATEGORY_LINK + 7,
+
/**
* A delivery has been created or updated. Events of this type point
- * to the relevant delivery as well as its associated link, session,
- * connection, and transport.
+ * to the relevant delivery.
*/
- PN_DELIVERY = PN_EVENT_CATEGORY_PROTOCOL+8,
+ PN_DELIVERY = PN_EVENT_CATEGORY_DELIVERY + 1,
+
/**
* The transport has new data to read and/or write. Events of this
- * type point to the relevant transport as well as its associated
- * connection.
+ * type point to the relevant transport.
*/
- PN_TRANSPORT = PN_EVENT_CATEGORY_PROTOCOL+9
+ PN_TRANSPORT = PN_EVENT_CATEGORY_TRANSPORT + 1
+
} pn_event_type_t;
/**
@@ -198,6 +294,11 @@ PN_EXTERN pn_event_type_t pn_event_type(
PN_EXTERN pn_event_category_t pn_event_category(pn_event_t *event);
/**
+ * Get the context associated with an event.
+ */
+PN_EXTERN void *pn_event_context(pn_event_t *event);
+
+/**
* Get the connection associated with an event.
*
* @param[in] event an event object
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/io.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/io.h?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/io.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/io.h Sat Sep 6 11:23:10 2014
@@ -44,6 +44,7 @@ typedef int pn_socket_t;
#endif
typedef struct pn_io_t pn_io_t;
+typedef struct pn_selector_t pn_selector_t;
PN_EXTERN pn_io_t *pn_io(void);
PN_EXTERN void pn_io_free(pn_io_t *io);
@@ -58,6 +59,7 @@ PN_EXTERN int pn_pipe(pn_io_t *io, pn_so
PN_EXTERN ssize_t pn_read(pn_io_t *io, pn_socket_t socket, void *buf, size_t size);
PN_EXTERN ssize_t pn_write(pn_io_t *io, pn_socket_t socket, const void *buf, size_t size);
PN_EXTERN bool pn_wouldblock(pn_io_t *io);
+PN_EXTERN pn_selector_t *pn_io_selector(pn_io_t *io);
#ifdef __cplusplus
}
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/object.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/object.h?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/object.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/object.h Sat Sep 6 11:23:10 2014
@@ -43,6 +43,7 @@ typedef void *(*pn_iterator_next_t)(void
typedef struct pn_iterator_t pn_iterator_t;
typedef struct {
+ const char *name;
void (*initialize)(void *);
void (*finalize)(void *);
uintptr_t (*hashcode)(void *);
@@ -51,6 +52,7 @@ typedef struct {
} pn_class_t;
#define PN_CLASS(PREFIX) { \
+ #PREFIX, \
PREFIX ## _initialize, \
PREFIX ## _finalize, \
PREFIX ## _hashcode, \
@@ -58,14 +60,17 @@ typedef struct {
PREFIX ## _inspect \
}
-PN_EXTERN void *pn_new(size_t size, pn_class_t *clazz);
-PN_EXTERN void pn_initialize(void *object, pn_class_t *clazz);
+PN_EXTERN void *pn_new(size_t size, const pn_class_t* clazz);
+PN_EXTERN void *pn_new2(size_t size, const pn_class_t* clazz, void *from);
+PN_EXTERN void pn_initialize(void *object, const pn_class_t *clazz);
PN_EXTERN void *pn_incref(void *object);
+PN_EXTERN void *pn_incref2(void *object, void *from);
PN_EXTERN void pn_decref(void *object);
+PN_EXTERN void pn_decref2(void *object, void *from);
PN_EXTERN int pn_refcount(void *object);
PN_EXTERN void pn_finalize(void *object);
PN_EXTERN void pn_free(void *object);
-PN_EXTERN pn_class_t *pn_class(void *object);
+PN_EXTERN const pn_class_t *pn_class(void* object);
PN_EXTERN uintptr_t pn_hashcode(void *object);
PN_EXTERN intptr_t pn_compare(void *a, void *b);
PN_EXTERN bool pn_equals(void *a, void *b);
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/sasl.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/sasl.h?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/sasl.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/sasl.h Sat Sep 6 11:23:10 2014
@@ -54,7 +54,8 @@ typedef enum {
PN_SASL_AUTH=1, /** failed due to bad credentials */
PN_SASL_SYS=2, /** failed due to a system error */
PN_SASL_PERM=3, /** failed due to unrecoverable error */
- PN_SASL_TEMP=4 /** failed due to transient error */
+ PN_SASL_TEMP=4, /** failed due to transient error */
+ PN_SASL_SKIPPED=5 /** the peer didn't perform the sasl exchange */
} pn_sasl_outcome_t;
/** The state of the SASL negotiation process */
@@ -113,6 +114,18 @@ PN_EXTERN void pn_sasl_client(pn_sasl_t
*/
PN_EXTERN void pn_sasl_server(pn_sasl_t *sasl);
+/** Configure a SASL server layer to permit the client to skip the SASL exchange.
+ *
+ * If the peer client skips the SASL exchange (i.e. goes right to the AMQP header)
+ * this server layer will succeed and result in the outcome of PN_SASL_SKIPPED.
+ * The default behavior is to fail and close the connection if the client skips
+ * SASL.
+ *
+ * @param[in] sasl the SASL layer to configure
+ * @param[in] allow true -> allow skip; false -> forbid skip
+ */
+ PN_EXTERN void pn_sasl_allow_skip(pn_sasl_t *sasl, bool allow);
+
/** Configure the SASL layer to use the "PLAIN" mechanism.
*
* A utility function to configure a simple client SASL layer using
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/selector.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/selector.h?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/selector.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/selector.h Sat Sep 6 11:23:10 2014
@@ -34,9 +34,7 @@ extern "C" {
#define PN_WRITABLE (2)
#define PN_EXPIRED (4)
-typedef struct pn_selector_t pn_selector_t;
-
-PN_EXTERN pn_selector_t *pn_selector(void);
+pn_selector_t *pni_selector(void);
PN_EXTERN void pn_selector_free(pn_selector_t *selector);
PN_EXTERN void pn_selector_add(pn_selector_t *selector, pn_selectable_t *selectable);
PN_EXTERN void pn_selector_update(pn_selector_t *selector, pn_selectable_t *selectable);
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/terminus.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/terminus.h?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/terminus.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/terminus.h Sat Sep 6 11:23:10 2014
@@ -90,10 +90,10 @@ typedef enum {
* counting down.
*/
typedef enum {
- PN_LINK_CLOSE, /**< the terminus is orphaned when the parent link is closed */
- PN_SESSION_CLOSE, /**< the terminus is orphaned when the parent session is closed */
- PN_CONNECTION_CLOSE, /**< the terminus is orphaned when the parent connection is closed */
- PN_NEVER /**< the terminus is never considered orphaned */
+ PN_EXPIRE_WITH_LINK, /**< the terminus is orphaned when the parent link is closed */
+ PN_EXPIRE_WITH_SESSION, /**< the terminus is orphaned when the parent session is closed */
+ PN_EXPIRE_WITH_CONNECTION, /**< the terminus is orphaned when the parent connection is closed */
+ PN_EXPIRE_NEVER /**< the terminus is never considered orphaned */
} pn_expiry_policy_t;
/**
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/transport.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/transport.h?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/transport.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/transport.h Sat Sep 6 11:23:10 2014
@@ -328,16 +328,17 @@ PN_EXTERN char *pn_transport_tail(pn_tra
*
* This is equivalent to copying @c size bytes afther the tail pointer
* and then calling ::pn_transport_process with an argument of @c
- * size. It is an error to call this with a @c size larger than the
- * capacity reported by ::pn_transport_capacity.
+ * size. Only some of the bytes will be copied if there is
+ * insufficienty capacity available. Use ::pn_transport_capacity to
+ * determine how much capacity the transport has.
*
* @param[in] transport the transport
* @param[in] src the start of the data to push into the transport
* @param[in] size the amount of data to push into the transport
*
- * @return 0 on success, or error code if < 0
+ * @return the number of bytes pushed on success, or error code if < 0
*/
-PN_EXTERN int pn_transport_push(pn_transport_t *transport, const char *src, size_t size);
+PN_EXTERN ssize_t pn_transport_push(pn_transport_t *transport, const char *src, size_t size);
/**
* Process input data following the tail pointer.
@@ -404,9 +405,9 @@ PN_EXTERN const char *pn_transport_head(
* @param[in] transport the transport
* @param[out] dst the destination buffer
* @param[in] size the capacity of the destination buffer
- * @return 0 on success, or error code if < 0
+ * @return number of bytes copied on success, or error code if < 0
*/
-PN_EXTERN int pn_transport_peek(pn_transport_t *transport, char *dst, size_t size);
+PN_EXTERN ssize_t pn_transport_peek(pn_transport_t *transport, char *dst, size_t size);
/**
* Removes @c size bytes of output from the pending output queue
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/types.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/types.h?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/types.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/types.h Sat Sep 6 11:23:10 2014
@@ -23,6 +23,7 @@
*/
#include <proton/import_export.h>
+#include <stddef.h>
#include <sys/types.h>
#include <proton/type_compat.h>
@@ -58,11 +59,10 @@ typedef struct {
typedef struct {
size_t size;
- char *start;
+ const char *start;
} pn_bytes_t;
-PN_EXTERN pn_bytes_t pn_bytes(size_t size, char *start);
-PN_EXTERN pn_bytes_t pn_bytes_dup(size_t size, const char *start);
+PN_EXTERN pn_bytes_t pn_bytes(size_t size, const char *start);
/** @}
*/
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/src/buffer.c
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/src/buffer.c?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/src/buffer.c (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/src/buffer.c Sat Sep 6 11:23:10 2014
@@ -273,6 +273,18 @@ pn_bytes_t pn_buffer_bytes(pn_buffer_t *
}
}
+pn_buffer_memory_t pn_buffer_memory(pn_buffer_t *buf)
+{
+ if (buf) {
+ pn_buffer_defrag(buf);
+ pn_buffer_memory_t r = {buf->size, buf->bytes};
+ return r;
+ } else {
+ pn_buffer_memory_t r = {0, NULL};
+ return r;
+ }
+}
+
int pn_buffer_print(pn_buffer_t *buf)
{
printf("pn_buffer(\"");
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/codec.c
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/codec.c?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/codec.c (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/codec.c Sat Sep 6 11:23:10 2014
@@ -92,7 +92,7 @@ static void pn_data_finalize(void *objec
pn_free(data->encoder);
}
-static pn_fields_t *pni_node_fields(pn_data_t *data, pni_node_t *node)
+static const pn_fields_t *pni_node_fields(pn_data_t *data, pni_node_t *node)
{
if (!node) return NULL;
if (node->atom.type != PN_DESCRIBED) return NULL;
@@ -103,8 +103,9 @@ static pn_fields_t *pni_node_fields(pn_d
return NULL;
}
- if (descriptor->atom.u.as_ulong < 256) {
- return &FIELDS[descriptor->atom.u.as_ulong];
+ if (descriptor->atom.u.as_ulong >= FIELD_MIN && descriptor->atom.u.as_ulong <= FIELD_MAX) {
+ const pn_fields_t *f = &FIELDS[descriptor->atom.u.as_ulong-FIELD_MIN];
+ return (f->name_index!=0) ? f : NULL;
} else {
return NULL;
}
@@ -233,9 +234,16 @@ int pni_inspect_atom(pn_atom_t *atom, pn
if (quote) if ((err = pn_string_addf(str, "\""))) return err;
return 0;
}
+ case PN_LIST:
+ return pn_string_addf(str, "<list>");
+ case PN_MAP:
+ return pn_string_addf(str, "<map>");
+ case PN_ARRAY:
+ return pn_string_addf(str, "<array>");
+ case PN_DESCRIBED:
+ return pn_string_addf(str, "<described>");
default:
- assert(false);
- return PN_ERR;
+ return pn_string_addf(str, "<undefined: %i>", atom->type);
}
}
@@ -245,9 +253,9 @@ int pni_inspect_enter(void *ctx, pn_data
pn_atom_t *atom = (pn_atom_t *) &node->atom;
pni_node_t *parent = pn_data_node(data, node->parent);
- pn_fields_t *fields = pni_node_fields(data, parent);
+ const pn_fields_t *fields = pni_node_fields(data, parent);
pni_node_t *grandparent = parent ? pn_data_node(data, parent->parent) : NULL;
- pn_fields_t *grandfields = pni_node_fields(data, grandparent);
+ const pn_fields_t *grandfields = pni_node_fields(data, grandparent);
int index = pni_node_index(data, node);
int err;
@@ -256,7 +264,9 @@ int pni_inspect_enter(void *ctx, pn_data
if (atom->type == PN_NULL) {
return 0;
}
- const char *name = grandfields->fields[index];
+ const char *name = (index < grandfields->field_count)
+ ? FIELD_STRINGPOOL+FIELD_FIELDS[grandfields->first_field_index+index]
+ : NULL;
if (name) {
err = pn_string_addf(str, "%s=", name);
if (err) return err;
@@ -275,7 +285,7 @@ int pni_inspect_enter(void *ctx, pn_data
return pn_string_addf(str, "{");
default:
if (fields && index == 0) {
- err = pn_string_addf(str, "%s", fields->name);
+ err = pn_string_addf(str, "%s", FIELD_STRINGPOOL+FIELD_NAME[fields->name_index]);
if (err) return err;
err = pn_string_addf(str, "(");
if (err) return err;
@@ -305,7 +315,7 @@ int pni_inspect_exit(void *ctx, pn_data_
pn_string_t *str = (pn_string_t *) ctx;
pni_node_t *parent = pn_data_node(data, node->parent);
pni_node_t *grandparent = parent ? pn_data_node(data, parent->parent) : NULL;
- pn_fields_t *grandfields = pni_node_fields(data, grandparent);
+ const pn_fields_t *grandfields = pni_node_fields(data, grandparent);
pni_node_t *next = pn_data_node(data, node->next);
int err;
@@ -356,7 +366,7 @@ static int pn_data_inspect(void *obj, pn
pn_data_t *pn_data(size_t capacity)
{
- static pn_class_t clazz = PN_CLASS(pn_data);
+ static const pn_class_t clazz = PN_CLASS(pn_data);
pn_data_t *data = (pn_data_t *) pn_new(sizeof(pn_data_t), &clazz);
data->capacity = capacity;
data->size = 0;
@@ -407,12 +417,12 @@ void pn_data_clear(pn_data_t *data)
int pn_data_grow(pn_data_t *data)
{
- data->capacity = 2*(data->capacity ? data->capacity : 16);
+ data->capacity = 2*(data->capacity ? data->capacity : 2);
data->nodes = (pni_node_t *) realloc(data->nodes, data->capacity * sizeof(pni_node_t));
return 0;
}
-ssize_t pn_data_intern(pn_data_t *data, char *start, size_t size)
+ssize_t pn_data_intern(pn_data_t *data, const char *start, size_t size)
{
size_t offset = pn_buffer_size(data->buf);
int err = pn_buffer_append(data->buf, start, size);
@@ -454,7 +464,7 @@ int pn_data_intern_node(pn_data_t *data,
node->data = true;
node->data_offset = offset;
node->data_size = bytes->size;
- pn_bytes_t buf = pn_buffer_bytes(data->buf);
+ pn_buffer_memory_t buf = pn_buffer_memory(data->buf);
bytes->start = buf.start + offset;
if (pn_buffer_capacity(data->buf) != oldcap) {
@@ -1102,7 +1112,7 @@ int pn_data_resize(pn_data_t *data, size
}
-pni_node_t *pn_data_node(pn_data_t *data, size_t nd)
+pni_node_t *pn_data_node(pn_data_t *data, pni_nid_t nd)
{
if (nd) {
return &data->nodes[nd - 1];
@@ -1348,7 +1358,7 @@ bool pn_data_lookup(pn_data_t *data, con
void pn_data_dump(pn_data_t *data)
{
- printf("{current=%" PN_ZI ", parent=%" PN_ZI "}\n", data->current, data->parent);
+ printf("{current=%" PN_ZI ", parent=%" PN_ZI "}\n", (size_t) data->current, (size_t) data->parent);
for (unsigned i = 0; i < data->size; i++)
{
pni_node_t *node = &data->nodes[i];
@@ -1356,7 +1366,11 @@ void pn_data_dump(pn_data_t *data)
pni_inspect_atom((pn_atom_t *) &node->atom, data->str);
printf("Node %i: prev=%" PN_ZI ", next=%" PN_ZI ", parent=%" PN_ZI ", down=%" PN_ZI
", children=%" PN_ZI ", type=%s (%s)\n",
- i + 1, node->prev, node->next, node->parent, node->down, node->children,
+ i + 1, (size_t) node->prev,
+ (size_t) node->next,
+ (size_t) node->parent,
+ (size_t) node->down,
+ (size_t) node->children,
pn_type_name(node->atom.type), pn_string_get(data->str));
}
}
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/data.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/data.h?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/data.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/data.h Sat Sep 6 11:23:10 2014
@@ -27,39 +27,41 @@
#include "decoder.h"
#include "encoder.h"
+typedef uint16_t pni_nid_t;
+
typedef struct {
- size_t next;
- size_t prev;
- size_t down;
- size_t parent;
- size_t children;
+ char *start;
+ size_t data_offset;
+ size_t data_size;
pn_atom_t atom;
+ pn_type_t type;
+ pni_nid_t next;
+ pni_nid_t prev;
+ pni_nid_t down;
+ pni_nid_t parent;
+ pni_nid_t children;
// for arrays
bool described;
- pn_type_t type;
bool data;
- size_t data_offset;
- size_t data_size;
- char *start;
bool small;
} pni_node_t;
struct pn_data_t {
- size_t capacity;
- size_t size;
pni_node_t *nodes;
pn_buffer_t *buf;
- size_t parent;
- size_t current;
- size_t base_parent;
- size_t base_current;
pn_decoder_t *decoder;
pn_encoder_t *encoder;
pn_error_t *error;
pn_string_t *str;
+ pni_nid_t capacity;
+ pni_nid_t size;
+ pni_nid_t parent;
+ pni_nid_t current;
+ pni_nid_t base_parent;
+ pni_nid_t base_current;
};
-pni_node_t *pn_data_node(pn_data_t *data, size_t nd);
+pni_node_t *pn_data_node(pn_data_t *data, pni_nid_t nd);
int pni_data_traverse(pn_data_t *data,
int (*enter)(void *ctx, pn_data_t *data, pni_node_t *node),
int (*exit)(void *ctx, pn_data_t *data, pni_node_t *node),
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/decoder.c
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/decoder.c?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/decoder.c (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/decoder.c Sat Sep 6 11:23:10 2014
@@ -54,7 +54,7 @@ static void pn_decoder_finalize(void *ob
pn_decoder_t *pn_decoder()
{
- static pn_class_t clazz = PN_CLASS(pn_decoder);
+ static const pn_class_t clazz = PN_CLASS(pn_decoder);
return (pn_decoder_t *) pn_new(sizeof(pn_decoder_t), &clazz);
}
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/encoder.c
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/encoder.c?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/encoder.c (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/encoder.c Sat Sep 6 11:23:10 2014
@@ -56,7 +56,7 @@ static void pn_encoder_finalize(void *ob
pn_encoder_t *pn_encoder()
{
- static pn_class_t clazz = PN_CLASS(pn_encoder);
+ static const pn_class_t clazz = PN_CLASS(pn_encoder);
return (pn_encoder_t *) pn_new(sizeof(pn_encoder_t), &clazz);
}
Added: qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatch_actions.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatch_actions.h?rev=1622849&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatch_actions.h (added)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatch_actions.h Sat Sep 6 11:23:10 2014
@@ -0,0 +1,45 @@
+#ifndef _PROTON_DISPATCH_ACTIONS_H
+#define _PROTON_DISPATCH_ACTIONS_H 1
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "dispatcher/dispatcher.h"
+
+/* Transport actions */
+int pn_do_open(pn_dispatcher_t *disp);
+int pn_do_begin(pn_dispatcher_t *disp);
+int pn_do_attach(pn_dispatcher_t *disp);
+int pn_do_transfer(pn_dispatcher_t *disp);
+int pn_do_flow(pn_dispatcher_t *disp);
+int pn_do_disposition(pn_dispatcher_t *disp);
+int pn_do_detach(pn_dispatcher_t *disp);
+int pn_do_end(pn_dispatcher_t *disp);
+int pn_do_close(pn_dispatcher_t *disp);
+
+/* SASL actions */
+int pn_do_init(pn_dispatcher_t *disp);
+int pn_do_mechanisms(pn_dispatcher_t *disp);
+int pn_do_challenge(pn_dispatcher_t *disp);
+int pn_do_response(pn_dispatcher_t *disp);
+int pn_do_outcome(pn_dispatcher_t *disp);
+
+#endif // _PROTON_DISPATCH_ACTIONS_H
Propchange: qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatch_actions.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatch_actions.h
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatcher/dispatcher.c
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatcher/dispatcher.c?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatcher/dispatcher.c (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatcher/dispatcher.c Sat Sep 6 11:23:10 2014
@@ -30,6 +30,41 @@
#include "../util.h"
#include "../platform_fmt.h"
+#include "dispatch_actions.h"
+
+int pni_bad_frame(pn_dispatcher_t* disp) {
+ pn_transport_log(disp->transport, "Error dispatching frame: Unknown performative");
+ return PN_ERR;
+}
+
+// We could use a table based approach here if we needed to dynamically
+// add new performatives
+static inline int pni_dispatch_action(pn_dispatcher_t* disp, uint64_t lcode)
+{
+ pn_action_t *action;
+ switch (lcode) {
+ /* Regular AMQP fames */
+ case OPEN: action = pn_do_open; break;
+ case BEGIN: action = pn_do_begin; break;
+ case ATTACH: action = pn_do_attach; break;
+ case FLOW: action = pn_do_flow; break;
+ case TRANSFER: action = pn_do_transfer; break;
+ case DISPOSITION: action = pn_do_disposition; break;
+ case DETACH: action = pn_do_detach; break;
+ case END: action = pn_do_end; break;
+ case CLOSE: action = pn_do_close; break;
+
+ /* SASL frames */
+ case SASL_MECHANISMS: action = pn_do_mechanisms; break;
+ case SASL_INIT: action = pn_do_init; break;
+ case SASL_CHALLENGE: action = pn_do_challenge; break;
+ case SASL_RESPONSE: action = pn_do_response; break;
+ case SASL_OUTCOME: action = pn_do_outcome; break;
+ default: action = pni_bad_frame; break;
+ };
+ return action(disp);
+}
+
pn_dispatcher_t *pn_dispatcher(uint8_t frame_type, pn_transport_t *transport)
{
pn_dispatcher_t *disp = (pn_dispatcher_t *) calloc(sizeof(pn_dispatcher_t), 1);
@@ -40,11 +75,7 @@ pn_dispatcher_t *pn_dispatcher(uint8_t f
(pn_env_bool("PN_TRACE_FRM") ? PN_TRACE_FRM : PN_TRACE_OFF) |
(pn_env_bool("PN_TRACE_DRV") ? PN_TRACE_DRV : PN_TRACE_OFF);
- disp->input = pn_buffer(1024);
- disp->fragment = 0;
-
disp->channel = 0;
- disp->code = 0;
disp->args = pn_data(16);
disp->payload = NULL;
disp->size = 0;
@@ -67,7 +98,6 @@ pn_dispatcher_t *pn_dispatcher(uint8_t f
void pn_dispatcher_free(pn_dispatcher_t *disp)
{
if (disp) {
- pn_buffer_free(disp->input);
pn_data_free(disp->args);
pn_data_free(disp->output_args);
pn_buffer_free(disp->frame);
@@ -77,12 +107,6 @@ void pn_dispatcher_free(pn_dispatcher_t
}
}
-void pn_dispatcher_action(pn_dispatcher_t *disp, uint8_t code,
- pn_action_t *action)
-{
- disp->actions[code] = action;
-}
-
typedef enum {IN, OUT} pn_dir_t;
static void pn_do_trace(pn_dispatcher_t *disp, uint16_t ch, pn_dir_t dir,
@@ -92,6 +116,10 @@ static void pn_do_trace(pn_dispatcher_t
pn_string_format(disp->scratch, "%u %s ", ch, dir == OUT ? "->" : "<-");
pn_inspect(args, disp->scratch);
+ if (pn_data_size(args)==0) {
+ pn_string_addf(disp->scratch, "(EMPTY FRAME)");
+ }
+
if (size) {
char buf[1024];
int e = pn_quote_data(buf, 1024, payload, size);
@@ -122,7 +150,8 @@ int pn_dispatch_frame(pn_dispatcher_t *d
}
disp->channel = frame.channel;
- // XXX: assuming numeric
+ // XXX: assuming numeric -
+ // if we get a symbol we should map it to the numeric value and dispatch on that
uint64_t lcode;
bool scanned;
int e = pn_data_scan(disp->args, "D?L.", &scanned, &lcode);
@@ -134,19 +163,15 @@ int pn_dispatch_frame(pn_dispatcher_t *d
pn_transport_log(disp->transport, "Error dispatching frame");
return PN_ERR;
}
- uint8_t code = lcode;
- disp->code = code;
disp->size = frame.size - dsize;
if (disp->size)
disp->payload = frame.payload + dsize;
pn_do_trace(disp, disp->channel, IN, disp->args, disp->payload, disp->size);
- pn_action_t *action = disp->actions[code];
- int err = action(disp);
+ int err = pni_dispatch_action(disp, lcode);
disp->channel = 0;
- disp->code = 0;
pn_data_clear(disp->args);
disp->size = 0;
disp->payload = NULL;
@@ -212,7 +237,7 @@ int pn_post_frame(pn_dispatcher_t *disp,
encode_performatives:
pn_buffer_clear( disp->frame );
- pn_bytes_t buf = pn_buffer_bytes( disp->frame );
+ pn_buffer_memory_t buf = pn_buffer_memory( disp->frame );
buf.size = pn_buffer_available( disp->frame );
ssize_t wr = pn_data_encode( disp->output_args, buf.start, buf.size );
@@ -290,7 +315,7 @@ int pn_post_transfer_frame(pn_dispatcher
encode_performatives:
pn_buffer_clear( disp->frame );
- pn_bytes_t buf = pn_buffer_bytes( disp->frame );
+ pn_buffer_memory_t buf = pn_buffer_memory( disp->frame );
buf.size = pn_buffer_available( disp->frame );
ssize_t wr = pn_data_encode(disp->output_args, buf.start, buf.size);
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatcher/dispatcher.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatcher/dispatcher.h?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatcher/dispatcher.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatcher/dispatcher.h Sat Sep 6 11:23:10 2014
@@ -33,17 +33,7 @@ typedef struct pn_dispatcher_t pn_dispat
typedef int (pn_action_t)(pn_dispatcher_t *disp);
-#define SCRATCH (1024)
-#define CODEC_LIMIT (1024)
-
struct pn_dispatcher_t {
- pn_action_t *actions[256];
- uint8_t frame_type;
- pn_trace_t trace;
- pn_buffer_t *input;
- size_t fragment;
- uint16_t channel;
- uint8_t code;
pn_data_t *args;
const char *payload;
size_t size;
@@ -55,18 +45,19 @@ struct pn_dispatcher_t {
size_t capacity;
size_t available; /* number of raw bytes pending output */
char *output;
- pn_transport_t *transport;
- bool halt;
- bool batch;
+ pn_transport_t *transport; // TODO: We keep this to get access to logging - perhaps move logging
uint64_t output_frames_ct;
uint64_t input_frames_ct;
pn_string_t *scratch;
+ pn_trace_t trace;
+ uint16_t channel;
+ uint8_t frame_type; // Used when constructing outgoing frames
+ bool halt;
+ bool batch;
};
pn_dispatcher_t *pn_dispatcher(uint8_t frame_type, pn_transport_t *transport);
void pn_dispatcher_free(pn_dispatcher_t *disp);
-void pn_dispatcher_action(pn_dispatcher_t *disp, uint8_t code,
- pn_action_t *action);
int pn_scan_args(pn_dispatcher_t *disp, const char *fmt, ...);
void pn_set_payload(pn_dispatcher_t *disp, const char *data, size_t size);
int pn_post_frame(pn_dispatcher_t *disp, uint16_t ch, const char *fmt, ...);
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/src/engine/engine-internal.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/src/engine/engine-internal.h?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/src/engine/engine-internal.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/src/engine/engine-internal.h Sat Sep 6 11:23:10 2014
@@ -51,6 +51,7 @@ struct pn_endpoint_t {
pn_endpoint_t *transport_prev;
bool modified;
bool freed;
+ bool posted_final;
};
typedef struct {
@@ -95,8 +96,6 @@ typedef struct {
bool disp;
} pn_session_state_t;
-#define SCRATCH (1024)
-
#include <proton/sasl.h>
#include <proton/ssl.h>
@@ -111,21 +110,14 @@ typedef struct pn_io_layer_t {
} pn_io_layer_t;
struct pn_transport_t {
- bool freed;
pn_tracer_t tracer;
size_t header_count;
pn_sasl_t *sasl;
pn_ssl_t *ssl;
pn_connection_t *connection; // reference counted
pn_dispatcher_t *disp;
- bool open_sent;
- bool open_rcvd;
- bool close_sent;
- bool close_rcvd;
char *remote_container;
char *remote_hostname;
- uint16_t channel_max;
- uint16_t remote_channel_max;
pn_data_t *remote_offered_capabilities;
pn_data_t *remote_desired_capabilities;
pn_data_t *remote_properties;
@@ -144,15 +136,14 @@ struct pn_transport_t {
/* dead remote detection */
pn_millis_t local_idle_timeout;
+ pn_millis_t remote_idle_timeout;
pn_timestamp_t dead_remote_deadline;
uint64_t last_bytes_input;
/* keepalive */
- pn_millis_t remote_idle_timeout;
pn_timestamp_t keepalive_deadline;
uint64_t last_bytes_output;
- pn_error_t *error;
pn_hash_t *local_channels;
pn_hash_t *remote_channels;
pn_string_t *scratch;
@@ -166,14 +157,23 @@ struct pn_transport_t {
size_t output_pending;
char *output_buf;
+ void *context;
+
/* input from peer */
size_t input_size;
size_t input_pending;
char *input_buf;
+
+ uint16_t channel_max;
+ uint16_t remote_channel_max;
+ bool freed;
+ bool open_sent;
+ bool open_rcvd;
+ bool close_sent;
+ bool close_rcvd;
bool tail_closed; // input stream closed by driver
bool head_closed;
-
- void *context;
+ bool done_processing; // if true, don't call pn_process again
};
struct pn_connection_t {
@@ -211,80 +211,80 @@ struct pn_session_t {
};
struct pn_terminus_t {
- pn_terminus_type_t type;
pn_string_t *address;
- pn_durability_t durability;
- pn_expiry_policy_t expiry_policy;
- pn_seconds_t timeout;
- bool dynamic;
- pn_distribution_mode_t distribution_mode;
pn_data_t *properties;
pn_data_t *capabilities;
pn_data_t *outcomes;
pn_data_t *filter;
+ pn_durability_t durability;
+ pn_expiry_policy_t expiry_policy;
+ pn_seconds_t timeout;
+ pn_terminus_type_t type;
+ pn_distribution_mode_t distribution_mode;
+ bool dynamic;
};
struct pn_link_t {
pn_endpoint_t endpoint;
- pn_string_t *name;
- pn_session_t *session; // reference counted
pn_terminus_t source;
pn_terminus_t target;
pn_terminus_t remote_source;
pn_terminus_t remote_target;
+ pn_link_state_t state;
+ pn_string_t *name;
+ pn_session_t *session; // reference counted
pn_delivery_t *unsettled_head;
pn_delivery_t *unsettled_tail;
pn_delivery_t *current;
pn_delivery_t *settled_head;
pn_delivery_t *settled_tail;
- uint8_t snd_settle_mode;
- uint8_t rcv_settle_mode;
- uint8_t remote_snd_settle_mode;
- uint8_t remote_rcv_settle_mode;
+ void *context;
size_t unsettled_count;
pn_sequence_t available;
pn_sequence_t credit;
pn_sequence_t queued;
+ int drained; // number of drained credits
+ uint8_t snd_settle_mode;
+ uint8_t rcv_settle_mode;
+ uint8_t remote_snd_settle_mode;
+ uint8_t remote_rcv_settle_mode;
bool drain_flag_mode; // receiver only
bool drain;
- int drained; // number of drained credits
- void *context;
- pn_link_state_t state;
};
struct pn_disposition_t {
+ pn_condition_t condition;
uint64_t type;
pn_data_t *data;
pn_data_t *annotations;
- pn_condition_t condition;
- uint32_t section_number;
uint64_t section_offset;
+ uint32_t section_number;
bool failed;
bool undeliverable;
bool settled;
};
struct pn_delivery_t {
- pn_link_t *link; // reference counted
- pn_buffer_t *tag;
pn_disposition_t local;
pn_disposition_t remote;
- bool updated;
- bool settled; // tracks whether we're in the unsettled list or not
+ pn_link_t *link; // reference counted
+ pn_buffer_t *tag;
pn_delivery_t *unsettled_next;
pn_delivery_t *unsettled_prev;
pn_delivery_t *settled_next;
pn_delivery_t *settled_prev;
pn_delivery_t *work_next;
pn_delivery_t *work_prev;
- bool work;
pn_delivery_t *tpwork_next;
pn_delivery_t *tpwork_prev;
- bool tpwork;
+ pn_delivery_state_t state;
pn_buffer_t *bytes;
- bool done;
void *context;
- pn_delivery_state_t state;
+ bool updated;
+ bool settled; // tracks whether we're in the unsettled list or not
+ bool work;
+ bool tpwork;
+ bool done;
};
#define PN_SET_LOCAL(OLD, NEW) \
@@ -310,5 +310,6 @@ void pn_clear_tpwork(pn_delivery_t *deli
void pn_work_update(pn_connection_t *connection, pn_delivery_t *delivery);
void pn_clear_modified(pn_connection_t *connection, pn_endpoint_t *endpoint);
void pn_connection_unbound(pn_connection_t *conn);
+int pn_do_error(pn_transport_t *transport, const char *condition, const char *fmt, ...);
#endif /* engine-internal.h */
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org