You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by mc...@apache.org on 2015/06/03 22:30:51 UTC
[14/34] qpid-proton git commit: PROTON-799: Created a utility module
for the Ruby Engine APIs.
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/bab61a22
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/bab61a22
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/bab61a22
Branch: refs/heads/master
Commit: bab61a22af652e743e2b4a561ee782dae4cdfb38
Parents: 3a64230
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Tue Feb 24 13:38:50 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Wed Jun 3 16:29:21 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/bab61a22/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/bab61a22/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