2024-11-28 08:31:00 +00:00
|
|
|
#ifndef _INCLUDE_EVENT_H_
|
|
|
|
#define _INCLUDE_EVENT_H_
|
|
|
|
|
2024-11-30 10:26:46 +00:00
|
|
|
#define CONCAT_(prefix, suffix) prefix##suffix
|
|
|
|
/// Concatenate `prefix, suffix` into `prefixsuffix`
|
|
|
|
#define CONCAT(prefix, suffix) CONCAT_(prefix, suffix)
|
|
|
|
|
|
|
|
/// Register event handler
|
|
|
|
#define ON_EVENT_EX(name, func, data) \
|
|
|
|
static void func (const char* event_name, void *args, void* user_data); \
|
|
|
|
int CONCAT(func, _register_ret) = etif_event_register(#name, func, data);\
|
|
|
|
static void func (const char* event_name, void *args, void* user_data)
|
|
|
|
#define ON_EVENT(name) ON_EVENT_EX(name, CONCAT(_event_ ## name ## _handle_line_, __LINE__), NULL)
|
|
|
|
|
2024-11-28 08:31:00 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef void (*event_callback)(const char*, void*, void*);
|
|
|
|
|
2024-11-30 10:26:46 +00:00
|
|
|
void etif_event(const char *event_name, void *args, size_t args_size);
|
|
|
|
int etif_event_register(const char *event_name, event_callback callback, void* user_data);
|
|
|
|
int etif_event_unregister(const char *event_name, event_callback callback, void* user_data);
|
|
|
|
void* etif_event_thread(void*);
|
2024-11-28 08:31:00 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|