You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2017/06/09 01:25:43 UTC

[20/50] [abbrv] qpid-proton git commit: PROTON-1288: remove un-necessary internal::value_ref class.

PROTON-1288: remove un-necessary internal::value_ref class.


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

Branch: refs/heads/go1
Commit: d588798b719d6c724958d456d24e7e354351386f
Parents: a4e5c84
Author: Alan Conway <ac...@redhat.com>
Authored: Fri May 19 14:59:09 2017 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed May 24 14:38:01 2017 -0400

----------------------------------------------------------------------
 .../bindings/cpp/include/proton/message.hpp     |  2 +-
 proton-c/bindings/cpp/include/proton/value.hpp  | 37 +++-----------------
 proton-c/bindings/cpp/src/error_condition.cpp   |  2 +-
 proton-c/bindings/cpp/src/message.cpp           |  8 +++--
 proton-c/bindings/cpp/src/proton_bits.cpp       |  2 +-
 proton-c/bindings/cpp/src/terminus.cpp          |  2 +-
 proton-c/bindings/cpp/src/value.cpp             | 15 ++------
 7 files changed, 16 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d588798b/proton-c/bindings/cpp/include/proton/message.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/message.hpp b/proton-c/bindings/cpp/include/proton/message.hpp
index 85ccff6..ff60c99 100644
--- a/proton-c/bindings/cpp/include/proton/message.hpp
+++ b/proton-c/bindings/cpp/include/proton/message.hpp
@@ -324,7 +324,7 @@ class message {
     pn_message_t *pn_msg() const;
 
     mutable pn_message_t *pn_msg_;
-    mutable internal::value_ref body_;
+    mutable value body_;
     mutable property_map application_properties_;
     mutable annotation_map message_annotations_;
     mutable annotation_map delivery_annotations_;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d588798b/proton-c/bindings/cpp/include/proton/value.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/value.hpp b/proton-c/bindings/cpp/include/proton/value.hpp
index 3ac1763..75927f7 100644
--- a/proton-c/bindings/cpp/include/proton/value.hpp
+++ b/proton-c/bindings/cpp/include/proton/value.hpp
@@ -42,7 +42,6 @@ class value_base {
     internal::data& data();
     internal::data data_;
 
-  friend class value_ref;
   friend class codec::encoder;
   friend class codec::decoder;
 };
@@ -116,41 +115,13 @@ class value : public internal::value_base, private internal::comparable<value> {
     /// Complex types are printed in a non-standard human-readable format but
     /// that may change in future so should not be parsed.
   friend PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, const value&);
-};
-
-namespace internal {
-
-// value_ref is a `pn_data_t* p` that can be returned as a value& and used to modify
-// the underlying value in-place.
-//
-// Classes with a value_ref member can return it as a value& in accessor functions.
-// It can also be used to copy a pn_data_t* p to a proton::value via: value(value_ref(p));
-// None of the constructors make copies, they just refer to the same value.
-//
-class value_ref : public value {
-  public:
-    value_ref(pn_data_t* = 0);
-    value_ref(const internal::data&);
-    value_ref(const value_base&);
-
-    // Use refer() not operator= to avoid confusion with value op=
-    void refer(pn_data_t*);
-    void refer(const internal::data&);
-    void refer(const value_base&);
 
-    // Reset to refer to nothing, release existing references. Equivalent to refer(0).
-    void reset();
-
-    // Assignments to value_ref means assigning to the value.
-    template <class T> value_ref& operator=(const T& x) {
-        static_cast<value&>(*this) = x;
-        return *this;
-    }
+    ///@cond INTERNAL - used to refer to existing pn_data_t* values as proton::value
+    value(pn_data_t* d);          // Refer to existing pn_data_t
+    void reset(pn_data_t* d = 0); // Refer to a new pn_data_t
+    ///@endcond
 };
 
-}
-
-
 /// @copydoc scalar::get
 /// @related proton::value
 template<class T> T get(const value& v) { T x; get(v, x); return x; }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d588798b/proton-c/bindings/cpp/src/error_condition.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/error_condition.cpp b/proton-c/bindings/cpp/src/error_condition.cpp
