You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2017/01/10 15:58:40 UTC
[19/55] [partial] qpid-proton-j git commit: PROTON-1385: retain
proton-j content only, the rest remains in the other repo at:
https://git-wip-us.apache.org/repos/asf/qpid-proton.git
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/python/setup.py.in
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setup.py.in b/proton-c/bindings/python/setup.py.in
deleted file mode 100755
index 57f4368..0000000
--- a/proton-c/bindings/python/setup.py.in
+++ /dev/null
@@ -1,323 +0,0 @@
-#!/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.
-
-"""
-python-qpid-proton setup script
-
-DISCLAIMER: This script took lots of inspirations from PyZMQ, which is licensed
-under the 'MODIFIED BSD LICENSE'.
-
-Although inspired by the work in PyZMQ, this script and the modules it depends
-on were largely simplified to meet the requirements of the library.
-
-The behavior of this script is to build the registered `_cproton` extension
-using the installed Qpid Proton C library and header files. If the library and
-headers are not installed, or the installed version does not match the version
-of these python bindings, then the script will attempt to build the extension
-using the Proton C sources included in the python source distribution package.
-
-While the above removes the need of *always* having Qpid Proton C development
-files installed, it does not solve the need of having `swig` and the libraries
-qpid-proton requires installed to make this setup work.
-
-From the Python side, this scripts overrides 1 command - build_ext - and it adds a
-new one. The latter - Configure - is called from the former to setup/discover what's
-in the system. The rest of the comands and steps are done normally without any kind
-of monkey patching.
-"""
-
-import glob
-import os
-import subprocess
-import sys
-
-import distutils.spawn as ds_spawn
-import distutils.sysconfig as ds_sys
-from distutils.ccompiler import new_compiler, get_default_compiler
-from distutils.core import setup, Extension
-from distutils.command.build import build
-from distutils.command.build_ext import build_ext
-from distutils.command.sdist import sdist
-from distutils import errors
-
-from setuputils import log
-from setuputils import misc
-
-
-_PROTON_VERSION=(@PN_VERSION_MAJOR@,
- @PN_VERSION_MINOR@,
- @PN_VERSION_POINT@)
-_PROTON_VERSION_STR = "%d.%d.%d" % _PROTON_VERSION
-
-
-class CheckSDist(sdist):
-
- def run(self):
- self.distribution.run_command('configure')
-
- # Append the source that was removed during
- # the configuration step.
- _cproton = self.distribution.ext_modules[-1]
- _cproton.sources.append('cproton.i')
-
- try:
- sdist.run(self)
- finally:
- for src in ['cproton.py', 'cproton_wrap.c']:
- if os.path.exists(src):
- os.remove(src)
-
-
-class Configure(build_ext):
- description = "Discover Qpid Proton version"
-
- @property
- def compiler_type(self):
- compiler = self.compiler
- if compiler is None:
- return get_default_compiler()
- elif isinstance(compiler, str):
- return compiler
- else:
- return compiler.compiler_type
-
- def prepare_swig_wrap(self):
- """Run swig against the sources. This will cause swig to compile the
- cproton.i file into a .c file called cproton_wrap.c, and create
- cproton.py.
- """
- ext = self.distribution.ext_modules[-1]
-
- if 'SWIG' in os.environ:
- self.swig = os.environ['SWIG']
-
- try:
- # This will actually call swig to generate the files
- # and list the sources.
- self.swig_sources(ext.sources, ext)
- except (errors.DistutilsExecError, errors.DistutilsPlatformError) as e:
- if not (os.path.exists('cproton_wrap.c') or
- os.path.exists('cproton.py')):
- raise e
-
- # now remove the cproton.i file from the source list so we don't run
- # swig again.
- ext.sources = ext.sources[1:]
- ext.swig_opts = []
-
- def use_bundled_proton(self):
- """The proper version of libqpid-proton is not installed on the system,
- so use the included proton-c sources to build the extension
- """
- log.info("Building the bundled proton-c sources into the extension")
-
- setup_path = os.path.dirname(os.path.realpath(__file__))
- base = self.get_finalized_command('build').build_base
- build_include = os.path.join(base, 'include')
- proton_base = os.path.abspath(os.path.join(setup_path, 'proton-c'))
- proton_src = os.path.join(proton_base, 'src')
- proton_include = os.path.join(proton_base, 'include')
-
- log.debug("Using Proton C sources: %s" % proton_base)
-
- # Collect all the Proton C files that need to be built.
- # we could've used `glob(.., '*', '*.c')` but I preferred going
- # with an explicit list of subdirs that we can control and expand
- # depending on the version. Specifically, lets avoid adding things
- # we don't need.
-
- sources = []
- for subdir in ['core', 'core/object', 'compiler',
- 'extra', 'message', 'reactor', 'messenger', 'handlers',
- 'platform', 'reactor/io/posix']:
-
- sources.extend(glob.glob(os.path.join(proton_src, subdir, '*.c')))
-
- sources.extend(filter(lambda x: not x.endswith('dump.c'),
- glob.iglob(os.path.join(proton_src, '*.c'))))
-
- # Look for any optional libraries that proton needs, and adjust the
- # source list and compile flags as necessary.
- libraries = []
-
- # -D flags (None means no value, just define)
- macros=[('qpid_proton_EXPORTS', None),
- ('USE_ATOLL', None),
- ('USE_STRERROR_R', None)]
-
- # Check whether openssl is installed by poking
- # pkg-config for a minimum version 0. If it's installed, it should
- # return True and we'll use it. Otherwise, we'll use the stub.
- if misc.pkg_config_version_installed('openssl', atleast='0'):
- libraries += ['ssl', 'crypto']
- sources.append(os.path.join(proton_src, 'ssl', 'openssl.c'))
- else:
- sources.append(os.path.join(proton_src, 'ssl', 'ssl_stub.c'))
- log.warn("OpenSSL not installed - disabling SSL support!")
-
- # create a temp compiler to check for optional compile-time features
- cc = new_compiler(compiler=self.compiler_type)
- cc.output_dir = self.build_temp
-
- # Some systems need to link to `rt`. Check whether `clock_gettime` is
- # around and if librt is needed
- if cc.has_function('clock_gettime'):
- macros.append(('USE_CLOCK_GETTIME', None))
- else:
- if cc.has_function('clock_gettime', libraries=['rt']):
- libraries.append('rt')
- macros.append(('USE_CLOCK_GETTIME', None))
-
- # 0.10 added an implementation for cyrus. Check
- # if it is available before adding the implementation to the sources
- # list. Eventually, `sasl.c` will be added and one of the existing
- # implementations will be used.
- if cc.has_function('sasl_client_done', includes=['sasl/sasl.h'],
- libraries=['sasl2']):
- libraries.append('sasl2')
- sources.append(os.path.join(proton_src, 'sasl', 'cyrus_sasl.c'))
- else:
- sources.append(os.path.join(proton_src, 'sasl', 'none_sasl.c'))
- log.warn("Cyrus SASL not installed - only the ANONYMOUS and"
- " PLAIN mechanisms will be supported!")
- sources.append(os.path.join(proton_src, 'sasl', 'sasl.c'))
-
- # compile all the proton sources. We'll add the resulting list of
- # objects to the _cproton extension as 'extra objects'. We do this
- # instead of just lumping all the sources into the extension to prevent
- # any proton-specific compilation flags from affecting the compilation
- # of the generated swig code
-
- cc = new_compiler(compiler=self.compiler_type)
- ds_sys.customize_compiler(cc)
-
- objects = cc.compile(sources,
- macros=macros,
- include_dirs=[build_include,
- proton_include,
- proton_src],
- # compiler command line options:
- extra_postargs=['-std=gnu99'],
- output_dir=self.build_temp)
-
- #
- # Now update the _cproton extension instance passed to setup to include
- # the objects and libraries
- #
- _cproton = self.distribution.ext_modules[-1]
- _cproton.extra_objects = objects
- _cproton.include_dirs.append(build_include)
- _cproton.include_dirs.append(proton_include)
-
- # swig will need to access the proton headers:
- _cproton.swig_opts.append('-I%s' % build_include)
- _cproton.swig_opts.append('-I%s' % proton_include)
-
- # lastly replace the libqpid-proton dependency with libraries required
- # by the Proton objects:
- _cproton.libraries=libraries
-
- def libqpid_proton_installed(self, version):
- """Check to see if the proper version of the Proton development library
- and headers are already installed
- """
- return misc.pkg_config_version_installed('libqpid-proton', version)
-
- def use_installed_proton(self):
- """The Proton development headers and library are installed, update the
- _cproton extension to tell it where to find the library and headers.
- """
- # update the Extension instance passed to setup() to use the installed
- # headers and link library
- _cproton = self.distribution.ext_modules[-1]
- incs = misc.pkg_config_get_var('libqpid-proton', 'includedir')
- for i in incs.split():
- _cproton.swig_opts.append('-I%s' % i)
- _cproton.include_dirs.append(i)
- ldirs = misc.pkg_config_get_var('libqpid-proton', 'libdir')
- _cproton.library_dirs.extend(ldirs.split())
-
- def run(self):
- # check if the Proton library and headers are installed and are
- # compatible with this version of the binding.
- if self.libqpid_proton_installed(_PROTON_VERSION_STR):
- self.use_installed_proton()
- else:
- # Proton not installed or compatible, use bundled proton-c sources
- self.use_bundled_proton()
- self.prepare_swig_wrap()
-
-
-class CustomBuildOrder(build):
- # The sole purpose of this class is to re-order
- # the commands execution so that `build_ext` is executed *before*
- # build_py. We need this to make sure `cproton.py` is generated
- # before the python modules are collected. Otherwise, it won't
- # be installed.
- sub_commands = [
- ('build_ext', build.has_ext_modules),
- ('build_py', build.has_pure_modules),
- ('build_clib', build.has_c_libraries),
- ('build_scripts', build.has_scripts),
- ]
-
-
-class CheckingBuildExt(build_ext):
- """Subclass build_ext to build qpid-proton using `cmake`"""
-
- def run(self):
- # Discover qpid-proton in the system
- self.distribution.run_command('configure')
- build_ext.run(self)
-
-
-# Override `build_ext` and add `configure`
-cmdclass = {'configure': Configure,
- 'build': CustomBuildOrder,
- 'build_ext': CheckingBuildExt,
- 'sdist': CheckSDist}
-
-setup(name='python-qpid-proton',
- version=_PROTON_VERSION_STR + os.environ.get('PROTON_VERSION_SUFFIX', ''),
- description='An AMQP based messaging library.',
- author='Apache Qpid',
- author_email='proton@qpid.apache.org',
- url='http://qpid.apache.org/proton/',
- packages=['proton'],
- py_modules=['cproton'],
- license="Apache Software License",
- classifiers=["License :: OSI Approved :: Apache Software License",
- "Intended Audience :: Developers",
- "Programming Language :: Python",
- "Programming Language :: Python :: 2",
- "Programming Language :: Python :: 2.6",
- "Programming Language :: Python :: 2.7",
- "Programming Language :: Python :: 3",
- "Programming Language :: Python :: 3.3",
- "Programming Language :: Python :: 3.4",
- "Programming Language :: Python :: 3.5"],
- cmdclass=cmdclass,
- # Note well: the following extension instance is modified during the
- # installation! If you make changes below, you may need to update the
- # Configure class above
- ext_modules=[Extension('_cproton',
- sources=['cproton.i', 'cproton_wrap.c'],
- swig_opts=['-threads'],
- extra_compile_args=['-pthread'],
- libraries=['qpid-proton'])])
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/python/setuputils/PYZMQ_LICENSE.BSD
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setuputils/PYZMQ_LICENSE.BSD b/proton-c/bindings/python/setuputils/PYZMQ_LICENSE.BSD
deleted file mode 100644
index a0a3790..0000000
--- a/proton-c/bindings/python/setuputils/PYZMQ_LICENSE.BSD
+++ /dev/null
@@ -1,32 +0,0 @@
-PyZMQ is licensed under the terms of the Modified BSD License (also known as
-New or Revised BSD), as follows:
-
-Copyright (c) 2009-2012, Brian Granger, Min Ragan-Kelley
-
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-Redistributions of source code must retain the above copyright notice, this
-list of conditions and the following disclaimer.
-
-Redistributions in binary form must reproduce the above copyright notice, this
-list of conditions and the following disclaimer in the documentation and/or
-other materials provided with the distribution.
-
-Neither the name of PyZMQ nor the names of its contributors may be used to
-endorse or promote products derived from this software without specific prior
-written permission.
-
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/python/setuputils/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setuputils/__init__.py b/proton-c/bindings/python/setuputils/__init__.py
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/python/setuputils/log.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setuputils/log.py b/proton-c/bindings/python/setuputils/log.py
deleted file mode 100644
index f11b255..0000000
--- a/proton-c/bindings/python/setuputils/log.py
+++ /dev/null
@@ -1,46 +0,0 @@
-#-----------------------------------------------------------------------------
-# Copyright (C) PyZMQ Developers
-# Distributed under the terms of the Modified BSD License.
-#
-# This bundling code is largely adapted from pyzmq-static's get.sh by
-# Brandon Craig-Rhodes, which is itself BSD licensed.
-#-----------------------------------------------------------------------------
-
-#-----------------------------------------------------------------------------
-# Logging (adapted from h5py: http://h5py.googlecode.com)
-#-----------------------------------------------------------------------------
-
-#-----------------------------------------------------------------------------
-# This log code is largely adapted from pyzmq's code
-# PyZMQ Developers, which is itself Modified BSD licensed.
-#-----------------------------------------------------------------------------
-
-
-import os
-import sys
-import logging
-
-
-logger = logging.getLogger()
-if os.environ.get('DEBUG'):
- logger.setLevel(logging.DEBUG)
-else:
- logger.setLevel(logging.INFO)
-logger.addHandler(logging.StreamHandler(sys.stderr))
-
-
-def debug(msg):
- logger.debug(msg)
-
-
-def info(msg):
- logger.info(msg)
-
-
-def fatal(msg, code=1):
- logger.error("Fatal: " + msg)
- exit(code)
-
-
-def warn(msg):
- logger.error("Warning: " + msg)
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/python/setuputils/misc.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setuputils/misc.py b/proton-c/bindings/python/setuputils/misc.py
deleted file mode 100644
index 54a8fde..0000000
--- a/proton-c/bindings/python/setuputils/misc.py
+++ /dev/null
@@ -1,86 +0,0 @@
-#-----------------------------------------------------------------------------
-# Copyright (C) PyZMQ Developers
-# Distributed under the terms of the Modified BSD License.
-#
-# This bundling code is largely adapted from pyzmq-static's get.sh by
-# Brandon Craig-Rhodes, which is itself BSD licensed.
-#-----------------------------------------------------------------------------
-
-#-----------------------------------------------------------------------------
-# These functions were largely adapted from pyzmq's code
-# PyZMQ Developers, which is itself Modified BSD licensed.
-#-----------------------------------------------------------------------------
-
-
-import errno
-import os
-import subprocess
-import sys
-
-from . import log
-
-def _call_pkg_config(args):
- """Spawn a subprocess running pkg-config with the given args.
-
- :param args: list of strings to pass to pkg-config's command line.
- Refer to pkg-config's documentation for more detail.
-
- Return the Popen object, or None if the command failed
- """
- try:
- return subprocess.Popen(['pkg-config'] + args,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE,
- universal_newlines=True)
- except OSError as e:
- if e.errno == errno.ENOENT:
- log.warn("command not found: pkg-config")
- else:
- log.warn("Running pkg-config failed - %s." % e)
- return None
-
-
-
-def pkg_config_version_installed(package, version=None, atleast=None):
- """Check if version of a package is is installed
-
- This function returns True/False depending on whether
- the package is found and is the correct version.
-
- :param version: The exact version of the package required
- :param atleast: True if installed package is at least this version
- """
-
- if version is None and atleast is None:
- log.fatal('package version string required')
- elif version and atleast:
- log.fatal('Specify either version or atleast, not both')
-
- check = 'exact' if version else 'atleast'
- p = _call_pkg_config(['--%s-version=%s' % (check,
- version or atleast),
- package])
- if p:
- out,err = p.communicate()
- if p.returncode:
- log.info("Did not find %s via pkg-config: %s" % (package, err))
- return False
- log.info("Using %s version %s (found via pkg-config)" %
- (package,
- _call_pkg_config(['--modversion', package]).communicate()[0]))
- return True
- return False
-
-
-def pkg_config_get_var(package, name):
- """Retrieve the value of the named package variable as a string
- """
- p = _call_pkg_config(['--variable=%s' % name, package])
- if not p:
- log.warn("pkg-config: var %s get failed, package %s", name, package)
- return ""
- out,err = p.communicate()
- if p.returncode:
- out = ""
- log.warn(err)
- return out
-
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/.gitignore
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/.gitignore b/proton-c/bindings/ruby/.gitignore
deleted file mode 100644
index 153f4ae..0000000
--- a/proton-c/bindings/ruby/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-coverage
-ext/cproton/cproton.c
-html
-lib/*.so
-pkg
-tmp
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/.yardopts
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/.yardopts b/proton-c/bindings/ruby/.yardopts
deleted file mode 100644
index bea5abe..0000000
--- a/proton-c/bindings/ruby/.yardopts
+++ /dev/null
@@ -1 +0,0 @@
---no-private lib/**/*.rb
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/CMakeLists.txt b/proton-c/bindings/ruby/CMakeLists.txt
deleted file mode 100644
index 05c2a72..0000000
--- a/proton-c/bindings/ruby/CMakeLists.txt
+++ /dev/null
@@ -1,96 +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.
-#
-
-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
- ${PROTON_HEADERS}
-)
-
-include_directories (${RUBY_INCLUDE_PATH})
-swig_add_module(cproton-ruby ruby ruby.i)
-swig_link_libraries(cproton-ruby ${BINDING_DEPS} ${RUBY_LIBRARY})
-
-# set a compiler macro to relay the Ruby version to the extension.
-# Don't use the global CMAKE_C_FLAGS, -fvisibility=hidden causes an obscure
-# failure with release builds.
-string(REPLACE "." "" CFLAG_RUBY_VERSION "${RUBY_VERSION}")
-string(SUBSTRING "${CFLAG_RUBY_VERSION}" 0 2 CFLAG_RUBY_VERSION)
-set(CMAKE_C_FLAGS "-DRUBY${CFLAG_RUBY_VERSION}")
-
-set_target_properties(cproton-ruby
- PROPERTIES
- PREFIX ""
- OUTPUT_NAME "cproton"
- LINK_FLAGS "${CATCH_UNDEFINED}" )
-
-if (CHECK_SYSINSTALL_RUBY)
- execute_process(COMMAND ${RUBY_EXECUTABLE}
- -r rbconfig -e "print RbConfig::CONFIG['vendorarchdir'] || ''"
- RESULT_VARIABLE RESULT_RUBY_ARCHLIB_DIR
- OUTPUT_VARIABLE OUTPUT_RUBY_ARCHLIB_DIR)
-
- if(OUTPUT_RUBY_ARCHLIB_DIR STREQUAL "")
- execute_process(COMMAND ${RUBY_EXECUTABLE}
- -r rbconfig -e "print RbConfig::CONFIG['archdir'] || ''"
- RESULT_VARIABLE RESULT_RUBY_ARCHLIB_DIR
- OUTPUT_VARIABLE OUTPUT_RUBY_ARCHLIB_DIR)
- endif()
-
- set(RUBY_ARCHLIB_DIR_DEFAULT "${OUTPUT_RUBY_ARCHLIB_DIR}")
-else (CHECK_SYSINSTALL_RUBY)
- set (RUBY_ARCHLIB_DIR_DEFAULT ${BINDINGS_DIR}/ruby)
-endif (CHECK_SYSINSTALL_RUBY)
-
-if (NOT RUBY_ARCHLIB_DIR)
- set (RUBY_ARCHLIB_DIR ${RUBY_ARCHLIB_DIR_DEFAULT})
-endif()
-
-install(TARGETS cproton-ruby
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
-install(FILES lib/qpid_proton.rb
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
-install(DIRECTORY lib/codec
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
-install(DIRECTORY lib/core
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
-install(DIRECTORY lib/event
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
-install(DIRECTORY lib/handler
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
-install(DIRECTORY lib/messenger
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
-install(DIRECTORY lib/reactor
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
-install(DIRECTORY lib/types
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
-install(DIRECTORY lib/util
- DESTINATION ${RUBY_ARCHLIB_DIR}
- COMPONENT Ruby)
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/ChangeLog
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/ChangeLog b/proton-c/bindings/ruby/ChangeLog
deleted file mode 100644
index ec0429e..0000000
--- a/proton-c/bindings/ruby/ChangeLog
+++ /dev/null
@@ -1,36 +0,0 @@
-Version 0.7:
- * PROTON-452: Exposed Messenger interrupt method.
- * PROTON-454: Add route method to Messenger.
- * PROTON-455: Add rewrite method to Messenger.
- * PROTON-456: Add password property to Messenger.
-
-Version 0.6:
- * PROTON-427: Removed the flag argument from Messenger.settle.
-
-version 0.5:
- * Duck typed the Array class to work with Qpid::Proton::Data.
- * Duck typed the Hash class to work with Qpid::Proton::Data.
- * Fixed broken Rspec tests due to changes in under Proton C.
- - Messenger.receive can accept a negative maximum
- - When testing bad subscribe attempts, tests now use a random string.
- * Fixed encoding decimal128 values.
- * Added properties field to Qpid::Proton::Message.
- * Hashes are now automatically encoded into Data objects.
- * Fixed encoding Time objects.
- * Added instructions field to Qpid::Proton::Message.
- * Added annotations field to Qpid::Proton::Message.
- * Fixed encoding Symbol objects.
- * Added body field to Qpid::Proton::Message.
-
-version 0.4:
- * No language-specific features developed in this release.
-
-version 0.3:
- * No language-specific features developed in this release.
- * Dropped the Rakefile in favor of packaging with a gemspec.
- * Removed the qpid_proton/version.rb file as unused.
-
-version 0.2:
- * First implementation of the stable APIs on top of swig.
- * Wrote the Rspec tests to test the new APIs.
- * Added SimpleCov support to monitor Rspec test coverage.
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/LICENSE
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/LICENSE b/proton-c/bindings/ruby/LICENSE
deleted file mode 100644
index 6b0b127..0000000
--- a/proton-c/bindings/ruby/LICENSE
+++ /dev/null
@@ -1,203 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed 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.
-
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/README.rdoc
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/README.rdoc b/proton-c/bindings/ruby/README.rdoc
deleted file mode 100644
index 1663957..0000000
--- a/proton-c/bindings/ruby/README.rdoc
+++ /dev/null
@@ -1,31 +0,0 @@
-Qpid Proton Ruby Language Bindings
-==================================
-
-The Ruby code contained here provides Ruby language bindings for working
-with the Proton messaging framework.
-
-
-Creating The Bindings
-=====================
-
-To generate the bindings, you will need to have the Proton messaging
-libraries installed. You will also need to have Swig [1].
-
-To generate the bindings, simply type:
-
- gem build qpid_proton.gemspec
-
-This will generate the Ruby wrapper for the C libraries and bundle them,
-along with the public APIs, into a gemfile. You can then install that
-gem file using:
-
- gem install qpid_proton-##.gem
-
-where ## is the release version.
-
-[1] http://www.swig.org/
-
-KNOWN ISSUES
-============
-
- * Setting a pn_atom_t of type String to a nil returns an empty string.
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/TODO
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/TODO b/proton-c/bindings/ruby/TODO
deleted file mode 100644
index 80e0272..0000000
--- a/proton-c/bindings/ruby/TODO
+++ /dev/null
@@ -1,14 +0,0 @@
-Proton Ruby bindings TODO List
-========================================================================
-
-Beyond this simple laundry list, you can find the list of bugs and
-enhacements to be fixed by going to Apache Proton JIRA instance:
-
- https://issues.apache.org/jira/browse/PROTON
-
-Fixes & Improvements
-========================================================================
-* Fix the data mangling that occurs at specific lengths.
-* Find a better way to map between nil/empty strings for pn_atom_t.
-* Fill out the remaining tests for Qpid::Proton::Messenger
-
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/ext/cproton/extconf.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/ext/cproton/extconf.rb b/proton-c/bindings/ruby/ext/cproton/extconf.rb
deleted file mode 100644
index 6c9500b..0000000
--- a/proton-c/bindings/ruby/ext/cproton/extconf.rb
+++ /dev/null
@@ -1,48 +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.
-#
-
-require 'mkmf'
-
-# set the ruby version compiler flag
-runtime_version = RUBY_VERSION.gsub(/\./,'')[0,2]
-$CFLAGS << " -DRUBY#{runtime_version}"
-
-dir_config("qpid-proton")
-
-REQUIRED_LIBRARIES = [
- "qpid-proton",
- ]
-
-REQUIRED_LIBRARIES.each do |library|
- abort "Missing library: #{library}" unless have_library library
-end
-
-REQUIRED_HEADERS = [
- "proton/engine.h",
- "proton/message.h",
- "proton/sasl.h",
- "proton/messenger.h"
- ]
-
-REQUIRED_HEADERS.each do |header|
- abort "Missing header: #{header}" unless have_header header
-end
-
-create_makefile('cproton')
-
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/lib/codec/data.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/codec/data.rb b/proton-c/bindings/ruby/lib/codec/data.rb
deleted file mode 100644
index 010177d..0000000
--- a/proton-c/bindings/ruby/lib/codec/data.rb
+++ /dev/null
@@ -1,912 +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 Qpid::Proton::Codec
-
- # +DataError+ is raised when an error occurs while encoding
- # or decoding data.
- class DataError < Exception; end
-
- # The +Data+ class provides an interface for decoding, extracting,
- # creating, and encoding arbitrary AMQP data. A +Data+ object
- # contains a tree of AMQP values. Leaf nodes in this tree correspond
- # to scalars in the AMQP type system such as INT or STRING. Interior
- # nodes in this tree correspond to compound values in the AMQP type
- # system such as *LIST*,*MAP*, *ARRAY*, or *DESCRIBED*. The root node
- # of the tree is the +Data+ object itself and can have an arbitrary
- # number of children.
- #
- # A +Data+ object maintains the notion of the current sibling node
- # and a current parent node. Siblings are ordered within their parent.
- # Values are accessed and/or added by using the #next, #prev,
- # #enter, and #exit methods to navigate to the desired location in
- # the tree and using the supplied variety of mutator and accessor
- # methods to access or add a value of the desired type.
- #
- # The mutator methods will always add a value _after_ the current node
- # in the tree. If the current node has a next sibling the mutator method
- # will overwrite the value on this node. If there is no current node
- # or the current node has no next sibling then one will be added. The
- # accessor methods always set the added/modified node to the current
- # node. The accessor methods read the value of the current node and do
- # not change which node is current.
- #
- # The following types of scalar values are supported:
- #
- # * NULL
- # * BOOL
- # * UBYTE
- # * BYTE
- # * USHORT
- # * SHORT
- # * UINT
- # * INT
- # * CHAR
- # * ULONG
- # * LONG
- # * TIMESTAMP
- # * FLOAT
- # * DOUBLE
- # * DECIMAL32
- # * DECIMAL64
- # * DECIMAL128
- # * UUID
- # * BINARY
- # * STRING
- # * SYMBOL
- #
- # The following types of compound values are supported:
- #
- # * DESCRIBED
- # * ARRAY
- # * LIST
- # * MAP
- #
- class Data
-
- # Creates a new instance with the specified capacity.
- #
- # @param capacity [Fixnum, Object] The initial capacity or content.
- #
- def initialize(capacity = 16)
- if (!capacity.nil?) &&
- (capacity.is_a?(Fixnum) ||
- capacity.is_a?(Bignum))
- @data = Cproton.pn_data(capacity)
- @free = true
- else
- @data = capacity
- @free = false
- end
-
- # destructor
- ObjectSpace.define_finalizer(self, self.class.finalize!(@data, @free))
- end
-
- # @private
- def self.finalize!(data, free)
- proc {
- Cproton.pn_data_free(data) if free
- }
- end
-
- # @private
- def to_s
- tmp = Cproton.pn_string("")
- Cproton.pn_inspect(@data, tmp)
- result = Cproton.pn_string_get(tmp)
- Cproton.pn_free(tmp)
- return result
- end
-
- # Clears the object.
- #
- def clear
- Cproton.pn_data_clear(@data)
- end
-
- # Clears the current node and sets the parent to the root node.
- #
- # Clearing the current node sets it *before* the first node, calling
- # #next will advance to the first node.
- #
- def rewind
- Cproton.pn_data_rewind(@data)
- end
-
- # Advances the current node to its next sibling and returns its types.
- #
- # If there is no next sibling the current node remains unchanged
- # and nil is returned.
- #
- def next
- Cproton.pn_data_next(@data)
- end
-
- # Advances the current node to its previous sibling and returns its type.
- #
- # If there is no previous sibling then the current node remains unchanged
- # and nil is return.
- #
- def prev
- return Cproton.pn_data_prev(@data) ? type : nil
- end
-
- # Sets the parent node to the current node and clears the current node.
- #
- # Clearing the current node sets it _before_ the first child.
- #
- def enter
- Cproton.pn_data_enter(@data)
- end
-
- # Sets the current node to the parent node and the parent node to its own
- # parent.
- #
- def exit
- Cproton.pn_data_exit(@data)
- end
-
- # Returns the numeric type code of the current node.
- #
- # @return [Fixnum] The current node type.
- # @return [nil] If there is no current node.
- #
- def type_code
- dtype = Cproton.pn_data_type(@data)
- return (dtype == -1) ? nil : dtype
- end
-
- # Return the type object for the current node
- #
- # @param [Fixnum] The object type.
- #
- # @see #type_code
- #
- def type
- Mapping.for_code(type_code)
- end
-
- # Returns a representation of the data encoded in AMQP format.
- #
- # @return [String] The context of the Data as an AMQP data string.
- #
- # @example
- #
- # @data.string = "This is a test."
- # @encoded = @data.encode
- #
- # # @encoded now contains the text "This is a test." encoded for
- # # AMQP transport.
- #
- def encode
- buffer = "\0"*1024
- loop do
- cd = Cproton.pn_data_encode(@data, buffer, buffer.length)
- if cd == Cproton::PN_OVERFLOW
- buffer *= 2
- elsif cd >= 0
- return buffer[0...cd]
- else
- check(cd)
- end
- end
- end
-
- # Decodes the first value from supplied AMQP data and returns the number
- # of bytes consumed.
- #
- # @param encoded [String] The encoded data.
- #
- # @example
- #
- # # SCENARIO: A string of encoded data, @encoded, contains the text
- # # of "This is a test." and is passed to an instance of Data
- # # for decoding.
- #
- # @data.decode(@encoded)
- # @data.string #=> "This is a test."
- #
- def decode(encoded)
- check(Cproton.pn_data_decode(@data, encoded, encoded.length))
- end
-
- # Puts a list value.
- #
- # Elements may be filled by entering the list node and putting element
- # values.
- #
- # @example
- #
- # data = Qpid::Proton::Codec::Data.new
- # data.put_list
- # data.enter
- # data.int = 1
- # data.int = 2
- # data.int = 3
- # data.exit
- #
- def put_list
- check(Cproton.pn_data_put_list(@data))
- end
-
- # If the current node is a list, this returns the number of elements.
- # Otherwise, it returns zero.
- #
- # List elements can be accessed by entering the list.
- #
- # @example
- #
- # count = @data.list
- # @data.enter
- # (0...count).each
- # type = @data.next
- # puts "Value: #{@data.string}" if type == STRING
- # # ... process other node types
- # end
- def list
- Cproton.pn_data_get_list(@data)
- end
-
- # Puts a map value.
- #
- # Elements may be filled by entering the map node and putting alternating
- # key/value pairs.
- #
- # @example
- #
- # data = Qpid::Proton::Codec::Data.new
- # data.put_map
- # data.enter
- # data.string = "key"
- # data.string = "value"
- # data.exit
- #
- def put_map
- check(Cproton.pn_data_put_map(@data))
- end
-
- # If the current node is a map, this returns the number of child
- # elements. Otherwise, it returns zero.
- #
- # Key/value pairs can be accessed by entering the map.
- #
- # @example
- #
- # count = @data.map
- # @data.enter
- # (0...count).each do
- # type = @data.next
- # puts "Key=#{@data.string}" if type == STRING
- # # ... process other key types
- # type = @data.next
- # puts "Value=#{@data.string}" if type == STRING
- # # ... process other value types
- # end
- # @data.exit
- def map
- Cproton.pn_data_get_map(@data)
- end
-
- # @private
- def get_map
- ::Hash.proton_data_get(self)
- end
-
- # Puts an array value.
- #
- # Elements may be filled by entering the array node and putting the
- # element values. The values must all be of the specified array element
- # type.
- #
- # If an array is *described* then the first child value of the array
- # is the descriptor and may be of any type.
- #
- # @param described [Boolean] True if the array is described.
- # @param element_type [Fixnum] The AMQP type for each element of the array.
- #
- # @example
- #
- # # create an array of integer values
- # data = Qpid::Proton::Codec::Data.new
- # data.put_array(false, INT)
- # data.enter
- # data.int = 1
- # data.int = 2
- # data.int = 3
- # data.exit
- #
- # # create a described array of double values
- # data.put_array(true, DOUBLE)
- # data.enter
- # data.symbol = "array-descriptor"
- # data.double = 1.1
- # data.double = 1.2
- # data.double = 1.3
- # data.exit
- #
- def put_array(described, element_type)
- check(Cproton.pn_data_put_array(@data, described, element_type.code))
- end
-
- # If the current node is an array, returns a tuple of the element count, a
- # boolean indicating whether the array is described, and the type of each
- # element. Otherwise it returns +(0, false, nil).
- #
- # Array data can be accessed by entering the array.
- #
- # @example
- #
- # # get the details of thecurrent array
- # count, described, array_type = @data.array
- #
- # # enter the node
- # data.enter
- #
- # # get the next node
- # data.next
- # puts "Descriptor: #{data.symbol}" if described
- # (0...count).each do
- # @data.next
- # puts "Element: #{@data.string}"
- # end
- def array
- count = Cproton.pn_data_get_array(@data)
- described = Cproton.pn_data_is_array_described(@data)
- array_type = Cproton.pn_data_get_array_type(@data)
- return nil if array_type == -1
- [count, described, Mapping.for_code(array_type) ]
- end
-
- # @private
- def get_array
- ::Array.proton_get(self)
- end
-
- # Puts a described value.
- #
- # A described node has two children, the descriptor and the value.
- # These are specified by entering the node and putting the
- # desired values.
- #
- # @example
- #
- # data = Qpid::Proton::Codec::Data.new
- # data.put_described
- # data.enter
- # data.symbol = "value-descriptor"
- # data.string = "the value"
- # data.exit
- #
- def put_described
- check(Cproton.pn_data_put_described(@data))
- end
-
- # @private
- def get_described
- raise TypeError, "not a described type" unless self.described?
- self.enter
- self.next
- type = self.type
- descriptor = type.get(self)
- self.next
- type = self.type
- value = type.get(self)
- self.exit
- Qpid::Proton::Types::Described.new(descriptor, value)
- end
-
- # Checks if the current node is a described value.
- #
- # The described and value may be accessed by entering the described value.
- #
- # @example
- #
- # if @data.described?
- # @data.enter
- # puts "The symbol is #{@data.symbol}"
- # puts "The value is #{@data.string}"
- # end
- def described?
- Cproton.pn_data_is_described(@data)
- end
-
- # Puts a null value.
- #
- def null
- check(Cproton.pn_data_put_null(@data))
- end
-
- # Utility method for Qpid::Proton::Codec::Mapping
- #
- # @private
- #
- def null=(value)
- null
- end
-
- # Puts an arbitrary object type.
- #
- # The Data instance will determine which AMQP type is appropriate and will
- # use that to encode the object.
- #
- # @param object [Object] The value.
- #
- def object=(object)
- Mapping.for_class(object.class).put(self, object)
- end
-
- # Gets the current node, based on how it was encoded.
- #
- # @return [Object] The current node.
- #
- def object
- type = self.type
- return nil if type.nil?
- type.get(data)
- end
-
- # Checks if the current node is null.
- #
- # @return [Boolean] True if the node is null.
- #
- def null?
- Cproton.pn_data_is_null(@data)
- end
-
- # Puts a boolean value.
- #
- # @param value [Boolean] The boolean value.
- #
- def bool=(value)
- check(Cproton.pn_data_put_bool(@data, value))
- end
-
- # If the current node is a boolean, then it returns the value. Otherwise,
- # it returns false.
- #
- # @return [Boolean] The boolean value.
- #
- def bool
- Cproton.pn_data_get_bool(@data)
- end
-
- # Puts an unsigned byte value.
- #
- # @param value [Fixnum] The unsigned byte value.
- #
- def ubyte=(value)
- check(Cproton.pn_data_put_ubyte(@data, value))
- end
-
- # If the current node is an unsigned byte, returns its value. Otherwise,
- # it returns 0.
- #
- # @return [Fixnum] The unsigned byte value.
- #
- def ubyte
- Cproton.pn_data_get_ubyte(@data)
- end
-
- # Puts a byte value.
- #
- # @param value [Fixnum] The byte value.
- #
- def byte=(value)
- check(Cproton.pn_data_put_byte(@data, value))
- end
-
- # If the current node is an byte, returns its value. Otherwise,
- # it returns 0.
- #
- # @return [Fixnum] The byte value.
- #
- def byte
- Cproton.pn_data_get_byte(@data)
- end
-
- # Puts an unsigned short value.
- #
- # @param value [Fixnum] The unsigned short value
- #
- def ushort=(value)
- check(Cproton.pn_data_put_ushort(@data, value))
- end
-
- # If the current node is an unsigned short, returns its value. Otherwise,
- # it returns 0.
- #
- # @return [Fixnum] The unsigned short value.
- #
- def ushort
- Cproton.pn_data_get_ushort(@data)
- end
-
- # Puts a short value.
- #
- # @param value [Fixnum] The short value.
- #
- def short=(value)
- check(Cproton.pn_data_put_short(@data, value))
- end
-
- # If the current node is a short, returns its value. Otherwise,
- # returns a 0.
- #
- # @return [Fixnum] The short value.
- #
- def short
- Cproton.pn_data_get_short(@data)
- end
-
- # Puts an unsigned integer value.
- #
- # @param value [Fixnum] the unsigned integer value
- #
- def uint=(value)
- raise TypeError if value.nil?
- raise RangeError, "invalid uint: #{value}" if value < 0
- check(Cproton.pn_data_put_uint(@data, value))
- end
-
- # If the current node is an unsigned int, returns its value. Otherwise,
- # returns 0.
- #
- # @return [Fixnum] The unsigned integer value.
- #
- def uint
- Cproton.pn_data_get_uint(@data)
- end
-
- # Puts an integer value.
- #
- # ==== Options
- #
- # * value - the integer value
- def int=(value)
- check(Cproton.pn_data_put_int(@data, value))
- end
-
- # If the current node is an integer, returns its value. Otherwise,
- # returns 0.
- #
- # @return [Fixnum] The integer value.
- #
- def int
- Cproton.pn_data_get_int(@data)
- end
-
- # Puts a character value.
- #
- # @param value [Fixnum] The character value.
- #
- def char=(value)
- check(Cproton.pn_data_put_char(@data, value))
- end
-
- # If the current node is a character, returns its value. Otherwise,
- # returns 0.
- #
- # @return [Fixnum] The character value.
- #
- def char
- Cproton.pn_data_get_char(@data)
- end
-
- # Puts an unsigned long value.
- #
- # @param value [Fixnum] The unsigned long value.
- #
- def ulong=(value)
- raise TypeError if value.nil?
- raise RangeError, "invalid ulong: #{value}" if value < 0
- check(Cproton.pn_data_put_ulong(@data, value))
- end
-
- # If the current node is an unsigned long, returns its value. Otherwise,
- # returns 0.
- #
- # @return [Fixnum] The unsigned long value.
- #
- def ulong
- Cproton.pn_data_get_ulong(@data)
- end
-
- # Puts a long value.
- #
- # @param value [Fixnum] The long value.
- #
- def long=(value)
- check(Cproton.pn_data_put_long(@data, value))
- end
-
- # If the current node is a long, returns its value. Otherwise, returns 0.
- #
- # @return [Fixnum] The long value.
- def long
- Cproton.pn_data_get_long(@data)
- end
-
- # Puts a timestamp value.
- #
- # @param value [Fixnum] The timestamp value.
- #
- def timestamp=(value)
- value = value.to_i if (!value.nil? && value.is_a?(Time))
- check(Cproton.pn_data_put_timestamp(@data, value))
- end
-
- # If the current node is a timestamp, returns its value. Otherwise,
- # returns 0.
- #
- # @return [Fixnum] The timestamp value.
- #
- def timestamp
- Cproton.pn_data_get_timestamp(@data)
- end
-
- # Puts a float value.
- #
- # @param value [Float] The floating point value.
- #
- def float=(value)
- check(Cproton.pn_data_put_float(@data, value))
- end
-
- # If the current node is a float, returns its value. Otherwise,
- # returns 0.
- #
- # @return [Float] The floating point value.
- #
- def float
- Cproton.pn_data_get_float(@data)
- end
-
- # Puts a double value.
- #
- # @param value [Float] The double precision floating point value.
- #
- def double=(value)
- check(Cproton.pn_data_put_double(@data, value))
- end
-
- # If the current node is a double, returns its value. Otherwise,
- # returns 0.
- #
- # @return [Float] The double precision floating point value.
- #
- def double
- Cproton.pn_data_get_double(@data)
- end
-
- # Puts a decimal32 value.
- #
- # @param value [Fixnum] The decimal32 value.
- #
- def decimal32=(value)
- check(Cproton.pn_data_put_decimal32(@data, value))
- end
-
- # If the current node is a decimal32, returns its value. Otherwise,
- # returns 0.
- #
- # @return [Fixnum] The decimal32 value.
- #
- def decimal32
- Cproton.pn_data_get_decimal32(@data)
- end
-
- # Puts a decimal64 value.
- #
- # @param value [Fixnum] The decimal64 value.
- #
- def decimal64=(value)
- check(Cproton.pn_data_put_decimal64(@data, value))
- end
-
- # If the current node is a decimal64, returns its value. Otherwise,
- # it returns 0.
- #
- # @return [Fixnum] The decimal64 value.
- #
- def decimal64
- Cproton.pn_data_get_decimal64(@data)
- end
-
- # Puts a decimal128 value.
- #
- # @param value [Fixnum] The decimal128 value.
- #
- def decimal128=(value)
- raise TypeError, "invalid decimal128 value: #{value}" if value.nil?
- value = value.to_s(16).rjust(32, "0")
- bytes = []
- value.scan(/(..)/) {|v| bytes << v[0].to_i(16)}
- check(Cproton.pn_data_put_decimal128(@data, bytes))
- end
-
- # If the current node is a decimal128, returns its value. Otherwise,
- # returns 0.
- #
- # @return [Fixnum] The decimal128 value.
- #
- def decimal128
- value = ""
- Cproton.pn_data_get_decimal128(@data).each{|val| value += ("%02x" % val)}
- value.to_i(16)
- end
-
- # Puts a +UUID+ value.
- #
- # The UUID is expected to be in the format of a string or else a 128-bit
- # integer value.
- #
- # @param value [String, Numeric] A string or numeric representation of the UUID.
- #
- # @example
- #
- # # set a uuid value from a string value
- # require 'securerandom'
- # @data.uuid = SecureRandom.uuid
- #
- # # or
- # @data.uuid = "fd0289a5-8eec-4a08-9283-81d02c9d2fff"
- #
- # # set a uuid value from a 128-bit value
- # @data.uuid = 0 # sets to 00000000-0000-0000-0000-000000000000
- #
- def uuid=(value)
- raise ::ArgumentError, "invalid uuid: #{value}" if value.nil?
-
- # if the uuid that was submitted was numeric value, then translated
- # it into a hex string, otherwise assume it was a string represtation
- # and attempt to decode it
- if value.is_a? Numeric
- value = "%032x" % value
- else
- raise ::ArgumentError, "invalid uuid: #{value}" if !valid_uuid?(value)
-
- value = (value[0, 8] +
- value[9, 4] +
- value[14, 4] +
- value[19, 4] +
- value[24, 12])
- end
- bytes = []
- value.scan(/(..)/) {|v| bytes << v[0].to_i(16)}
- check(Cproton.pn_data_put_uuid(@data, bytes))
- end
-
- # If the current value is a +UUID+, returns its value. Otherwise,
- # it returns nil.
- #
- # @return [String] The string representation of the UUID.
- #
- def uuid
- value = ""
- Cproton.pn_data_get_uuid(@data).each{|val| value += ("%02x" % val)}
- value.insert(8, "-").insert(13, "-").insert(18, "-").insert(23, "-")
- end
-
- # Puts a binary value.
- #
- # A binary string is encoded as an ASCII 8-bit string value. This is in
- # contranst to other strings, which are treated as UTF-8 encoded.
- #
- # @param value [String] An arbitrary string value.
- #
- # @see #string=
- #
- def binary=(value)
- check(Cproton.pn_data_put_binary(@data, value))
- end
-
- # If the current node is binary, returns its value. Otherwise, it returns
- # an empty string ("").
- #
- # @return [String] The binary string.
- #
- # @see #string
- #
- def binary
- Qpid::Proton::Types::BinaryString.new(Cproton.pn_data_get_binary(@data))
- end
-
- # Puts a UTF-8 encoded string value.
- #
- # *NOTE:* A nil value is stored as an empty string rather than as a nil.
- #
- # @param value [String] The UTF-8 encoded string value.
- #
- # @see #binary=
- #
- def string=(value)
- check(Cproton.pn_data_put_string(@data, value))
- end
-
- # If the current node is a string, returns its value. Otherwise, it
- # returns an empty string ("").
- #
- # @return [String] The UTF-8 encoded string.
- #
- # @see #binary
- #
- def string
- Qpid::Proton::Types::UTFString.new(Cproton.pn_data_get_string(@data))
- end
-
- # Puts a symbolic value.
- #
- # @param value [String] The symbolic string value.
- #
- def symbol=(value)
- check(Cproton.pn_data_put_symbol(@data, value))
- end
-
- # If the current node is a symbol, returns its value. Otherwise, it
- # returns an empty string ("").
- #
- # @return [String] The symbolic string value.
- #
- def symbol
- Cproton.pn_data_get_symbol(@data)
- end
-
- # Get the current value as a single object.
- #
- # @return [Object] The current node's object.
- #
- # @see #type_code
- # @see #type
- #
- def get
- type.get(self);
- end
-
- # Puts a new value with the given type into the current node.
- #
- # @param value [Object] The value.
- # @param type_code [Mapping] The value's type.
- #
- # @private
- #
- def put(value, type_code);
- type_code.put(self, value);
- end
-
- private
-
- def valid_uuid?(value)
- # ensure that the UUID is in the right format
- # xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx
- value =~ /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/
- end
-
- # @private
- def check(err)
- if err < 0
- raise DataError, "[#{err}]: #{Cproton.pn_data_error(@data)}"
- else
- return err
- end
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/lib/codec/mapping.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/codec/mapping.rb b/proton-c/bindings/ruby/lib/codec/mapping.rb
deleted file mode 100644
index 4a7d5a7..0000000
--- a/proton-c/bindings/ruby/lib/codec/mapping.rb
+++ /dev/null
@@ -1,169 +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 Qpid::Proton::Codec
-
- # Maps between Proton types and their Ruby native language counterparts.
- #
- # @private
- class Mapping
-
- attr_reader :code
- attr_reader :put_method
- attr_reader :get_method
-
- # Creates a new mapping.
- #
- # ==== Arguments
- #
- # * code - the AMQP code for this type
- # * name - the AMQP name for this type
- # * klasses - the Ruby classes for this type
- # * getter - overrides the get method for the type
- def initialize(code, name, klasses = nil, getter = nil)
-
- @debug = (name == "bool")
-
- @code = code
- @name = name
-
- @@by_preferred ||= {}
- @@by_code ||= {}
- @@by_code["#{code}"] = self
- @@by_name ||= {}
- @@by_name[name] = self
- @@by_class ||= {}
-
- unless klasses.nil?
- klasses.each do |klass|
- raise "entry exists for #{klass}" if @@by_class.keys.include? klass
- @@by_class[klass] = self unless klass.nil?
- end
- end
-
- @put_method = (name + "=").intern
-
- if getter.nil?
- @get_method = name.intern
- else
- @get_method = getter.intern
- end
- end
-
- def to_s; @name; end
-
- def put(data, value)
- data.__send__(@put_method, value)
- end
-
- def get(data)
- data.__send__(@get_method)
- end
-
- def self.for_class(klass) # :nodoc:
- @@by_class[klass]
- end
-
- def self.for_code(code)
- @@by_code["#{code}"]
- end
-
- end
-
- NULL = Mapping.new(Cproton::PN_NULL, "null", [NilClass], "nil?")
- BOOL = Mapping.new(Cproton::PN_BOOL, "bool", [TrueClass, FalseClass], "bool")
- UBYTE = Mapping.new(Cproton::PN_UBYTE, "ubyte")
- BYTE = Mapping.new(Cproton::PN_BYTE, "byte")
- USHORT = Mapping.new(Cproton::PN_USHORT, "ushort")
- SHORT = Mapping.new(Cproton::PN_SHORT, "short")
- UINT = Mapping.new(Cproton::PN_UINT, "uint")
- INT = Mapping.new(Cproton::PN_INT, "int")
- CHAR = Mapping.new(Cproton::PN_CHAR, "char")
- ULONG = Mapping.new(Cproton::PN_ULONG, "ulong")
- LONG = Mapping.new(Cproton::PN_LONG, "long", [Fixnum, Bignum])
- TIMESTAMP = Mapping.new(Cproton::PN_TIMESTAMP, "timestamp", [Date, Time])
- FLOAT = Mapping.new(Cproton::PN_FLOAT, "float")
- DOUBLE = Mapping.new(Cproton::PN_DOUBLE, "double", [Float])
- DECIMAL32 = Mapping.new(Cproton::PN_DECIMAL32, "decimal32")
- DECIMAL64 = Mapping.new(Cproton::PN_DECIMAL64, "decimal64")
- DECIMAL128 = Mapping.new(Cproton::PN_DECIMAL128, "decimal128")
- UUID = Mapping.new(Cproton::PN_UUID, "uuid")
- BINARY = Mapping.new(Cproton::PN_BINARY, "binary")
- STRING = Mapping.new(Cproton::PN_STRING, "string", [String, Symbol,
- Qpid::Proton::Types::UTFString,
- Qpid::Proton::Types::BinaryString])
-
- # @private
- class << STRING
- def put(data, value)
- # if we have a symbol then convert it to a string
- value = value.to_s if value.is_a?(Symbol)
-
- isutf = false
-
- if value.is_a?(Qpid::Proton::Types::UTFString)
- isutf = true
- else
- # For Ruby 1.8 we will just treat all strings as binary.
- # For Ruby 1.9+ we can check the encoding first to see what it is
- if RUBY_VERSION >= "1.9"
- # If the string is ASCII-8BIT then treat is as binary. Otherwise,
- # try to convert it to UTF-8 and, if successful, send as that.
- if value.encoding != Encoding::ASCII_8BIT &&
- value.encode(Encoding::UTF_8).valid_encoding?
- isutf = true
- end
- end
- end
-
- data.string = value if isutf
- data.binary = value if !isutf
-
- end
- end
-
- SYMBOL = Mapping.new(Cproton::PN_SYMBOL, "symbol")
- DESCRIBED = Mapping.new(Cproton::PN_DESCRIBED, "described", [Qpid::Proton::Types::Described], "get_described")
- ARRAY = Mapping.new(Cproton::PN_ARRAY, "array", nil, "get_array")
- LIST = Mapping.new(Cproton::PN_LIST, "list", [::Array], "get_array")
- MAP = Mapping.new(Cproton::PN_MAP, "map", [::Hash], "get_map")
-
- # @private
- class << MAP
- def put(data, map, options = {})
- data.put_map
- data.enter
- map.each_pair do |key, value|
- if options[:keys] == :SYMBOL
- SYMBOL.put(data, key)
- else
- Mapping.for_class(key.class).put(data, key)
- end
-
- if value.nil?
- data.null
- else
- Mapping.for_class(value.class).put(data, value)
- end
- end
- data.exit
- end
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/lib/core/base_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/base_handler.rb b/proton-c/bindings/ruby/lib/core/base_handler.rb
deleted file mode 100644
index 9a7ece4..0000000
--- a/proton-c/bindings/ruby/lib/core/base_handler.rb
+++ /dev/null
@@ -1,31 +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 Qpid::Proton
-
- class BaseHandler
-
- # Override to process unhandled events.
- #
- def on_unhandled(method, *args)
- end
-
- end
-
-end
http://git-wip-us.apache.org/repos/asf/qpid-proton-j/blob/2f85988e/proton-c/bindings/ruby/lib/core/connection.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/connection.rb b/proton-c/bindings/ruby/lib/core/connection.rb
deleted file mode 100644
index 252193d..0000000
--- a/proton-c/bindings/ruby/lib/core/connection.rb
+++ /dev/null
@@ -1,328 +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 Qpid::Proton
-
- # A Connection option has at most one Qpid::Proton::Transport instance.
- #
- class Connection < Endpoint
-
- # @private
- include Util::SwigHelper
-
- # @private
- PROTON_METHOD_PREFIX = "pn_connection"
-
- # @!attribute hostname
- #
- # @return [String] The AMQP hostname for the connection.
- #
- proton_accessor :hostname
-
- # @private
- proton_reader :attachments
-
- attr_accessor :overrides
- attr_accessor :session_policy
-
- # @private
- include Util::Wrapper
-
- # @private
- def self.wrap(impl)
- return nil if impl.nil?
-
- self.fetch_instance(impl, :pn_connection_attachments) || Connection.new(impl)
- end
-
- # Constructs a new instance of Connection.
- #
- # You do *not* need to provide the underlying C struct, as this is
- # automatically generated as needed. The argument is a convenience
- # for returning existing Connection objects.
- #
- # @param impl [pn_connection_t] The pn_connection_t struct.
- #
- def initialize(impl = Cproton.pn_connection)
- super()
- @impl = impl
- @offered_capabilities = nil
- @desired_capabilities = nil
- @properties = nil
- @overrides = nil
- @collector = nil
- @session_policy = nil
- self.class.store_instance(self, :pn_connection_attachments)
- end
-
- def overrides?
- !@overrides.nil?
- end
-
- def session_policy?
- !@session_policy.nil?
- end
-
- # This method is used when working within the context of an event.
- #
- # @return [Connection] The connection itself.
- #
- def connection
- self
- end
-
- # The Transport to which this connection is bound.
- #
- # @return [Transport] The transport, or nil if the Connection is unbound.
- #
- def transport
- Transport.wrap(Cproton.pn_connection_transport(@impl))
- end
-
- # Associates the connection with an event collector.
- #
- # By doing this, key changes in the endpoint's state are reported to
- # the connector via Event objects that can be inspected and processed.
- #
- # Note that, by registering a collector, the user is requesting that an
- # indefinite number of events be queued up on its behalf. This means
- # that, unless the application eventual processes these events, the
- # storage requirements for keeping them will grow without bound. So be
- # careful and do not register a collector with a connection unless the
- # application will process the events.
- #
- # @param collector [Event::Collector] The event collector.
- #
- def collect(collector)
- if collector.nil?
- Cproton.pn_connection_collect(@impl, nil)
- else
- Cproton.pn_connection_collect(@impl, collector.impl)
- end
- @collector = collector
- end
-
- # Get the AMQP container name advertised by the remote connection
- # endpoint.
- #
- # This will return nil until the REMOTE_ACTIVE state is reached.
- #
- # Any non-nil container returned by this operation will be valid
- # until the connection is unbound from a transport, or freed,
- # whichever happens sooner.
- #
- # @return [String] The remote connection's AMQP container name.
- #
- # @see #container
- #
- def remote_container
- Cproton.pn_connection_remote_container(@impl)
- end
-
- def container=(name)
- Cproton.pn_connection_set_container(@impl, name)
- end
-
- def container
- Cproton.pn_connection_get_container(@impl)
- end
-
- # Get the AMQP hostname set by the remote connection endpoint.
- #
- # This will return nil until the #REMOTE_ACTIVE state is
- # reached.
- #
- # @return [String] The remote connection's AMQP hostname.
- #
- # @see #hostname
- #
- def remote_hostname
- Cproton.pn_connection_remote_hostname(@impl)
- end
-
- # Get the AMQP offered capabilities suppolied by the remote connection
- # endpoint.
- #
- # This object returned is valid until the connection is freed. The Data
- # object will be empty until the remote connection is opened, as
- # indicated by the #REMOTE_ACTIVE flag.
- #
- # @return [Data] The offered capabilities.
- #
- def remote_offered_capabilities
- data_to_object(Cproton.pn_connection_remote_offered_capabilities(@impl))
- end
-
- # Get the AMQP desired capabilities supplied by the remote connection
- # endpoint.
- #
- # The object returned is valid until the connection is freed. The Data
- # object will be empty until the remote connection is opened, as
- # indicated by the #REMOTE_ACTIVE flag.
- #
- # @return [Data] The desired capabilities.
- #
- def remote_desired_capabilities
- data_to_object(Cproton.pn_connection_remote_desired_capabilities(@impl))
- end
-
- # Get the AMQP connection properties supplie by the remote connection
- # endpoint.
- #
- # The object returned is valid until the connection is freed. The Data
- # object will be empty until the remote connection is opened, as
- # indicated by the #REMOTE_ACTIVE flag.
- #
- # @return [Data] The remote properties.
- #
- def remote_properties
- data_to_object(Cproton.pn_connection_remote_properites(@impl))
- end
-
- # Opens the connection.
- #
- def open
- object_to_data(@offered_capabilities,
- Cproton.pn_connection_offered_capabilities(@impl))
- object_to_data(@desired_capabilities,
- Cproton.pn_connection_desired_capabilities(@impl))
- object_to_data(@properties,
- Cproton.pn_connection_properties(@impl))
- Cproton.pn_connection_open(@impl)
- end
-
- # Closes the connection.
- #
- # Once this operation has completed, the #LOCAL_CLOSED state flag will be
- # set.
- #
- def close
- self._update_condition
- Cproton.pn_connection_close(@impl)
- end
-
- # Gets the endpoint current state flags
- #
- # @see Endpoint#LOCAL_UNINIT
- # @see Endpoint#LOCAL_ACTIVE
- # @see Endpoint#LOCAL_CLOSED
- # @see Endpoint#LOCAL_MASK
- #
- # @return [Fixnum] The state flags.
- #
- def state
- Cproton.pn_connection_state(@impl)
- end
-
- # Returns the session for this connection.
- #
- # @return [Session] The session.
- #
- def session
- @session ||= Session.wrap(Cproton.pn_session(@impl))
- end
-
- # Returns the first session from the connection that matches the specified
- # state mask.
- #
- # Examines the state of each session owned by the connection, and returns
- # the first session that matches the given state mask. If the state mask
- # contains *both* local and remote flags, then an exact match against
- # those flags is performed. If the state mask contains only local *or*
- # remote flags, then a match occurs if a*any* of the local or remote flags
- # are set, respectively.
- #
- # @param mask [Fixnum] The state mask to be matched.
- #
- # @return [Session] The first matching session, or nil if none matched.
- #
- # @see Endpoint#LOCAL_UNINIT
- # @see Endpoint#LOCAL_ACTIVE
- # @see Endpoint#LOCAL_CLOSED
- # @see Endpoint#REMOTE_UNINIT
- # @see Endpoint#REMOTE_ACTIVE
- # @see Endpoint#REMOTE_CLOSED
- #
- def session_head(mask)
- Session.wrap(Cproton.pn_session_header(@impl, mask))
- end
-
- # Returns the first link that matches the given state mask.
- #
- # Examines the state of each link owned by the connection and returns the
- # first that matches the given state mask. If the state mask contains
- # *both* local and remote flags, then an exact match against those flags
- # is performed. If the state mask contains *only* local or remote flags,
- # then a match occurs if *any* of the local ore remote flags are set,
- # respectively.
- #
- # @param mask [Fixnum] The state mask to be matched.
- #
- # @return [Link] The first matching link, or nil if none matched.
- #
- # @see Endpoint#LOCAL_UNINIT
- # @see Endpoint#LOCAL_ACTIVE
- # @see Endpoint#LOCAL_CLOSED
- # @see Endpoint#REMOTE_UNINIT
- # @see Endpoint#REMOTE_ACTIVE
- # @see Endpoint#REMOTE_CLOSED
- #
- def link_head(mask)
- Link.wrap(Cproton.pn_link_head(@impl, mask))
- end
-
- # Extracts the first delivery on the connection that has pending
- # operations.
- #
- # A readable delivery indicates message data is waiting to be read. A
- # A writable delivery indcates that message data may be sent. An updated
- # delivery indicates that the delivery's disposition has changed.
- #
- # A delivery will never be *both* readable and writable, but it may be
- # both readable or writable and updated.
- #
- # @return [Delivery] The delivery, or nil if none are available.
- #
- # @see Delivery#next
- #
- def work_head
- Delivery.wrap(Cproton.pn_work_head(@impl))
- end
-
- # Returns the code for a connection error.
- #
- # @return [Fixnum] The error code.
- #
- def error
- Cproton.pn_error_code(Cproton.pn_connection_error(@impl))
- end
-
- # @private
- def _local_condition
- Cproton.pn_connection_condition(@impl)
- end
-
- # @private
- def _remote_condition
- Cproton.pn_connection_remote_condition(@impl)
- end
-
- end
-
-end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org