summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2011-01-11 16:02:23 +0000
committerTed Ross <tross@apache.org>2011-01-11 16:02:23 +0000
commit8850626ab31ff00e0eca619fda60a72775005eaa (patch)
tree26401f8d7645e4b6530def1321976892ffbbd51a
parente6d7b4bec1db40e93496177db4fdcc0b2cc8fcd2 (diff)
downloadqpid-python-8850626ab31ff00e0eca619fda60a72775005eaa.tar.gz
QMFv2 API change:
1) Added public constructor for DataAddr(Variant::Map) 2) Fixed Python and Ruby typemaps to support Variant::Map& and Variant::List& with const 3) Added support for building Queries based on object-id maps in both Python and Ruby wrappers git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1057709 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/bindings/qmf2/python/qmf2.py14
-rw-r--r--qpid/cpp/bindings/qmf2/ruby/qmf2.rb14
-rw-r--r--qpid/cpp/bindings/swig_python_typemaps.i24
-rw-r--r--qpid/cpp/bindings/swig_ruby_typemaps.i18
-rw-r--r--qpid/cpp/include/qmf/DataAddr.h1
-rw-r--r--qpid/cpp/src/qmf/DataAddr.cpp1
-rw-r--r--qpid/cpp/src/qmf/DataAddrImpl.h2
7 files changed, 59 insertions, 15 deletions
diff --git a/qpid/cpp/bindings/qmf2/python/qmf2.py b/qpid/cpp/bindings/qmf2/python/qmf2.py
index 28e40d59ca..911b080dfd 100644
--- a/qpid/cpp/bindings/qmf2/python/qmf2.py
+++ b/qpid/cpp/bindings/qmf2/python/qmf2.py
@@ -311,7 +311,7 @@ class Agent(object):
"""
"""
if q.__class__ == Query:
- q_arg = Query._impl
+ q_arg = q._impl
else:
q_arg = q
dur = cqpid.Duration(cqpid.Duration.SECOND.getMilliseconds() * timeout)
@@ -366,10 +366,11 @@ class Query(object):
"""
"""
- def __init__(self, *kwargs):
+ def __init__(self, arg1, arg2=None, arg3=None, *kwargs):
"""
"""
- pass
+ if arg1.__class__ == DataAddr:
+ self._impl = cqmf2.Query(arg1._impl)
#===================================================================================================
# DATA
@@ -518,8 +519,11 @@ class DataAddr(object):
"""
"""
- def __init__(self, impl):
- self._impl = impl
+ def __init__(self, arg):
+ if arg.__class__ == dict:
+ self._impl = cqmf2.DataAddr(arg)
+ else:
+ self._impl = arg
def __repr__(self):
return "%s:%s" % (self.getAgentName(), self.getName())
diff --git a/qpid/cpp/bindings/qmf2/ruby/qmf2.rb b/qpid/cpp/bindings/qmf2/ruby/qmf2.rb
index 6c6dbf357d..65cc695c45 100644
--- a/qpid/cpp/bindings/qmf2/ruby/qmf2.rb
+++ b/qpid/cpp/bindings/qmf2/ruby/qmf2.rb
@@ -233,8 +233,10 @@ module Qmf2
class Query
attr_reader :impl
- def initialize
- @impl = nil
+ def initialize(arg1, arg2=nil, arg3=nil)
+ if arg1.class == Qmf2::DataAddr
+ @impl = Cqmf2::Query.new(arg1.impl)
+ end
end
end
@@ -390,8 +392,12 @@ module Qmf2
class DataAddr
attr_reader :impl
- def initialize(impl)
- @impl = impl
+ def initialize(arg)
+ if arg.class == Hash
+ @impl = Cqmf2::DataAddr.new(arg)
+ else
+ @impl = arg
+ end
end
def ==(other)
diff --git a/qpid/cpp/bindings/swig_python_typemaps.i b/qpid/cpp/bindings/swig_python_typemaps.i
index d622ee36e2..57046d2944 100644
--- a/qpid/cpp/bindings/swig_python_typemaps.i
+++ b/qpid/cpp/bindings/swig_python_typemaps.i
@@ -271,10 +271,6 @@ typedef int Py_ssize_t;
Py_INCREF($result);
}
-%typemap(typecheck) qpid::types::Variant::Map& {
- $1 = PyDict_Check($input) ? 1 : 0;
-}
-
/*
* Variant types: C++ --> Python
*/
@@ -314,6 +310,16 @@ typedef int Py_ssize_t;
PyToList($input, $1);
}
+%typemap(in) const qpid::types::Variant::Map const & {
+ $1 = new qpid::types::Variant::Map();
+ PyToMap($input, $1);
+}
+
+%typemap(in) const qpid::types::Variant::List const & {
+ $1 = new qpid::types::Variant::List();
+ PyToList($input, $1);
+}
+
%typemap(freearg) qpid::types::Variant& {
delete $1;
}
@@ -334,7 +340,15 @@ typedef int Py_ssize_t;
$1 = PyDict_Check($input) ? 1 : 0;
}
-%typemap(typecheck) qpid::types::Variant::List& {
+%typemap(typecheck) qpid::types::Variant::List& {
+ $1 = PyList_Check($input) ? 1 : 0;
+}
+
+%typemap(typecheck) const qpid::types::Variant::Map const & {
+ $1 = PyDict_Check($input) ? 1 : 0;
+}
+
+%typemap(typecheck) const qpid::types::Variant::List const & {
$1 = PyList_Check($input) ? 1 : 0;
}
diff --git a/qpid/cpp/bindings/swig_ruby_typemaps.i b/qpid/cpp/bindings/swig_ruby_typemaps.i
index 25a8924c18..b91ca7dfb9 100644
--- a/qpid/cpp/bindings/swig_ruby_typemaps.i
+++ b/qpid/cpp/bindings/swig_ruby_typemaps.i
@@ -267,6 +267,16 @@
RbToList($input, $1);
}
+%typemap(in) const qpid::types::Variant::Map const & {
+ $1 = new qpid::types::Variant::Map();
+ RbToMap($input, $1);
+}
+
+%typemap(in) const qpid::types::Variant::List const & {
+ $1 = new qpid::types::Variant::List();
+ RbToList($input, $1);
+}
+
%typemap(freearg) qpid::types::Variant& {
delete $1;
}
@@ -291,6 +301,14 @@
$1 = (TYPE($input) == T_ARRAY) ? 1 : 0;
}
+%typemap(typecheck) qpid::types::Variant::Map const & {
+ $1 = (TYPE($input) == T_HASH) ? 1 : 0;
+}
+
+%typemap(typecheck) qpid::types::Variant::List const & {
+ $1 = (TYPE($input) == T_ARRAY) ? 1 : 0;
+}
+
%typemap(typecheck) qpid::types::Variant& {
$1 = (TYPE($input) == T_FLOAT ||
TYPE($input) == T_STRING ||
diff --git a/qpid/cpp/include/qmf/DataAddr.h b/qpid/cpp/include/qmf/DataAddr.h
index fd8a8599c1..72de0c986a 100644
--- a/qpid/cpp/include/qmf/DataAddr.h
+++ b/qpid/cpp/include/qmf/DataAddr.h
@@ -44,6 +44,7 @@ namespace qmf {
QMF_EXTERN bool operator==(const DataAddr&);
QMF_EXTERN bool operator<(const DataAddr&);
+ QMF_EXTERN DataAddr(const qpid::types::Variant::Map&);
QMF_EXTERN DataAddr(const std::string& name, const std::string& agentName, uint32_t agentEpoch=0);
QMF_EXTERN const std::string& getName() const;
QMF_EXTERN const std::string& getAgentName() const;
diff --git a/qpid/cpp/src/qmf/DataAddr.cpp b/qpid/cpp/src/qmf/DataAddr.cpp
index c864ac9bf4..fb51d5787f 100644
--- a/qpid/cpp/src/qmf/DataAddr.cpp
+++ b/qpid/cpp/src/qmf/DataAddr.cpp
@@ -38,6 +38,7 @@ DataAddr& DataAddr::operator=(const DataAddr& s) { return PI::assign(*this, s);
bool DataAddr::operator==(const DataAddr& o) { return *impl == *o.impl; }
bool DataAddr::operator<(const DataAddr& o) { return *impl < *o.impl; }
+DataAddr::DataAddr(const qpid::types::Variant::Map& m) { PI::ctor(*this, new DataAddrImpl(m)); }
DataAddr::DataAddr(const string& n, const string& a, uint32_t e) { PI::ctor(*this, new DataAddrImpl(n, a, e)); }
const string& DataAddr::getName() const { return impl->getName(); }
const string& DataAddr::getAgentName() const { return impl->getAgentName(); }
diff --git a/qpid/cpp/src/qmf/DataAddrImpl.h b/qpid/cpp/src/qmf/DataAddrImpl.h
index 26acd60575..3f9cae9453 100644
--- a/qpid/cpp/src/qmf/DataAddrImpl.h
+++ b/qpid/cpp/src/qmf/DataAddrImpl.h
@@ -32,7 +32,6 @@ namespace qmf {
//
// Impl-only methods
//
- DataAddrImpl(const qpid::types::Variant::Map&);
void setName(const std::string& n) { name = n; }
void setAgent(const std::string& n, uint32_t e=0) { agentName = n; agentEpoch = e; }
@@ -41,6 +40,7 @@ namespace qmf {
//
bool operator==(const DataAddrImpl&);
bool operator<(const DataAddrImpl&);
+ DataAddrImpl(const qpid::types::Variant::Map&);
DataAddrImpl(const std::string& _name, const std::string& _agentName, uint32_t _agentEpoch=0) :
agentName(_agentName), name(_name), agentEpoch(_agentEpoch) {}
const std::string& getName() const { return name; }