aboutsummaryrefslogtreecommitdiff
path: root/include/salticidae/msg.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/salticidae/msg.h')
-rw-r--r--include/salticidae/msg.h19
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