qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tr...@apache.org
Subject svn commit: r1057774 - in /qpid/trunk/qpid/cpp/bindings: qmf2/examples/cpp/agent.cpp qmf2/examples/python/agent.py qmf2/python/qmf2.py qmf2/ruby/qmf2.rb swig_python_typemaps.i swig_ruby_typemaps.i
Date Tue, 11 Jan 2011 17:58:05 GMT
Author: tross
Date: Tue Jan 11 17:58:04 2011
New Revision: 1057774

URL: http://svn.apache.org/viewvc?rev=1057774&view=rev
Log:
Exposed asMap for DataAddr objects in Pyton and Ruby wrappers.
Enhanced the examples to show the passing of a DataAddr in an argument.

Modified:
    qpid/trunk/qpid/cpp/bindings/qmf2/examples/cpp/agent.cpp
    qpid/trunk/qpid/cpp/bindings/qmf2/examples/python/agent.py
    qpid/trunk/qpid/cpp/bindings/qmf2/python/qmf2.py
    qpid/trunk/qpid/cpp/bindings/qmf2/ruby/qmf2.rb
    qpid/trunk/qpid/cpp/bindings/swig_python_typemaps.i
    qpid/trunk/qpid/cpp/bindings/swig_ruby_typemaps.i

Modified: qpid/trunk/qpid/cpp/bindings/qmf2/examples/cpp/agent.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qmf2/examples/cpp/agent.cpp?rev=1057774&r1=1057773&r2=1057774&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/bindings/qmf2/examples/cpp/agent.cpp (original)
+++ qpid/trunk/qpid/cpp/bindings/qmf2/examples/cpp/agent.cpp Tue Jan 11 17:58:04 2011
@@ -48,6 +48,7 @@ private:
     AgentSession session;
     Schema sch_exception;
     Schema sch_control;
+    Schema sch_child;
     Data control;
     DataAddr controlAddr;
 
@@ -120,11 +121,23 @@ void ExampleAgent::setupSchema()
     failMethod.addArgument(SchemaProperty("details", SCHEMA_DATA_MAP, "{dir:IN}"));
     sch_control.addMethod(failMethod);
 
+    SchemaMethod createMethod("create_child", "{desc:'Create Child Object'}");
+    createMethod.addArgument(SchemaProperty("name", SCHEMA_DATA_STRING, "{dir:IN}"));
+    createMethod.addArgument(SchemaProperty("childAddr", SCHEMA_DATA_MAP, "{dir:OUT}"));
+    sch_control.addMethod(createMethod);
+
+    //
+    // Declare the child class
+    //
+    sch_child = Schema(SCHEMA_TYPE_DATA, package, "child");
+    sch_child.addProperty(SchemaProperty("name", SCHEMA_DATA_STRING));
+
     //
     // Register our schemata with the agent session.
     //
     session.registerSchema(sch_exception);
     session.registerSchema(sch_control);
+    session.registerSchema(sch_child);
 }
 
 void ExampleAgent::populateData()
@@ -185,6 +198,15 @@ bool ExampleAgent::method(AgentEvent& ev
                 session.raiseException(event, ex);
             }
         }
+
+        if (name == "create_child") {
+            const string& name(event.getArguments()["name"]);
+            Data child(sch_child);
+            child.setProperty("name", name);
+            DataAddr addr(session.addData(child, name));
+            event.addReturnArgument("childAddr", addr.asMap());
+            session.methodSuccess(event);
+        }
     }
 
     return true;

Modified: qpid/trunk/qpid/cpp/bindings/qmf2/examples/python/agent.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qmf2/examples/python/agent.py?rev=1057774&r1=1057773&r2=1057774&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/bindings/qmf2/examples/python/agent.py (original)
+++ qpid/trunk/qpid/cpp/bindings/qmf2/examples/python/agent.py Tue Jan 11 17:58:04 2011
@@ -88,6 +88,14 @@ class ExampleAgent(AgentHandler):
           ex.details = args['details']
           self.session.raiseException(handle, ex)
 