index ead1cff..91e763a 100644
--- a/proton-c/bindings/cpp/src/error_condition.cpp
+++ b/proton-c/bindings/cpp/src/error_condition.cpp
@@ -31,7 +31,7 @@ namespace proton {
 error_condition::error_condition(pn_condition_t* c) :
     name_(str(pn_condition_get_name(c))),
     description_(str(pn_condition_get_description(c))),
-    properties_(internal::value_ref(pn_condition_info(c)))
+    properties_(value(pn_condition_info(c)))
 {}
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d588798b/proton-c/bindings/cpp/src/message.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/message.cpp b/proton-c/bindings/cpp/src/message.cpp
index eecfa3b..59f8329 100644
--- a/proton-c/bindings/cpp/src/message.cpp
+++ b/proton-c/bindings/cpp/src/message.cpp
@@ -70,8 +70,10 @@ void swap(message& x, message& y) {
 }
 
 pn_message_t *message::pn_msg() const {
-    if (!pn_msg_) pn_msg_ = pn_message();
-    body_.refer(pn_message_body(pn_msg_));
+    if (!pn_msg_) {
+        pn_msg_ = pn_message();
+        body_.reset(pn_message_body(pn_msg_));
+    }
     return pn_msg_;
 }
 
@@ -144,7 +146,7 @@ std::string message::reply_to() const {
 }
 
 void message::correlation_id(const message_id& id) {
-    internal::value_ref(pn_message_correlation_id(pn_msg())) = id;
+    value(pn_message_correlation_id(pn_msg())) = id;
 }
 
 message_id message::correlation_id() const {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d588798b/proton-c/bindings/cpp/src/proton_bits.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_bits.cpp b/proton-c/bindings/cpp/src/proton_bits.cpp
index 18fc589..3e1b27f 100644
--- a/proton-c/bindings/cpp/src/proton_bits.cpp
+++ b/proton-c/bindings/cpp/src/proton_bits.cpp
@@ -70,7 +70,7 @@ void set_error_condition(const error_condition& e, pn_condition_t *c) {
     if (!e.description().empty()) {
         pn_condition_set_description(c, e.description().c_str());
     }
-    internal::value_ref(pn_condition_info(c)) = e.properties();
+    value(pn_condition_info(c)) = e.properties();
 }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d588798b/proton-c/bindings/cpp/src/terminus.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/terminus.cpp b/proton-c/bindings/cpp/src/terminus.cpp
index 8065fe4..c751fd0 100644
--- a/proton-c/bindings/cpp/src/terminus.cpp
+++ b/proton-c/bindings/cpp/src/terminus.cpp
@@ -49,7 +49,7 @@ bool terminus::dynamic() const {
 }
 
 value terminus::node_properties() const {
-    return internal::value_ref(pn_terminus_properties(object_));
+    return value(pn_terminus_properties(object_));
 }
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d588798b/proton-c/bindings/cpp/src/value.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/value.cpp b/proton-c/bindings/cpp/src/value.cpp
index ceb3463..edf9074 100644
--- a/proton-c/bindings/cpp/src/value.cpp
+++ b/proton-c/bindings/cpp/src/value.cpp
@@ -34,6 +34,7 @@ using codec::encoder;
 using codec::start;
 
 value::value() {}
+value::value(pn_data_t *d) { data_ = make_wrapper(d); }
 value::value(const value& x) { *this = x; }
 #if PN_CPP_HAS_RVALUE_REFERENCES
 value::value(value&& x) { swap(*this, x); }
@@ -189,22 +190,12 @@ std::ostream& operator<<(std::ostream& o, const value& x) {
     return o << d;
 }
 
-namespace internal {
-value_ref::value_ref(pn_data_t* p) { refer(p); }
-value_ref::value_ref(const internal::data& d) { refer(d); }
-value_ref::value_ref(const value_base& v) { refer(v); }
-
-void value_ref::refer(pn_data_t* p) { data_ = make_wrapper(p); }
-void value_ref::refer(const internal::data& d) { data_ = d; }
-void value_ref::refer(const value_base& v) { data_ = v.data_; }
-
-void value_ref::reset() { refer(0); }
-} // namespace internal
-
 std::string to_string(const value& x) {
     std::ostringstream os;
     os << std::boolalpha << x;
     return os.str();
 }
 
+void value::reset(pn_data_t *d) { data_ = make_wrapper(d); }
+
 } // namespace proton


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