http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/php/get_include_dir.php ---------------------------------------------------------------------- diff --git a/proton-c/bindings/php/get_include_dir.php b/proton-c/bindings/php/get_include_dir.php deleted file mode 100644 index 6103e41..0000000 --- a/proton-c/bindings/php/get_include_dir.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php -/* - * - * 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. - * -*/ - - -$prefix = $argv[1]; -$include_path = ini_get("include_path"); - -$php_dir = null; -$pear_dir = null; -$abs_dir = null; - -foreach (explode(PATH_SEPARATOR, $include_path) as $include_dir) { - if (strpos($include_dir, ".") === false && - strpos($include_dir, $prefix) === 0) { - $abs_dir = $include_dir; - $suffix = substr($abs_dir, strlen($prefix)); - if (strpos($suffix, "php") !== false) { - $php_dir = $abs_dir; - } - if (strpos($suffix, "pear") !== false) { - $pear_dir = $abs_dir; - } - } -} - -if ($php_dir) { - print $php_dir; -} else if ($pear_dir) { - print $pear_dir; -} else if ($abs_dir) { - print $abs_dir; -} - -print "\n"; - -?>
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/php/php.i ---------------------------------------------------------------------- diff --git a/proton-c/bindings/php/php.i b/proton-c/bindings/php/php.i deleted file mode 100644 index 6e927f7..0000000 --- a/proton-c/bindings/php/php.i +++ /dev/null @@ -1,229 +0,0 @@ -/* - * 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 - -// provided by SWIG development libraries -%include php.swg - -#if SWIG_VERSION < 0x020000 -%include compat.swg -#endif - -%header %{ -/* Include the headers needed by the code in this wrapper file */ -#include <proton/types.h> -#include <proton/connection.h> -#include <proton/condition.h> -#include <proton/delivery.h> -#include <proton/event.h> -#include <proton/message.h> -#include <proton/messenger.h> -#include <proton/session.h> -#include <proton/url.h> -#include <proton/reactor.h> -#include <proton/handlers.h> -#include <proton/sasl.h> - -#define zend_error_noreturn zend_error -%} - -%apply (char *STRING, int LENGTH) { (char *STRING, size_t LENGTH) }; - -// ssize_t return value -// -%typemap(out) ssize_t { - ZVAL_LONG($result, (long)$1); -} - -// (char **OUTPUT_BUFFER, ssize_t *OUTPUT_LEN) -// -// typemap for binary buffer output arguments. Given an uninitialized pointer for a -// buffer (OUTPUT_BUFFER) and a pointer to an un-initialized size/error (OUTPUT_LEN), a buffer -// will be allocated and filled with binary data. *OUTPUT_BUFFER will be set to the address -// of the allocated buffer. *OUTPUT_LEN will be set to the size of the data. The maximum -// length of the buffer must be provided by a separate argument. -// -// The return value is an array, with [0] set to the length of the output buffer OR an -// error code and [1] set to the returned string object. This value is appended to the -// function's return value (also an array). -// -%typemap(in,numinputs=0) (char **OUTPUT_BUFFER, ssize_t *OUTPUT_LEN) (char *Buff = 0, ssize_t outLen = 0) { - // setup locals for output. - $1 = &Buff; - $2 = &outLen; -} -%typemap(argout,fragment="t_output_helper") (char **OUTPUT_BUFFER, ssize_t *OUTPUT_LEN) { - // convert to array: [0]=len||error, [1]=binary string - zval *tmp; - ALLOC_INIT_ZVAL(tmp); - array_init(tmp); - ssize_t len = *($2); - add_next_index_long(tmp, len); // write the len|error code - if (len >= 0) { - add_next_index_stringl(tmp, *($1), len, 0); // 0 == take ownership of $1 memory - } else { - add_next_index_string(tmp, "", 1); // 1 = strdup the "" - } - t_output_helper(&$result, tmp); // append it to output array -} - -%typemap(in) pn_bytes_t { - if (ZVAL_IS_NULL(*$input)) { - $1.start = NULL; - $1.size = 0; - } else { - $1.start = Z_STRVAL_PP($input); - $1.size = Z_STRLEN_PP($input); - } -} - -%typemap(out) pn_bytes_t { - ZVAL_STRINGL($result, $1.start, $1.size, 1); -} - -%typemap(in) pn_uuid_t { - memmove($1.bytes, Z_STRVAL_PP($input), 16); -} - -%typemap(out) pn_uuid_t { - ZVAL_STRINGL($result, $1.bytes, 16, 1); -} - -%typemap(in) pn_decimal128_t { - memmove($1.bytes, Z_STRVAL_PP($input), 16); -} - -%typemap(out) pn_decimal128_t { - ZVAL_STRINGL($result, $1.bytes, 16, 1); -} - -// The PHP SWIG typedefs define the typemap STRING, LENGTH to be binary safe (allow -// embedded \0's). -// - -// allow pn_link_send/pn_input's input buffer to be binary safe -ssize_t pn_link_send(pn_link_t *transport, char *STRING, size_t LENGTH); -%ignore pn_link_send; -ssize_t pn_transport_input(pn_transport_t *transport, char *STRING, size_t LENGTH); -%ignore pn_transport_input; - - -// Use the OUTPUT_BUFFER,OUTPUT_LEN typemap to allow these functions to return -// variable length binary data. - -%rename(pn_link_recv) wrap_pn_link_recv; -// in PHP: array = pn_link_recv(link, MAXLEN); -// array[0] = size || error code -// array[1] = native string containing binary data -%inline %{ - void wrap_pn_link_recv(pn_link_t *link, size_t maxCount, char **OUTPUT_BUFFER, ssize_t *OUTPUT_LEN) { - *OUTPUT_BUFFER = emalloc(sizeof(char) * maxCount); - *OUTPUT_LEN = pn_link_recv(link, *OUTPUT_BUFFER, maxCount ); - } -%} -%ignore pn_link_recv; - -%rename(pn_transport_output) wrap_pn_transport_output; -// in PHP: array = pn_transport_output(transport, MAXLEN); -// array[0] = size || error code -// array[1] = native string containing binary data -%inline %{ - void wrap_pn_transport_output(pn_transport_t *transport, size_t maxCount, char **OUTPUT_BUFFER, ssize_t *OUTPUT_LEN) { - *OUTPUT_BUFFER = emalloc(sizeof(char) * maxCount); - *OUTPUT_LEN = pn_transport_output(transport, *OUTPUT_BUFFER, maxCount); - } -%} -%ignore pn_transport_output; - -%rename(pn_message_encode) wrap_pn_message_encode; -%inline %{ - void wrap_pn_message_encode(pn_message_t *message, size_t maxCount, char **OUTPUT_BUFFER, ssize_t *OUTPUT_LEN) { - *OUTPUT_BUFFER = emalloc(sizeof(char) * maxCount); - *OUTPUT_LEN = maxCount; - int err = pn_message_encode(message, *OUTPUT_BUFFER, OUTPUT_LEN); - if (err) { - *OUTPUT_LEN = err; - efree(*OUTPUT_BUFFER); - } - } -%} -%ignore pn_message_encode; - - - -// -// allow pn_delivery/pn_delivery_tag to accept a binary safe string: -// - -%rename(pn_delivery) wrap_pn_delivery; -// in PHP: delivery = pn_delivery(link, "binary safe string"); -// -%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; - -// pn_delivery_tag: output a copy of the pn_delivery_tag buffer -// -%typemap(in,numinputs=0) (const char **RETURN_STRING, size_t *RETURN_LEN) (char *Buff = 0, size_t outLen = 0) { - $1 = &Buff; // setup locals for holding output values. - $2 = &outLen; -} -%typemap(argout) (const char **RETURN_STRING, size_t *RETURN_LEN) { - // This allocates a copy of the binary buffer for return to the caller - ZVAL_STRINGL($result, *($1), *($2), 1); // 1 = duplicate the input buffer -} - -// Suppress "Warning(451): Setting a const char * variable may leak memory." on pn_delivery_tag_t -%warnfilter(451) pn_delivery_tag_t; -%rename(pn_delivery_tag) wrap_pn_delivery_tag; -// in PHP: str = pn_delivery_tag(delivery); -// -%inline %{ - void wrap_pn_delivery_tag(pn_delivery_t *d, const char **RETURN_STRING, size_t *RETURN_LEN) { - pn_delivery_tag_t tag = pn_delivery_tag(d); - *RETURN_STRING = tag.start; - *RETURN_LEN = tag.size; - } -%} -%ignore pn_delivery_tag; - - - -// -// reference counter management for passing a context to/from the listener/connector -// - -%typemap(in) void *PHP_CONTEXT { - // since we hold a pointer to the context we must increment the reference count - Z_ADDREF_PP($input); - $1 = *$input; -} - -// return the context. Apparently, PHP won't let us return a pointer to a reference -// counted zval, so we must return a copy of the data -%typemap(out) void * { - *$result = *(zval *)($1); - zval_copy_ctor($result); -} - -%include "proton/cproton.i" http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/php/proton.ini.in ---------------------------------------------------------------------- diff --git a/proton-c/bindings/php/proton.ini.in b/proton-c/bindings/php/proton.ini.in deleted file mode 100644 index 51a774e..0000000 --- a/proton-c/bindings/php/proton.ini.in +++ /dev/null @@ -1,21 +0,0 @@ -;; -; 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. -;; - -; Enable cproton extension module -@PROTON_INI@ http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/php/proton.php ---------------------------------------------------------------------- diff --git a/proton-c/bindings/php/proton.php b/proton-c/bindings/php/proton.php deleted file mode 100644 index 8cad1b2..0000000 --- a/proton-c/bindings/php/proton.php +++ /dev/null @@ -1,1119 +0,0 @@ -<?php - -/** - * 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("cproton.php"); - -class ProtonException extends Exception {} - -class Timeout extends ProtonException {} - -class MessengerException extends ProtonException {} - -class MessageException extends ProtonException {} - -function code2exc($err) { - switch ($err) { - case PN_TIMEOUT: - return "Timeout"; - default: - return null; - } -} - -class Messenger -{ - private $impl; - - public function __construct($name=null) { - $this->impl = pn_messenger($name); - } - - public function __destruct() { - pn_messenger_free($this->impl); - } - - public function __toString() { - return 'Messenger("' . pn_messenger_name($this->impl) . '")'; - } - - private function _check($value) { - if ($value < 0) { - $exc = code2exc($value); - if ($exc == null) $exc = "MessengerException"; - throw new $exc("[$value]: " . pn_error_text(pn_messenger_error($this->impl))); - } else { - return $value; - } - } - - public function __get($name) { - switch ($name) { - case "name": - return pn_messenger_name($this->impl); - case "certificate": - return pn_messenger_get_certificate($this->impl); - case "private_key": - return pn_messenger_get_private_key($this->impl); - case "password": - return pn_messenger_get_password($this->impl); - case "trusted_certificates": - return pn_messenger_get_trusted_certificates($this->impl); - case "incoming": - return $this->incoming(); - case "outgoing": - return $this->outgoing(); - default: - throw new Exception("unknown property: " . $name); - } - } - - public function __set($name, $value) { - switch ($name) { - case "certificate": - $this->_check(pn_messenger_set_certificate($this->impl, $value)); - break; - case "private_key": - $this->_check(pn_messenger_set_private_key($this->impl, $value)); - break; - case "password": - $this->_check(pn_messenger_set_password($this->impl, $value)); - break; - case "trusted_certificates": - $this->_check(pn_messenger_set_trusted_certificates($this->impl, $value)); - break; - case "timeout": - $this->_check(pn_messenger_set_timeout($this->impl, $value)); - break; - case "outgoing_window": - $this->_check(pn_messenger_set_outgoing_window($this->impl, $value)); - break; - case "incoming_window": - $this->_check(pn_messenger_set_incoming_window($this->impl, $value)); - break; - default: - throw new Exception("unknown property: " . $name); - } - } - - public function start() { - $this->_check(pn_messenger_start($this->impl)); - } - - public function stop() { - $this->_check(pn_messenger_stop($this->impl)); - } - - public function subscribe($source) { - if ($source == null) { - throw new MessengerException("null source passed to subscribe"); - } - $this->_check(pn_messenger_subscribe($this->impl, $source)); - } - - public function outgoing_tracker() { - return pn_messenger_outgoing_tracker($this->impl); - } - - public function put($message) { - $message->_pre_encode(); - $this->_check(pn_messenger_put($this->impl, $message->impl)); - return $this->outgoing_tracker(); - } - - public function send($n = -1) { - $this->_check(pn_messenger_send($this->impl, $n)); - } - - public function recv($n = -1) { - $this->_check(pn_messenger_recv($this->impl, $n)); - } - - public function incoming_tracker() { - return pn_messenger_incoming_tracker($this->impl); - } - - public function get($message) { - $this->_check(pn_messenger_get($this->impl, $message->impl)); - $message->_post_decode(); - return $this->incoming_tracker(); - } - - public function accept($tracker = null) { - if ($tracker == null) { - $tracker = $this->incoming_tracker(); - $flag = PN_CUMULATIVE; - } else { - $flag = 0; - } - $this->_check(pn_messenger_accept($this->impl, $tracker, $flag)); - } - - public function reject($tracker = null) { - if ($tracker == null) { - $tracker = $this->incoming_tracker(); - $flag = PN_CUMULATIVE; - } else { - $flag = 0; - } - $this->_check(pn_messenger_reject($this->impl, $tracker, $flag)); - } - - public function route($pattern, $address) { - $this->_check(pn_messenger_route($this->impl, $pattern, $address)); - } - - public function outgoing() { - return pn_messenger_outgoing($this->impl); - } - - public function incoming() { - return pn_messenger_incoming($this->impl); - } - - public function status($tracker) { - return pn_messenger_status($this->impl, $tracker); - } - -} - -class Message { - - const DEFAULT_PRIORITY = PN_DEFAULT_PRIORITY; - - var $impl; - var $_id; - var $_correlation_id; - public $instructions = null; - public $annotations = null; - public $properties = null; - public $body = null; - - public function __construct() { - $this->impl = pn_message(); - $this->_id = new Data(pn_message_id($this->impl)); - $this->_correlation_id = new Data(pn_message_correlation_id($this->impl)); - } - - public function __destruct() { - pn_message_free($this->impl); - } - - public function __tostring() { - $tmp = pn_string(""); - pn_inspect($this->impl, $tmp); - $result = pn_string_get($tmp); - pn_free($tmp); - return $result; - } - - private function _check($value) { - if ($value < 0) { - $exc = code2exc($value); - if ($exc == null) $exc = "MessageException"; - throw new $exc("[$value]: " . pn_message_error($this->impl)); - } else { - return $value; - } - } - - public function __get($name) { - if ($name == "impl") - throw new Exception(); - $getter = "_get_$name"; - return $this->$getter(); - } - - public function __set($name, $value) { - $setter = "_set_$name"; - $this->$setter($value); - } - - function _pre_encode() { - $inst = new Data(pn_message_instructions($this->impl)); - $ann = new Data(pn_message_annotations($this->impl)); - $props = new Data(pn_message_properties($this->impl)); - $body = new Data(pn_message_body($this->impl)); - - $inst->clear(); - if ($this->instructions != null) - $inst->put_object($this->instructions); - $ann->clear(); - if ($this->annotations != null) - $ann->put_object($this->annotations); - $props->clear(); - if ($this->properties != null) - $props->put_object($this->properties); - - $body->clear(); - if ($this->body != null) { - $body->put_object($this->body); - } - } - - function _post_decode() { - $inst = new Data(pn_message_instructions($this->impl)); - $ann = new Data(pn_message_annotations($this->impl)); - $props = new Data(pn_message_properties($this->impl)); - $body = new Data(pn_message_body($this->impl)); - - if ($inst->next()) - $this->instructions = $inst->get_object(); - else - $this->instructions = null; - if ($ann->next()) - $this->annotations = $ann->get_object(); - else - $this->annotations = null; - if ($props->next()) - $this->properties = $props->get_object(); - else - $this->properties = null; - if ($body->next()) - $this->body = $body->get_object(); - else - $this->body = null; - } - - public function clear() { - pn_message_clear($this->impl); - $this->instructions = null; - $this->annotations = null; - $this->properties = null; - $this->body = null; - } - - private function _get_inferred() { - return pn_message_is_inferred($this->impl); - } - - private function _set_inferred($value) { - $this->_check(pn_message_set_inferred($this->impl, $value)); - } - - private function _get_durable() { - return pn_message_is_durable($this->impl); - } - - private function _set_durable($value) { - $this->_check(pn_message_set_durable($this->impl, $value)); - } - - private function _get_priority() { - return pn_message_get_priority($this->impl); - } - - private function _set_priority($value) { - $this->_check(pn_message_set_priority($this->impl, $value)); - } - - private function _get_ttl() { - return pn_message_get_ttl($this->impl); - } - - private function _set_ttl($value) { - $this->_check(pn_message_set_ttl($this->impl, $value)); - } - - private function _get_first_acquirer() { - return pn_message_is_first_acquirer($this->impl); - } - - private function _set_first_acquirer($value) { - $this->_check(pn_message_set_first_acquirer($this->impl, $value)); - } - - private function _get_delivery_count() { - return pn_message_get_delivery_count($this->impl); - } - - private function _set_delivery_count($value) { - $this->_check(pn_message_set_delivery_count($this->impl, $value)); - } - - private function _get_id() { - return $this->_id->get_object(); - } - - private function _set_id($value) { - $this->_id->rewind(); - $this->_id->put_object($value); - } - - private function _get_user_id() { - return pn_message_get_user_id($this->impl); - } - - private function _set_user_id($value) { - $this->_check(pn_message_set_user_id($this->impl, $value)); - } - - private function _get_address() { - return pn_message_get_address($this->impl); - } - - private function _set_address($value) { - $this->_check(pn_message_set_address($this->impl, $value)); - } - - private function _get_subject() { - return pn_message_get_subject($this->impl); - } - - private function _set_subject($value) { - $this->_check(pn_message_set_subject($this->impl, $value)); - } - - private function _get_reply_to() { - return pn_message_get_reply_to($this->impl); - } - - private function _set_reply_to($value) { - $this->_check(pn_message_set_reply_to($this->impl, $value)); - } - - private function _get_correlation_id() { - return $this->_correlation_id->get_object(); - } - - private function _set_correlation_id($value) { - $this->_correlation_id->rewind(); - $this->_correlation_id->put_object($value); - } - - private function _get_content_type() { - return pn_message_get_content_type($this->impl); - } - - private function _set_content_type($value) { - $this->_check(pn_message_set_content_type($this->impl, $value)); - } - - private function _get_content_encoding() { - return pn_message_get_content_encoding($this->impl); - } - - private function _set_content_encoding($value) { - $this->_check(pn_message_set_content_encoding($this->impl, $value)); - } - - private function _get_expiry_time() { - return pn_message_get_expiry_time($this->impl); - } - - private function _set_expiry_time($value) { - $this->_check(pn_message_set_expiry_time($this->impl, $value)); - } - - private function _get_creation_time() { - return pn_message_get_creation_time($this->impl); - } - - private function _set_creation_time($value) { - $this->_check(pn_message_set_creation_time($this->impl, $value)); - } - - private function _get_group_id() { - return pn_message_get_group_id($this->impl); - } - - private function _set_group_id($value) { - $this->_check(pn_message_set_group_id($this->impl, $value)); - } - - private function _get_group_sequence() { - return pn_message_get_group_sequence($this->impl); - } - - private function _set_group_sequence($value) { - $this->_check(pn_message_set_group_sequence($this->impl, $value)); - } - - private function _get_reply_to_group_id() { - return pn_message_get_reply_to_group_id($this->impl); - } - - private function _set_reply_to_group_id($value) { - $this->_check(pn_message_set_reply_to_group_id($this->impl, $value)); - } - - public function encode() { - $this->_pre_encode(); - $sz = 16; - while (true) { - list($err, $data) = pn_message_encode($this->impl, $sz); - if ($err == PN_OVERFLOW) { - $sz *= 2; - continue; - } else { - $this->_check($err); - return $data; - } - } - } - - public function decode($data) { - $this->_check(pn_message_decode($this->impl, $data, strlen($data))); - $this->_post_decode(); - } -} - -class Binary { - - public $bytes; - - public function __construct($bytes) { - $this->bytes = $bytes; - } - - public function __tostring() { - return "Binary($this->bytes)"; - } - -} - -class Symbol { - - public $name; - - public function __construct($name) { - $this->name = $name; - } - - public function __tostring() { - return "Symbol($this->name)"; - } - -} - -class UUID { - - public $bytes; - - public function __construct($bytes) { - if (strlen($bytes) != 16) { - throw new Exception("invalid argument: exactly 16 bytes required"); - } - $this->bytes = $bytes; - } - - public function __tostring() { - $b = $this->bytes; - return sprintf("UUID(%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x)", - ord($b[0]), ord($b[1]), ord($b[2]), ord($b[3]), - ord($b[4]), ord($b[5]), ord($b[6]), ord($b[7]), ord($b[8]), ord($b[9]), - ord($b[10]), ord($b[11]), ord($b[12]), ord($b[13]), ord($b[14]), ord($b[15])); - } - -} - -class PList { - - public $elements; - - public function __construct() { - $this->elements = func_get_args(); - } - - public function __tostring() { - return "PList(" . implode(", ", $this->elements) . ")"; - } - -} - -class Char { - - public $codepoint; - - public function __construct($codepoint) { - $this->codepoint = $codepoint; - } - - public function __tostring() { - return "Char($this->codepoint)"; - } - -} - -class Described { - - public $descriptor; - public $value; - - public function __construct($descriptor, $value) { - $this->descriptor = $descriptor; - $this->value = $value; - } - - public function __tostring() { - return "Described($this->descriptor, $this->value)"; - } - -} - -class DataException extends ProtonException {} - -class Data { - - const NULL = PN_NULL; - const BOOL = PN_BOOL; - const UBYTE = PN_UBYTE; - const BYTE = PN_BYTE; - const USHORT = PN_USHORT; - const SHORT = PN_SHORT; - const UINT = PN_UINT; - const INT = PN_INT; - const CHAR = PN_CHAR; - const ULONG = PN_ULONG; - const LONG = PN_LONG; - const TIMESTAMP = PN_TIMESTAMP; - const FLOAT = PN_FLOAT; - const DOUBLE = PN_DOUBLE; - const DECIMAL32 = PN_DECIMAL32; - const DECIMAL64 = PN_DECIMAL64; - const DECIMAL128 = PN_DECIMAL128; - const UUID = PN_UUID; - const BINARY = PN_BINARY; - const STRING = PN_STRING; - const SYMBOL = PN_SYMBOL; - const DESCRIBED = PN_DESCRIBED; - const PARRAY = PN_ARRAY; - const PLIST = PN_LIST; - const MAP = PN_MAP; - - private $impl; - private $free; - - public function __construct($capacity=16) { - if (is_int($capacity)) { - $this->impl = pn_data($capacity); - $this->free = true; - } else { - $this->impl = $capacity; - $this->free = false; - } - } - - public function __destruct() { - if ($this->free) - pn_data_free($this->impl); - } - - public function _check($value) { - if ($value < 0) { - $exc = code2exc($value); - if ($exc == null) $exc = "DataException"; - throw new $exc("[$value]"); - } else { - return $value; - } - } - - public function clear() { - pn_data_clear($this->impl); - } - - public function rewind() { - pn_data_rewind($this->impl); - } - - public function next() { - $found = pn_data_next($this->impl); - if ($found) - return $this->type(); - else - return null; - } - - public function prev() { - $found = pn_data_prev($this->impl); - if ($found) - return $this->type(); - else - return null; - } - - public function enter() { - return pn_data_enter($this->impl); - } - - public function exit_() { - return pn_data_exit($this->impl); - } - - public function type() { - $dtype = pn_data_type($this->impl); - if ($dtype == -1) - return null; - else - return $dtype; - } - - public function encode() { - $size = 1024; - while (true) { - list($cd, $enc) = pn_data_encode($this->impl, $size); - if ($cd == PN_OVERFLOW) - $size *= 2; - else if ($cd >= 0) - return $enc; - else - $this->_check($cd); - } - } - - public function decode($encoded) { - return $this->_check(pn_data_decode($this->impl, $encoded)); - } - - public function put_list() { - $this->_check(pn_data_put_list($this->impl)); - } - - public function put_map() { - $this->_check(pn_data_put_map($this->impl)); - } - - public function put_array($described, $element_type) { - $this->_check(pn_data_put_array($this->impl, $described, $element_type)); - } - - public function put_described() { - $this->_check(pn_data_put_described($this->impl)); - } - - public function put_null() { - $this->_check(pn_data_put_null($this->impl)); - } - - public function put_bool($b) { - $this->_check(pn_data_put_bool($this->impl, $b)); - } - - public function put_ubyte($ub) { - $this->_check(pn_data_put_ubyte($this->impl, $ub)); - } - - public function put_byte($b) { - $this->_check(pn_data_put_byte($this->impl, $b)); - } - - public function put_ushort($us) { - $this->_check(pn_data_put_ushort($this->impl, $us)); - } - - public function put_short($s) { - $this->_check(pn_data_put_short($this->impl, $s)); - } - - public function put_uint($ui) { - $this->_check(pn_data_put_uint($this->impl, $ui)); - } - - public function put_int($i) { - $this->_check(pn_data_put_int($this->impl, $i)); - } - - public function put_char($c) { - if ($c instanceof Char) { - $c = $c->codepoint; - } else { - $c = ord($c); - } - $this->_check(pn_data_put_char($this->impl, $c)); - } - - public function put_ulong($ul) { - $this->_check(pn_data_put_ulong($this->impl, $ul)); - } - - public function put_long($l) { - $this->_check(pn_data_put_long($this->impl, $l)); - } - - public function put_timestamp($t) { - $this->_check(pn_data_put_timestamp($this->impl, $t)); - } - - public function put_float($f) { - $this->_check(pn_data_put_float($this->impl, $f)); - } - - public function put_double($d) { - $this->_check(pn_data_put_double($this->impl, $d)); - } - - public function put_decimal32($d) { - $this->_check(pn_data_put_decimal32($this->impl, $d)); - } - - public function put_decimal64($d) { - $this->_check(pn_data_put_decimal64($this->impl, $d)); - } - - public function put_decimal128($d) { - $this->_check(pn_data_put_decimal128($this->impl, $d)); - } - - public function put_uuid($u) { - if ($u instanceof UUID) { - $u = $u->bytes; - } - $this->_check(pn_data_put_uuid($this->impl, $u)); - } - - public function put_binary($b) { - if ($b instanceof Binary) { - $b = $b->bytes; - } - $this->_check(pn_data_put_binary($this->impl, $b)); - } - - public function put_string($s) { - $this->_check(pn_data_put_string($this->impl, $s)); - } - - public function put_symbol($s) { - if ($s instanceof Symbol) { - $s = $s->name; - } - $this->_check(pn_data_put_symbol($this->impl, $s)); - } - - public function get_list() { - return pn_data_get_list($this->impl); - } - - public function get_map() { - return pn_data_get_map($this->impl); - } - - public function get_array() { - $count = pn_data_get_array($this->impl); - $described = pn_data_is_array_described($this->impl); - $type = pn_data_get_array_type($this->impl); - if ($type == -1) - $type = null; - return array($count, $described, $type); - } - - public function is_described() { - return pn_data_is_described($this->impl); - } - - public function is_null() { - $this->_check(pn_data_get_null($this->impl)); - } - - public function get_bool() { - return pn_data_get_bool($this->impl); - } - - public function get_ubyte() { - return pn_data_get_ubyte($this->impl); - } - - public function get_byte() { - return pn_data_get_byte($this->impl); - } - - public function get_ushort() { - return pn_data_get_ushort($this->impl); - } - - public function get_short() { - return pn_data_get_short($this->impl); - } - - public function get_uint() { - return pn_data_get_uint($this->impl); - } - - public function get_int() { - return pn_data_get_int($this->impl); - } - - public function get_char() { - return new Char(pn_data_get_char($this->impl)); - } - - public function get_ulong() { - return pn_data_get_ulong($this->impl); - } - - public function get_long() { - return pn_data_get_long($this->impl); - } - - public function get_timestamp() { - return pn_data_get_timestamp($this->impl); - } - - public function get_float() { - return pn_data_get_float($this->impl); - } - - public function get_double() { - return pn_data_get_double($this->impl); - } - - # XXX: need to convert - public function get_decimal32() { - return pn_data_get_decimal32($this->impl); - } - - # XXX: need to convert - public function get_decimal64() { - return pn_data_get_decimal64($this->impl); - } - - # XXX: need to convert - public function get_decimal128() { - return pn_data_get_decimal128($this->impl); - } - - public function get_uuid() { - if (pn_data_type($this->impl) == Data::UUID) - return new UUID(pn_data_get_uuid($this->impl)); - else - return null; - } - - public function get_binary() { - return new Binary(pn_data_get_binary($this->impl)); - } - - public function get_string() { - return pn_data_get_string($this->impl); - } - - public function get_symbol() { - return new Symbol(pn_data_get_symbol($this->impl)); - } - - public function copy($src) { - $this->_check(pn_data_copy($this->impl, $src->impl)); - } - - public function format() { - $sz = 16; - while (true) { - list($err, $result) = pn_data_format($this->impl, $sz); - if ($err == PN_OVERFLOW) { - $sz *= 2; - continue; - } else { - $this->_check($err); - return $result; - } - } - } - - public function dump() { - pn_data_dump($this->impl); - } - - public function get_null() { - return null; - } - - public function get_php_described() { - if ($this->enter()) { - try { - $this->next(); - $descriptor = $this->get_object(); - $this->next(); - $value = $this->get_object(); - $this->exit_(); - } catch (Exception $e) { - $this->exit_(); - throw $e; - } - return new Described($descriptor, $value); - } - } - - public function get_php_array() { - if ($this->enter()) { - try { - $result = array(); - while ($this->next()) { - $result[] = $this->get_object(); - } - $this->exit_(); - } catch (Exception $e) { - $this->exit_(); - throw $e; - } - return $result; - } - } - - public function put_php_list($lst) { - $this->put_list(); - $this->enter(); - try { - foreach ($lst->elements as $e) { - $this->put_object($e); - } - $this->exit_(); - } catch (Exception $e) { - $this->exit_(); - throw $e; - } - } - - public function get_php_list() { - if ($this->enter()) { - try { - $result = new PList(); - while ($this->next()) { - $result->elements[] = $this->get_object(); - } - $this->exit_(); - } catch (Exception $e) { - $this->exit_(); - throw $e; - } - - return $result; - } - } - - public function put_php_map($ary) { - $this->put_map(); - $this->enter(); - try { - foreach ($ary as $k => $v) { - $this->put_object($k); - $this->put_object($v); - } - $this->exit_(); - } catch (Exception $e) { - $this->exit_(); - throw $e; - } - } - - public function get_php_map() { - if ($this->enter()) { - try { - $result = array(); - while ($this->next()) { - $k = $this->get_object(); - switch ($this->type()) { - case Data::BINARY: - $k = $k->bytes; - break; - case Data::SYMBOL: - $k = $k->name; - break; - case Data::STRING: - case Data::UBYTE: - case Data::BYTE: - case Data::USHORT: - case Data::SHORT: - case Data::UINT: - case Data::INT: - case Data::ULONG: - case Data::LONG: - break; - default: - $k = "$k"; - break; - } - if ($this->next()) - $v = $this->get_object(); - else - $v = null; - $result[$k] = $v; - } - $this->exit_(); - } catch (Exception $e) { - $this->exit_(); - throw $e; - } - return $result; - } - } - - private $put_mappings = array - ("NULL" => "put_null", - "boolean" => "put_bool", - "UUID" => "put_uuid", - "string" => "put_string", - "Binary" => "put_binary", - "Symbol" => "put_symbol", - "integer" => "put_long", - "Char" => "put_char", - "double" => "put_double", - "Described" => "put_php_described", - "PList" => "put_php_list", - "array" => "put_php_map" - ); - private $get_mappings = array - (Data::NULL => "get_null", - Data::BOOL => "get_bool", - Data::UBYTE => "get_ubyte", - Data::BYTE => "get_byte", - Data::USHORT => "get_ushort", - Data::SHORT => "get_short", - Data::UINT => "get_uint", - Data::INT => "get_int", - Data::CHAR => "get_char", - Data::ULONG => "get_ulong", - Data::LONG => "get_long", - Data::TIMESTAMP => "get_timestamp", - Data::FLOAT => "get_float", - Data::DOUBLE => "get_double", - Data::DECIMAL32 => "get_decimal32", - Data::DECIMAL64 => "get_decimal64", - Data::DECIMAL128 => "get_decimal128", - Data::UUID => "get_uuid", - Data::BINARY => "get_binary", - Data::STRING => "get_string", - Data::SYMBOL => "get_symbol", - Data::DESCRIBED => "get_php_described", - Data::PARRAY => "get_php_array", - Data::PLIST => "get_php_list", - Data::MAP => "get_php_map" - ); - - public function put_object($obj) { - $type = gettype($obj); - if ($type == "object") { - $type = get_class($obj); - } - $putter = $this->put_mappings[$type]; - if ($putter == null) - throw new DataException("unknown type: $type"); - $this->$putter($obj); - } - - public function get_object() { - $type = $this->type(); - if ($type == null) return null; - $getter = $this->get_mappings[$type]; - return $this->$getter(); - } - -} - -?> http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/php/tests.php ---------------------------------------------------------------------- diff --git a/proton-c/bindings/php/tests.php b/proton-c/bindings/php/tests.php deleted file mode 100644 index 8ae45cf..0000000 --- a/proton-c/bindings/php/tests.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php -/* - * - * 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("proton.php"); - -function round_trip($body) { - $msg = new Message(); - $msg->inferred = true; - $msg->durable = true; - $msg->id = 10; - $msg->correlation_id = "asdf"; - $msg->properties = array(); - $msg->properties["null"] = null; - $msg->properties["boolean"] = true; - $msg->properties["integer"] = 123; - $msg->properties["double"] = 3.14159; - $msg->properties["binary"] = new Binary("binary"); - $msg->properties["symbol"] = new Symbol("symbol"); - $msg->properties["uuid"] = new UUID("1234123412341234"); - $msg->properties["list"] = new PList(1, 2, 3, 4); - $msg->properties["char"] = new Char(321); - $msg->body = $body; - assert($msg->id == 10); - assert($msg->correlation_id == "asdf"); - - $copy = new Message(); - $copy->decode($msg->encode()); - assert($copy->id == $msg->id); - assert($copy->correlation_id == $msg->correlation_id); - $diff = array_diff($msg->properties, $copy->properties); - assert($copy->durable == $msg->durable); - assert(count($diff) == 0); - assert($copy->body == $msg->body); -} - -round_trip("this is a string body"); -round_trip(new Binary("this is a binary body")); -round_trip(new Symbol("this is a symbol body")); -round_trip(true); -round_trip(1234); -round_trip(3.14159); -round_trip(array("pi" => 3.14159, "blueberry-pi" => "yummy")); - -?> http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/python/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/proton-c/bindings/python/CMakeLists.txt b/proton-c/bindings/python/CMakeLists.txt deleted file mode 100644 index fe732d9..0000000 --- a/proton-c/bindings/python/CMakeLists.txt +++ /dev/null @@ -1,179 +0,0 @@ -# -# 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. -# - -# 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}) - -set_source_files_properties(cproton.i PROPERTIES CPLUSPLUS NO) - -# Suppress warnings in swig generated code. -set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") - -list(APPEND SWIG_MODULE_cproton_EXTRA_DEPS - ${CMAKE_SOURCE_DIR}/proton-c/include/proton/cproton.i - ${PROTON_HEADERS} -) - -swig_add_module(cproton python cproton.i) -swig_link_libraries(cproton ${BINDING_DEPS} ${PYTHON_LIBRARIES}) -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() - -set (pysrc-generated cproton.py) -set (pysrc - proton/__init__.py - proton/handlers.py - proton/reactor.py - proton/utils.py - proton/wrapper.py - proton/_compat.py - ) -# extra files included in the source distribution -set(py_dist_files - cproton.i - MANIFEST.in - setuputils - docs - ) - -macro (py_compile directory files artifacts) - foreach (src_file ${files}) - install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -c \"import py_compile; py_compile.compile('${src_file}', cfile='${src_file}c')\" - WORKING_DIRECTORY ${directory})") - install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -O -c \"import py_compile; py_compile.compile('${src_file}', cfile='${src_file}o')\" - WORKING_DIRECTORY ${directory})") - list(APPEND ${artifacts} ${directory}/${src_file} - ${directory}/${src_file}c - ${directory}/${src_file}o) - endforeach (src_file) -endmacro(py_compile) - -py_compile(${CMAKE_CURRENT_BINARY_DIR} ${pysrc-generated} CPROTON_ARTIFACTS) -py_compile(${CMAKE_CURRENT_SOURCE_DIR} "${pysrc}" PROTON_ARTIFACTS) - -find_program(EPYDOC_EXE epydoc) -mark_as_advanced (EPYDOC_EXE) -if (EPYDOC_EXE) - foreach (py_src_doc ${pysrc}) - list(APPEND PY_DOC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${py_src_doc}") - endforeach(py_src_doc) - add_custom_target(docs-py COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../env.py -- - PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_CURRENT_SOURCE_DIR} - ${EPYDOC_EXE} -v --no-private --html -o ${CMAKE_CURRENT_BINARY_DIR}/html - ${PY_DOC_FILES} - DEPENDS ${SWIG_MODULE_${cproton}_REAL_NAME}) - add_dependencies(docs docs-py) - install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html/" - DESTINATION "${PROTON_SHARE}/docs/api-py" - COMPONENT documentation - OPTIONAL) -endif (EPYDOC_EXE) - -find_program(SPHINX_EXE sphinx-build) -mark_as_advanced (SPHINX_EXE) -if (SPHINX_EXE) - add_custom_target(tutorial-py COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../env.py -- - PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_CURRENT_SOURCE_DIR} - ${SPHINX_EXE} -b html ${CMAKE_CURRENT_SOURCE_DIR}/docs ${CMAKE_CURRENT_BINARY_DIR}/tutorial) - add_dependencies(docs tutorial-py) - install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tutorial/" - DESTINATION "${PROTON_SHARE}/docs/tutorial-py" - COMPONENT documentation - OPTIONAL) -endif (SPHINX_EXE) - -install(FILES ${CPROTON_ARTIFACTS} - DESTINATION ${PYTHON_SITEARCH_PACKAGES} - COMPONENT Python) -install(FILES ${PROTON_ARTIFACTS} - DESTINATION "${PYTHON_SITEARCH_PACKAGES}/proton/" - COMPONENT Python) -install(TARGETS ${SWIG_MODULE_cproton_REAL_NAME} - DESTINATION ${PYTHON_SITEARCH_PACKAGES} - COMPONENT Python) - -set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "html;tutorial") - -# -# Set up the directory 'dist' for building the python native package -# source distribution for Pypi/pip -# - -set(py_dist_dir ${CMAKE_CURRENT_BINARY_DIR}/dist) - -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in - ${py_dist_dir}/setup.py -) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/README.rst.in - ${py_dist_dir}/README.rst -) - -file(COPY ${py_dist_files} DESTINATION ${py_dist_dir}) - -file(MAKE_DIRECTORY ${py_dist_dir}/proton) -file(COPY ${pysrc} DESTINATION ${py_dist_dir}/proton) - -add_custom_target(py_src_dist ALL) -add_dependencies(py_src_dist generated_c_files) -file(MAKE_DIRECTORY ${py_dist_dir}/proton-c) - -# copy generated source files from the binary dir to the dist -foreach(sfile ${qpid-proton-include-generated}) - string(REPLACE ${CMAKE_BINARY_DIR} ${py_dist_dir} dfile ${sfile}) - add_custom_command(TARGET py_src_dist - COMMAND ${CMAKE_COMMAND} -E - copy ${sfile} ${dfile}) -endforeach() - -# copy the proton C sources to the dist -set (all_src - ${qpid-proton-core} - ${qpid-proton-extra} - ${qpid-proton-include} - ${qpid-proton-include-extra} - ${qpid-proton-layers-all} - ${qpid-proton-platform-all} - ${qpid-proton-private-includes} - include/proton/cproton.i -) -foreach(sfile ${all_src}) - add_custom_command(TARGET py_src_dist - COMMAND ${CMAKE_COMMAND} -E - copy ${CMAKE_SOURCE_DIR}/proton-c/${sfile} ${py_dist_dir}/proton-c/${sfile}) -endforeach() http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/python/MANIFEST.in ---------------------------------------------------------------------- diff --git a/proton-c/bindings/python/MANIFEST.in b/proton-c/bindings/python/MANIFEST.in deleted file mode 100644 index a37ad72..0000000 --- a/proton-c/bindings/python/MANIFEST.in +++ /dev/null @@ -1,5 +0,0 @@ -graft docs -graft setuputils -graft proton-c -global-exclude proton-c *.pyc *.pyo - http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/python/PACKAGING.txt ---------------------------------------------------------------------- diff --git a/proton-c/bindings/python/PACKAGING.txt b/proton-c/bindings/python/PACKAGING.txt deleted file mode 100644 index fa127f0..0000000 --- a/proton-c/bindings/python/PACKAGING.txt +++ /dev/null @@ -1,26 +0,0 @@ -This document describes how to build a native Python source package. -This can be used to install the Python bindings via pip. - -First configure the project using 'cmake' then build it. You do not -need to install the project. See the INSTALL.md file at the project's -top directory for details on building. - -Once you have built the project, there should be a 'dist' directory in -the Python bindings directory in the build directory. - -For example, assuming the build directory is named 'build': - -$ cd build/proton-c/bindings/python/dist - -You can now run the setup.py script from within the dist directory to -build your source distribution package. - -To build a Python source distribution: - -$ python ./setup.py sdist - -To build and install: - -$ python ./setup.py build install - - http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/python/README.rst.in ---------------------------------------------------------------------- diff --git a/proton-c/bindings/python/README.rst.in b/proton-c/bindings/python/README.rst.in deleted file mode 100644 index 8be1dd3..0000000 --- a/proton-c/bindings/python/README.rst.in +++ /dev/null @@ -1,11 +0,0 @@ -Python bindings for Qpid Proton -=============================== - -This module provides version @PN_VERSION_MAJOR@.@PN_VERSION_MINOR@.@PN_VERSION_POINT@ of the Proton AMQP messaging toolkit. - -Qpid Proton is a high-performance, lightweight messaging library. It -can be used in the widest range of messaging applications, including -brokers, client libraries, routers, bridges, proxies, and more. Proton -makes it trivial to integrate with the AMQP 1.0 ecosystem from any -platform, environment, or language. More about `Proton <http://qpid.apache.org/proton/index.html>`_. - http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/python/cproton.i ---------------------------------------------------------------------- diff --git a/proton-c/bindings/python/cproton.i b/proton-c/bindings/python/cproton.i deleted file mode 100644 index b173dd8..0000000 --- a/proton-c/bindings/python/cproton.i +++ /dev/null @@ -1,415 +0,0 @@ -/* - * 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/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 -preprocessor directives within %inline blocks and the use of â#pragma SWIGâ." -This includes using macros in an %inline section. - -Keep preprocessor directives and macro expansions in the normal header section. -*/ - -PN_HANDLE(PNI_PYTRACER); -%} - -%include <cstring.i> - -%cstring_output_allocate_size(char **ALLOC_OUTPUT, size_t *ALLOC_SIZE, free(*$1)); -%cstring_output_maxsize(char *OUTPUT, size_t MAX_OUTPUT_SIZE) - -%include <pybuffer.i> -%pybuffer_binary(const char *BIN_IN, size_t BIN_LEN) - -// Typemap for methods that return binary data: -// force the return type as binary - this is necessary for Python3 -%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(size_t)) (char *BIN_OUT, size_t *BIN_SIZE) -(int res, size_t n, char *buff = 0, $*2_ltype size) { - res = SWIG_AsVal(size_t)($input, &n); - if (!SWIG_IsOK(res)) { - %argument_fail(res, "(char *BIN_OUT, size_t *BIN_SIZE)", $symname, $argnum); - } - buff= %new_array(n+1, char); - $1 = %static_cast(buff, $1_ltype); - size = %numeric_cast(n,$*2_ltype); - $2 = &size; -} -%typemap(freearg,noblock=1,match="in")(char *BIN_OUT, size_t *BIN_SIZE) { - if (buff$argnum) %delete_array(buff$argnum); -} -%typemap(argout,noblock=1) (char *BIN_OUT, size_t *BIN_SIZE) { - %append_output(PyBytes_FromStringAndSize($1,*$2)); -} - -// Typemap for those methods that return variable length text data in a buffer -// provided as a parameter. If the method fails we must avoid attempting to -// decode the contents of the buffer as it does not carry valid text data. -%typemap(in,noblock=1,fragment=SWIG_AsVal_frag(size_t)) (char *VTEXT_OUT, size_t *VTEXT_SIZE) -(int res, size_t n, char *buff = 0, $*2_ltype size) { - res = SWIG_AsVal(size_t)($input, &n); - if (!SWIG_IsOK(res)) { - %argument_fail(res, "(char *VTEXT_OUT, size_t *VTEXT_SIZE)", $symname, $argnum); - } - buff = %new_array(n+1, char); - $1 = %static_cast(buff, $1_ltype); - size = %numeric_cast(n,$*2_ltype); - $2 = &size; -} -%typemap(freearg,noblock=1,match="in")(char *VTEXT_OUT, size_t *VTEXT_SIZE) { - if (buff$argnum) %delete_array(buff$argnum); -} -%typemap(argout,noblock=1,fragment="SWIG_FromCharPtrAndSize") (char *VTEXT_OUT, size_t *VTEXT_SIZE) { - %append_output(SWIG_FromCharPtrAndSize($1,*$2)); -} - - -// These are not used/needed in the python binding -%ignore pn_dtag; -%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 = PyBytes_AsString($input); - - if (!$1.start) { - return NULL; - } - $1.size = PyBytes_Size($input); - } -} - -%typemap(out) pn_bytes_t { - $result = PyBytes_FromStringAndSize($1.start, $1.size); -} - -%typemap(out) pn_delivery_tag_t { - $result = PyBytes_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 = PyBytes_AsString($input); - if (b) { - memmove($1.bytes, b, (PyBytes_Size($input) < 16 ? PyBytes_Size($input) : 16)); - } else { - return NULL; - } - } -} - -%typemap(out) pn_uuid_t { - $result = PyBytes_FromStringAndSize($1.bytes, 16); -} - -%apply pn_uuid_t { pn_decimal128_t }; - -int pn_message_encode(pn_message_t *msg, char *BIN_OUT, size_t *BIN_SIZE); -%ignore pn_message_encode; - -int pn_message_decode(pn_message_t *msg, const char *BIN_IN, size_t BIN_LEN); -%ignore pn_message_decode; - -ssize_t pn_link_send(pn_link_t *transport, const char *BIN_IN, size_t BIN_LEN); -%ignore pn_link_send; - -%rename(pn_link_recv) wrap_pn_link_recv; -%inline %{ - int wrap_pn_link_recv(pn_link_t *link, char *BIN_OUT, size_t *BIN_SIZE) { - ssize_t sz = pn_link_recv(link, BIN_OUT, *BIN_SIZE); - if (sz >= 0) { - *BIN_SIZE = sz; - } else { - *BIN_SIZE = 0; - } - return sz; - } -%} -%ignore pn_link_recv; - -ssize_t pn_transport_push(pn_transport_t *transport, const char *BIN_IN, size_t BIN_LEN); -%ignore pn_transport_push; - -%rename(pn_transport_peek) wrap_pn_transport_peek; -%inline %{ - int wrap_pn_transport_peek(pn_transport_t *transport, char *BIN_OUT, size_t *BIN_SIZE) { - ssize_t sz = pn_transport_peek(transport, BIN_OUT, *BIN_SIZE); - if (sz >= 0) { - *BIN_SIZE = sz; - } else { - *BIN_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.start, tag.size); - } -%} -%ignore pn_delivery_tag; - -ssize_t pn_data_decode(pn_data_t *data, const char *BIN_IN, size_t BIN_LEN); -%ignore pn_data_decode; - -%rename(pn_data_encode) wrap_pn_data_encode; -%inline %{ - int wrap_pn_data_encode(pn_data_t *data, char *BIN_OUT, size_t *BIN_SIZE) { - ssize_t sz = pn_data_encode(data, BIN_OUT, *BIN_SIZE); - if (sz >= 0) { - *BIN_SIZE = sz; - } else { - *BIN_SIZE = 0; - } - return sz; - } -%} -%ignore pn_data_encode; - -%rename(pn_data_format) wrap_pn_data_format; -%inline %{ - int wrap_pn_data_format(pn_data_t *data, char *VTEXT_OUT, size_t *VTEXT_SIZE) { - int err = pn_data_format(data, VTEXT_OUT, VTEXT_SIZE); - if (err) *VTEXT_SIZE = 0; - return err; - } -%} -%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; - -char* pn_ssl_get_remote_subject_subfield(pn_ssl_t *ssl, pn_ssl_cert_subject_subfield field); -%ignore pn_ssl_get_remote_subject_subfield; - -int pn_ssl_get_cert_fingerprint(pn_ssl_t *ssl, char *OUTPUT, size_t MAX_OUTPUT_SIZE, pn_ssl_hash_alg hash_alg); -%ignore pn_ssl_get_cert_fingerprint; - -%rename(pn_ssl_get_peer_hostname) wrap_pn_ssl_get_peer_hostname; -%inline %{ - int wrap_pn_ssl_get_peer_hostname(pn_ssl_t *ssl, char *VTEXT_OUT, size_t *VTEXT_SIZE) { - int err = pn_ssl_get_peer_hostname(ssl, VTEXT_OUT, VTEXT_SIZE); - if (err) *VTEXT_SIZE = 0; - return err; - } -%} -%ignore pn_ssl_get_peer_hostname; - - -%immutable PN_PYREF; -%inline %{ - extern const pn_class_t *PN_PYREF; - - #define CID_pn_pyref CID_pn_void - #define pn_pyref_new NULL - #define pn_pyref_initialize NULL - #define pn_pyref_finalize NULL - #define pn_pyref_free NULL - #define pn_pyref_hashcode pn_void_hashcode - #define pn_pyref_compare pn_void_compare - #define pn_pyref_inspect pn_void_inspect - - static void pn_pyref_incref(void *object) { - PyObject* p = (PyObject*) object; - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - Py_XINCREF(p); - SWIG_PYTHON_THREAD_END_BLOCK; - } - - static void pn_pyref_decref(void *object) { - PyObject* p = (PyObject*) object; - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - Py_XDECREF(p); - SWIG_PYTHON_THREAD_END_BLOCK; - } - - static int pn_pyref_refcount(void *object) { - return 1; - } - - static const pn_class_t *pn_pyref_reify(void *object) { - return PN_PYREF; - } - - const pn_class_t PNI_PYREF = PN_METACLASS(pn_pyref); - const pn_class_t *PN_PYREF = &PNI_PYREF; - - void *pn_py2void(PyObject *object) { - return object; - } - - PyObject *pn_void2py(void *object) { - if (object) { - PyObject* p = (PyObject*) object; - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - Py_INCREF(p); - SWIG_PYTHON_THREAD_END_BLOCK; - return p; - } else { - Py_RETURN_NONE; - } - } - - PyObject *pn_cast_pn_void(void *object) { - 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; - PyObject *pytrans = SWIG_NewPointerObj(transport, SWIGTYPE_p_pn_transport_t, 0); - PyObject *pymsg = PyString_FromString(message); - PyObject *result = PyObject_CallFunctionObjArgs(pytracer, pytrans, pymsg, NULL); - if (!result) { - PyErr_PrintEx(true); - } - Py_XDECREF(pytrans); - Py_XDECREF(pymsg); - Py_XDECREF(result); - SWIG_PYTHON_THREAD_END_BLOCK; - } - - void pn_transport_set_pytracer(pn_transport_t *transport, PyObject *obj) { - pn_record_t *record = pn_transport_attachments(transport); - pn_record_def(record, PNI_PYTRACER, PN_PYREF); - pn_record_set(record, PNI_PYTRACER, obj); - pn_transport_set_tracer(transport, pn_pytracer); - } - - PyObject *pn_transport_get_pytracer(pn_transport_t *transport) { - pn_record_t *record = pn_transport_attachments(transport); - PyObject *obj = (PyObject *)pn_record_get(record, PNI_PYTRACER); - if (obj) { - Py_XINCREF(obj); - return obj; - } else { - Py_RETURN_NONE; - } - } - -%} - -%include "proton/cproton.i" http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/python/docs/conf.py ---------------------------------------------------------------------- diff --git a/proton-c/bindings/python/docs/conf.py b/proton-c/bindings/python/docs/conf.py deleted file mode 100644 index cae646c..0000000 --- a/proton-c/bindings/python/docs/conf.py +++ /dev/null @@ -1,242 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Apache Qpid Proton documentation build configuration file, created by -# sphinx-quickstart on Mon Feb 16 14:13:09 2015. -# -# This file is execfile()d with the current directory set to its containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys, os - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) - -# -- General configuration ----------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo'] - -# Add any paths that contain templates here, relative to this directory. -#templates_path = ['_templates'] - -# The suffix of source filenames. -source_suffix = '.rst' - -# The encoding of source files. -#source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'Apache Qpid Proton' -copyright = u'2015, Apache Qpid' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = '0.17.0' -# The full version, including alpha/beta/rc tags. -release = '0.17.0-SNAPSHOT' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -#language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -#today = '' -# Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = [] - -# The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -#add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -#show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] - - -# -- Options for HTML output --------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = 'sphinxdoc' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -#html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# "<project> v<release> documentation". -#html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -#html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -#html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -#html_static_path = ['_static'] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -#html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -#html_additional_pages = {} - -# If false, no module index is generated. -#html_domain_indices = True - -# If false, no index is generated. -#html_use_index = True - -# If true, the index is split into individual pages for each letter. -#html_split_index = False - -# If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a <link> tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -#html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None - -# Output file base name for HTML help builder. -htmlhelp_basename = 'ApacheQpidProtondoc' - - -# -- Options for LaTeX output -------------------------------------------------- - -latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -#'preamble': '', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). -latex_documents = [ - ('index', 'ApacheQpidProton.tex', u'Apache Qpid Proton Documentation', - u'The Apache Qpid Community', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -#latex_use_parts = False - -# If true, show page references after internal links. -#latex_show_pagerefs = False - -# If true, show URL addresses after external links. -#latex_show_urls = False - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -#latex_domain_indices = True - - -# -- Options for manual page output -------------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'apacheqpidproton', u'Apache Qpid Proton Documentation', - [u'The Apache Qpid Community'], 1) -] - -# If true, show URL addresses after external links. -#man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------------ - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ('index', 'ApacheQpidProton', u'Apache Qpid Proton Documentation', - u'The Apache Qpid Community', 'ApacheQpidProton', 'One line description of project.', - 'Miscellaneous'), -] - -# Documents to append as an appendix to all manuals. -#texinfo_appendices = [] - -# If false, no module index is generated. -#texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/python/docs/index.rst ---------------------------------------------------------------------- diff --git a/proton-c/bindings/python/docs/index.rst b/proton-c/bindings/python/docs/index.rst deleted file mode 100644 index 927762b..0000000 --- a/proton-c/bindings/python/docs/index.rst +++ /dev/null @@ -1,11 +0,0 @@ -Apache Qpid Proton: python documentation -======================================== - -Contents: - -.. toctree:: - :maxdepth: 2 - - tutorial - overview - http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/python/docs/overview.rst ---------------------------------------------------------------------- diff --git a/proton-c/bindings/python/docs/overview.rst b/proton-c/bindings/python/docs/overview.rst deleted file mode 100644 index f82deb2..0000000 --- a/proton-c/bindings/python/docs/overview.rst +++ /dev/null @@ -1,160 +0,0 @@ -############ -API Overview -############ - -========================= -An overview of the model -========================= - -Messages are transferred between connected peers over 'links'. At the -sending peer the link is called a sender. At the receiving peer it is -called a receiver. Messages are sent by senders and received by -receivers. Links may have named 'source' and 'target' addresses (for -example to identify the queue from which message were to be received -or to which they were to be sent). - -Links are established over sessions. Sessions are established over -connections. Connections are (generally) established between two -uniquely identified containers. Though a connection can have multiple -sessions, often this is not needed. The container API allows you to -ignore sessions unless you actually require them. - -The sending of a message over a link is called a delivery. The message -is the content sent, including all meta-data such as headers and -annotations. The delivery is the protocol exchange associated with the -transfer of that content. - -To indicate that a delivery is complete, either the sender or the -receiver 'settles' it. When the other side learns that it has been -settled, they will no longer communicate about that delivery. The -receiver can also indicate whether they accept or reject the -message. - -Three different delivery levels or 'guarantees' can be achieved: -at-most-once, at-least-once or exactly-once. See -:ref:`delivery-guarantees` for more detail. - -======================================================= -A summary of the most commonly used classes and members -======================================================= - -A brief summary of some of the key classes follows. - -The :py:class:`~proton.reactor.Container` class is a convenient entry -point into the API, allowing connections and links to be -established. Applications are structured as one or more event -handlers. Handlers can be set at Container, Connection, or Link -scope. Messages are sent by establishing an approprate sender and -invoking its :py:meth:`~proton.Sender.send()` method. This is -typically done when the sender is sendable, a condition indicated by -the :py:meth:`~proton.handlers.MessagingHandler.on_sendable()` event, to -avoid execessive build up of messages. Messages can be received by -establishing an appropriate receiver and handling the -:py:meth:`~proton.handlers.MessagingHandler.on_message()` event. - -.. autoclass:: proton.reactor.Container - :show-inheritance: proton.reactor.Reactor - :members: connect, create_receiver, create_sender, run, schedule - :undoc-members: - - .. py:attribute:: container_id - - The identifier used to identify this container in any - connections it establishes. Container names should be - unique. By default a UUID will be used. - - The :py:meth:`~proton.reactor.Container.connect()` method returns - an instance of :py:class:`~proton.Connection`, the - :py:meth:`~proton.reactor.Container.create_receiver()` method - returns an instance of :py:class:`~proton.Receiver` and the - :py:meth:`~proton.reactor.Container.create_sender()` method - returns an instance of :py:class:`~proton.Sender`. - -.. autoclass:: proton.Connection - :members: open, close, state, session, hostname, container, - remote_container, remote_desired_capabilities, remote_hostname, remote_offered_capabilities , remote_properties - :undoc-members: - -.. autoclass:: proton.Receiver - :show-inheritance: proton.Link - :members: flow, recv, drain, draining - :undoc-members: - -.. autoclass:: proton.Sender - :show-inheritance: proton.Link - :members: offered, send - :undoc-members: - -.. autoclass:: proton.Link - :members: name, state, is_sender, is_receiver, - credit, queued, session, connection, - source, target, remote_source, remote_target - :undoc-members: - - The :py:meth:`~proton.Link.source()`, - :py:meth:`~proton.Link.target()`, - :py:meth:`~proton.Link.remote_source()` and - :py:meth:`~proton.Link.remote_target()` methods all return an - instance of :py:class:`~proton.Terminus`. - - -.. autoclass:: proton.Delivery - :members: update, settle, settled, remote_state, local_state, partial, readable, writable, - link, session, connection - :undoc-members: - -.. autoclass:: proton.handlers.MessagingHandler - :members: on_start, on_reactor_init, - on_message, - on_accepted, - on_rejected, - on_settled, - on_sendable, - on_connection_error, - on_link_error, - on_session_error, - on_disconnected, - accept, reject, release, settle - :undoc-members: - -.. autoclass:: proton.Event - :members: delivery, link, receiver, sender, session, connection, reactor, context - :undoc-members: - -.. autoclass:: proton.Message - :members: address, id, priority, subject, ttl, reply_to, correlation_id, durable, user_id, - content_type, content_encoding, creation_time, expiry_time, delivery_count, first_acquirer, - group_id, group_sequence, reply_to_group_id, - send, recv, encode, decode - :undoc-members: - -.. autoclass:: proton.Terminus - :members: address, dynamic, properties, capabilities, filter - :undoc-members: - -.. _delivery-guarantees: - -=================== -Delivery guarantees -=================== - -For at-most-once, the sender settles the message as soon as it sends -it. If the connection is lost before the message is received by the -receiver, the message will not be delivered. - -For at-least-once, the receiver accepts and settles the message on -receipt. If the connection is lost before the sender is informed of -the settlement, then the delivery is considered in-doubt and should be -retried. This will ensure it eventually gets delivered (provided of -course the connection and link can be reestablished). It may mean that -it is delivered multiple times though. - -Finally, for exactly-once, the receiver accepts the message but -doesn't settle it. The sender settles once it is aware that the -receiver accepted it. In this way the receiver retains knowledge of an -accepted message until it is sure the sender knows it has been -accepted. If the connection is lost before settlement, the receiver -informs the sender of all the unsettled deliveries it knows about, and -from this the sender can deduce which need to be redelivered. The -sender likewise informs the receiver which deliveries it knows about, -from which the receiver can deduce which have already been settled. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
