Skip to content

Commit d7162e6

Browse files
committed
Remove experimental c++ trait-detection
1 parent 8fbfc62 commit d7162e6

File tree

6 files changed

+29
-24
lines changed

6 files changed

+29
-24
lines changed

src/MsgPack/Packer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,10 @@ namespace msgpack {
360360

361361
// ---------- CUSTOM format ----------
362362

363-
template <typename C>
364-
auto pack(const C& c) -> typename std::enable_if<has_to_msgpack<C, Packer&>::value>::type {
365-
c.to_msgpack(*this);
366-
}
363+
// template <typename C>
364+
// auto pack(const C& c) -> typename std::enable_if<has_to_msgpack<C, Packer&>::value>::type {
365+
// c.to_msgpack(*this);
366+
// }
367367

368368
// ---------- Array/Map Size format ----------
369369

src/MsgPack/Types.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,17 +257,17 @@ namespace msgpack {
257257
MAP4 = 0x0F, // same as FIXMAP
258258
};
259259

260-
template <typename ClassType, typename ArgType>
261-
using has_to_msgpack_impl = typename std::enable_if<
262-
std::is_same<decltype(&ClassType::to_msgpack), void (ClassType::*)(ArgType) const>::value>::type;
263-
template <typename ClassType, typename ArgType>
264-
using has_to_msgpack = arx::is_detected<has_to_msgpack_impl, ClassType, ArgType>;
260+
// template <typename ClassType, typename ArgType>
261+
// using has_to_msgpack_impl = typename std::enable_if<
262+
// std::is_same<decltype(&ClassType::to_msgpack), void (ClassType::*)(ArgType) const>::value>::type;
263+
// template <typename ClassType, typename ArgType>
264+
// using has_to_msgpack = arx::is_detected<has_to_msgpack_impl, ClassType, ArgType>;
265265

266-
template <typename ClassType, typename ArgType>
267-
using has_from_msgpack_impl = typename std::enable_if<
268-
std::is_same<decltype(&ClassType::from_msgpack), void (ClassType::*)(ArgType)>::value>::type;
269-
template <typename ClassType, typename ArgType>
270-
using has_from_msgpack = arx::is_detected<has_from_msgpack_impl, ClassType, ArgType>;
266+
// template <typename ClassType, typename ArgType>
267+
// using has_from_msgpack_impl = typename std::enable_if<
268+
// std::is_same<decltype(&ClassType::from_msgpack), void (ClassType::*)(ArgType)>::value>::type;
269+
// template <typename ClassType, typename ArgType>
270+
// using has_from_msgpack = arx::is_detected<has_from_msgpack_impl, ClassType, ArgType>;
271271

272272
} // namespace msgpack
273273
} // namespace arduino

src/MsgPack/Unpacker.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,11 @@ namespace msgpack {
438438

439439
// ---------- CUSTOM format ----------
440440

441-
template <typename C>
442-
auto unpack(C& c) -> typename std::enable_if<has_from_msgpack<C, Unpacker&>::value, bool>::type {
443-
c.from_msgpack(*this);
444-
return b_decode_success;
445-
}
441+
// template <typename C>
442+
// auto unpack(C& c) -> typename std::enable_if<has_from_msgpack<C, Unpacker&>::value, bool>::type {
443+
// c.from_msgpack(*this);
444+
// return b_decode_success;
445+
// }
446446

447447
// ---------- Array/Map Size format ----------
448448

src/dispatcher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class RpcFunctionDispatcher {
5252

5353
// handler not found
5454
MsgPack::object::nil_t nil;
55-
packer.serialize(RpcError(FUNCTION_NOT_FOUND_ERR, name), nil);
55+
RpcError(FUNCTION_NOT_FOUND_ERR, name).to_msgpack(packer);
5656
return false;
5757
}
5858

src/error.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ struct RpcError {
2121
RpcError(int c, const MsgPack::str_t& tb)
2222
: code(c), traceback(tb) {}
2323

24-
MSGPACK_DEFINE(code, traceback); // -> [code, traceback]
24+
void to_msgpack(MsgPack::Packer& packer) const {
25+
packer.to_array(code, traceback);
26+
}
27+
void from_msgpack(MsgPack::Unpacker& unpacker) {
28+
unpacker.from_array(code, traceback);
29+
}
2530
};
2631

2732
#endif

src/wrapper.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class RpcFunctionWrapper: public IFunctionWrapper {
3737
// First check the parameters size
3838
if (!unpacker.isArray()){
3939
RpcError error(MALFORMED_CALL_ERR, "Unserializable parameters array");
40-
packer.serialize(error, nil);
40+
error.to_msgpack(packer);
4141
return false;
4242
}
4343

@@ -46,13 +46,13 @@ class RpcFunctionWrapper: public IFunctionWrapper {
4646
unpacker.deserialize(param_size);
4747
if (param_size.size() < sizeof...(Args)){
4848
RpcError error(MALFORMED_CALL_ERR, "Missing call parameters (WARNING: Default param resolution is not implemented)");
49-
packer.serialize(error, nil);
49+
error.to_msgpack(packer);
5050
return false;
5151
}
5252

5353
if (param_size.size() > sizeof...(Args)){
5454
RpcError error(MALFORMED_CALL_ERR, "Too many parameters");
55-
packer.serialize(error, nil);
55+
error.to_msgpack(packer);
5656
return false;
5757
}
5858

0 commit comments

Comments
 (0)