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:31:04 UTC
[27/34] qpid-proton git commit: PROTON-799: Added the ClassWrapper
mixin for the Ruby engine APIs.
PROTON-799: Added the ClassWrapper mixin for the Ruby engine APIs.
This mixin enables mapping an underlying C library engine class to the
appropriate Ruby class type.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3ca8e249
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3ca8e249
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3ca8e249
Branch: refs/heads/master
Commit: 3ca8e2495f8fbbd558e8fc0398f8c9c3dbf81a1a
Parents: cf0e109
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Wed Feb 4 09:35:31 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Wed Jun 3 16:29:24 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
.../bindings/ruby/lib/util/class_wrapper.rb | 52 ++++++++++++++++++++
2 files changed, 53 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3ca8e249/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 16394f9..9060b54 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -36,6 +36,7 @@ require "util/constants"
require "util/swig_helper"
require "util/condition"
require "util/wrapper"
+require "util/class_wrapper"
require "util/engine"
require "util/uuid"
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3ca8e249/proton-c/bindings/ruby/lib/util/class_wrapper.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/util/class_wrapper.rb b/proton-c/bindings/ruby/lib/util/class_wrapper.rb
new file mode 100644
index 0000000..134f655
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/util/class_wrapper.rb
@@ -0,0 +1,52 @@
+#--
+# 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
+
+ # This mixin provides a method for mapping from an underlying Proton
+ # C library class to a Ruby class.
+ #
+ # @private
+ #
+ module ClassWrapper
+
+ WRAPPERS =
+ {
+ "pn_void" => proc {|x| Cproton.pn_void2rb(x)},
+ "pn_rbref" => proc {|x| Cproton.pn_void2rb(x)},
+ "pn_connection" => proc {|x| Qpid::Proton::Connection.wrap(Cproton.pn_cast_pn_connection(x))},
+ "pn_session" => proc {|x| Qpid::Proton::Session.wrap(Cproton.pn_cast_pn_session(x))},
+ "pn_link" => proc {|x| Qpid::Proton::Link.wrap(Cproton.pn_cast_pn_link(x))},
+ "pn_delivery" => proc {|x| Qpid::Proton::Delivery.wrap(Cproton.pn_cast_pn_delivery(x))},
+ "pn_transport" => proc {|x| Qpid::Proton::Transport.wrap(Cproton.pn_cast_pn_transport(x))},
+ "pn_selectable" => proc {|x| Qpid::Proton::Selectable.wrap(Cproton.pn_cast_pn_selectable(x))},
+ }
+
+ def class_wrapper(clazz, c_impl, &block)
+ proc_func = WRAPPERS[clazz]
+ if !proc_func.nil?
+ proc_func.yield(c_impl)
+ elsif block_given?
+ yield(c_impl)
+ end
+ end
+
+ end
+
+end
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org