qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcpie...@apache.org
Subject [16/35] qpid-proton git commit: PROTON-799: Created a utility module for the Ruby Engine APIs.
Date Tue, 19 May 2015 17:22:36 GMT
PROTON-799: Created a utility module for the Ruby Engine APIs.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e14ca869
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e14ca869
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e14ca869

Branch: refs/heads/ruby-engine-apis
Commit: e14ca869c6a722da2928360f3fc29a58eb7451c5
Parents: 70042ad
Author: Darryl L. Pierce <mcpierce@gmail.com>
Authored: Tue Feb 24 13:38:50 2015 -0500
Committer: Darryl L. Pierce <mcpierce@gmail.com>
Committed: Tue May 19 10:16:56 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/ruby/lib/qpid_proton.rb |  1 +
 proton-c/bindings/ruby/lib/util/engine.rb | 82 ++++++++++++++++++++++++++
 2 files changed, 83 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e14ca869/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index f1b17ea..bcc7edd 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -32,6 +32,7 @@ require "util/version"
 require "util/error_handler"
 require "util/constants"
 require "util/swig_helper"
+require "util/engine"
 
 # Types
 require "types/strings"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e14ca869/proton-c/bindings/ruby/lib/util/engine.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/util/engine.rb b/proton-c/bindings/ruby/lib/util/engine.rb
new file mode 100644
index 0000000..53aa672
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/util/engine.rb
@@ -0,0 +1,82 @@
+#--
+# 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::Util
+
+  # @private
+  module Engine
+
+    # Convenience method to receive messages from a delivery.
+    #
+    # @param delivery [Qpid::Proton::Delivery] The delivery.
+    # @param message [Qpid::Proton::Message] The message to use.
+    #
+    # @return [Qpid::Proton::Message] the message
+    #
+    def self.receive_message(delivery, msg = nil)
+      msg = Qpid::Proton::Message.new if msg.nil?
+      msg.decode(delivery.link.receive(delivery.pending))
+      delivery.link.advance
+      return msg
+    end
+
+    def data_to_object(data_impl) # :nodoc:
+      object = nil
+      unless data_impl.nil?
+        data = Qpid::Proton::Codec::Data.new(data_impl)
+        data.rewind
+        data.next
+        object = data.object
+        data.rewind
+      end
+      return object
+    end
+
+    def object_to_data(object, data_impl) # :nodoc:
+      unless object.nil?
+        data = Data.new(data_impl)
+        data.object = object
+      end
+    end
+
+    def condition_to_object(condition) # :nodoc:
+      result = nil
+      if Cproton.pn_condition_is_set(condition)
+        result = Condition.new(Cproton.pn_condition_get_name(condition),
+                               Cproton.pn_condition_get_description(condition),
+                               data_to_object(Cproton.pn_condition_info(condition)))
+      end
+      return result
+    end
+
+    def object_to_condition(object, condition) # :nodoc:
+      Cproton.pn_condition_clear(condition)
+      unless object.nil?
+        Cproton.pn_condition_set_name(condition, object.name)
+        Cproton.pn_condition_set_description(condition, object.description)
+        info = Data.new(Cproton.pn_condition_info(condition))
+        if object.info?
+          info.object = object.info
+        end
+      end
+    end
+
+  end
+
+end


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message