+      elif methodName == "create_child":
+        name = args['name']
+        child = Data(self.sch_child)
+        child.name = name
+        addr = self.session.addData(child, name)
+        handle.addReturnArgument("childAddr", addr.asMap())
+        self.session.methodSuccess(handle)
+
 
   def setupSchema(self):
     """
@@ -126,11 +134,23 @@ class ExampleAgent(AgentHandler):
     failMethod.addArgument(SchemaProperty("details", SCHEMA_DATA_MAP, direction=DIR_IN))
     self.sch_control.addMethod(failMethod)
 
+    createMethod = SchemaMethod("create_child", desc="Create Child Object")
+    createMethod.addArgument(SchemaProperty("name", SCHEMA_DATA_STRING, direction=DIR_IN))
+    createMethod.addArgument(SchemaProperty("childAddr", SCHEMA_DATA_MAP, direction=DIR_OUT))
+    self.sch_control.addMethod(createMethod)
+
+    ##
+    ## Declare a child object
+    ##
+    self.sch_child = Schema(SCHEMA_TYPE_DATA, package, "child")
+    self.sch_child.addProperty(SchemaProperty("name", SCHEMA_DATA_STRING))
+
     ##
     ## Register our schemata with the agent session.
     ##
     self.session.registerSchema(self.sch_exception)
     self.session.registerSchema(self.sch_control)
+    self.session.registerSchema(self.sch_child)
 
 
   def populateData(self):

Modified: qpid/trunk/qpid/cpp/bindings/qmf2/python/qmf2.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qmf2/python/qmf2.py?rev=1057774&r1=1057773&r2=1057774&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/bindings/qmf2/python/qmf2.py (original)
+++ qpid/trunk/qpid/cpp/bindings/qmf2/python/qmf2.py Tue Jan 11 17:58:04 2011
@@ -533,6 +533,11 @@ class DataAddr(object):
         self.getName() == other.getName() and \
         self.getAgentEpoch() == other.getAgentEpoch()
 
+  def asMap(self):
+    """
+    """
+    return self._impl.asMap()
+
   def getAgentName(self):
     """
     """

Modified: qpid/trunk/qpid/cpp/bindings/qmf2/ruby/qmf2.rb
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qmf2/ruby/qmf2.rb?rev=1057774&r1=1057773&r2=1057774&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/bindings/qmf2/ruby/qmf2.rb (original)
+++ qpid/trunk/qpid/cpp/bindings/qmf2/ruby/qmf2.rb Tue Jan 11 17:58:04 2011
@@ -404,6 +404,7 @@ module Qmf2
       return @impl == other.impl
     end
 
+    def as_map()       @impl.asMap          end
     def agent_name()   @impl.getAgentName   end
     def name()         @impl.getName        end
     def agent_epoch()  @impl.getAgentEpoch  end

Modified: qpid/trunk/qpid/cpp/bindings/swig_python_typemaps.i
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/swig_python_typemaps.i?rev=1057774&r1=1057773&r2=1057774&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/bindings/swig_python_typemaps.i (original)
+++ qpid/trunk/qpid/cpp/bindings/swig_python_typemaps.i Tue Jan 11 17:58:04 2011
@@ -274,12 +274,24 @@ typedef int Py_ssize_t;
 /*
  * Variant types: C++ --> Python
  */
+%typemap(out) qpid::types::Variant::Map {
+    $result = MapToPy(&$1);
+    if ($result)
+        Py_INCREF($result);
+}
+
 %typemap(out) qpid::types::Variant::Map& {
     $result = MapToPy($1);
     if ($result)
         Py_INCREF($result);
 }
 
+%typemap(out) qpid::types::Variant::List {
+    $result = ListToPy(&$1);
+    if ($result)
+        Py_INCREF($result);
+}
+
 %typemap(out) qpid::types::Variant::List& {
     $result = ListToPy($1);
     if ($result)
@@ -344,6 +356,16 @@ typedef int Py_ssize_t;
     $1 = PyList_Check($input) ? 1 : 0;
 }
 
+%typemap(typecheck) qpid::types::Variant& {
+    $1 = (PyFloat_Check($input)  ||
+          PyString_Check($input) ||
+          PyInt_Check($input)    ||
+          PyLong_Check($input)   ||
+          PyDict_Check($input)   ||
+          PyList_Check($input)   ||
+          PyBool_Check($input)) ? 1 : 0;
+}
+
 %typemap(typecheck) const qpid::types::Variant::Map const & {
     $1 = PyDict_Check($input) ? 1 : 0;
 }
@@ -352,7 +374,7 @@ typedef int Py_ssize_t;
     $1 = PyList_Check($input) ? 1 : 0;
 }
 
-%typemap(typecheck) qpid::types::Variant& {
+%typemap(typecheck) const qpid::types::Variant const & {
     $1 = (PyFloat_Check($input)  ||
           PyString_Check($input) ||
           PyInt_Check($input)    ||

Modified: qpid/trunk/qpid/cpp/bindings/swig_ruby_typemaps.i
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/swig_ruby_typemaps.i?rev=1057774&r1=1057773&r2=1057774&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/bindings/swig_ruby_typemaps.i (original)
+++ qpid/trunk/qpid/cpp/bindings/swig_ruby_typemaps.i Tue Jan 11 17:58:04 2011
@@ -237,10 +237,18 @@
 /*
  * Variant types: C++ --> Ruby
  */
+%typemap(out) qpid::types::Variant::Map {
+    $result = MapToRb(&$1);
+}
+
 %typemap(out) qpid::types::Variant::Map& {
     $result = MapToRb($1);
 }
 
+%typemap(out) qpid::types::Variant::List {
+    $result = ListToRb(&$1);
+}
+
 %typemap(out) qpid::types::Variant::List& {
     $result = ListToRb($1);
 }
@@ -301,6 +309,15 @@
     $1 = (TYPE($input) == T_ARRAY) ? 1 : 0;
 }
 
+%typemap(typecheck) qpid::types::Variant& {
+    $1 = (TYPE($input) == T_FLOAT  ||
+          TYPE($input) == T_STRING ||
+          TYPE($input) == T_FIXNUM ||
+          TYPE($input) == T_BIGNUM ||
+          TYPE($input) == T_TRUE   ||
+          TYPE($input) == T_FALSE) ? 1 : 0;
+}
+
 %typemap(typecheck) qpid::types::Variant::Map const & {
     $1 = (TYPE($input) == T_HASH) ? 1 : 0;
 }
@@ -309,7 +326,7 @@
     $1 = (TYPE($input) == T_ARRAY) ? 1 : 0;
 }
 
-%typemap(typecheck) qpid::types::Variant& {
+%typemap(typecheck) const qpid::types::Variant const & {
     $1 = (TYPE($input) == T_FLOAT  ||
           TYPE($input) == T_STRING ||
           TYPE($input) == T_FIXNUM ||



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message