aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-06-04 16:13:52 -0400
committerDeterminant <[email protected]>2019-06-04 16:13:52 -0400
commitebada91a1327da99f1827c7e4c15fc3bee527d58 (patch)
tree904aeb2afbc54612b704f89a80c7a48953943220 /include
parent9f294eb2e0ae0bed8120fc34fd9782f2f0a9ac74 (diff)
more bindings
Diffstat (limited to 'include')
-rw-r--r--include/salticidae/event.h25
-rw-r--r--include/salticidae/msg.h15
-rw-r--r--include/salticidae/network.h18
-rw-r--r--include/salticidae/stream.h16
-rw-r--r--include/salticidae/type.h27
5 files changed, 97 insertions, 4 deletions
diff --git a/include/salticidae/event.h b/include/salticidae/event.h
index 19bd250..27d081a 100644
--- a/include/salticidae/event.h
+++ b/include/salticidae/event.h
@@ -645,9 +645,34 @@ class ThreadCall {
}
+#ifdef SALTICIDAE_CBINDINGS
using eventcontext_t = salticidae::EventContext;
+using sigev_t = salticidae::SigEvent;
+#endif
#else
+
+#ifdef SALTICIDAE_CBINDINGS
typedef struct eventcontext_t;
+typedef struct sigevent_t;
+#endif
+
#endif
+
+#ifdef SALTICIDAE_CBINDINGS
+extern "C" {
+
+eventcontext_t *eventcontext_new();
+void eventcontext_dispatch(eventcontext_t *self);
+void eventcontext_stop(eventcontext_t *self);
+void eventcontext_free(eventcontext_t *self);
+
+typedef void (*sigev_callback_t)(int fd, int events);
+sigev_t *sigev_new(const eventcontext_t *self, sigev_callback_t cb);
+void sigev_add(sigev_t *self, int sig);
+void sigev_free(sigev_t *self);
+
+}
+#endif
+
#endif
diff --git a/include/salticidae/msg.h b/include/salticidae/msg.h
index 128e287..6964ab2 100644
--- a/include/salticidae/msg.h
+++ b/include/salticidae/msg.h
@@ -267,14 +267,27 @@ const size_t MsgBase<OpcodeType>::header_size =
0;
}
+#ifdef SALTICIDAE_CBINDINGS
using msg_t = salticidae::MsgBase<_opcode_t>;
+#endif
+
#else
+
+#ifdef SALTICIDAE_CBINDINGS
typedef struct msg_t msg_t;
#endif
+#endif
+
+#ifdef SALTICIDAE_CBINDINGS
extern "C" {
-void msg_new();
+msg_t *msg_new(_opcode_t opcode, bytearray_t *_moved_payload);
+datastream_t *msg_get_payload(msg_t *msg);
+const _opcode_t &msg_get_opcode(const msg_t *msg);
+void msg_free(msg_t *msg);
+
}
+#endif
#endif
diff --git a/include/salticidae/network.h b/include/salticidae/network.h
index 12fe720..b176b65 100644
--- a/include/salticidae/network.h
+++ b/include/salticidae/network.h
@@ -782,22 +782,28 @@ const O PeerNetwork<O, _, OPCODE_PONG>::MsgPong::opcode = OPCODE_PONG;
}
+#ifdef SALTICIDAE_CBINDINGS
using msgnetwork_t = salticidae::MsgNetwork<_opcode_t>;
using msgnetwork_config_t = msgnetwork_t::Config;
using msgnetwork_conn_t = msgnetwork_t::conn_t;
+#endif
#else
+
+#ifdef SALTICIDAE_CBINDINGS
typedef struct msg_t;
typedef struct msgnetwork_t;
typedef struct msgnetwork_config_t;
typedef struct msgnetwork_conn_t;
#endif
+#endif
+
+#ifdef SALTICIDAE_CBINDINGS
extern "C" {
void salticidae_injected_msg_callback(const msg_t *msg, msgnetwork_conn_t *conn);
-msg_t _test_create_msg();
msgnetwork_t *msgnetwork_new(const eventcontext_t *ec, const msgnetwork_config_t *config);
bool msgnetwork_send_msg(msgnetwork_t *self, const msg_t *msg, const msgnetwork_conn_t *conn);
@@ -806,13 +812,21 @@ msgnetwork_conn_t *msgnetwork_connect(msgnetwork_t *self, const netaddr_t *addr)
void msgnetwork_listen(msgnetwork_t *self, const netaddr_t *listen_addr);
-typedef void (*msgnetwork_msg_callback_t)(const msg_t *msg, const msgnetwork_conn_t *conn);
+typedef void (*msgnetwork_msg_callback_t)(const msg_t *, const msgnetwork_conn_t *);
#ifdef SALTICIDAE_CBINDINGS_STR_OP
void msgnetwork_reg_handler(msgnetwork_t *self, const char *opcode, msgnetwork_msg_callback_t cb);
#else
void msgnetwork_reg_handler(msgnetwork_t *self, uint8_t opcode, msgnetwork_msg_callback_t cb);
#endif
+
+typedef void (*msgnetwork_conn_callback_t)(const msgnetwork_conn_t *, bool);
+
+void msgnetwork_reg_conn_handler(msgnetwork_t *self, msgnetwork_conn_callback_t cb);
+
+msgnetwork_t *msgnetwork_conn_get_net(const msgnetwork_conn_t *conn);
+
}
+#endif
#endif
diff --git a/include/salticidae/stream.h b/include/salticidae/stream.h
index 9eda2bd..e146273 100644
--- a/include/salticidae/stream.h
+++ b/include/salticidae/stream.h
@@ -467,14 +467,21 @@ namespace std {
};
}
+#ifdef SALTICIDAE_CBINDINGS
using uint256_t = salticidae::uint256_t;
using datastream_t = salticidae::DataStream;
+#endif
#else
+
+#ifdef SALTICIDAE_CBINDINGS
typedef struct datastream_t;
typedef struct uint256_t;
#endif
+#endif
+
+#ifdef SALTICIDAE_CBINDINGS
extern "C" {
uint256_t *uint256_new();
@@ -499,8 +506,17 @@ void datastream_put_i16(datastream_t *self, int16_t val);
void datastream_put_i32(datastream_t *self, int32_t val);
void datastream_put_data(datastream_t *self,
uint8_t *begin, uint8_t *end);
+
+uint8_t datastream_get_u8(datastream_t *self);
+uint16_t datastream_get_u16(datastream_t *self);
+uint32_t datastream_get_u32(datastream_t *self);
+int8_t datastream_get_i8(datastream_t *self);
+int16_t datastream_get_i16(datastream_t *self);
+int32_t datastream_get_i32(datastream_t *self);
const uint8_t *datastream_get_data_inplace(datastream_t *self, size_t len);
uint256_t *datastream_get_hash(const datastream_t *self);
}
#endif
+
+#endif
diff --git a/include/salticidae/type.h b/include/salticidae/type.h
index 3ec202a..0ebcce7 100644
--- a/include/salticidae/type.h
+++ b/include/salticidae/type.h
@@ -35,6 +35,9 @@
#include <functional>
#include <mutex>
+#include "config.h"
+
+#ifdef __cplusplus
namespace salticidae {
const auto _1 = std::placeholders::_1;
@@ -89,10 +92,32 @@ inline auto generic_bind(ReturnType(ClassType::* f)(Args...), FArgs&&... fargs)
}
+#ifdef SALTICIDAE_CBINDINGS
+using bytearray_t = salticidae::bytearray_t;
+#endif
+
+#else
+
+#ifdef SALTICIDAE_CBINDINGS
+typedef struct bytearray_t bytearray_t;
+#endif
+
+#endif
+
#ifdef SALTICIDAE_CBINDINGS_STR_OP
-using _opcode_t = std::string;
+using _opcode_t = char *;
#else
using _opcode_t = uint8_t;
#endif
+#ifdef SALTICIDAE_CBINDINGS
+extern "C" {
+
+uint8_t *bytearray_data(bytearray_t *arr);
+size_t bytearray_size(bytearray_t *arr);
+void bytearray_free();
+
+}
+#endif
+
#endif