1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-04 00:33:13 +02:00

core: add macro to define hdata variable with different field and name

This commit is contained in:
Sébastien Helleu
2024-03-15 18:34:17 +01:00
parent 080eecef2c
commit 305b046370
2 changed files with 20 additions and 4 deletions
+10 -2
View File
@@ -22,11 +22,19 @@
#include <time.h>
#define HDATA_VAR(__struct, __name, __type, __update_allowed, \
/* create a hdata variable (name is the same as the struct field */
#define HDATA_VAR(__struct, __field, __type, __update_allowed, \
__array_size, __hdata_name) \
hdata_new_var (hdata, #__name, offsetof (__struct, __name), \
hdata_new_var (hdata, #__field, offsetof (__struct, __field), \
WEECHAT_HDATA_##__type, __update_allowed, \
__array_size, __hdata_name)
/* create a hdata variable with a custom name */
#define HDATA_VAR_NAME(__struct, __field, __name, __type, \
__update_allowed, __array_size, __hdata_name) \
hdata_new_var (hdata, __name, offsetof (__struct, __field), \
WEECHAT_HDATA_##__type, __update_allowed, \
__array_size, __hdata_name)
/* create a hdata list */
#define HDATA_LIST(__name, __flags) \
hdata_new_list (hdata, #__name, &(__name), __flags);
+10 -2
View File
@@ -2263,9 +2263,17 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
(weechat_plugin->hdata_new_var)(__hdata, __name, __offset, __type, \
__update_allowed, __array_size, \
__hdata_name)
#define WEECHAT_HDATA_VAR(__struct, __name, __type, __update_allowed, \
#define WEECHAT_HDATA_VAR(__struct, __field, __type, __update_allowed, \
__array_size, __hdata_name) \
weechat_hdata_new_var (hdata, #__name, offsetof (__struct, __name), \
weechat_hdata_new_var (hdata, #__field, \
offsetof (__struct, __field), \
WEECHAT_HDATA_##__type, __update_allowed, \
__array_size, __hdata_name)
#define WEECHAT_HDATA_VAR_NAME(__struct, __field, __name, __type, \
__update_allowed, __array_size, \
__hdata_name) \
weechat_hdata_new_var (hdata, __name, \
offsetof (__struct, __field), \
WEECHAT_HDATA_##__type, __update_allowed, \
__array_size, __hdata_name)
#define weechat_hdata_new_list(__hdata, __name, __pointer, __flags) \