You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2017/12/04 19:00:21 UTC
[1/5] qpid-proton git commit: PROTON-1707: [C++ binding] Simplify
source directory structure - Remove pointless extra directories
Repository: qpid-proton
Updated Branches:
refs/heads/master 25efd103a -> 25025e9b3
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/reconnect_options_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/reconnect_options_impl.hpp b/proton-c/bindings/cpp/src/reconnect_options_impl.hpp
new file mode 100644
index 0000000..2aca82d
--- /dev/null
+++ b/proton-c/bindings/cpp/src/reconnect_options_impl.hpp
@@ -0,0 +1,45 @@
+#ifndef PROTON_CPP_RECONNECT_OPTIONSIMPL_H
+#define PROTON_CPP_RECONNECT_OPTIONSIMPL_H
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/duration.hpp"
+
+#include <string>
+#include <vector>
+
+namespace proton {
+
+class reconnect_options::impl {
+ public:
+ impl() : delay(10), delay_multiplier(2.0), max_delay(duration::FOREVER), max_attempts(0) {}
+
+ duration delay;
+ float delay_multiplier;
+ duration max_delay;
+ int max_attempts;
+ std::vector<std::string> failover_urls;
+};
+
+}
+
+#endif /*!PROTON_CPP_RECONNECT_OPTIONSIMPL_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/scalar_test.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/scalar_test.hpp b/proton-c/bindings/cpp/src/scalar_test.hpp
new file mode 100644
index 0000000..a54eabe
--- /dev/null
+++ b/proton-c/bindings/cpp/src/scalar_test.hpp
@@ -0,0 +1,209 @@
+#ifndef SCALAR_TEST_HPP
+#define SCALAR_TEST_HPP
+
+/*
+ * 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.
+ */
+
+// Template tests used by both scalar_test.cpp and value_test.hpp to test conversion
+// of scalar values via a proton::scalar or a proton::value.
+
+#include "test_bits.hpp"
+
+#include "proton/types.hpp"
+#include "proton/error.hpp"
+
+#include <sstream>
+
+
+namespace test {
+
+using namespace proton;
+
+// Inserting and extracting simple C++ values using same-type get<T> and coerce<T>
+template <class V, class T> void simple_type_test(T x, type_id tid, const std::string& s, T y) {
+ V vx(x); // Construct from C++ value
+ ASSERT_EQUAL(tid, vx.type());
+ ASSERT(!vx.empty());
+ ASSERT_EQUAL(x, get<T>(vx));
+ ASSERT_EQUAL(x, coerce<T>(vx));
+
+ V vxa = x; // Assign from C++ value
+ ASSERT_EQUAL(tid, vxa.type());
+ ASSERT(!vx.empty());
+ ASSERT_EQUAL(vx, vxa);
+ ASSERT_EQUAL(x, get<T>(vxa));
+ ASSERT_EQUAL(x, coerce<T>(vxa));
+
+ V v2; // Default construct
+ ASSERT(v2.type() == NULL_TYPE);
+ ASSERT(v2.empty());
+ v2 = x; // Assign from C++ value
+ ASSERT_EQUAL(tid, v2.type());
+ ASSERT_EQUAL(vx, v2);
+ ASSERT_EQUAL(x, get<T>(v2));
+ ASSERT_EQUAL(x, coerce<T>(v2));
+
+ V v3(vx); // Copy construct
+ ASSERT_EQUAL(tid, v3.type());
+ ASSERT_EQUAL(vx, v3);
+ ASSERT_EQUAL(x, get<T>(v3));
+ ASSERT_EQUAL(x, coerce<T>(v3));
+
+ V v4 = vx; // Copy assign
+ ASSERT_EQUAL(tid, v4.type());
+ ASSERT_EQUAL(x, get<T>(v4));
+ ASSERT_EQUAL(x, coerce<T>(v4));
+
+ ASSERT_EQUAL(s, to_string(vx)); // Stringify
+ V vy(y);
+ ASSERT(vx != vy); // Compare
+ ASSERT(vx < vy);
+ ASSERT(vy > vx);
+}
+
+// Test native C/C++ integer types via their mapped integer type ([u]int_x_t)
+template <class V, class T> void simple_integral_test() {
+ typedef typename internal::integer_type<sizeof(T), internal::is_signed<T>::value>::type int_type;
+ simple_type_test<V>(T(3), internal::type_id_of<int_type>::value, "3", T(4));
+}
+
+// Test invalid gets, valid same-type get<T> is tested by simple_type_test
+// Templated to test both scalar and value.
+template<class V> void bad_get_test() {
+ try { get<bool>(V(int8_t(1))); FAIL("byte as bool"); } catch (conversion_error) {}
+ try { get<uint8_t>(V(true)); FAIL("bool as uint8_t"); } catch (conversion_error) {}
+ try { get<uint8_t>(V(int8_t(1))); FAIL("int8 as uint8"); } catch (conversion_error) {}
+ try { get<int16_t>(V(uint16_t(1))); FAIL("uint16 as int16"); } catch (conversion_error) {}
+ try { get<int16_t>(V(int32_t(1))); FAIL("int32 as int16"); } catch (conversion_error) {}
+ try { get<symbol>(V(std::string())); FAIL("string as symbol"); } catch (conversion_error) {}
+ try { get<std::string>(V(binary())); FAIL("binary as string"); } catch (conversion_error) {}
+ try { get<binary>(V(symbol())); FAIL("symbol as binary"); } catch (conversion_error) {}
+ try { get<binary>(V(timestamp())); FAIL("timestamp as binary"); } catch (conversion_error) {}
+ try { get<int>(V(timestamp())); FAIL("timestamp as int"); } catch (conversion_error) {}
+ try { get<timestamp>(V(0)); FAIL("int as timestamp"); } catch (conversion_error) {}
+ try { get<timestamp>(V(std::string())); FAIL("string as timestamp"); } catch (conversion_error) {}
+}
+
+// Test some valid coercions and some bad ones with mixed types.
+// Templated to test both scalar and value.
+template<class V> void coerce_test() {
+ // Valid C++ conversions should work with coerce.
+ ASSERT_EQUAL(false, coerce<bool>(V(0)));
+ ASSERT_EQUAL(true, coerce<bool>(V(-1)));
+ ASSERT_EQUAL(true, coerce<bool>(V(int64_t(0xFFFF0000))));
+
+ ASSERT_EQUAL(1, coerce<uint8_t>(V(uint64_t(1)))); // In range.
+ ASSERT_EQUAL(1, coerce<uint8_t>(V(uint32_t(0xFF01)))); // int truncate.
+ ASSERT_EQUAL(0xFFFF, coerce<uint16_t>(V(int8_t(-1)))); // Sign extend.
+ ASSERT_EQUAL(-1, coerce<int32_t>(V(uint64_t(0xFFFFFFFFul)))); // 2s complement
+
+ ASSERT_EQUALISH(1.2f, coerce<float>(V(double(1.2))), 0.001f);
+ ASSERT_EQUALISH(3.4, coerce<double>(V(float(3.4))), 0.001);
+ ASSERT_EQUALISH(23.0, coerce<double>(V(uint64_t(23))), 0.001); // int to double.
+ ASSERT_EQUAL(-1945, coerce<int>(V(float(-1945.123)))); // round to int.
+
+ // String-like conversions.
+ ASSERT_EQUAL(std::string("foo"), coerce<std::string>(V(symbol("foo"))));
+ ASSERT_EQUAL(std::string("foo"), coerce<std::string>(V(binary("foo"))));
+
+ // Bad coercions, types are not `is_convertible`
+ V s("foo");
+ try { coerce<bool>(s); FAIL("string as bool"); } catch (conversion_error) {}
+ try { coerce<int>(s); FAIL("string as int"); } catch (conversion_error) {}
+ try { coerce<double>(s); FAIL("string as double"); } catch (conversion_error) {}
+
+ try { coerce<std::string>(V(0)); FAIL("int as string"); } catch (conversion_error) {}
+ try { coerce<symbol>(V(true)); FAIL("bool as symbol"); } catch (conversion_error) {}
+ try { coerce<binary>(V(0.0)); FAIL("double as binary"); } catch (conversion_error) {}
+ try { coerce<symbol>(V(binary())); FAIL("binary as symbol"); } catch (conversion_error) {}
+ try { coerce<binary>(V(symbol())); FAIL("symbol as binary"); } catch (conversion_error) {}
+ try { coerce<binary>(s); } catch (conversion_error) {}
+ try { coerce<symbol>(s); } catch (conversion_error) {}
+}
+
+template <class V> void null_test() {
+ V v;
+ ASSERT(v.empty());
+ ASSERT_EQUAL(NULL_TYPE, v.type());
+ get<null>(v);
+ null n;
+ get(v, n);
+ V v2(n);
+ ASSERT(v.empty());
+ ASSERT_EQUAL(NULL_TYPE, v.type());
+ v = "foo";
+ ASSERT_EQUAL(STRING, v.type());
+ try { get<null>(v); FAIL("Expected conversion_error"); } catch (conversion_error) {}
+ v = null();
+ get<null>(v);
+}
+
+// Nasty hack for uninterpreted decimal<> types.
+template <class T> T make(const char c) { T x; std::fill(x.begin(), x.end(), c); return x; }
+
+template <class V> void scalar_test_group(int& failed) {
+ // Direct AMQP-mapped types.
+ RUN_TEST(failed, simple_type_test<V>(false, BOOLEAN, "false", true));
+ RUN_TEST(failed, simple_type_test<V>(uint8_t(42), UBYTE, "42", uint8_t(50)));
+ RUN_TEST(failed, simple_type_test<V>(int8_t(-42), BYTE, "-42", int8_t(-40)));
+ RUN_TEST(failed, simple_type_test<V>(uint16_t(4242), USHORT, "4242", uint16_t(5252)));
+ RUN_TEST(failed, simple_type_test<V>(int16_t(-4242), SHORT, "-4242", int16_t(3)));
+ RUN_TEST(failed, simple_type_test<V>(uint32_t(4242), UINT, "4242", uint32_t(5252)));
+ RUN_TEST(failed, simple_type_test<V>(int32_t(-4242), INT, "-4242", int32_t(3)));
+ RUN_TEST(failed, simple_type_test<V>(uint64_t(4242), ULONG, "4242", uint64_t(5252)));
+ RUN_TEST(failed, simple_type_test<V>(int64_t(-4242), LONG, "-4242", int64_t(3)));
+ RUN_TEST(failed, simple_type_test<V>(wchar_t('X'), CHAR, "88", wchar_t('Y')));
+ RUN_TEST(failed, simple_type_test<V>(float(1.234), FLOAT, "1.234", float(2.345)));
+ RUN_TEST(failed, simple_type_test<V>(double(11.2233), DOUBLE, "11.2233", double(12)));
+ RUN_TEST(failed, simple_type_test<V>(timestamp(1234), TIMESTAMP, "1234", timestamp(12345)));
+ RUN_TEST(failed, simple_type_test<V>(make<decimal32>(1), DECIMAL32, "decimal32(0x01010101)", make<decimal32>(2)));
+ RUN_TEST(failed, simple_type_test<V>(make<decimal64>(3), DECIMAL64, "decimal64(0x0303030303030303)", make<decimal64>(4)));
+ RUN_TEST(failed, simple_type_test<V>(make<decimal128>(5), DECIMAL128, "decimal128(0x05050505050505050505050505050505)", make<decimal128>(6)));
+ RUN_TEST(failed, simple_type_test<V>(
+ uuid::copy("\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff"),
+ UUID, "00112233-4455-6677-8899-aabbccddeeff",
+ uuid::copy("\xff\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff")));
+ RUN_TEST(failed, simple_type_test<V>(std::string("xxx"), STRING, "xxx", std::string("yyy")));
+ RUN_TEST(failed, simple_type_test<V>(symbol("aaa"), SYMBOL, "aaa", symbol("aaaa")));
+ RUN_TEST(failed, simple_type_test<V>(binary("\010aaa"), BINARY, "b\"\\x08aaa\"", binary("aaaa")));
+
+ // Test native C++ integral types.
+ RUN_TEST(failed, (simple_integral_test<V, char>()));
+ RUN_TEST(failed, (simple_integral_test<V, signed char>()));
+ RUN_TEST(failed, (simple_integral_test<V, unsigned char>()));
+ RUN_TEST(failed, (simple_integral_test<V, short>()));
+ RUN_TEST(failed, (simple_integral_test<V, int>()));
+ RUN_TEST(failed, (simple_integral_test<V, long>()));
+ RUN_TEST(failed, (simple_integral_test<V, unsigned short>()));
+ RUN_TEST(failed, (simple_integral_test<V, unsigned int>()));
+ RUN_TEST(failed, (simple_integral_test<V, unsigned long>()));
+#if PN_CPP_HAS_LONG_LONG_TYPE
+ RUN_TEST(failed, (simple_integral_test<V, long long>()));
+ RUN_TEST(failed, (simple_integral_test<V, unsigned long long>()));
+#endif
+
+
+ RUN_TEST(failed, (coerce_test<V>()));
+ RUN_TEST(failed, (null_test<V>()));
+ RUN_TEST(failed, (bad_get_test<V>()));
+}
+
+}
+
+#endif // SCALAR_TEST_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/test_bits.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/test_bits.hpp b/proton-c/bindings/cpp/src/test_bits.hpp
new file mode 100644
index 0000000..4e019f2
--- /dev/null
+++ b/proton-c/bindings/cpp/src/test_bits.hpp
@@ -0,0 +1,158 @@
+#ifndef TEST_BITS_HPP
+#define TEST_BITS_HPP
+/*
+ * 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.
+ */
+
+#include "msg.hpp"
+#include "proton/types.hpp"
+
+#include <stdexcept>
+#include <iostream>
+#include <iterator>
+#include <sstream>
+#include <cstring>
+#include <math.h>
+
+namespace test {
+
+struct fail : public std::logic_error {
+ explicit fail(const std::string& what) : logic_error(what) {}
+};
+
+struct error : public std::logic_error {
+ explicit error(const std::string& what) : logic_error(what) {}
+};
+
+template <class T, class U>
+void assert_equal(const T& want, const U& got, const std::string& what) {
+ if (!(want == got))
+ throw fail(MSG(what << " " << want << " != " << got));
+}
+
+template <class T>
+inline void assert_equalish(T want, T got, T delta, const std::string& what)
+{
+ if (!(fabs(want-got) <= delta))
+ throw fail(MSG(what << " " << want << " !=~ " << got));
+}
+
+#define FAIL_MSG(WHAT) (MSG(__FILE__ << ":" << __LINE__ << ": " << WHAT).str())
+#define FAIL(WHAT) throw test::fail(FAIL_MSG(WHAT))
+#define ASSERT(TEST) do { if (!(TEST)) FAIL("failed ASSERT(" #TEST ")"); } while(false)
+#define ASSERT_EQUAL(WANT, GOT) \
+ test::assert_equal((WANT), (GOT), FAIL_MSG("failed ASSERT_EQUAL(" #WANT ", " #GOT ")"))
+#define ASSERT_EQUALISH(WANT, GOT, DELTA) \
+ test::assert_equalish((WANT), (GOT), (DELTA), FAIL_MSG("failed ASSERT_EQUALISH(" #WANT ", " #GOT ")"))
+#define ASSERT_THROWS(WANT, EXPR) do { try { EXPR; FAIL("Expected " #WANT); } catch(const WANT&) {} } while(0)
+
+#define RUN_TEST(BAD_COUNT, TEST) \
+ do { \
+ try { \
+ std::cout << "TEST: " << #TEST << std::endl; \
+ TEST; \
+ break; \
+ } catch(const test::fail& e) { \
+ std::cout << "FAIL " << #TEST << std::endl << e.what() << std::endl; \
+ } catch(const std::exception& e) { \
+ std::cout << "ERROR " << #TEST << std::endl << __FILE__ << ":" << __LINE__ << ": " << e.what() << std::endl; \
+ } \
+ ++BAD_COUNT; \
+ } while(0)
+
+/* Like RUN_TEST but only if one of the argv strings is found in the test EXPR */
+#define RUN_ARGV_TEST(BAD_COUNT, EXPR) do { \
+ if (argc == 1) { \
+ RUN_TEST(BAD_COUNT, EXPR); \
+ } else { \
+ for (int i = 1; i < argc; ++i) { \
+ if (strstr(#EXPR, argv[i])) { \
+ RUN_TEST(BAD_COUNT, EXPR); \
+ break; \
+ } \
+ } \
+ } \
+ } while(0)
+
+
+template<class T> std::string str(const T& x) {
+ std::ostringstream s; s << std::boolalpha << x; return s.str();
+}
+
+// A way to easily create literal collections that can be compared to std:: collections
+// and to print std collections
+// e.g.
+// std::vector<string> v = ...;
+// ASSERT_EQUAL(many<string>() + "a" + "b" + "c", v);
+template <class T> struct many : public std::vector<T> {
+ many() {}
+ template<class S> explicit many(const S& s) : std::vector<T>(s.begin(), s.end()) {}
+ many& operator+=(const T& t) { this->push_back(t); return *this; }
+ many& operator<<(const T& t) { return *this += t; }
+ many operator+(const T& t) { many<T> l(*this); return l += t; }
+};
+
+template <class T, class S> bool operator==(const many<T>& m, const S& s) {
+ return m.size() == s.size() && S(m.begin(), m.end()) == s;
+}
+
+template <class T, class S> bool operator==(const S& s, const many<T>& m) {
+ return m.size() == s.size() && S(m.begin(), m.end()) == s;
+}
+
+template <class T> std::ostream& operator<<(std::ostream& o, const many<T>& m) {
+ std::ostream_iterator<T> oi(o, " ");
+ std::copy(m.begin(), m.end(), oi);
+ return o;
+}
+
+}
+
+namespace std {
+template <class T> std::ostream& operator<<(std::ostream& o, const std::vector<T>& s) {
+ return o << test::many<T>(s);
+}
+
+template <class T> std::ostream& operator<<(std::ostream& o, const std::deque<T>& s) {
+ return o << test::many<T>(s);
+}
+
+template <class T> std::ostream& operator<<(std::ostream& o, const std::list<T>& s) {
+ return o << test::many<T>(s);
+}
+
+template <class K, class T> std::ostream& operator<<(std::ostream& o, const std::map<K, T>& x) {
+ return o << test::many<std::pair<K, T> >(x);
+}
+
+template <class U, class V> std::ostream& operator<<(std::ostream& o, const std::pair<U, V>& p) {
+ return o << "( " << p.first << " , " << p.second << " )";
+}
+
+#if PN_CPP_HAS_CPP11
+template <class K, class T> std::ostream& operator<<(std::ostream& o, const std::unordered_map<K, T>& x) {
+ return o << test::many<std::pair<const K, T> >(x);
+}
+
+template <class T> std::ostream& operator<<(std::ostream& o, const std::forward_list<T>& s) {
+ return o << test::many<T>(s);
+}
+#endif
+}
+
+#endif // TEST_BITS_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/types_internal.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/types_internal.hpp b/proton-c/bindings/cpp/src/types_internal.hpp
new file mode 100644
index 0000000..bff93a0
--- /dev/null
+++ b/proton-c/bindings/cpp/src/types_internal.hpp
@@ -0,0 +1,74 @@
+#ifndef TYPES_INTERNAL_HPP
+#define TYPES_INTERNAL_HPP
+/*
+ * 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.
+ */
+
+#include "proton/internal/type_traits.hpp"
+#include "proton/error.hpp"
+#include "proton/binary.hpp"
+#include <sstream>
+
+///@file
+/// Inline helpers for encode/decode/type conversion/ostream operators.
+
+namespace proton {
+
+/// Byte copy between two objects, only enabled if their sizes are equal.
+template <class T, class U>
+typename internal::enable_if<sizeof(T) == sizeof(U)>::type byte_copy(T &to, const U &from) {
+ const char *p = reinterpret_cast<const char*>(&from);
+ std::copy(p, p + sizeof(T), reinterpret_cast<char*>(&to));
+}
+
+inline conversion_error
+make_conversion_error(type_id want, type_id got, const std::string& msg=std::string()) {
+ std::ostringstream s;
+ s << "unexpected type, want: " << want << " got: " << got;
+ if (!msg.empty()) s << ": " << msg;
+ return conversion_error(s.str());
+}
+
+/// Convert std::string to pn_bytes_t
+inline pn_bytes_t pn_bytes(const std::string& s) {
+ pn_bytes_t b = { s.size(), s.empty() ? 0 : const_cast<char*>(&s[0]) };
+ return b;
+}
+
+inline pn_bytes_t pn_bytes(const binary& s) {
+ pn_bytes_t b = { s.size(), s.empty() ? 0 : reinterpret_cast<const char*>(&s[0]) };
+ return b;
+}
+
+inline std::string str(const pn_bytes_t& b) { return std::string(b.start, b.size); }
+inline binary bin(const pn_bytes_t& b) { return binary(b.start, b.start+b.size); }
+
+// Save all stream format state, restore in destructor.
+struct ios_guard {
+ std::ios &guarded;
+ std::ios old;
+ ios_guard(std::ios& x) : guarded(x), old(0) { old.copyfmt(guarded); }
+ ~ios_guard() { guarded.copyfmt(old); }
+};
+
+// Convert a char (signed or unsigned) into an unsigned 1 byte integer that will ostream
+// as a numeric byte value, not a character and will not get sign-extended.
+inline unsigned int printable_byte(uint8_t byte) { return byte; }
+
+}
+#endif // TYPES_INTERNAL_HPP
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[4/5] qpid-proton git commit: PROTON-1710: [C++ binding] Can't run
container with less than 1 thread
Posted by as...@apache.org.
PROTON-1710: [C++ binding] Can't run container with less than 1 thread
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/25025e9b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/25025e9b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/25025e9b
Branch: refs/heads/master
Commit: 25025e9b3dee948f60656c88002a59be598a206d
Parents: 88a927e
Author: Andrew Stitcher <as...@apache.org>
Authored: Mon Dec 4 12:44:07 2017 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Mon Dec 4 13:49:36 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/cpp/src/proactor_container_impl.cpp | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/25025e9b/proton-c/bindings/cpp/src/proactor_container_impl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proactor_container_impl.cpp b/proton-c/bindings/cpp/src/proactor_container_impl.cpp
index 2f09f51..a55cdcb 100644
--- a/proton-c/bindings/cpp/src/proactor_container_impl.cpp
+++ b/proton-c/bindings/cpp/src/proactor_container_impl.cpp
@@ -678,6 +678,7 @@ void container::impl::run(int threads) {
#if PN_CPP_SUPPORTS_THREADS
// Run handler threads
+ threads = std::max(threads, 1); // Ensure at least 1 thread
typedef std::vector<std::thread*> vt; // pointer vector to work around failures in older compilers
vt ts(threads-1);
for (vt::iterator i = ts.begin(); i != ts.end(); ++i) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[2/5] qpid-proton git commit: PROTON-1707: [C++ binding] Simplify
source directory structure - Remove pointless extra directories
Posted by as...@apache.org.
PROTON-1707: [C++ binding] Simplify source directory structure
- Remove pointless extra directories
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/5199e8c2
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/5199e8c2
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/5199e8c2
Branch: refs/heads/master
Commit: 5199e8c2abdb4cc0e42e4235dc44ed55dcd0abd9
Parents: 25efd10
Author: Andrew Stitcher <as...@apache.org>
Authored: Wed Nov 29 02:54:30 2017 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Mon Dec 4 12:57:59 2017 -0500
----------------------------------------------------------------------
proton-c/bindings/cpp/CMakeLists.txt | 7 +-
proton-c/bindings/cpp/src/connection_driver.cpp | 153 ++++++++++++++
proton-c/bindings/cpp/src/contexts.hpp | 144 +++++++++++++
proton-c/bindings/cpp/src/include/contexts.hpp | 144 -------------
.../bindings/cpp/src/include/link_namer.hpp | 51 -----
.../cpp/src/include/messaging_adapter.hpp | 42 ----
proton-c/bindings/cpp/src/include/msg.hpp | 58 -----
.../cpp/src/include/proactor_container_impl.hpp | 168 ---------------
.../src/include/proactor_work_queue_impl.hpp | 41 ----
.../bindings/cpp/src/include/proton_bits.hpp | 162 --------------
.../cpp/src/include/reconnect_options_impl.hpp | 45 ----
.../bindings/cpp/src/include/scalar_test.hpp | 209 -------------------
proton-c/bindings/cpp/src/include/test_bits.hpp | 158 --------------
.../bindings/cpp/src/include/types_internal.hpp | 74 -------
.../bindings/cpp/src/io/connection_driver.cpp | 153 --------------
proton-c/bindings/cpp/src/io/link_namer.cpp | 34 ---
proton-c/bindings/cpp/src/link_namer.cpp | 34 +++
proton-c/bindings/cpp/src/link_namer.hpp | 51 +++++
proton-c/bindings/cpp/src/messaging_adapter.hpp | 42 ++++
proton-c/bindings/cpp/src/msg.hpp | 58 +++++
.../cpp/src/proactor_container_impl.hpp | 168 +++++++++++++++
.../cpp/src/proactor_work_queue_impl.hpp | 41 ++++
proton-c/bindings/cpp/src/proton_bits.hpp | 162 ++++++++++++++
.../bindings/cpp/src/reconnect_options_impl.hpp | 45 ++++
proton-c/bindings/cpp/src/scalar_test.hpp | 209 +++++++++++++++++++
proton-c/bindings/cpp/src/test_bits.hpp | 158 ++++++++++++++
proton-c/bindings/cpp/src/types_internal.hpp | 74 +++++++
27 files changed, 1342 insertions(+), 1343 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt
index a7c2866..109b543 100644
--- a/proton-c/bindings/cpp/CMakeLists.txt
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -68,8 +68,7 @@ set(CXX_EXAMPLE_LINK_FLAGS "${SANITIZE_FLAGS}" CACHE INTERNAL "")
include_directories(
"${CMAKE_SOURCE_DIR}/proton-c/include"
- "${CMAKE_CURRENT_SOURCE_DIR}/include"
- "${CMAKE_CURRENT_SOURCE_DIR}/src/include")
+ "${CMAKE_CURRENT_SOURCE_DIR}/include")
add_definitions(${CXX_STANDARD} ${CXX_WARNING_FLAGS} "-DPN_CPP_USE_DEPRECATED_API=1")
@@ -78,6 +77,7 @@ set(qpid-proton-cpp-source
src/byte_array.cpp
src/map.cpp
src/connection.cpp
+ src/connection_driver.cpp
src/connection_options.cpp
src/container.cpp
src/proactor_container_impl.cpp
@@ -92,9 +92,8 @@ set(qpid-proton-cpp-source
src/error.cpp
src/error_condition.cpp
src/handler.cpp
- src/io/connection_driver.cpp
- src/io/link_namer.cpp
src/link.cpp
+ src/link_namer.cpp
src/listener.cpp
src/message.cpp
src/messaging_adapter.cpp
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/connection_driver.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/connection_driver.cpp b/proton-c/bindings/cpp/src/connection_driver.cpp
new file mode 100644
index 0000000..cc83f51
--- /dev/null
+++ b/proton-c/bindings/cpp/src/connection_driver.cpp
@@ -0,0 +1,153 @@
+/*
+ * 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.
+ */
+
+#include "proton/io/connection_driver.hpp"
+
+#include "proton/connection.hpp"
+#include "proton/container.hpp"
+#include "proton/error.hpp"
+#include "proton/messaging_handler.hpp"
+#include "proton/transport.hpp"
+#include "proton/uuid.hpp"
+#include "proton/work_queue.hpp"
+
+#include "contexts.hpp"
+#include "messaging_adapter.hpp"
+#include "msg.hpp"
+#include "proton_bits.hpp"
+
+#include <proton/connection.h>
+#include <proton/transport.h>
+#include <proton/event.h>
+
+#include <algorithm>
+
+
+namespace proton {
+namespace io {
+
+void connection_driver::init() {
+ if (pn_connection_driver_init(&driver_, pn_connection(), pn_transport()) != 0) {
+ this->~connection_driver(); // Dtor won't be called on throw from ctor.
+ throw proton::error(std::string("connection_driver allocation failed"));
+ }
+}
+
+connection_driver::connection_driver() : handler_(0) { init(); }
+
+connection_driver::connection_driver(const std::string& id) : container_id_(id), handler_(0) {
+ init();
+}
+
+connection_driver::~connection_driver() {
+ pn_connection_driver_destroy(&driver_);
+}
+
+void connection_driver::configure(const connection_options& opts, bool server) {
+ proton::connection c(connection());
+ opts.apply_unbound(c);
+ if (server) pn_transport_set_server(driver_.transport);
+ pn_connection_driver_bind(&driver_);
+ opts.apply_bound(c);
+ handler_ = opts.handler();
+}
+
+void connection_driver::connect(const connection_options& opts) {
+ connection_options all;
+ all.container_id(container_id_);
+ all.update(opts);
+ configure(all, false);
+ connection().open();
+}
+
+void connection_driver::accept(const connection_options& opts) {
+ connection_options all;
+ all.container_id(container_id_);
+ all.update(opts);
+ configure(all, true);
+}
+
+bool connection_driver::has_events() const {
+ return driver_.collector && pn_collector_peek(driver_.collector);
+}
+
+bool connection_driver::dispatch() {
+ pn_event_t* c_event;
+ while ((c_event = pn_connection_driver_next_event(&driver_)) != NULL) {
+ try {
+ if (handler_ != 0) {
+ messaging_adapter::dispatch(*handler_, c_event);
+ }
+ } catch (const std::exception& e) {
+ pn_condition_t *cond = pn_transport_condition(driver_.transport);
+ if (!pn_condition_is_set(cond)) {
+ pn_condition_format(cond, "exception", "%s", e.what());
+ }
+ }
+ }
+ return !pn_connection_driver_finished(&driver_);
+}
+
+mutable_buffer connection_driver::read_buffer() {
+ pn_rwbytes_t buffer = pn_connection_driver_read_buffer(&driver_);
+ return mutable_buffer(buffer.start, buffer.size);
+}
+
+void connection_driver::read_done(size_t n) {
+ return pn_connection_driver_read_done(&driver_, n);
+}
+
+void connection_driver::read_close() {
+ pn_connection_driver_read_close(&driver_);
+}
+
+const_buffer connection_driver::write_buffer() {
+ pn_bytes_t buffer = pn_connection_driver_write_buffer(&driver_);
+ return const_buffer(buffer.start, buffer.size);
+}
+
+void connection_driver::write_done(size_t n) {
+ return pn_connection_driver_write_done(&driver_, n);
+}
+
+void connection_driver::write_close() {
+ pn_connection_driver_write_close(&driver_);
+}
+
+timestamp connection_driver::tick(timestamp now) {
+ return timestamp(pn_transport_tick(driver_.transport, now.milliseconds()));
+}
+
+void connection_driver::disconnected(const proton::error_condition& err) {
+ pn_condition_t* condition = pn_transport_condition(driver_.transport);
+ if (!pn_condition_is_set(condition)) {
+ set_error_condition(err, condition);
+ }
+ pn_connection_driver_close(&driver_);
+}
+
+proton::connection connection_driver::connection() const {
+ return make_wrapper(driver_.connection);
+}
+
+proton::transport connection_driver::transport() const {
+ return make_wrapper(driver_.transport);
+}
+
+}}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/contexts.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/contexts.hpp b/proton-c/bindings/cpp/src/contexts.hpp
new file mode 100644
index 0000000..4c5d679
--- /dev/null
+++ b/proton-c/bindings/cpp/src/contexts.hpp
@@ -0,0 +1,144 @@
+#ifndef PROTON_CPP_CONTEXTS_H
+#define PROTON_CPP_CONTEXTS_H
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/work_queue.hpp"
+#include "proton/message.hpp"
+#include "proton/internal/pn_unique_ptr.hpp"
+
+struct pn_record_t;
+struct pn_link_t;
+struct pn_session_t;
+struct pn_connection_t;
+struct pn_listener_t;
+
+namespace proton {
+
+class proton_handler;
+class connector;
+
+namespace io {class link_namer;}
+
+// Base class for C++ classes that are used as proton contexts.
+// Contexts are pn_objects managed by pn reference counts, the C++ value is allocated in-place.
+class context {
+ public:
+ // identifies a context, contains a record pointer and a handle.
+ typedef std::pair<pn_record_t*, pn_handle_t> id;
+
+ virtual ~context();
+
+ // Allocate a default-constructed T as a proton object.
+ // T must be a subclass of context.
+ template <class T> static T *create() { return new(alloc(sizeof(T))) T(); }
+
+ // The pn_class for a context
+ static pn_class_t* pn_class();
+
+ // Get the context identified by id as a C++ T*, return null pointer if not present.
+ template <class T> static T* ptr(id id_) {
+ return reinterpret_cast<T*>(pn_record_get(id_.first, id_.second));
+ }
+
+ // If the context is not present, create it with value x.
+ template <class T> static T& ref(id id_) {
+ T* ctx = context::ptr<T>(id_);
+ if (!ctx) {
+ ctx = create<T>();
+ pn_record_def(id_.first, id_.second, pn_class());
+ pn_record_set(id_.first, id_.second, ctx);
+ pn_decref(ctx);
+ }
+ return *ctx;
+ }
+
+ private:
+ static void *alloc(size_t n);
+};
+
+class listener_context;
+class reconnect_context;
+
+// Connection context used by all connections.
+class connection_context : public context {
+ public:
+ connection_context();
+ static connection_context& get(pn_connection_t *c);
+
+ class container* container;
+ pn_session_t *default_session; // Owned by connection.
+ message event_message; // re-used by messaging_adapter for performance.
+ io::link_namer* link_gen; // Link name generator.
+
+ messaging_handler* handler;
+ std::string connected_address_;
+ internal::pn_unique_ptr<connection_options> connection_options_;
+ internal::pn_unique_ptr<reconnect_context> reconnect_context_;
+ listener_context* listener_context_;
+ work_queue work_queue_;
+};
+
+// This is not a context object on its own, but an optional part of connection
+class reconnect_context {
+ public:
+ reconnect_context(const reconnect_options& ro);
+
+ internal::pn_unique_ptr<const reconnect_options> reconnect_options_;
+ duration delay_;
+ int retries_;
+ int current_url_;
+};
+
+class listener_context : public context {
+ public:
+ listener_context();
+ static listener_context& get(pn_listener_t* c);
+
+ listen_handler* listen_handler_;
+ internal::pn_unique_ptr<const connection_options> connection_options_;
+};
+
+class link_context : public context {
+ public:
+ link_context() : handler(0), credit_window(10), pending_credit(0), auto_accept(true), auto_settle(true), draining(false) {}
+ static link_context& get(pn_link_t* l);
+
+ messaging_handler* handler;
+ int credit_window;
+ uint32_t pending_credit;
+ bool auto_accept;
+ bool auto_settle;
+ bool draining;
+};
+
+class session_context : public context {
+ public:
+ session_context() : handler(0) {}
+ static session_context& get(pn_session_t* s);
+
+ messaging_handler* handler;
+};
+
+}
+
+#endif /*!PROTON_CPP_CONTEXTS_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/include/contexts.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/contexts.hpp b/proton-c/bindings/cpp/src/include/contexts.hpp
deleted file mode 100644
index 4c5d679..0000000
--- a/proton-c/bindings/cpp/src/include/contexts.hpp
+++ /dev/null
@@ -1,144 +0,0 @@
-#ifndef PROTON_CPP_CONTEXTS_H
-#define PROTON_CPP_CONTEXTS_H
-
-/*
- *
- * 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.
- *
- */
-
-#include "proton/work_queue.hpp"
-#include "proton/message.hpp"
-#include "proton/internal/pn_unique_ptr.hpp"
-
-struct pn_record_t;
-struct pn_link_t;
-struct pn_session_t;
-struct pn_connection_t;
-struct pn_listener_t;
-
-namespace proton {
-
-class proton_handler;
-class connector;
-
-namespace io {class link_namer;}
-
-// Base class for C++ classes that are used as proton contexts.
-// Contexts are pn_objects managed by pn reference counts, the C++ value is allocated in-place.
-class context {
- public:
- // identifies a context, contains a record pointer and a handle.
- typedef std::pair<pn_record_t*, pn_handle_t> id;
-
- virtual ~context();
-
- // Allocate a default-constructed T as a proton object.
- // T must be a subclass of context.
- template <class T> static T *create() { return new(alloc(sizeof(T))) T(); }
-
- // The pn_class for a context
- static pn_class_t* pn_class();
-
- // Get the context identified by id as a C++ T*, return null pointer if not present.
- template <class T> static T* ptr(id id_) {
- return reinterpret_cast<T*>(pn_record_get(id_.first, id_.second));
- }
-
- // If the context is not present, create it with value x.
- template <class T> static T& ref(id id_) {
- T* ctx = context::ptr<T>(id_);
- if (!ctx) {
- ctx = create<T>();
- pn_record_def(id_.first, id_.second, pn_class());
- pn_record_set(id_.first, id_.second, ctx);
- pn_decref(ctx);
- }
- return *ctx;
- }
-
- private:
- static void *alloc(size_t n);
-};
-
-class listener_context;
-class reconnect_context;
-
-// Connection context used by all connections.
-class connection_context : public context {
- public:
- connection_context();
- static connection_context& get(pn_connection_t *c);
-
- class container* container;
- pn_session_t *default_session; // Owned by connection.
- message event_message; // re-used by messaging_adapter for performance.
- io::link_namer* link_gen; // Link name generator.
-
- messaging_handler* handler;
- std::string connected_address_;
- internal::pn_unique_ptr<connection_options> connection_options_;
- internal::pn_unique_ptr<reconnect_context> reconnect_context_;
- listener_context* listener_context_;
- work_queue work_queue_;
-};
-
-// This is not a context object on its own, but an optional part of connection
-class reconnect_context {
- public:
- reconnect_context(const reconnect_options& ro);
-
- internal::pn_unique_ptr<const reconnect_options> reconnect_options_;
- duration delay_;
- int retries_;
- int current_url_;
-};
-
-class listener_context : public context {
- public:
- listener_context();
- static listener_context& get(pn_listener_t* c);
-
- listen_handler* listen_handler_;
- internal::pn_unique_ptr<const connection_options> connection_options_;
-};
-
-class link_context : public context {
- public:
- link_context() : handler(0), credit_window(10), pending_credit(0), auto_accept(true), auto_settle(true), draining(false) {}
- static link_context& get(pn_link_t* l);
-
- messaging_handler* handler;
- int credit_window;
- uint32_t pending_credit;
- bool auto_accept;
- bool auto_settle;
- bool draining;
-};
-
-class session_context : public context {
- public:
- session_context() : handler(0) {}
- static session_context& get(pn_session_t* s);
-
- messaging_handler* handler;
-};
-
-}
-
-#endif /*!PROTON_CPP_CONTEXTS_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/include/link_namer.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/link_namer.hpp b/proton-c/bindings/cpp/src/include/link_namer.hpp
deleted file mode 100644
index d107728..0000000
--- a/proton-c/bindings/cpp/src/include/link_namer.hpp
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef PROTON_IO_LINK_NAMER_HPP
-#define PROTON_IO_LINK_NAMER_HPP
-
-/*
- *
- * 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.
- *
- */
-
-#include "proton/internal/export.hpp"
-#include <string>
-
-namespace proton {
-
-class connection;
-
-namespace io {
-
-/// **Unsettled API** - Generate default link names that are unique
-/// within a container. base_container provides a default
-/// implementation.
-class link_namer {
- public:
- virtual ~link_namer() {}
-
- /// Generate a unique link name.
- virtual std::string link_name() = 0;
-};
-
-/// **Unsettled API** - Set the link_namer to use on a connection.
-PN_CPP_EXTERN void set_link_namer(connection&, link_namer&);
-
-} // io
-} // proton
-
-#endif // PROTON_IO_LINK_NAMER_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/include/messaging_adapter.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/messaging_adapter.hpp b/proton-c/bindings/cpp/src/include/messaging_adapter.hpp
deleted file mode 100644
index 10c7682..0000000
--- a/proton-c/bindings/cpp/src/include/messaging_adapter.hpp
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef PROTON_CPP_MESSAGING_ADAPTER_H
-#define PROTON_CPP_MESSAGING_ADAPTER_H
-
-/*
- *
- * 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.
- *
- */
-
-///@cond INTERNAL
-
-struct pn_event_t;
-
-namespace proton {
-
-class messaging_handler;
-
-/// Convert the low level proton-c events to the higher level proton::messaging_handler calls
-class messaging_adapter
-{
- public:
- static void dispatch(messaging_handler& delegate, pn_event_t* e);
-};
-
-}
-///@endcond INTERNAL
-#endif /*!PROTON_CPP_MESSAGING_ADAPTER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/include/msg.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/msg.hpp b/proton-c/bindings/cpp/src/include/msg.hpp
deleted file mode 100644
index b24b25c..0000000
--- a/proton-c/bindings/cpp/src/include/msg.hpp
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef PROTON_MSG_H
-#define PROTON_MSG_H
-
-/*
- *
- * 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.
- *
- */
-
-#include <sstream>
-#include <iostream>
-
-namespace proton {
-
-/** A simple facade for std::ostringstream that allows
- * in place construction of a message and automatic conversion
- * to string.
- * E.g.
- *@code
- * void foo(const std::string&);
- * foo(msg() << "hello " << 32);
- *@endcode
- * Will construct the string "hello 32" and pass it to foo()
- */
-struct msg {
- std::ostringstream os;
- msg() {}
- msg(const msg& m) : os(m.str()) {}
- std::string str() const { return os.str(); }
- operator std::string() const { return str(); }
- template <class T> msg& operator<<(const T& t) { os << t; return *this; }
-};
-
-inline std::ostream& operator<<(std::ostream& o, const msg& m) { return o << m.str(); }
-
-/** Construct a message using operator << and append (file:line) */
-#define QUOTe_(x) #x
-#define QUOTE(x) QUOTe_(x)
-#define MSG(message) (::proton::msg() << message)
-
-}
-
-#endif /*!PROTON_MSG_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/include/proactor_container_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/proactor_container_impl.hpp b/proton-c/bindings/cpp/src/include/proactor_container_impl.hpp
deleted file mode 100644
index 06dbcb5..0000000
--- a/proton-c/bindings/cpp/src/include/proactor_container_impl.hpp
+++ /dev/null
@@ -1,168 +0,0 @@
-#ifndef PROTON_CPP_PROACTOR_CONTAINERIMPL_H
-#define PROTON_CPP_PROACTOR_CONTAINERIMPL_H
-
-/*
- *
- * 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.
- *
- */
-
-#include "proton/fwd.hpp"
-#include "proton/container.hpp"
-#include "proton/connection.hpp"
-#include "proton/connection_options.hpp"
-#include "proton/duration.hpp"
-#include "proton/error_condition.hpp"
-#include "proton/messaging_handler.hpp"
-#include "proton/receiver.hpp"
-#include "proton/receiver_options.hpp"
-#include "proton/sender.hpp"
-#include "proton/sender_options.hpp"
-#include "proton/work_queue.hpp"
-
-#include "proton_bits.hpp"
-
-#include <list>
-#include <map>
-#include <set>
-#include <string>
-#include <vector>
-
-#if PN_CPP_SUPPORTS_THREADS
-#include <mutex>
-# define MUTEX(x) std::mutex x;
-# define GUARD(x) std::lock_guard<std::mutex> g(x)
-# define ONCE_FLAG(x) std::once_flag x;
-# define CALL_ONCE(x, ...) std::call_once(x, __VA_ARGS__)
-#else
-# define MUTEX(x)
-# define GUARD(x)
-# define ONCE_FLAG(x)
-# define CALL_ONCE(x, f, o) ((o)->*(f))()
-#endif
-
-struct pn_proactor_t;
-struct pn_listener_t;
-struct pn_event_t;
-
-namespace proton {
-
-namespace internal {
-class connector;
-}
-
-class container::impl {
- public:
- impl(container& c, const std::string& id, messaging_handler* = 0);
- ~impl();
- std::string id() const { return id_; }
- returned<connection> connect(const std::string&, const connection_options&);
- returned<sender> open_sender(
- const std::string&, const proton::sender_options &, const connection_options &);
- returned<receiver> open_receiver(
- const std::string&, const proton::receiver_options &, const connection_options &);
- listener listen(const std::string&);
- listener listen(const std::string&, const connection_options& lh);
- listener listen(const std::string&, listen_handler& lh);
- void client_connection_options(const connection_options &);
- connection_options client_connection_options() const { return client_connection_options_; }
- void server_connection_options(const connection_options &);
- connection_options server_connection_options() const { return server_connection_options_; }
- void sender_options(const proton::sender_options&);
- class sender_options sender_options() const { return sender_options_; }
- void receiver_options(const proton::receiver_options&);
- class receiver_options receiver_options() const { return receiver_options_; }
- void run(int threads);
- void stop(const error_condition& err);
- void auto_stop(bool set);
- void schedule(duration, work);
- template <class T> static void set_handler(T s, messaging_handler* h);
- template <class T> static messaging_handler* get_handler(T s);
- static work_queue::impl* make_work_queue(container&);
-
- private:
- class common_work_queue;
- class connection_work_queue;
- class container_work_queue;
- pn_listener_t* listen_common_lh(const std::string&);
- pn_connection_t* make_connection_lh(const url& url, const connection_options&);
- void setup_connection_lh(const url& url, pn_connection_t *pnc);
- void start_connection(const url& url, pn_connection_t* c);
- void reconnect(pn_connection_t* pnc);
- duration next_delay(reconnect_context& rc);
- bool setup_reconnect(pn_connection_t* pnc);
- void reset_reconnect(pn_connection_t* pnc);
-
- // Event loop to run in each container thread
- void thread();
- bool handle(pn_event_t*);
- void run_timer_jobs();
-
- int threads_;
- container& container_;
- MUTEX(lock_)
-
- ONCE_FLAG(start_once_)
- ONCE_FLAG(stop_once_)
- void start_event();
- void stop_event();
-
- typedef std::set<container_work_queue*> work_queues;
- work_queues work_queues_;
- MUTEX(work_queues_lock_)
- container_work_queue* add_work_queue();
- void remove_work_queue(container_work_queue*);
-
- struct scheduled {
- timestamp time; // duration from epoch for task
- work task;
-
- // We want to get to get the *earliest* first so test is "reversed"
- bool operator < (const scheduled& r) const { return r.time < time; }
- };
- std::vector<scheduled> deferred_; // This vector is kept as a heap
- MUTEX(deferred_lock_)
-
- pn_proactor_t* proactor_;
- messaging_handler* handler_;
- std::string id_;
- connection_options client_connection_options_;
- connection_options server_connection_options_;
- proton::sender_options sender_options_;
- proton::receiver_options receiver_options_;
- error_condition disconnect_error_;
-
- bool auto_stop_;
- bool stopping_;
- friend class connector;
-};
-
-template <class T>
-void container::impl::set_handler(T s, messaging_handler* mh) {
- internal::set_messaging_handler(s, mh);
-}
-
-template <class T>
-messaging_handler* container::impl::get_handler(T s) {
- return internal::get_messaging_handler(s);
-}
-
-
-}
-
-#endif /*!PROTON_CPP_PROACTOR_CONTAINERIMPL_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/include/proactor_work_queue_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/proactor_work_queue_impl.hpp b/proton-c/bindings/cpp/src/include/proactor_work_queue_impl.hpp
deleted file mode 100644
index cd9037a..0000000
--- a/proton-c/bindings/cpp/src/include/proactor_work_queue_impl.hpp
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef PROTON_CPP_EVENT_LOOP_IMPL_HPP
-#define PROTON_CPP_EVENT_LOOP_IMPL_HPP
-
-/*
- *
- * 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.
- *
- */
-
-#include "proton/fwd.hpp"
-
-namespace proton {
-
-class work_queue::impl {
- public:
- virtual ~impl() {};
- virtual bool add(work f) = 0;
- void add_void(work f) { add(f); }
- virtual void schedule(duration, work) = 0;
- virtual void run_all_jobs() = 0;
- virtual void finished() = 0;
-};
-
-}
-
-#endif // PROTON_CPP_EVENT_LOOP_IMPL_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/include/proton_bits.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/proton_bits.hpp b/proton-c/bindings/cpp/src/include/proton_bits.hpp
deleted file mode 100644
index b6636f9..0000000
--- a/proton-c/bindings/cpp/src/include/proton_bits.hpp
+++ /dev/null
@@ -1,162 +0,0 @@
-#ifndef PROTON_BITS_HPP
-#define PROTON_BITS_HPP
-/*
- * 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.
- */
-#include <proton/link.h>
-#include <proton/session.h>
-
-#include <string>
-#include <iosfwd>
-
-#include "contexts.hpp"
-
-/**@file
- *
- * Assorted internal proton utilities.
- */
-
-struct pn_error_t;
-
-struct pn_data_t;
-struct pn_transport_t;
-struct pn_sasl_t;
-struct pn_ssl_t;
-struct pn_connection_t;
-struct pn_session_t;
-struct pn_link_t;
-struct pn_delivery_t;
-struct pn_condition_t;
-struct pn_acceptor_t;
-struct pn_terminus_t;
-struct pn_reactor_t;
-struct pn_record_t;
-
-namespace proton {
-
-namespace internal { class data; }
-class transport;
-class sasl;
-class ssl;
-class connection;
-class session;
-class link;
-class sender;
-class receiver;
-class transfer;
-class tracker;
-class delivery;
-class error_condition;
-class acceptor;
-class terminus;
-class source;
-class target;
-class reactor;
-class messaging_handler;
-
-std::string error_str(long code);
-
-/** Print the error string from pn_error_t, or from code if pn_error_t has no error. */
-std::string error_str(pn_error_t*, long code=0);
-
-/** Make a void* inspectable via operator <<. */
-struct inspectable { void* value; inspectable(void* o) : value(o) {} };
-
-/** Stream a proton object via pn_inspect. */
-std::ostream& operator<<(std::ostream& o, const inspectable& object);
-
-void set_error_condition(const error_condition&, pn_condition_t*);
-
-/// Convert a const char* to std::string, convert NULL to the empty string.
-inline std::string str(const char* s) { return s ? s : std::string(); }
-
-namespace internal {
-
-// These traits relate the wrapped and wrapper classes for the templated factories below
-template <class T> struct wrapped {};
-template <> struct wrapped<internal::data> { typedef pn_data_t type; };
-template <> struct wrapped<transport> { typedef pn_transport_t type; };
-template <> struct wrapped<connection> { typedef pn_connection_t type; };
-template <> struct wrapped<session> { typedef pn_session_t type; };
-template <> struct wrapped<link> { typedef pn_link_t type; };
-template <> struct wrapped<sender> { typedef pn_link_t type; };
-template <> struct wrapped<receiver> { typedef pn_link_t type; };
-template <> struct wrapped<transfer> { typedef pn_delivery_t type; };
-template <> struct wrapped<tracker> { typedef pn_delivery_t type; };
-template <> struct wrapped<delivery> { typedef pn_delivery_t type; };
-template <> struct wrapped<error_condition> { typedef pn_condition_t type; };
-template <> struct wrapped<terminus> { typedef pn_terminus_t type; };
-template <> struct wrapped<source> { typedef pn_terminus_t type; };
-template <> struct wrapped<target> { typedef pn_terminus_t type; };
-
-template <class T> struct wrapper {};
-template <> struct wrapper<pn_data_t> { typedef internal::data type; };
-template <> struct wrapper<pn_transport_t> { typedef transport type; };
-template <> struct wrapper<pn_connection_t> { typedef connection type; };
-template <> struct wrapper<pn_session_t> { typedef session type; };
-template <> struct wrapper<pn_link_t> { typedef link type; };
-template <> struct wrapper<pn_delivery_t> { typedef transfer type; };
-template <> struct wrapper<pn_condition_t> { typedef error_condition type; };
-template <> struct wrapper<pn_terminus_t> { typedef terminus type; };
-
-// Factory for wrapper types
-template <class T>
-class factory {
-public:
- static T wrap(typename wrapped<T>::type* t) { return t; }
- static typename wrapped<T>::type* unwrap(const T& t) { return t.pn_object(); }
-};
-
-template <class T> struct context {};
-template <> struct context<link> {typedef link_context type; };
-template <> struct context<receiver> {typedef link_context type; };
-template <> struct context<sender> {typedef link_context type; };
-template <> struct context<session> {typedef session_context type; };
-template <> struct context<connection> {typedef connection_context type; };
-
-template <class T>
-inline void set_messaging_handler(T t, messaging_handler* mh) { context<T>::type::get(factory<T>::unwrap(t)).handler = mh; }
-
-template <class T>
-inline messaging_handler* get_messaging_handler(T* t) { return context<typename internal::wrapper<T>::type>::type::get(t).handler; }
-
-class returned_factory {
- public:
- template <class T> static returned<T> make(typename internal::wrapped<T>::type* pn) {
- return returned<T>(pn);
- }
-};
-
-} // namespace internal
-
-template <class T>
-typename internal::wrapper<T>::type make_wrapper(T* t) { return internal::factory<typename internal::wrapper<T>::type>::wrap(t); }
-
-template <class U>
-U make_wrapper(typename internal::wrapped<U>::type* t) { return internal::factory<U>::wrap(t); }
-
-template <class T>
-typename internal::wrapped<T>::type* unwrap(const T& t) { return internal::factory<T>::unwrap(t); }
-
-template <class T> returned<T> make_returned(typename internal::wrapped<T>::type* pn) {
- return internal::returned_factory::make<T>(pn);
-}
-
-}
-
-#endif // PROTON_BITS_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/include/reconnect_options_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/reconnect_options_impl.hpp b/proton-c/bindings/cpp/src/include/reconnect_options_impl.hpp
deleted file mode 100644
index 2aca82d..0000000
--- a/proton-c/bindings/cpp/src/include/reconnect_options_impl.hpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef PROTON_CPP_RECONNECT_OPTIONSIMPL_H
-#define PROTON_CPP_RECONNECT_OPTIONSIMPL_H
-
-/*
- *
- * 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.
- *
- */
-
-#include "proton/duration.hpp"
-
-#include <string>
-#include <vector>
-
-namespace proton {
-
-class reconnect_options::impl {
- public:
- impl() : delay(10), delay_multiplier(2.0), max_delay(duration::FOREVER), max_attempts(0) {}
-
- duration delay;
- float delay_multiplier;
- duration max_delay;
- int max_attempts;
- std::vector<std::string> failover_urls;
-};
-
-}
-
-#endif /*!PROTON_CPP_RECONNECT_OPTIONSIMPL_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/include/scalar_test.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/scalar_test.hpp b/proton-c/bindings/cpp/src/include/scalar_test.hpp
deleted file mode 100644
index a54eabe..0000000
--- a/proton-c/bindings/cpp/src/include/scalar_test.hpp
+++ /dev/null
@@ -1,209 +0,0 @@
-#ifndef SCALAR_TEST_HPP
-#define SCALAR_TEST_HPP
-
-/*
- * 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.
- */
-
-// Template tests used by both scalar_test.cpp and value_test.hpp to test conversion
-// of scalar values via a proton::scalar or a proton::value.
-
-#include "test_bits.hpp"
-
-#include "proton/types.hpp"
-#include "proton/error.hpp"
-
-#include <sstream>
-
-
-namespace test {
-
-using namespace proton;
-
-// Inserting and extracting simple C++ values using same-type get<T> and coerce<T>
-template <class V, class T> void simple_type_test(T x, type_id tid, const std::string& s, T y) {
- V vx(x); // Construct from C++ value
- ASSERT_EQUAL(tid, vx.type());
- ASSERT(!vx.empty());
- ASSERT_EQUAL(x, get<T>(vx));
- ASSERT_EQUAL(x, coerce<T>(vx));
-
- V vxa = x; // Assign from C++ value
- ASSERT_EQUAL(tid, vxa.type());
- ASSERT(!vx.empty());
- ASSERT_EQUAL(vx, vxa);
- ASSERT_EQUAL(x, get<T>(vxa));
- ASSERT_EQUAL(x, coerce<T>(vxa));
-
- V v2; // Default construct
- ASSERT(v2.type() == NULL_TYPE);
- ASSERT(v2.empty());
- v2 = x; // Assign from C++ value
- ASSERT_EQUAL(tid, v2.type());
- ASSERT_EQUAL(vx, v2);
- ASSERT_EQUAL(x, get<T>(v2));
- ASSERT_EQUAL(x, coerce<T>(v2));
-
- V v3(vx); // Copy construct
- ASSERT_EQUAL(tid, v3.type());
- ASSERT_EQUAL(vx, v3);
- ASSERT_EQUAL(x, get<T>(v3));
- ASSERT_EQUAL(x, coerce<T>(v3));
-
- V v4 = vx; // Copy assign
- ASSERT_EQUAL(tid, v4.type());
- ASSERT_EQUAL(x, get<T>(v4));
- ASSERT_EQUAL(x, coerce<T>(v4));
-
- ASSERT_EQUAL(s, to_string(vx)); // Stringify
- V vy(y);
- ASSERT(vx != vy); // Compare
- ASSERT(vx < vy);
- ASSERT(vy > vx);
-}
-
-// Test native C/C++ integer types via their mapped integer type ([u]int_x_t)
-template <class V, class T> void simple_integral_test() {
- typedef typename internal::integer_type<sizeof(T), internal::is_signed<T>::value>::type int_type;
- simple_type_test<V>(T(3), internal::type_id_of<int_type>::value, "3", T(4));
-}
-
-// Test invalid gets, valid same-type get<T> is tested by simple_type_test
-// Templated to test both scalar and value.
-template<class V> void bad_get_test() {
- try { get<bool>(V(int8_t(1))); FAIL("byte as bool"); } catch (conversion_error) {}
- try { get<uint8_t>(V(true)); FAIL("bool as uint8_t"); } catch (conversion_error) {}
- try { get<uint8_t>(V(int8_t(1))); FAIL("int8 as uint8"); } catch (conversion_error) {}
- try { get<int16_t>(V(uint16_t(1))); FAIL("uint16 as int16"); } catch (conversion_error) {}
- try { get<int16_t>(V(int32_t(1))); FAIL("int32 as int16"); } catch (conversion_error) {}
- try { get<symbol>(V(std::string())); FAIL("string as symbol"); } catch (conversion_error) {}
- try { get<std::string>(V(binary())); FAIL("binary as string"); } catch (conversion_error) {}
- try { get<binary>(V(symbol())); FAIL("symbol as binary"); } catch (conversion_error) {}
- try { get<binary>(V(timestamp())); FAIL("timestamp as binary"); } catch (conversion_error) {}
- try { get<int>(V(timestamp())); FAIL("timestamp as int"); } catch (conversion_error) {}
- try { get<timestamp>(V(0)); FAIL("int as timestamp"); } catch (conversion_error) {}
- try { get<timestamp>(V(std::string())); FAIL("string as timestamp"); } catch (conversion_error) {}
-}
-
-// Test some valid coercions and some bad ones with mixed types.
-// Templated to test both scalar and value.
-template<class V> void coerce_test() {
- // Valid C++ conversions should work with coerce.
- ASSERT_EQUAL(false, coerce<bool>(V(0)));
- ASSERT_EQUAL(true, coerce<bool>(V(-1)));
- ASSERT_EQUAL(true, coerce<bool>(V(int64_t(0xFFFF0000))));
-
- ASSERT_EQUAL(1, coerce<uint8_t>(V(uint64_t(1)))); // In range.
- ASSERT_EQUAL(1, coerce<uint8_t>(V(uint32_t(0xFF01)))); // int truncate.
- ASSERT_EQUAL(0xFFFF, coerce<uint16_t>(V(int8_t(-1)))); // Sign extend.
- ASSERT_EQUAL(-1, coerce<int32_t>(V(uint64_t(0xFFFFFFFFul)))); // 2s complement
-
- ASSERT_EQUALISH(1.2f, coerce<float>(V(double(1.2))), 0.001f);
- ASSERT_EQUALISH(3.4, coerce<double>(V(float(3.4))), 0.001);
- ASSERT_EQUALISH(23.0, coerce<double>(V(uint64_t(23))), 0.001); // int to double.
- ASSERT_EQUAL(-1945, coerce<int>(V(float(-1945.123)))); // round to int.
-
- // String-like conversions.
- ASSERT_EQUAL(std::string("foo"), coerce<std::string>(V(symbol("foo"))));
- ASSERT_EQUAL(std::string("foo"), coerce<std::string>(V(binary("foo"))));
-
- // Bad coercions, types are not `is_convertible`
- V s("foo");
- try { coerce<bool>(s); FAIL("string as bool"); } catch (conversion_error) {}
- try { coerce<int>(s); FAIL("string as int"); } catch (conversion_error) {}
- try { coerce<double>(s); FAIL("string as double"); } catch (conversion_error) {}
-
- try { coerce<std::string>(V(0)); FAIL("int as string"); } catch (conversion_error) {}
- try { coerce<symbol>(V(true)); FAIL("bool as symbol"); } catch (conversion_error) {}
- try { coerce<binary>(V(0.0)); FAIL("double as binary"); } catch (conversion_error) {}
- try { coerce<symbol>(V(binary())); FAIL("binary as symbol"); } catch (conversion_error) {}
- try { coerce<binary>(V(symbol())); FAIL("symbol as binary"); } catch (conversion_error) {}
- try { coerce<binary>(s); } catch (conversion_error) {}
- try { coerce<symbol>(s); } catch (conversion_error) {}
-}
-
-template <class V> void null_test() {
- V v;
- ASSERT(v.empty());
- ASSERT_EQUAL(NULL_TYPE, v.type());
- get<null>(v);
- null n;
- get(v, n);
- V v2(n);
- ASSERT(v.empty());
- ASSERT_EQUAL(NULL_TYPE, v.type());
- v = "foo";
- ASSERT_EQUAL(STRING, v.type());
- try { get<null>(v); FAIL("Expected conversion_error"); } catch (conversion_error) {}
- v = null();
- get<null>(v);
-}
-
-// Nasty hack for uninterpreted decimal<> types.
-template <class T> T make(const char c) { T x; std::fill(x.begin(), x.end(), c); return x; }
-
-template <class V> void scalar_test_group(int& failed) {
- // Direct AMQP-mapped types.
- RUN_TEST(failed, simple_type_test<V>(false, BOOLEAN, "false", true));
- RUN_TEST(failed, simple_type_test<V>(uint8_t(42), UBYTE, "42", uint8_t(50)));
- RUN_TEST(failed, simple_type_test<V>(int8_t(-42), BYTE, "-42", int8_t(-40)));
- RUN_TEST(failed, simple_type_test<V>(uint16_t(4242), USHORT, "4242", uint16_t(5252)));
- RUN_TEST(failed, simple_type_test<V>(int16_t(-4242), SHORT, "-4242", int16_t(3)));
- RUN_TEST(failed, simple_type_test<V>(uint32_t(4242), UINT, "4242", uint32_t(5252)));
- RUN_TEST(failed, simple_type_test<V>(int32_t(-4242), INT, "-4242", int32_t(3)));
- RUN_TEST(failed, simple_type_test<V>(uint64_t(4242), ULONG, "4242", uint64_t(5252)));
- RUN_TEST(failed, simple_type_test<V>(int64_t(-4242), LONG, "-4242", int64_t(3)));
- RUN_TEST(failed, simple_type_test<V>(wchar_t('X'), CHAR, "88", wchar_t('Y')));
- RUN_TEST(failed, simple_type_test<V>(float(1.234), FLOAT, "1.234", float(2.345)));
- RUN_TEST(failed, simple_type_test<V>(double(11.2233), DOUBLE, "11.2233", double(12)));
- RUN_TEST(failed, simple_type_test<V>(timestamp(1234), TIMESTAMP, "1234", timestamp(12345)));
- RUN_TEST(failed, simple_type_test<V>(make<decimal32>(1), DECIMAL32, "decimal32(0x01010101)", make<decimal32>(2)));
- RUN_TEST(failed, simple_type_test<V>(make<decimal64>(3), DECIMAL64, "decimal64(0x0303030303030303)", make<decimal64>(4)));
- RUN_TEST(failed, simple_type_test<V>(make<decimal128>(5), DECIMAL128, "decimal128(0x05050505050505050505050505050505)", make<decimal128>(6)));
- RUN_TEST(failed, simple_type_test<V>(
- uuid::copy("\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff"),
- UUID, "00112233-4455-6677-8899-aabbccddeeff",
- uuid::copy("\xff\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff")));
- RUN_TEST(failed, simple_type_test<V>(std::string("xxx"), STRING, "xxx", std::string("yyy")));
- RUN_TEST(failed, simple_type_test<V>(symbol("aaa"), SYMBOL, "aaa", symbol("aaaa")));
- RUN_TEST(failed, simple_type_test<V>(binary("\010aaa"), BINARY, "b\"\\x08aaa\"", binary("aaaa")));
-
- // Test native C++ integral types.
- RUN_TEST(failed, (simple_integral_test<V, char>()));
- RUN_TEST(failed, (simple_integral_test<V, signed char>()));
- RUN_TEST(failed, (simple_integral_test<V, unsigned char>()));
- RUN_TEST(failed, (simple_integral_test<V, short>()));
- RUN_TEST(failed, (simple_integral_test<V, int>()));
- RUN_TEST(failed, (simple_integral_test<V, long>()));
- RUN_TEST(failed, (simple_integral_test<V, unsigned short>()));
- RUN_TEST(failed, (simple_integral_test<V, unsigned int>()));
- RUN_TEST(failed, (simple_integral_test<V, unsigned long>()));
-#if PN_CPP_HAS_LONG_LONG_TYPE
- RUN_TEST(failed, (simple_integral_test<V, long long>()));
- RUN_TEST(failed, (simple_integral_test<V, unsigned long long>()));
-#endif
-
-
- RUN_TEST(failed, (coerce_test<V>()));
- RUN_TEST(failed, (null_test<V>()));
- RUN_TEST(failed, (bad_get_test<V>()));
-}
-
-}
-
-#endif // SCALAR_TEST_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/include/test_bits.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/test_bits.hpp b/proton-c/bindings/cpp/src/include/test_bits.hpp
deleted file mode 100644
index 4e019f2..0000000
--- a/proton-c/bindings/cpp/src/include/test_bits.hpp
+++ /dev/null
@@ -1,158 +0,0 @@
-#ifndef TEST_BITS_HPP
-#define TEST_BITS_HPP
-/*
- * 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.
- */
-
-#include "msg.hpp"
-#include "proton/types.hpp"
-
-#include <stdexcept>
-#include <iostream>
-#include <iterator>
-#include <sstream>
-#include <cstring>
-#include <math.h>
-
-namespace test {
-
-struct fail : public std::logic_error {
- explicit fail(const std::string& what) : logic_error(what) {}
-};
-
-struct error : public std::logic_error {
- explicit error(const std::string& what) : logic_error(what) {}
-};
-
-template <class T, class U>
-void assert_equal(const T& want, const U& got, const std::string& what) {
- if (!(want == got))
- throw fail(MSG(what << " " << want << " != " << got));
-}
-
-template <class T>
-inline void assert_equalish(T want, T got, T delta, const std::string& what)
-{
- if (!(fabs(want-got) <= delta))
- throw fail(MSG(what << " " << want << " !=~ " << got));
-}
-
-#define FAIL_MSG(WHAT) (MSG(__FILE__ << ":" << __LINE__ << ": " << WHAT).str())
-#define FAIL(WHAT) throw test::fail(FAIL_MSG(WHAT))
-#define ASSERT(TEST) do { if (!(TEST)) FAIL("failed ASSERT(" #TEST ")"); } while(false)
-#define ASSERT_EQUAL(WANT, GOT) \
- test::assert_equal((WANT), (GOT), FAIL_MSG("failed ASSERT_EQUAL(" #WANT ", " #GOT ")"))
-#define ASSERT_EQUALISH(WANT, GOT, DELTA) \
- test::assert_equalish((WANT), (GOT), (DELTA), FAIL_MSG("failed ASSERT_EQUALISH(" #WANT ", " #GOT ")"))
-#define ASSERT_THROWS(WANT, EXPR) do { try { EXPR; FAIL("Expected " #WANT); } catch(const WANT&) {} } while(0)
-
-#define RUN_TEST(BAD_COUNT, TEST) \
- do { \
- try { \
- std::cout << "TEST: " << #TEST << std::endl; \
- TEST; \
- break; \
- } catch(const test::fail& e) { \
- std::cout << "FAIL " << #TEST << std::endl << e.what() << std::endl; \
- } catch(const std::exception& e) { \
- std::cout << "ERROR " << #TEST << std::endl << __FILE__ << ":" << __LINE__ << ": " << e.what() << std::endl; \
- } \
- ++BAD_COUNT; \
- } while(0)
-
-/* Like RUN_TEST but only if one of the argv strings is found in the test EXPR */
-#define RUN_ARGV_TEST(BAD_COUNT, EXPR) do { \
- if (argc == 1) { \
- RUN_TEST(BAD_COUNT, EXPR); \
- } else { \
- for (int i = 1; i < argc; ++i) { \
- if (strstr(#EXPR, argv[i])) { \
- RUN_TEST(BAD_COUNT, EXPR); \
- break; \
- } \
- } \
- } \
- } while(0)
-
-
-template<class T> std::string str(const T& x) {
- std::ostringstream s; s << std::boolalpha << x; return s.str();
-}
-
-// A way to easily create literal collections that can be compared to std:: collections
-// and to print std collections
-// e.g.
-// std::vector<string> v = ...;
-// ASSERT_EQUAL(many<string>() + "a" + "b" + "c", v);
-template <class T> struct many : public std::vector<T> {
- many() {}
- template<class S> explicit many(const S& s) : std::vector<T>(s.begin(), s.end()) {}
- many& operator+=(const T& t) { this->push_back(t); return *this; }
- many& operator<<(const T& t) { return *this += t; }
- many operator+(const T& t) { many<T> l(*this); return l += t; }
-};
-
-template <class T, class S> bool operator==(const many<T>& m, const S& s) {
- return m.size() == s.size() && S(m.begin(), m.end()) == s;
-}
-
-template <class T, class S> bool operator==(const S& s, const many<T>& m) {
- return m.size() == s.size() && S(m.begin(), m.end()) == s;
-}
-
-template <class T> std::ostream& operator<<(std::ostream& o, const many<T>& m) {
- std::ostream_iterator<T> oi(o, " ");
- std::copy(m.begin(), m.end(), oi);
- return o;
-}
-
-}
-
-namespace std {
-template <class T> std::ostream& operator<<(std::ostream& o, const std::vector<T>& s) {
- return o << test::many<T>(s);
-}
-
-template <class T> std::ostream& operator<<(std::ostream& o, const std::deque<T>& s) {
- return o << test::many<T>(s);
-}
-
-template <class T> std::ostream& operator<<(std::ostream& o, const std::list<T>& s) {
- return o << test::many<T>(s);
-}
-
-template <class K, class T> std::ostream& operator<<(std::ostream& o, const std::map<K, T>& x) {
- return o << test::many<std::pair<K, T> >(x);
-}
-
-template <class U, class V> std::ostream& operator<<(std::ostream& o, const std::pair<U, V>& p) {
- return o << "( " << p.first << " , " << p.second << " )";
-}
-
-#if PN_CPP_HAS_CPP11
-template <class K, class T> std::ostream& operator<<(std::ostream& o, const std::unordered_map<K, T>& x) {
- return o << test::many<std::pair<const K, T> >(x);
-}
-
-template <class T> std::ostream& operator<<(std::ostream& o, const std::forward_list<T>& s) {
- return o << test::many<T>(s);
-}
-#endif
-}
-
-#endif // TEST_BITS_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/include/types_internal.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/include/types_internal.hpp b/proton-c/bindings/cpp/src/include/types_internal.hpp
deleted file mode 100644
index bff93a0..0000000
--- a/proton-c/bindings/cpp/src/include/types_internal.hpp
+++ /dev/null
@@ -1,74 +0,0 @@
-#ifndef TYPES_INTERNAL_HPP
-#define TYPES_INTERNAL_HPP
-/*
- * 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.
- */
-
-#include "proton/internal/type_traits.hpp"
-#include "proton/error.hpp"
-#include "proton/binary.hpp"
-#include <sstream>
-
-///@file
-/// Inline helpers for encode/decode/type conversion/ostream operators.
-
-namespace proton {
-
-/// Byte copy between two objects, only enabled if their sizes are equal.
-template <class T, class U>
-typename internal::enable_if<sizeof(T) == sizeof(U)>::type byte_copy(T &to, const U &from) {
- const char *p = reinterpret_cast<const char*>(&from);
- std::copy(p, p + sizeof(T), reinterpret_cast<char*>(&to));
-}
-
-inline conversion_error
-make_conversion_error(type_id want, type_id got, const std::string& msg=std::string()) {
- std::ostringstream s;
- s << "unexpected type, want: " << want << " got: " << got;
- if (!msg.empty()) s << ": " << msg;
- return conversion_error(s.str());
-}
-
-/// Convert std::string to pn_bytes_t
-inline pn_bytes_t pn_bytes(const std::string& s) {
- pn_bytes_t b = { s.size(), s.empty() ? 0 : const_cast<char*>(&s[0]) };
- return b;
-}
-
-inline pn_bytes_t pn_bytes(const binary& s) {
- pn_bytes_t b = { s.size(), s.empty() ? 0 : reinterpret_cast<const char*>(&s[0]) };
- return b;
-}
-
-inline std::string str(const pn_bytes_t& b) { return std::string(b.start, b.size); }
-inline binary bin(const pn_bytes_t& b) { return binary(b.start, b.start+b.size); }
-
-// Save all stream format state, restore in destructor.
-struct ios_guard {
- std::ios &guarded;
- std::ios old;
- ios_guard(std::ios& x) : guarded(x), old(0) { old.copyfmt(guarded); }
- ~ios_guard() { guarded.copyfmt(old); }
-};
-
-// Convert a char (signed or unsigned) into an unsigned 1 byte integer that will ostream
-// as a numeric byte value, not a character and will not get sign-extended.
-inline unsigned int printable_byte(uint8_t byte) { return byte; }
-
-}
-#endif // TYPES_INTERNAL_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/io/connection_driver.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/io/connection_driver.cpp b/proton-c/bindings/cpp/src/io/connection_driver.cpp
deleted file mode 100644
index cc83f51..0000000
--- a/proton-c/bindings/cpp/src/io/connection_driver.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * 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.
- */
-
-#include "proton/io/connection_driver.hpp"
-
-#include "proton/connection.hpp"
-#include "proton/container.hpp"
-#include "proton/error.hpp"
-#include "proton/messaging_handler.hpp"
-#include "proton/transport.hpp"
-#include "proton/uuid.hpp"
-#include "proton/work_queue.hpp"
-
-#include "contexts.hpp"
-#include "messaging_adapter.hpp"
-#include "msg.hpp"
-#include "proton_bits.hpp"
-
-#include <proton/connection.h>
-#include <proton/transport.h>
-#include <proton/event.h>
-
-#include <algorithm>
-
-
-namespace proton {
-namespace io {
-
-void connection_driver::init() {
- if (pn_connection_driver_init(&driver_, pn_connection(), pn_transport()) != 0) {
- this->~connection_driver(); // Dtor won't be called on throw from ctor.
- throw proton::error(std::string("connection_driver allocation failed"));
- }
-}
-
-connection_driver::connection_driver() : handler_(0) { init(); }
-
-connection_driver::connection_driver(const std::string& id) : container_id_(id), handler_(0) {
- init();
-}
-
-connection_driver::~connection_driver() {
- pn_connection_driver_destroy(&driver_);
-}
-
-void connection_driver::configure(const connection_options& opts, bool server) {
- proton::connection c(connection());
- opts.apply_unbound(c);
- if (server) pn_transport_set_server(driver_.transport);
- pn_connection_driver_bind(&driver_);
- opts.apply_bound(c);
- handler_ = opts.handler();
-}
-
-void connection_driver::connect(const connection_options& opts) {
- connection_options all;
- all.container_id(container_id_);
- all.update(opts);
- configure(all, false);
- connection().open();
-}
-
-void connection_driver::accept(const connection_options& opts) {
- connection_options all;
- all.container_id(container_id_);
- all.update(opts);
- configure(all, true);
-}
-
-bool connection_driver::has_events() const {
- return driver_.collector && pn_collector_peek(driver_.collector);
-}
-
-bool connection_driver::dispatch() {
- pn_event_t* c_event;
- while ((c_event = pn_connection_driver_next_event(&driver_)) != NULL) {
- try {
- if (handler_ != 0) {
- messaging_adapter::dispatch(*handler_, c_event);
- }
- } catch (const std::exception& e) {
- pn_condition_t *cond = pn_transport_condition(driver_.transport);
- if (!pn_condition_is_set(cond)) {
- pn_condition_format(cond, "exception", "%s", e.what());
- }
- }
- }
- return !pn_connection_driver_finished(&driver_);
-}
-
-mutable_buffer connection_driver::read_buffer() {
- pn_rwbytes_t buffer = pn_connection_driver_read_buffer(&driver_);
- return mutable_buffer(buffer.start, buffer.size);
-}
-
-void connection_driver::read_done(size_t n) {
- return pn_connection_driver_read_done(&driver_, n);
-}
-
-void connection_driver::read_close() {
- pn_connection_driver_read_close(&driver_);
-}
-
-const_buffer connection_driver::write_buffer() {
- pn_bytes_t buffer = pn_connection_driver_write_buffer(&driver_);
- return const_buffer(buffer.start, buffer.size);
-}
-
-void connection_driver::write_done(size_t n) {
- return pn_connection_driver_write_done(&driver_, n);
-}
-
-void connection_driver::write_close() {
- pn_connection_driver_write_close(&driver_);
-}
-
-timestamp connection_driver::tick(timestamp now) {
- return timestamp(pn_transport_tick(driver_.transport, now.milliseconds()));
-}
-
-void connection_driver::disconnected(const proton::error_condition& err) {
- pn_condition_t* condition = pn_transport_condition(driver_.transport);
- if (!pn_condition_is_set(condition)) {
- set_error_condition(err, condition);
- }
- pn_connection_driver_close(&driver_);
-}
-
-proton::connection connection_driver::connection() const {
- return make_wrapper(driver_.connection);
-}
-
-proton::transport connection_driver::transport() const {
- return make_wrapper(driver_.transport);
-}
-
-}}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/io/link_namer.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/io/link_namer.cpp b/proton-c/bindings/cpp/src/io/link_namer.cpp
deleted file mode 100644
index c8c7c8c..0000000
--- a/proton-c/bindings/cpp/src/io/link_namer.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.
- */
-
-#include "link_namer.hpp"
-
-#include "proton/connection.hpp"
-
-#include "contexts.hpp"
-#include "proton_bits.hpp"
-
-namespace proton {
-namespace io {
-
-void set_link_namer(connection& c, link_namer& l) {
- connection_context::get(unwrap(c)).link_gen = &l;
-}
-
-}}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/link_namer.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/link_namer.cpp b/proton-c/bindings/cpp/src/link_namer.cpp
new file mode 100644
index 0000000..c8c7c8c
--- /dev/null
+++ b/proton-c/bindings/cpp/src/link_namer.cpp
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+#include "link_namer.hpp"
+
+#include "proton/connection.hpp"
+
+#include "contexts.hpp"
+#include "proton_bits.hpp"
+
+namespace proton {
+namespace io {
+
+void set_link_namer(connection& c, link_namer& l) {
+ connection_context::get(unwrap(c)).link_gen = &l;
+}
+
+}}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/link_namer.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/link_namer.hpp b/proton-c/bindings/cpp/src/link_namer.hpp
new file mode 100644
index 0000000..d107728
--- /dev/null
+++ b/proton-c/bindings/cpp/src/link_namer.hpp
@@ -0,0 +1,51 @@
+#ifndef PROTON_IO_LINK_NAMER_HPP
+#define PROTON_IO_LINK_NAMER_HPP
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/internal/export.hpp"
+#include <string>
+
+namespace proton {
+
+class connection;
+
+namespace io {
+
+/// **Unsettled API** - Generate default link names that are unique
+/// within a container. base_container provides a default
+/// implementation.
+class link_namer {
+ public:
+ virtual ~link_namer() {}
+
+ /// Generate a unique link name.
+ virtual std::string link_name() = 0;
+};
+
+/// **Unsettled API** - Set the link_namer to use on a connection.
+PN_CPP_EXTERN void set_link_namer(connection&, link_namer&);
+
+} // io
+} // proton
+
+#endif // PROTON_IO_LINK_NAMER_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/messaging_adapter.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/messaging_adapter.hpp b/proton-c/bindings/cpp/src/messaging_adapter.hpp
new file mode 100644
index 0000000..10c7682
--- /dev/null
+++ b/proton-c/bindings/cpp/src/messaging_adapter.hpp
@@ -0,0 +1,42 @@
+#ifndef PROTON_CPP_MESSAGING_ADAPTER_H
+#define PROTON_CPP_MESSAGING_ADAPTER_H
+
+/*
+ *
+ * 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.
+ *
+ */
+
+///@cond INTERNAL
+
+struct pn_event_t;
+
+namespace proton {
+
+class messaging_handler;
+
+/// Convert the low level proton-c events to the higher level proton::messaging_handler calls
+class messaging_adapter
+{
+ public:
+ static void dispatch(messaging_handler& delegate, pn_event_t* e);
+};
+
+}
+///@endcond INTERNAL
+#endif /*!PROTON_CPP_MESSAGING_ADAPTER_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/msg.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/msg.hpp b/proton-c/bindings/cpp/src/msg.hpp
new file mode 100644
index 0000000..b24b25c
--- /dev/null
+++ b/proton-c/bindings/cpp/src/msg.hpp
@@ -0,0 +1,58 @@
+#ifndef PROTON_MSG_H
+#define PROTON_MSG_H
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include <sstream>
+#include <iostream>
+
+namespace proton {
+
+/** A simple facade for std::ostringstream that allows
+ * in place construction of a message and automatic conversion
+ * to string.
+ * E.g.
+ *@code
+ * void foo(const std::string&);
+ * foo(msg() << "hello " << 32);
+ *@endcode
+ * Will construct the string "hello 32" and pass it to foo()
+ */
+struct msg {
+ std::ostringstream os;
+ msg() {}
+ msg(const msg& m) : os(m.str()) {}
+ std::string str() const { return os.str(); }
+ operator std::string() const { return str(); }
+ template <class T> msg& operator<<(const T& t) { os << t; return *this; }
+};
+
+inline std::ostream& operator<<(std::ostream& o, const msg& m) { return o << m.str(); }
+
+/** Construct a message using operator << and append (file:line) */
+#define QUOTe_(x) #x
+#define QUOTE(x) QUOTe_(x)
+#define MSG(message) (::proton::msg() << message)
+
+}
+
+#endif /*!PROTON_MSG_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/proactor_container_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proactor_container_impl.hpp b/proton-c/bindings/cpp/src/proactor_container_impl.hpp
new file mode 100644
index 0000000..06dbcb5
--- /dev/null
+++ b/proton-c/bindings/cpp/src/proactor_container_impl.hpp
@@ -0,0 +1,168 @@
+#ifndef PROTON_CPP_PROACTOR_CONTAINERIMPL_H
+#define PROTON_CPP_PROACTOR_CONTAINERIMPL_H
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/fwd.hpp"
+#include "proton/container.hpp"
+#include "proton/connection.hpp"
+#include "proton/connection_options.hpp"
+#include "proton/duration.hpp"
+#include "proton/error_condition.hpp"
+#include "proton/messaging_handler.hpp"
+#include "proton/receiver.hpp"
+#include "proton/receiver_options.hpp"
+#include "proton/sender.hpp"
+#include "proton/sender_options.hpp"
+#include "proton/work_queue.hpp"
+
+#include "proton_bits.hpp"
+
+#include <list>
+#include <map>
+#include <set>
+#include <string>
+#include <vector>
+
+#if PN_CPP_SUPPORTS_THREADS
+#include <mutex>
+# define MUTEX(x) std::mutex x;
+# define GUARD(x) std::lock_guard<std::mutex> g(x)
+# define ONCE_FLAG(x) std::once_flag x;
+# define CALL_ONCE(x, ...) std::call_once(x, __VA_ARGS__)
+#else
+# define MUTEX(x)
+# define GUARD(x)
+# define ONCE_FLAG(x)
+# define CALL_ONCE(x, f, o) ((o)->*(f))()
+#endif
+
+struct pn_proactor_t;
+struct pn_listener_t;
+struct pn_event_t;
+
+namespace proton {
+
+namespace internal {
+class connector;
+}
+
+class container::impl {
+ public:
+ impl(container& c, const std::string& id, messaging_handler* = 0);
+ ~impl();
+ std::string id() const { return id_; }
+ returned<connection> connect(const std::string&, const connection_options&);
+ returned<sender> open_sender(
+ const std::string&, const proton::sender_options &, const connection_options &);
+ returned<receiver> open_receiver(
+ const std::string&, const proton::receiver_options &, const connection_options &);
+ listener listen(const std::string&);
+ listener listen(const std::string&, const connection_options& lh);
+ listener listen(const std::string&, listen_handler& lh);
+ void client_connection_options(const connection_options &);
+ connection_options client_connection_options() const { return client_connection_options_; }
+ void server_connection_options(const connection_options &);
+ connection_options server_connection_options() const { return server_connection_options_; }
+ void sender_options(const proton::sender_options&);
+ class sender_options sender_options() const { return sender_options_; }
+ void receiver_options(const proton::receiver_options&);
+ class receiver_options receiver_options() const { return receiver_options_; }
+ void run(int threads);
+ void stop(const error_condition& err);
+ void auto_stop(bool set);
+ void schedule(duration, work);
+ template <class T> static void set_handler(T s, messaging_handler* h);
+ template <class T> static messaging_handler* get_handler(T s);
+ static work_queue::impl* make_work_queue(container&);
+
+ private:
+ class common_work_queue;
+ class connection_work_queue;
+ class container_work_queue;
+ pn_listener_t* listen_common_lh(const std::string&);
+ pn_connection_t* make_connection_lh(const url& url, const connection_options&);
+ void setup_connection_lh(const url& url, pn_connection_t *pnc);
+ void start_connection(const url& url, pn_connection_t* c);
+ void reconnect(pn_connection_t* pnc);
+ duration next_delay(reconnect_context& rc);
+ bool setup_reconnect(pn_connection_t* pnc);
+ void reset_reconnect(pn_connection_t* pnc);
+
+ // Event loop to run in each container thread
+ void thread();
+ bool handle(pn_event_t*);
+ void run_timer_jobs();
+
+ int threads_;
+ container& container_;
+ MUTEX(lock_)
+
+ ONCE_FLAG(start_once_)
+ ONCE_FLAG(stop_once_)
+ void start_event();
+ void stop_event();
+
+ typedef std::set<container_work_queue*> work_queues;
+ work_queues work_queues_;
+ MUTEX(work_queues_lock_)
+ container_work_queue* add_work_queue();
+ void remove_work_queue(container_work_queue*);
+
+ struct scheduled {
+ timestamp time; // duration from epoch for task
+ work task;
+
+ // We want to get to get the *earliest* first so test is "reversed"
+ bool operator < (const scheduled& r) const { return r.time < time; }
+ };
+ std::vector<scheduled> deferred_; // This vector is kept as a heap
+ MUTEX(deferred_lock_)
+
+ pn_proactor_t* proactor_;
+ messaging_handler* handler_;
+ std::string id_;
+ connection_options client_connection_options_;
+ connection_options server_connection_options_;
+ proton::sender_options sender_options_;
+ proton::receiver_options receiver_options_;
+ error_condition disconnect_error_;
+
+ bool auto_stop_;
+ bool stopping_;
+ friend class connector;
+};
+
+template <class T>
+void container::impl::set_handler(T s, messaging_handler* mh) {
+ internal::set_messaging_handler(s, mh);
+}
+
+template <class T>
+messaging_handler* container::impl::get_handler(T s) {
+ return internal::get_messaging_handler(s);
+}
+
+
+}
+
+#endif /*!PROTON_CPP_PROACTOR_CONTAINERIMPL_H*/
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/proactor_work_queue_impl.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proactor_work_queue_impl.hpp b/proton-c/bindings/cpp/src/proactor_work_queue_impl.hpp
new file mode 100644
index 0000000..cd9037a
--- /dev/null
+++ b/proton-c/bindings/cpp/src/proactor_work_queue_impl.hpp
@@ -0,0 +1,41 @@
+#ifndef PROTON_CPP_EVENT_LOOP_IMPL_HPP
+#define PROTON_CPP_EVENT_LOOP_IMPL_HPP
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/fwd.hpp"
+
+namespace proton {
+
+class work_queue::impl {
+ public:
+ virtual ~impl() {};
+ virtual bool add(work f) = 0;
+ void add_void(work f) { add(f); }
+ virtual void schedule(duration, work) = 0;
+ virtual void run_all_jobs() = 0;
+ virtual void finished() = 0;
+};
+
+}
+
+#endif // PROTON_CPP_EVENT_LOOP_IMPL_HPP
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/5199e8c2/proton-c/bindings/cpp/src/proton_bits.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/proton_bits.hpp b/proton-c/bindings/cpp/src/proton_bits.hpp
new file mode 100644
index 0000000..b6636f9
--- /dev/null
+++ b/proton-c/bindings/cpp/src/proton_bits.hpp
@@ -0,0 +1,162 @@
+#ifndef PROTON_BITS_HPP
+#define PROTON_BITS_HPP
+/*
+ * 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.
+ */
+#include <proton/link.h>
+#include <proton/session.h>
+
+#include <string>
+#include <iosfwd>
+
+#include "contexts.hpp"
+
+/**@file
+ *
+ * Assorted internal proton utilities.
+ */
+
+struct pn_error_t;
+
+struct pn_data_t;
+struct pn_transport_t;
+struct pn_sasl_t;
+struct pn_ssl_t;
+struct pn_connection_t;
+struct pn_session_t;
+struct pn_link_t;
+struct pn_delivery_t;
+struct pn_condition_t;
+struct pn_acceptor_t;
+struct pn_terminus_t;
+struct pn_reactor_t;
+struct pn_record_t;
+
+namespace proton {
+
+namespace internal { class data; }
+class transport;
+class sasl;
+class ssl;
+class connection;
+class session;
+class link;
+class sender;
+class receiver;
+class transfer;
+class tracker;
+class delivery;
+class error_condition;
+class acceptor;
+class terminus;
+class source;
+class target;
+class reactor;
+class messaging_handler;
+
+std::string error_str(long code);
+
+/** Print the error string from pn_error_t, or from code if pn_error_t has no error. */
+std::string error_str(pn_error_t*, long code=0);
+
+/** Make a void* inspectable via operator <<. */
+struct inspectable { void* value; inspectable(void* o) : value(o) {} };
+
+/** Stream a proton object via pn_inspect. */
+std::ostream& operator<<(std::ostream& o, const inspectable& object);
+
+void set_error_condition(const error_condition&, pn_condition_t*);
+
+/// Convert a const char* to std::string, convert NULL to the empty string.
+inline std::string str(const char* s) { return s ? s : std::string(); }
+
+namespace internal {
+
+// These traits relate the wrapped and wrapper classes for the templated factories below
+template <class T> struct wrapped {};
+template <> struct wrapped<internal::data> { typedef pn_data_t type; };
+template <> struct wrapped<transport> { typedef pn_transport_t type; };
+template <> struct wrapped<connection> { typedef pn_connection_t type; };
+template <> struct wrapped<session> { typedef pn_session_t type; };
+template <> struct wrapped<link> { typedef pn_link_t type; };
+template <> struct wrapped<sender> { typedef pn_link_t type; };
+template <> struct wrapped<receiver> { typedef pn_link_t type; };
+template <> struct wrapped<transfer> { typedef pn_delivery_t type; };
+template <> struct wrapped<tracker> { typedef pn_delivery_t type; };
+template <> struct wrapped<delivery> { typedef pn_delivery_t type; };
+template <> struct wrapped<error_condition> { typedef pn_condition_t type; };
+template <> struct wrapped<terminus> { typedef pn_terminus_t type; };
+template <> struct wrapped<source> { typedef pn_terminus_t type; };
+template <> struct wrapped<target> { typedef pn_terminus_t type; };
+
+template <class T> struct wrapper {};
+template <> struct wrapper<pn_data_t> { typedef internal::data type; };
+template <> struct wrapper<pn_transport_t> { typedef transport type; };
+template <> struct wrapper<pn_connection_t> { typedef connection type; };
+template <> struct wrapper<pn_session_t> { typedef session type; };
+template <> struct wrapper<pn_link_t> { typedef link type; };
+template <> struct wrapper<pn_delivery_t> { typedef transfer type; };
+template <> struct wrapper<pn_condition_t> { typedef error_condition type; };
+template <> struct wrapper<pn_terminus_t> { typedef terminus type; };
+
+// Factory for wrapper types
+template <class T>
+class factory {
+public:
+ static T wrap(typename wrapped<T>::type* t) { return t; }
+ static typename wrapped<T>::type* unwrap(const T& t) { return t.pn_object(); }
+};
+
+template <class T> struct context {};
+template <> struct context<link> {typedef link_context type; };
+template <> struct context<receiver> {typedef link_context type; };
+template <> struct context<sender> {typedef link_context type; };
+template <> struct context<session> {typedef session_context type; };
+template <> struct context<connection> {typedef connection_context type; };
+
+template <class T>
+inline void set_messaging_handler(T t, messaging_handler* mh) { context<T>::type::get(factory<T>::unwrap(t)).handler = mh; }
+
+template <class T>
+inline messaging_handler* get_messaging_handler(T* t) { return context<typename internal::wrapper<T>::type>::type::get(t).handler; }
+
+class returned_factory {
+ public:
+ template <class T> static returned<T> make(typename internal::wrapped<T>::type* pn) {
+ return returned<T>(pn);
+ }
+};
+
+} // namespace internal
+
+template <class T>
+typename internal::wrapper<T>::type make_wrapper(T* t) { return internal::factory<typename internal::wrapper<T>::type>::wrap(t); }
+
+template <class U>
+U make_wrapper(typename internal::wrapped<U>::type* t) { return internal::factory<U>::wrap(t); }
+
+template <class T>
+typename internal::wrapped<T>::type* unwrap(const T& t) { return internal::factory<T>::unwrap(t); }
+
+template <class T> returned<T> make_returned(typename internal::wrapped<T>::type* pn) {
+ return internal::returned_factory::make<T>(pn);
+}
+
+}
+
+#endif // PROTON_BITS_HPP
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[5/5] qpid-proton git commit: NO-JIRA: Avoid mismatched comparison
warnings on Visual Studio
Posted by as...@apache.org.
NO-JIRA: Avoid mismatched comparison warnings on Visual Studio
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/88a927ec
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/88a927ec
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/88a927ec
Branch: refs/heads/master
Commit: 88a927ecb06e01e5dc1086cd6470c359a54eb0b0
Parents: f88c826
Author: Andrew Stitcher <as...@apache.org>
Authored: Fri Dec 1 15:38:31 2017 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Mon Dec 4 13:49:36 2017 -0500
----------------------------------------------------------------------
proton-c/src/proactor/win_iocp.c | 6 +++---
proton-c/src/reactor/io/windows/iocp.h | 2 +-
proton-c/src/reactor/io/windows/write_pipeline.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/88a927ec/proton-c/src/proactor/win_iocp.c
----------------------------------------------------------------------
diff --git a/proton-c/src/proactor/win_iocp.c b/proton-c/src/proactor/win_iocp.c
index 51b4874..0d276e8 100644
--- a/proton-c/src/proactor/win_iocp.c
+++ b/proton-c/src/proactor/win_iocp.c
@@ -99,7 +99,7 @@ typedef struct iocp_t iocp_t;
struct iocp_t {
HANDLE completion_port;
pn_list_t *zombie_list;
- int shared_pool_size;
+ unsigned shared_pool_size;
char *shared_pool_memory;
write_result_t **shared_results;
write_result_t **available_results;
@@ -276,7 +276,7 @@ void pni_shared_pool_create(iocp_t *iocp)
iocp->available_results = (write_result_t **) malloc(iocp->shared_pool_size * sizeof(write_result_t *));
iocp->shared_available_count = iocp->shared_pool_size;
char *mem = iocp->shared_pool_memory;
- for (int i = 0; i < iocp->shared_pool_size; i++) {
+ for (unsigned i = 0; i < iocp->shared_pool_size; i++) {
iocp->shared_results[i] = iocp->available_results[i] = pni_write_result(NULL, mem, IOCP_WBUFSIZE);
mem += IOCP_WBUFSIZE;
}
@@ -285,7 +285,7 @@ void pni_shared_pool_create(iocp_t *iocp)
void pni_shared_pool_free(iocp_t *iocp)
{
- for (int i = 0; i < iocp->shared_pool_size; i++) {
+ for (unsigned i = 0; i < iocp->shared_pool_size; i++) {
write_result_t *result = iocp->shared_results[i];
if (result->in_use)
pipeline_log("Proton buffer pool leak\n");
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/88a927ec/proton-c/src/reactor/io/windows/iocp.h
----------------------------------------------------------------------
diff --git a/proton-c/src/reactor/io/windows/iocp.h b/proton-c/src/reactor/io/windows/iocp.h
index 07f47be..6cf0bc0 100644
--- a/proton-c/src/reactor/io/windows/iocp.h
+++ b/proton-c/src/reactor/io/windows/iocp.h
@@ -39,7 +39,7 @@ struct iocp_t {
HANDLE completion_port;
pn_hash_t *iocpdesc_map;
pn_list_t *zombie_list;
- int shared_pool_size;
+ unsigned shared_pool_size;
char *shared_pool_memory;
write_result_t **shared_results;
write_result_t **available_results;
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/88a927ec/proton-c/src/reactor/io/windows/write_pipeline.c
----------------------------------------------------------------------
diff --git a/proton-c/src/reactor/io/windows/write_pipeline.c b/proton-c/src/reactor/io/windows/write_pipeline.c
index 905c7f6..238303c 100644
--- a/proton-c/src/reactor/io/windows/write_pipeline.c
+++ b/proton-c/src/reactor/io/windows/write_pipeline.c
@@ -96,7 +96,7 @@ void pni_shared_pool_create(iocp_t *iocp)
iocp->available_results = (write_result_t **) malloc(iocp->shared_pool_size * sizeof(write_result_t *));
iocp->shared_available_count = iocp->shared_pool_size;
char *mem = iocp->shared_pool_memory;
- for (int i = 0; i < iocp->shared_pool_size; i++) {
+ for (unsigned i = 0; i < iocp->shared_pool_size; i++) {
iocp->shared_results[i] = iocp->available_results[i] = pni_write_result(NULL, mem, IOCP_WBUFSIZE);
mem += IOCP_WBUFSIZE;
}
@@ -105,7 +105,7 @@ void pni_shared_pool_create(iocp_t *iocp)
void pni_shared_pool_free(iocp_t *iocp)
{
- for (int i = 0; i < iocp->shared_pool_size; i++) {
+ for (unsigned i = 0; i < iocp->shared_pool_size; i++) {
write_result_t *result = iocp->shared_results[i];
if (result->in_use)
pipeline_log("Proton buffer pool leak\n");
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
[3/5] qpid-proton git commit: PROTON-1654: [C++ binding] Improve
turning C++ features on/off - Specifically for gcc 4.4 and Visual Studio
compilers where this is a problem
Posted by as...@apache.org.
PROTON-1654: [C++ binding] Improve turning C++ features on/off
- Specifically for gcc 4.4 and Visual Studio compilers where this is a problem
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/f88c826c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/f88c826c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/f88c826c
Branch: refs/heads/master
Commit: f88c826c62f7aa624e1388131f4042e88f6a32ff
Parents: 5199e8c
Author: Andrew Stitcher <as...@apache.org>
Authored: Thu Nov 30 15:42:20 2017 -0500
Committer: Andrew Stitcher <as...@apache.org>
Committed: Mon Dec 4 13:49:36 2017 -0500
----------------------------------------------------------------------
examples/ProtonCppConfig.cmake | 3 +-
examples/cpp/CMakeLists.txt | 4 +--
examples/cpp/example_test.py | 8 ++---
proton-c/bindings/cpp/CMakeLists.txt | 36 ++++++++++++++------
proton-c/bindings/cpp/config_presets.hpp.in | 26 ++++++++++++++
proton-c/bindings/cpp/cpp.cmake | 20 ++++++++---
.../bindings/cpp/include/proton/container.hpp | 5 ---
.../cpp/include/proton/internal/config.hpp | 9 +++++
tools/py/proctest.py | 20 -----------
9 files changed, 84 insertions(+), 47 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f88c826c/examples/ProtonCppConfig.cmake
----------------------------------------------------------------------
diff --git a/examples/ProtonCppConfig.cmake b/examples/ProtonCppConfig.cmake
index 9709163..6ebdc69 100644
--- a/examples/ProtonCppConfig.cmake
+++ b/examples/ProtonCppConfig.cmake
@@ -28,7 +28,8 @@
# tree build and installed in the appropriate place for cmake on that system.
set (ProtonCpp_VERSION ${PN_VERSION})
-set (ProtonCpp_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/proton-c/include ${CMAKE_SOURCE_DIR}/proton-c/bindings/cpp/include)
+set (ProtonCpp_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/proton-c/include ${CMAKE_SOURCE_DIR}/proton-c/bindings/cpp/include
+ ${CMAKE_BINARY_DIR}/proton-c/bindings/cpp)
set (ProtonCpp_LIBRARIES ${C_EXAMPLE_LINK_FLAGS} qpid-proton-cpp)
set (ProtonCpp_DEFINITIONS ${CXX_EXAMPLE_FLAGS})
set (ProtonCpp_FOUND True)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f88c826c/examples/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt
index 0531aec..8768f71 100644
--- a/examples/cpp/CMakeLists.txt
+++ b/examples/cpp/CMakeLists.txt
@@ -31,7 +31,7 @@ add_definitions(${ProtonCpp_DEFINITIONS})
set (BUILD_CPP_03 OFF CACHE BOOL "Compile as C++03 even when C++11 is available")
# This effectively checks for cmake version 3.1 or later
if (DEFINED CMAKE_CXX_COMPILE_FEATURES)
- if (BUILD_CPP_03 OR MSVC)
+ if (BUILD_CPP_03)
set(STD 98)
else ()
set(STD 11)
@@ -93,7 +93,7 @@ macro(add_cpp_test name)
set(test_path "$<TARGET_FILE_DIR:broker>:$ENV{PATH}")
endif(WIN32)
set(run_env ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/proton-c/env.py ${EXAMPLE_ENV})
- add_test(NAME ${name} COMMAND ${run_env} "PATH=${test_path}" ${VALGRIND_ENV} -- ${ARGN})
+ add_test(NAME ${name} COMMAND ${run_env} "PATH=${test_path}" ${VALGRIND_ENV} "HAS_CPP11=${HAS_CPP11}" -- ${ARGN})
endmacro()
add_cpp_test(cpp-example-container ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example_test.py -v ContainerExampleTest)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f88c826c/examples/cpp/example_test.py
----------------------------------------------------------------------
diff --git a/examples/cpp/example_test.py b/examples/cpp/example_test.py
index bc4c6e6..5d8d45f 100644
--- a/examples/cpp/example_test.py
+++ b/examples/cpp/example_test.py
@@ -35,7 +35,7 @@ createdSASLDb = False
def _cyrusSetup(conf_dir):
"""Write out simple SASL config.tests
"""
- saslpasswd = os.getenv('SASLPASSWD') or find_file('saslpasswd2', os.getenv('PATH'))
+ saslpasswd = os.getenv('SASLPASSWD')
if saslpasswd:
t = Template("""sasldb_path: ${db}
mech_list: EXTERNAL DIGEST-MD5 SCRAM-SHA-1 CRAM-MD5 PLAIN ANONYMOUS
@@ -197,7 +197,7 @@ map{string(k1):int(42), symbol(k2):boolean(0)}
self.assertTrue(len(out) > 0);
self.assertEqual(["send"]*len(out), out)
- @unittest.skipUnless(find_exes('scheduled_send'), "not a C++11 build")
+ @unittest.skipUnless(os.getenv('HAS_CPP11'), "not a C++11 build")
def test_scheduled_send(self):
out = self.proc(["scheduled_send", "-a", self.addr+"scheduled_send", "-t", "0.1", "-i", "0.001"]).wait_exit().split()
self.assertTrue(len(out) > 0);
@@ -215,13 +215,13 @@ expected conversion_error: "unexpected type, want: uint got: string"
"""
self.assertMultiLineEqual(expect, self.proc(["message_properties"]).wait_exit())
- @unittest.skipUnless(find_exes('multithreaded_client'), "not a C++11 build")
+ @unittest.skipUnless(os.getenv('HAS_CPP11'), "not a C++11 build")
def test_multithreaded_client(self):
got = self.proc(["multithreaded_client", self.addr, "examples", "10"], helgrind=True).wait_exit()
self.maxDiff = None
self.assertRegexpMatches(got, "10 messages sent and received");
- @unittest.skipUnless(find_exes('multithreaded_client_flow_control'), "not a C++11 build")
+ @unittest.skipUnless(os.getenv('HAS_CPP11'), "not a C++11 build")
def test_multithreaded_client_flow_control(self):
got = self.proc(["multithreaded_client_flow_control", self.addr, "examples", "10", "2"], helgrind=True).wait_exit()
self.maxDiff = None
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f88c826c/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt
index 109b543..5858099 100644
--- a/proton-c/bindings/cpp/CMakeLists.txt
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -31,17 +31,10 @@ if (DEFINED CMAKE_CXX_COMPILE_FEATURES)
endif ()
set(CMAKE_CXX_STANDARD ${STD})
set(CMAKE_CXX_EXTENSIONS OFF)
-# AStitcher 20170804: Disabled for present - work on this when Windows C++ works
-# cmake_minimum_required(VERSION 3.1)
-# include(WriteCompilerDetectionHeader)
-# write_compiler_detection_header(
-# FILE cpp_features.h
-# PREFIX PN
-# COMPILERS GNU Clang MSVC SunPro
-# FEATURES ${CMAKE_CXX_COMPILE_FEATURES}
-# ALLOW_UNKNOWN_COMPILERS)
if (MSVC) # Compiler feature checks only needed for Visual Studio in this case
include(cpp.cmake)
+ else()
+ set (CPP_DEFINITIONS "HAS_CPP11")
endif()
else ()
if (BUILD_CPP_03)
@@ -53,6 +46,7 @@ else ()
check_cxx_compiler_flag("-std=c++0x" ACCEPTS_CXX0X)
if (ACCEPTS_CXX11)
set(CXX_STANDARD "-std=c++11")
+ set (CPP_DEFINITIONS "HAS_CPP11")
elseif(ACCEPTS_CXX0X)
set(CXX_STANDARD "-std=c++0x")
include(cpp.cmake) # Compiler checks needed for C++0x as not all C++11 may be supported
@@ -62,13 +56,34 @@ else ()
endif()
endif ()
+# Construct #define lines to insert in config_presets.hpp
+foreach(d ${CPP_DEFINITIONS})
+ set(presets "${presets}#define PN_CPP_LIB_${d} 1\n")
+endforeach()
+# For Visual Studio define the app compile time macros now, for everything else don't
+if(MSVC)
+ set(presets "${presets}\n// Compiled for MSVC version ${CMAKE_CXX_COMPILER_VERSION} (${MSVC_VERSION})\n")
+ foreach(d ${CPP_DEFINITIONS})
+ set(presets "${presets}# define PN_CPP_${d} 1\n")
+ endforeach()
+else()
+ set(presets "${presets}\n#if qpid_proton_cpp_EXPORTS\n")
+ foreach(d ${CPP_DEFINITIONS})
+ set(presets "${presets}# define PN_CPP_${d} 1\n")
+ endforeach()
+ set(presets "${presets}#endif // qpid_proton_cpp_EXPORTS\n")
+endif()
+
+configure_file(config_presets.hpp.in config_presets.hpp @ONLY)
+
# Make these CACHE INTERNAL so they will be set for the C++ examples
set(CXX_EXAMPLE_FLAGS "${CXX_WARNING_FLAGS} ${CMAKE_CXX_FLAGS} ${CXX_STANDARD}" CACHE INTERNAL "")
set(CXX_EXAMPLE_LINK_FLAGS "${SANITIZE_FLAGS}" CACHE INTERNAL "")
include_directories(
"${CMAKE_SOURCE_DIR}/proton-c/include"
- "${CMAKE_CURRENT_SOURCE_DIR}/include")
+ "${CMAKE_CURRENT_SOURCE_DIR}/include"
+ "${CMAKE_CURRENT_BINARY_DIR}")
add_definitions(${CXX_STANDARD} ${CXX_WARNING_FLAGS} "-DPN_CPP_USE_DEPRECATED_API=1")
@@ -162,6 +177,7 @@ if (MSVC)
endif (MSVC)
install (DIRECTORY "include/proton" DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.hpp")
+install (FILES "${CMAKE_CURRENT_BINARY_DIR}/config_presets.hpp" DESTINATION "${INCLUDE_INSTALL_DIR}/proton/internal")
add_subdirectory(docs)
add_subdirectory(${CMAKE_SOURCE_DIR}/tests/tools/apps/cpp ${CMAKE_BINARY_DIR}/tests/tools/apps/cpp)
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f88c826c/proton-c/bindings/cpp/config_presets.hpp.in
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/config_presets.hpp.in b/proton-c/bindings/cpp/config_presets.hpp.in
new file mode 100644
index 0000000..676681b
--- /dev/null
+++ b/proton-c/bindings/cpp/config_presets.hpp.in
@@ -0,0 +1,26 @@
+#ifndef PROTON_INTERNAL_CONFIG_PRESETS_HPP
+#define PROTON_INTERNAL_CONFIG_PRESETS_HPP
+
+/*
+ *
+ * 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.
+ *
+ */
+
+@presets@
+ #endif // PROTON_INTERNAL_CONFIG_PRESETS_HPP
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f88c826c/proton-c/bindings/cpp/cpp.cmake
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/cpp.cmake b/proton-c/bindings/cpp/cpp.cmake
index 051781c..0791044 100644
--- a/proton-c/bindings/cpp/cpp.cmake
+++ b/proton-c/bindings/cpp/cpp.cmake
@@ -24,14 +24,18 @@ include(CheckCXXSourceCompiles)
macro (cxx_test prog name)
check_cxx_source_compiles("${prog}" HAS_${name})
if (HAS_${name})
- add_definitions(-DPN_CPP_HAS_${name}=1)
+ list(APPEND CPP_DEFINITIONS "HAS_${name}")
+ else()
+ set(CPP_TEST_FAILED True)
endif()
endmacro()
-check_cxx_source_compiles("#if defined(__cplusplus) && __cplusplus >= 201103\nint main(int, char**) { return 0; }\n#endif" CPP11)
+set(CPP_DEFINITIONS "")
+set(CMAKE_REQUIRED_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD} ${CXX_WARNING_FLAGS}")
+cxx_test("#if defined(__cplusplus) && __cplusplus >= 201103\nint main(int, char**) { return 0; }\n#endif" CPP11)
# Don't need to check individual flags if compiler claims to be C++11 or later as they will be set automatically
-if (NOT CPP11)
- set(CMAKE_REQUIRED_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD} ${CXX_WARNING_FLAGS}")
+if (NOT HAS_CPP11)
+ set(CPP_TEST_FAILED False)
cxx_test("long long ll; int main(int, char**) { return 0; }" LONG_LONG_TYPE)
cxx_test("int* x = nullptr; int main(int, char**) { return 0; }" NULLPTR)
cxx_test("#include <string>\nvoid blah(std::string&&) {} int main(int, char**) { blah(\"hello\"); return 0; }" RVALUE_REFERENCES)
@@ -48,5 +52,11 @@ if (NOT CPP11)
cxx_test("#include <thread>\nstd::thread t; int main(int, char**) { return 0; }" STD_THREAD)
cxx_test("#include <mutex>\nstd::mutex m; int main(int, char**) { return 0; }" STD_MUTEX)
cxx_test("#include <atomic>\nstd::atomic<int> a; int main(int, char**) { return 0; }" STD_ATOMIC)
- unset(CMAKE_REQUIRED_FLAGS) # Don't contaminate later C tests with C++ flags
+
+ # If all the tests passed this is the same as if we have C++11 for the purposes of compilation
+ # (this shortens the compile command line for VS 2017 significantly)
+ if (NOT CPP_TEST_FAILED)
+ set(CPP_DEFINITIONS "HAS_CPP11")
+ endif()
endif()
+unset(CMAKE_REQUIRED_FLAGS) # Don't contaminate later C tests with C++ flags
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f88c826c/proton-c/bindings/cpp/include/proton/container.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/container.hpp b/proton-c/bindings/cpp/include/proton/container.hpp
index 7f4ed21..e80acbe 100644
--- a/proton-c/bindings/cpp/include/proton/container.hpp
+++ b/proton-c/bindings/cpp/include/proton/container.hpp
@@ -35,11 +35,6 @@
/// @file
/// @copybrief proton::container
-/// @cond INTERNAL
-/// True if the library can support multithreaded containers.
-#define PN_CPP_SUPPORTS_THREADS PN_CPP_HAS_STD_THREAD && PN_CPP_HAS_STD_MUTEX
-/// @endcond
-
namespace proton {
/// A top-level container of connections, sessions, and links.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f88c826c/proton-c/bindings/cpp/include/proton/internal/config.hpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/internal/config.hpp b/proton-c/bindings/cpp/include/proton/internal/config.hpp
index 42de663..321aebf 100644
--- a/proton-c/bindings/cpp/include/proton/internal/config.hpp
+++ b/proton-c/bindings/cpp/include/proton/internal/config.hpp
@@ -33,6 +33,15 @@
/// default. Otherwise they can be enabled or disabled separately
/// with -D on the compile line.
+// Read library compilation presets -
+// This sets the options the library itself was compiled with
+// and sets up the compilation options is we are compiling the library itself
+#include "config_presets.hpp"
+
+/// Whether the library supports threads depends on the configuration of the library compilation only
+#define PN_CPP_SUPPORTS_THREADS PN_CPP_LIB_HAS_CPP11 || (PN_CPP_LIB_HAS_STD_THREAD && PN_CPP_LIB_HAS_STD_MUTEX)
+/// @endcond
+
/// The Apple clang compiler doesn't really support PN_CPP_HAS_THREAD_LOCAL
/// before Xcode 8 even though it claims to be C++11 compatible
#if defined(__clang__) && defined(__apple_build_version__) && ((__clang_major__ * 100) + __clang_minor__) >= 301
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/f88c826c/tools/py/proctest.py
----------------------------------------------------------------------
diff --git a/tools/py/proctest.py b/tools/py/proctest.py
index 802376e..35eb216 100644
--- a/tools/py/proctest.py
+++ b/tools/py/proctest.py
@@ -213,26 +213,6 @@ class ProcTestCase(unittest.TestCase):
from functools import reduce
-def find_file(filename, path):
- """
- Find filename in path. Path is a list of directory names or OS path strings
- separated with os.pathsep. return absolute path to the file or None
-
- """
- dirs = reduce((lambda x,y: x+y), (p.split(os.pathsep) for p in path))
- for d in dirs:
- if os.path.exists(os.path.join(d, filename)):
- return os.path.abspath(os.path.join(d, filename))
- return None
-
-def find_exes(*filenames):
- """
- True if all filenames in the list are found on the system PATH.
- """
- for f in filenames:
- if not find_file(f, os.getenv('PATH')): return False
- return True
-
#### Skip decorators missing in python 2.6
def _id(obj):
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org