From 9f294eb2e0ae0bed8120fc34fd9782f2f0a9ac74 Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 3 Jun 2019 17:30:01 -0400 Subject: WIP: C bindings --- include/salticidae/msg.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include/salticidae/msg.h') 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 @@ -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::header_size = 0; } +using msg_t = salticidae::MsgBase<_opcode_t>; +#else +typedef struct msg_t msg_t; +#endif + +extern "C" { + +void msg_new(); +} + #endif -- cgit v1.2.3