Return-Path: X-Original-To: apmail-qpid-commits-archive@www.apache.org Delivered-To: apmail-qpid-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 23EE810416 for ; Tue, 19 May 2015 17:22:23 +0000 (UTC) Received: (qmail 88479 invoked by uid 500); 19 May 2015 17:22:22 -0000 Delivered-To: apmail-qpid-commits-archive@qpid.apache.org Received: (qmail 88424 invoked by uid 500); 19 May 2015 17:22:22 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 87838 invoked by uid 99); 19 May 2015 17:22:22 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 May 2015 17:22:22 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3ED19E3A63; Tue, 19 May 2015 17:22:22 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mcpierce@apache.org To: commits@qpid.apache.org Date: Tue, 19 May 2015 17:22:36 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [16/35] 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/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 Authored: Tue Feb 24 13:38:50 2015 -0500 Committer: Darryl L. Pierce 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