From 92c513d6dd7b9b6e07663d6335fbd11cfb7b05c7 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 10 Dec 2019 19:28:54 -0800 Subject: [PATCH] de-templateize xcode --- src/Makefile | 1 + src/{dataencode.h => dataencode.cpp} | 13 +- src/dataimpl.h | 14 ++ src/evhelper.cpp | 59 +++++ src/evhelper.h | 53 +---- src/pvaproto.h | 314 +++++++++++++-------------- src/server.cpp | 8 +- src/serverchan.cpp | 2 +- src/serverconn.cpp | 4 +- src/serverintrospect.cpp | 1 - src/udp_collector.cpp | 2 +- test/testsock.cpp | 28 +-- test/testudp.cpp | 2 +- test/testxcode.cpp | 9 +- 14 files changed, 265 insertions(+), 245 deletions(-) rename src/{dataencode.h => dataencode.cpp} (94%) diff --git a/src/Makefile b/src/Makefile index 793b286..eedc4df 100644 --- a/src/Makefile +++ b/src/Makefile @@ -50,6 +50,7 @@ LIB_SRCS += unittest.cpp LIB_SRCS += util.cpp LIB_SRCS += bitmask.cpp LIB_SRCS += data.cpp +LIB_SRCS += dataencode.cpp LIB_SRCS += evhelper.cpp LIB_SRCS += udp_collector.cpp LIB_SRCS += server.cpp diff --git a/src/dataencode.h b/src/dataencode.cpp similarity index 94% rename from src/dataencode.h rename to src/dataencode.cpp index 270685b..1f9270f 100644 --- a/src/dataencode.h +++ b/src/dataencode.cpp @@ -25,8 +25,7 @@ namespace pvxs { namespace impl { -template -void to_wire(Buf& buf, const FieldDesc* cur) +void to_wire(Buffer& buf, const FieldDesc* cur) { // we assume FieldDesc* is valid (checked on creation) to_wire(buf, cur->code.code); @@ -52,15 +51,7 @@ void to_wire(Buf& buf, const FieldDesc* cur) } } -typedef std::map> TypeStore; - -struct TypeDeserContext { - std::vector& descs; - TypeStore& cache; -}; - -template -void from_wire(Buf& buf, TypeDeserContext& ctxt, unsigned depth=0) +void from_wire(Buffer& buf, TypeDeserContext& ctxt, unsigned depth) { if(!buf.good() || depth>20) { buf.fault(); diff --git a/src/dataimpl.h b/src/dataimpl.h index 5338ba8..8b22ff1 100644 --- a/src/dataimpl.h +++ b/src/dataimpl.h @@ -16,6 +16,7 @@ namespace pvxs { namespace impl { +struct Buffer; /** Describes a single field, leaf or otherwise, in a nested structure. * @@ -61,6 +62,19 @@ struct FieldDesc { inline size_t size() const { return num_index; } }; +PVXS_API +void to_wire(Buffer& buf, const FieldDesc* cur); + +typedef std::map> TypeStore; + +struct TypeDeserContext { + std::vector& descs; + TypeStore& cache; +}; + +PVXS_API +void from_wire(Buffer& buf, TypeDeserContext& ctxt, unsigned depth=0); + struct StructTop; struct FieldStorage { diff --git a/src/evhelper.cpp b/src/evhelper.cpp index 21dc010..753ecab 100644 --- a/src/evhelper.cpp +++ b/src/evhelper.cpp @@ -290,6 +290,61 @@ void evsocket::mcast_iface(const SockAddr& iface) const // IPV6_MULTICAST_IF } +void to_wire(Buffer& buf, const SockAddr& val) +{ + if(!buf.ensure(16)) { + buf.fault(); + return; + + } else if(val.family()==AF_INET) { + for(unsigned i=0; i<10; i++) + buf[i]=0; + buf[10] = buf[11] = 0xff; + + memcpy(buf.save()+12, &val->in.sin_addr.s_addr, 4); + + } else if(val.family()==AF_INET6) { + static_assert (sizeof(val->in6.sin6_addr)==16, ""); + memcpy(buf.save(), &val->in6.sin6_addr, 16); + } + buf._skip(16); +} + +void from_wire(Buffer &buf, SockAddr& val) +{ + if(!buf.ensure(16)) { + buf.fault(); + return; + } + + // win32 lacks IN6_IS_ADDR_V4MAPPED() + bool ismapped = true; + for(unsigned i=0u; i<10; i++) + ismapped &= buf[i]==0; + ismapped &= buf[10]==0xff; + ismapped &= buf[11]==0xff; + + if(ismapped) { + val->in = {}; + val->in.sin_family = AF_INET; + memcpy(&val->in.sin_addr.s_addr, buf.save()+12, 4); + + } else { + val->in6 = {}; + val->in6.sin6_family = AF_INET6; + + static_assert (sizeof(val->in6.sin6_addr)==16, ""); + memcpy(&val->in6.sin6_addr, buf.save(), 16); + } + buf._skip(16); +} + + +bool Buffer::refill(size_t more) { return false; } + +FixedBuf::~FixedBuf() {} + +VectorOutBuf::~VectorOutBuf() {} bool VectorOutBuf::refill(size_t more) { assert(pos <= limit); @@ -309,6 +364,8 @@ bool VectorOutBuf::refill(size_t more) { return true; } +EvOutBuf::~EvOutBuf() { refill(0); } + bool EvOutBuf::refill(size_t more) { if(err) return false; @@ -334,6 +391,8 @@ bool EvOutBuf::refill(size_t more) return true; } +EvInBuf::~EvInBuf() { refill(0); } + bool EvInBuf::refill(size_t more) { if(err) return false; diff --git a/src/evhelper.h b/src/evhelper.h index b899b16..e67214f 100644 --- a/src/evhelper.h +++ b/src/evhelper.h @@ -82,56 +82,11 @@ typedef owned_ptr evlisten; typedef owned_ptr evbufferevent; typedef owned_ptr evbuf; -template -void to_wire(Buf& buf, const SockAddr& val) -{ - if(!buf.ensure(16)) { - buf.fault(); - return; +PVXS_API +void to_wire(Buffer& buf, const SockAddr& val); - } else if(val.family()==AF_INET) { - for(unsigned i=0; i<10; i++) - buf[i]=0; - buf[10] = buf[11] = 0xff; - - memcpy(buf.save()+12, &val->in.sin_addr.s_addr, 4); - - } else if(val.family()==AF_INET6) { - static_assert (sizeof(val->in6.sin6_addr)==16, ""); - memcpy(buf.save(), &val->in6.sin6_addr, 16); - } - buf._skip(16); -} - -template -void from_wire(Buf &buf, SockAddr& val) -{ - if(!buf.ensure(16)) { - buf.fault(); - return; - } - - // win32 lacks IN6_IS_ADDR_V4MAPPED() - bool ismapped = true; - for(unsigned i=0u; i<10; i++) - ismapped &= buf[i]==0; - ismapped &= buf[10]==0xff; - ismapped &= buf[11]==0xff; - - if(ismapped) { - val->in = {}; - val->in.sin_family = AF_INET; - memcpy(&val->in.sin_addr.s_addr, buf.save()+12, 4); - - } else { - val->in6 = {}; - val->in6.sin6_family = AF_INET6; - - static_assert (sizeof(val->in6.sin6_addr)==16, ""); - memcpy(&val->in6.sin6_addr, buf.save(), 16); - } - buf._skip(16); -} +PVXS_API +void from_wire(Buffer &buf, SockAddr& val); struct PVXS_API evsocket { diff --git a/src/pvaproto.h b/src/pvaproto.h index 8fcf2b0..56d7253 100644 --- a/src/pvaproto.h +++ b/src/pvaproto.h @@ -25,18 +25,20 @@ namespace pvxs {namespace impl { //! view of a slice of a buffer. -//! Don't use directly. cf. FixedBuf -template -struct BufCommon { - typedef E value_type; +//! Don't use directly. cf. FixedBuf +struct PVXS_API Buffer { + typedef uint8_t value_type; typedef void is_buffer; protected: // valid range to read/write is [pos, limit) - E *pos, *limit; + uint8_t *pos, *limit; bool err; - constexpr BufCommon(bool be, E* buf, size_t n) :pos(buf), limit(buf+n), err(false), be(be) {} + virtual bool refill(size_t more); + + constexpr Buffer(bool be, uint8_t* buf, size_t n) :pos(buf), limit(buf+n), err(false), be(be) {} + virtual ~Buffer() {} public: const bool be; @@ -48,7 +50,7 @@ public: // ensure (be resize/refill) that size()>=i inline bool ensure(size_t i) { - return !err && (i<=size() || static_cast(this)->refill(i)); + return !err && (i<=size() || refill(i)); } inline void skip(size_t i) { do { @@ -58,7 +60,7 @@ public: } pos = limit; i -= size(); - } while(static_cast(this)->refill(i)); + } while(refill(i)); fault(); } @@ -66,32 +68,32 @@ public: EPICS_ALWAYS_INLINE size_t size() const { return limit-pos; } // the following assume good()==true && !empty() - EPICS_ALWAYS_INLINE E& operator[](size_t i) const { return pos[i]; } - EPICS_ALWAYS_INLINE void push(E v) { *pos++ = v; } - EPICS_ALWAYS_INLINE E pop() { return *pos++; } + EPICS_ALWAYS_INLINE uint8_t& operator[](size_t i) const { return pos[i]; } + EPICS_ALWAYS_INLINE void push(uint8_t v) { *pos++ = v; } + EPICS_ALWAYS_INLINE uint8_t pop() { return *pos++; } // further assumes size()>=i EPICS_ALWAYS_INLINE void _skip(size_t i) { pos+=i; } - E* save() const { return this->pos; } + uint8_t* save() const { return pos; } }; //! (de)serialization to/from buffers which are fixed size and contigious -template -struct FixedBuf : public BufCommon > +struct PVXS_API FixedBuf : public Buffer { - typedef BufCommon base_type; - EPICS_ALWAYS_INLINE bool refill(size_t more) { return false; } + typedef Buffer base_type; + EPICS_ALWAYS_INLINE bool refill(size_t more) override final { return false; } template - constexpr FixedBuf(bool be, E(&buf)[N]) :base_type(be, buf, N) {} - constexpr FixedBuf(bool be, E* buf, size_t n) :base_type(be, buf, n) {} - FixedBuf(bool be, std::vector& buf) :base_type(be, buf.data(), buf.size()) {} + constexpr FixedBuf(bool be, uint8_t(&buf)[N]) :base_type(be, buf, N) {} + constexpr FixedBuf(bool be, uint8_t* buf, size_t n) :base_type(be, buf, n) {} + FixedBuf(bool be, std::vector& buf) :base_type(be, buf.data(), buf.size()) {} + virtual ~FixedBuf(); }; //! serialize into a vector, resizing as necessary -class VectorOutBuf : public BufCommon +class PVXS_API VectorOutBuf : public Buffer { - typedef BufCommon base_type; + typedef Buffer base_type; std::vector& backing; public: // note: vector::data() is not constexpr in c++11 @@ -99,13 +101,14 @@ public: :base_type(be, b.data(), b.size()) ,backing(b) {} - PVXS_API bool refill(size_t more); + virtual ~VectorOutBuf(); + virtual bool refill(size_t more) override final; }; //! serialize into an evbuffer, resizing as necessary -class EvOutBuf : public BufCommon +class PVXS_API EvOutBuf : public Buffer { - typedef BufCommon base_type; + typedef Buffer base_type; evbuffer * const backing; uint8_t* base; // original pos public: @@ -115,15 +118,14 @@ public: ,backing(b) ,base(nullptr) {refill(isize);} - ~EvOutBuf() - {refill(0);} - PVXS_API bool refill(size_t more); + virtual ~EvOutBuf(); + virtual bool refill(size_t more) override final; }; //! deserialize from an evbuffer, possibly segmented -class EvInBuf : public BufCommon +class PVXS_API EvInBuf : public Buffer { - typedef BufCommon base_type; + typedef Buffer base_type; evbuffer * const backing; uint8_t* base; // original pos after ctor or refill() public: @@ -133,14 +135,34 @@ public: ,backing(b) ,base(nullptr) {refill(ifill);} - ~EvInBuf() - {refill(0);} + virtual ~EvInBuf(); - PVXS_API bool refill(size_t more); + virtual bool refill(size_t more) override final; }; -template -inline void _from_wire(Buf& buf, uint8_t *mem, bool reverse) +// assumes prior buf.ensure(M) where M>=N +template +inline void _to_wire(Buffer& buf, const uint8_t *mem, bool reverse) +{ + if(!buf.ensure(N)) { + buf.fault(); + return; + + } else if(reverse) { + // byte order mis-match + for(unsigned i=0; i +inline void _from_wire(Buffer& buf, uint8_t *mem, bool reverse) { if(!buf.ensure(N)) { buf.fault(); @@ -159,14 +181,40 @@ inline void _from_wire(Buf& buf, uint8_t *mem, bool reverse) buf._skip(N); } +/** Write sizeof(T) bytes from buf from val + * + * @param buf output buffer. buf[0] through buf[sizeof(T)-1] must be valid. + * @param val input variable + */ +template=2 && std::is_scalar{} && !std::is_pointer{}, int>::type =0> +inline void to_wire(Buffer& buf, const T& val) +{ + union { + T v; + uint8_t b[sizeof(T)]; + } pun; + pun.v = val; + _to_wire(buf, pun.b, buf.be ^ (EPICS_BYTE_ORDER==EPICS_ENDIAN_BIG)); +} + +template{}, int>::type =0> +inline void to_wire(Buffer& buf, const T& val) +{ + if(!buf.ensure(1)) { + buf.fault(); + } else { + buf.push(val); + } +} + /** Read sizeof(T) bytes from buf and store in val * * @param buf input buffer. buf[0] through buf[sizeof(T)-1] must be valid. * @param val output variable * @param be true if value encoded in buf is in MSBF order, false if in LSBF order */ -template::value, int>::type =0> -inline void from_wire(Buf& buf, T& val) +template::value, int>::type =0> +inline void from_wire(Buffer& buf, T& val) { union { T v; @@ -190,8 +238,26 @@ struct Size { size_t size; }; -template -void from_wire(Buf& buf, Size& size) +inline +void to_wire(Buffer& buf, const Size& size) +{ + if(!buf.ensure(1)) { + buf.fault(); + + } else if(size.size<254) { + buf.push(size.size); + + } else if(size.size<=0xffffffff) { + buf.push(254); + to_wire(buf, uint32_t(size.size)); + + } else { + buf.fault(); + } +} + +inline +void from_wire(Buffer& buf, Size& size) { if(!buf.ensure(1)) { buf.fault(); @@ -218,6 +284,54 @@ void from_wire(Buf& buf, Size& size) } } +inline +void to_wire(Buffer& buf, const char *s) +{ + Size len{s ? strlen(s) : 0}; + to_wire(buf, len); + if(!buf.ensure(len.size)) { + buf.fault(); + + } else { + for(size_t i=0; i bytes) +{ + if(!buf.ensure(bytes.size())) { + buf.fault(); + + } else { + for (auto byte : bytes) { + buf.push(byte); + } + } + +} + struct Status { enum type_t { Ok =0, @@ -231,8 +345,8 @@ struct Status { inline bool isSuccess() const { return code==Ok || code==Warn; } }; -template -void to_wire(Buf& buf, const Status& sts) +inline +void to_wire(Buffer& buf, const Status& sts) { if(!buf.ensure(1)) { buf.fault(); @@ -247,8 +361,8 @@ void to_wire(Buf& buf, const Status& sts) } } -template -void from_wire(Buf& buf, Status& sts) +inline +void from_wire(Buffer& buf, Status& sts) { if(!buf.ensure(1)) { buf.fault(); @@ -260,126 +374,12 @@ void from_wire(Buf& buf, Status& sts) sts.trace.clear(); } else { - sts.code = buf.pop(); + sts.code = Status::type_t(buf.pop()); from_wire(buf, sts.msg); from_wire(buf, sts.trace); } } -template -void from_wire(Buf& buf, std::string& s) -{ - Size len{0}; - from_wire(buf, len); - if(!buf.ensure(len.size)) { - buf.fault(); - - } else { - s = std::string((char*)buf.save(), len.size); - buf._skip(len.size); - } -} - -// assumes prior buf.ensure(M) where M>=N -template -inline void _to_wire(Buf& buf, const uint8_t *mem, bool reverse) -{ - if(!buf.ensure(N)) { - buf.fault(); - return; - - } else if(reverse) { - // byte order mis-match - for(unsigned i=0; i=2 && std::is_scalar{} && !std::is_pointer{}, int>::type =0> -inline void to_wire(Buf& buf, const T& val) -{ - union { - T v; - uint8_t b[sizeof(T)]; - } pun; - pun.v = val; - _to_wire(buf, pun.b, buf.be ^ (EPICS_BYTE_ORDER==EPICS_ENDIAN_BIG)); -} - -template{}, int>::type =0> -inline void to_wire(Buf& buf, const T& val) -{ - if(!buf.ensure(1)) { - buf.fault(); - } else { - buf.push(val); - } -} - -template -void to_wire(Buf& buf, const Size& size) -{ - if(!buf.ensure(1)) { - buf.fault(); - - } else if(size.size<254) { - buf.push(size.size); - - } else if(size.size<=0xffffffff) { - buf.push(254); - to_wire(buf, uint32_t(size.size)); - - } else { - buf.fault(); - } -} - -template -void to_wire(Buf& buf, const char *s) -{ - Size len{s ? strlen(s) : 0}; - to_wire(buf, len); - if(!buf.ensure(len.size)) { - buf.fault(); - - } else { - for(size_t i=0; i -inline void to_wire(Buf& buf, const std::string& s) -{ - to_wire(buf, s.c_str()); -} - -template -void to_wire(Buf& buf, std::initializer_list bytes) -{ - if(!buf.ensure(bytes.size())) { - buf.fault(); - - } else { - for (auto byte : bytes) { - buf.push(byte); - } - } - -} - /* PVA Message Header * * 0 1 2 3 diff --git a/src/server.cpp b/src/server.cpp index b2f981b..56a77d2 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -524,7 +524,7 @@ void Server::Pvt::onSearch(const UDPManager::Search& msg) to_wire(M, uint16_t(effective.tcp_port)); to_wire(M, "tcp"); // "found" flag - to_wire(M, {uint8_t(nreply!=0 ? 1 : 0)}); + to_wire(M, uint8_t(nreply!=0 ? 1 : 0)); to_wire(M, uint16_t(nreply)); for(auto i : range(msg.names.size())) { @@ -534,7 +534,7 @@ void Server::Pvt::onSearch(const UDPManager::Search& msg) auto pktlen = M.save()-searchReply.data(); // now going back to fill in header - FixedBuf H(true, searchReply.data(), 8); + FixedBuf H(true, searchReply.data(), 8); to_wire(H, Header{CMD_SEARCH_RESPONSE, pva_flags::Server, uint32_t(pktlen-8)}); if(!M.good() || !H.good()) { @@ -558,12 +558,12 @@ void Server::Pvt::doBeacons(short evt) to_wire(M, uint16_t(effective.tcp_port)); to_wire(M, "tcp"); // "NULL" serverStatus - to_wire(M, {0xff}); + to_wire(M, uint8_t(0xff)); auto pktlen = M.save()-searchReply.data(); // now going back to fill in header - FixedBuf H(true, searchReply.data(), 8); + FixedBuf H(true, searchReply.data(), 8); to_wire(H, Header{CMD_BEACON, pva_flags::Server, uint32_t(pktlen-8)}); assert(M.good() && H.good()); diff --git a/src/serverchan.cpp b/src/serverchan.cpp index 8a8349b..b9e1a43 100644 --- a/src/serverchan.cpp +++ b/src/serverchan.cpp @@ -152,7 +152,7 @@ void ServerConn::handle_SEARCH() to_wire(M, iface->bind_addr.port()); to_wire(M, "tcp"); // "found" flag - to_wire(M, {uint8_t(nreply!=0 ? 1 : 0)}); + to_wire(M, uint8_t(nreply!=0 ? 1 : 0)); to_wire(M, uint16_t(nreply)); for(auto i : range(op._names.size())) { diff --git a/src/serverconn.cpp b/src/serverconn.cpp index 3fa5099..e0e851c 100644 --- a/src/serverconn.cpp +++ b/src/serverconn.cpp @@ -76,7 +76,7 @@ ServerConn::ServerConn(ServIface* iface, evutil_socket_t sock, struct sockaddr * to_wire(M, "ca"); auto bend = M.save(); - FixedBuf H(be, save, 8); + FixedBuf H(be, save, 8); to_wire(H, Header{CMD_CONNECTION_VALIDATION, pva_flags::Server, uint32_t(bend-bstart)}); assert(M.good() && H.good()); @@ -339,7 +339,7 @@ void ServerConn::bevRead() peerBE = header[2]&pva_flags::MSB; // a bit verbose :P - FixedBuf L(peerBE, header+4, 4); + FixedBuf L(peerBE, header+4, 4); uint32_t len = 0; from_wire(L, len); assert(L.good()); diff --git a/src/serverintrospect.cpp b/src/serverintrospect.cpp index 6fffebc..8209099 100644 --- a/src/serverintrospect.cpp +++ b/src/serverintrospect.cpp @@ -8,7 +8,6 @@ #include #include "dataimpl.h" -#include "dataencode.h" #include "serverconn.h" namespace pvxs { namespace impl { diff --git a/src/udp_collector.cpp b/src/udp_collector.cpp index fd473fa..7266c8d 100644 --- a/src/udp_collector.cpp +++ b/src/udp_collector.cpp @@ -92,7 +92,7 @@ struct UDPCollector : public UDPManager::Search, bool be = buf[2]&pva_flags::MSB; - FixedBuf M(be, buf.data(), nrx); + FixedBuf M(be, buf.data(), nrx); uint8_t cmd = M[3]; diff --git a/test/testsock.cpp b/test/testsock.cpp index 565063f..5b18509 100644 --- a/test/testsock.cpp +++ b/test/testsock.cpp @@ -103,9 +103,9 @@ void test_from_wire() testDiag("Enter %s", __func__); { - uint32_t val; - const uint8_t buf[] = {0x12, 0x34, 0x56, 0x78, 0xff, 0xff}; - FixedBuf pkt(true, buf); + uint32_t val=0; + uint8_t buf[] = {0x12, 0x34, 0x56, 0x78, 0xff, 0xff}; + FixedBuf pkt(true, buf); from_wire(pkt, val); testEq(pkt.size(), 2u); @@ -114,9 +114,9 @@ void test_from_wire() } { - uint32_t val; - const uint8_t buf[] = {0x78, 0x56, 0x34, 0x12, 0xff, 0xff}; - FixedBuf pkt(false, buf); + uint32_t val=0; + uint8_t buf[] = {0x78, 0x56, 0x34, 0x12, 0xff, 0xff}; + FixedBuf pkt(false, buf); from_wire(pkt, val); testEq(pkt.size(), 2u); @@ -126,8 +126,8 @@ void test_from_wire() { uint32_t val = 0; - const uint8_t buf[] = {0x12, 0x34, 0x56, 0x78, 0xff, 0xff, 0xff, 0xff}; - FixedBuf pkt(true, buf, 2); + uint8_t buf[] = {0x12, 0x34, 0x56, 0x78, 0xff, 0xff, 0xff, 0xff}; + FixedBuf pkt(true, buf, 2); from_wire(pkt, val); testEq(pkt.size(), 2u); @@ -137,8 +137,8 @@ void test_from_wire() { SockAddr val; - const uint8_t buf[] = {0,0,0,0, 0,0,0,0, 0,0,0xff,0xff, 0x7f,0,0,1, 0xde, 0xad, 0xbe, 0xef}; - FixedBuf pkt(true, buf); + uint8_t buf[] = {0,0,0,0, 0,0,0,0, 0,0,0xff,0xff, 0x7f,0,0,1, 0xde, 0xad, 0xbe, 0xef}; + FixedBuf pkt(true, buf); from_wire(pkt, val); testEq(pkt.size(), 4u); @@ -155,7 +155,7 @@ void test_to_wire() { const uint32_t val = 0xdeadbeef; uint8_t buf[8]; - FixedBuf pkt(true, buf); + FixedBuf pkt(true, buf); to_wire(pkt, val); testEq(pkt.size(), 4u); @@ -167,7 +167,7 @@ void test_to_wire() { const uint32_t val = 0xdeadbeef; uint8_t buf[8]; - FixedBuf pkt(false, buf); + FixedBuf pkt(false, buf); to_wire(pkt, val); testEq(pkt.size(), 4u); @@ -179,7 +179,7 @@ void test_to_wire() { const SockAddr val(SockAddr::loopback(AF_INET)); uint8_t buf[16+4]; - FixedBuf pkt(true, buf); + FixedBuf pkt(true, buf); to_wire(pkt, val); testEq(pkt.size(), 4u); @@ -192,7 +192,7 @@ void test_to_wire() { const uint32_t val = 0xdeadbeef; uint8_t buf[8] = {0,0,0,0,0,0,0,0}; - FixedBuf pkt(true, buf, 2); + FixedBuf pkt(true, buf, 2); to_wire(pkt, val); testEq(pkt.size(), 2u); diff --git a/test/testudp.cpp b/test/testudp.cpp index 8b715be..3c37f3b 100644 --- a/test/testudp.cpp +++ b/test/testudp.cpp @@ -134,7 +134,7 @@ void testSearch(bool be, std::initializer_list names) auto pktlen = M.save()-msg.data(); - FixedBuf H(be, msg.data(), 8); + FixedBuf H(be, msg.data(), 8); to_wire(H, Header{CMD_SEARCH, 0, uint32_t(pktlen-8)}); testOk1(M.good() && H.good()); diff --git a/test/testxcode.cpp b/test/testxcode.cpp index 75482e7..266ed57 100644 --- a/test/testxcode.cpp +++ b/test/testxcode.cpp @@ -9,7 +9,8 @@ #include #include -#include "dataencode.h" +#include "dataimpl.h" +#include "pvaproto.h" namespace { using namespace pvxs; @@ -52,7 +53,7 @@ void testDecode1() TypeStore cache; { - FixedBuf buf(true, msg); + FixedBuf buf(true, msg); TypeDeserContext ctxt{descs, cache}; from_wire(buf, ctxt); if(testOk1(buf.good())) @@ -118,7 +119,7 @@ void testXCodeNTScalar() std::vector descs; TypeStore cache; { - FixedBuf buf(true, msg); + FixedBuf buf(true, msg); TypeDeserContext ctxt{descs, cache}; from_wire(buf, ctxt); if(testOk1(buf.good())) @@ -244,7 +245,7 @@ void testXCodeNTNDArray() std::vector descs; TypeStore cache; { - FixedBuf buf(true, msg); + FixedBuf buf(true, msg); TypeDeserContext ctxt{descs, cache}; from_wire(buf, ctxt); if(testOk1(buf.good()))