diff options
author | Determinant <tederminant@gmail.com> | 2019-06-03 17:30:01 -0400 |
---|---|---|
committer | Determinant <tederminant@gmail.com> | 2019-06-03 17:30:01 -0400 |
commit | 9f294eb2e0ae0bed8120fc34fd9782f2f0a9ac74 (patch) | |
tree | d5005c9888874bd2b169fcd51418a3fab36fe631 /include/salticidae/msg.h | |
parent | 9ec5a371f5c05fda8ddeac3470be6fc5c67d44e9 (diff) |
WIP: C bindings
Diffstat (limited to 'include/salticidae/msg.h')
-rw-r--r-- | include/salticidae/msg.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/salticidae/msg.h b/include/salticidae/msg.h index 03eb6dd..128e287 100644 --- a/include/salticidae/msg.h +++ b/include/salticidae/msg.h @@ -34,6 +34,7 @@ #include "salticidae/stream.h" #include "salticidae/netaddr.h" +#ifdef __cplusplus namespace salticidae { template<typename OpcodeType> @@ -69,6 +70,14 @@ class MsgBase { set_checksum(); } +#ifdef SALTICIDAE_CBINDINGS + MsgBase(const OpcodeType &opcode, bytearray_t &&payload): magic(0x0) { + set_opcode(opcode); + set_payload(std::move(payload)); + set_checksum(); + } +#endif + MsgBase(const MsgBase &other): magic(other.magic), opcode(other.opcode), @@ -258,4 +267,14 @@ const size_t MsgBase<OpcodeType>::header_size = 0; } +using msg_t = salticidae::MsgBase<_opcode_t>; +#else +typedef struct msg_t msg_t; +#endif + +extern "C" { + +void msg_new(); +} + #endif |