wslua: simplify __WSLUA_REGISTER_META and _CLASS
Get rid of ATTRS_BLOCK, which is either empty or sets a value for attr. We can initialize attr in any case, either to NULL or to the attributes provided by the caller. This makes the code a bit easier to read (at least for me). Change-Id: Ib26ea5ec099b365303de5aaf407470ad48b126f9 Reviewed-on: https://code.wireshark.org/review/32186 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx> Petri-Dish: Martin Kaiser <wireshark@kaiser.cx> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
092d73e43e
commit
6e1d30ce87
|
@ -423,36 +423,36 @@ extern int wslua_reg_attributes(lua_State *L, const wslua_attribute_table *t, gb
|
|||
/* pop the metatable */ \
|
||||
lua_pop(L, 1)
|
||||
|
||||
#define __WSLUA_REGISTER_META(C, ATTRS_BLOCK) { \
|
||||
#define __WSLUA_REGISTER_META(C, ATTRS) { \
|
||||
const wslua_class C ## _class = { \
|
||||
.name = #C, \
|
||||
.instance_meta = C ## _meta, \
|
||||
ATTRS_BLOCK \
|
||||
.attrs = ATTRS \
|
||||
}; \
|
||||
wslua_register_classinstance_meta(L, &C ## _class); \
|
||||
WSLUA_REGISTER_GC(C); \
|
||||
}
|
||||
|
||||
#define WSLUA_REGISTER_META(C) __WSLUA_REGISTER_META(C,)
|
||||
#define WSLUA_REGISTER_META(C) __WSLUA_REGISTER_META(C, NULL)
|
||||
#define WSLUA_REGISTER_META_WITH_ATTRS(C) \
|
||||
__WSLUA_REGISTER_META(C, .attrs = C ## _attributes)
|
||||
__WSLUA_REGISTER_META(C, C ## _attributes)
|
||||
|
||||
#define __WSLUA_REGISTER_CLASS(C, ATTRS_BLOCK) { \
|
||||
#define __WSLUA_REGISTER_CLASS(C, ATTRS) { \
|
||||
const wslua_class C ## _class = { \
|
||||
.name = #C, \
|
||||
.class_methods = C ## _methods, \
|
||||
.class_meta = C ## _meta, \
|
||||
.instance_methods = C ## _methods, \
|
||||
.instance_meta = C ## _meta, \
|
||||
ATTRS_BLOCK \
|
||||
.attrs = ATTRS \
|
||||
}; \
|
||||
wslua_register_class(L, &C ## _class); \
|
||||
WSLUA_REGISTER_GC(C); \
|
||||
}
|
||||
|
||||
#define WSLUA_REGISTER_CLASS(C) __WSLUA_REGISTER_CLASS(C,)
|
||||
#define WSLUA_REGISTER_CLASS(C) __WSLUA_REGISTER_CLASS(C, NULL)
|
||||
#define WSLUA_REGISTER_CLASS_WITH_ATTRS(C) \
|
||||
__WSLUA_REGISTER_CLASS(C, .attrs = C ## _attributes)
|
||||
__WSLUA_REGISTER_CLASS(C, C ## _attributes)
|
||||
|
||||
#define WSLUA_INIT(L) \
|
||||
luaL_openlibs(L); \
|
||||
|
|
Loading…
Reference in New Issue