diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/honeysuckle.c | 19 | ||||
-rw-r--r-- | src/honeysuckle.h | 45 | ||||
-rw-r--r-- | src/hs_create_table.c | 10 |
4 files changed, 52 insertions, 24 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a7aa827..e5ed893 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ set(HONEYSUCKLE_SOURCES ${HS_ROOT}/hs_pushstring.c ${HS_ROOT}/hs_throw_error.c ${HS_ROOT}/hs_parse_args.c + ${HS_ROOT}/hs_create_table.c ${HS_ROOT}/honeysuckle.c ) add_library(honeysuckle ${HONEYSUCKLE_SOURCES}) @@ -39,6 +40,7 @@ set(TEST_SOURCES # ${TEST_ROOT}/hs_rxx_tests.c ) add_executable(test EXCLUDE_FROM_ALL ${TEST_SOURCES}) +set_target_properties(test PROPERTIES CMAKE_C_FLAGS "-Wall -Wextra -Werror -Wfatal-errors -Wpedantic") target_link_libraries(test ${LUA_LIBRARIES} honeysuckle) include(GNUInstallDirs) diff --git a/src/honeysuckle.c b/src/honeysuckle.c index 1d8da6b..2689544 100644 --- a/src/honeysuckle.c +++ b/src/honeysuckle.c @@ -1,24 +1,5 @@ #include "honeysuckle.h" -void hs_parse_args_(lua_State *L, int n_args, struct hs_arg *arguments) -{ - L = L; -} - -int hs_parse_overloaded_(lua_State *L, ...) -{ - L = L; - return -1; -} - - -int hs_create_table(lua_State *L, ...) -{ - lua_createtable(L, 0, 0); - L = L; - return 0; -} - int hs_create_enum(lua_State *L, ...) { lua_createtable(L, 0, 0); diff --git a/src/honeysuckle.h b/src/honeysuckle.h index db26562..f54a261 100644 --- a/src/honeysuckle.h +++ b/src/honeysuckle.h @@ -60,8 +60,10 @@ struct hs_arg { void hs_parse_args_(lua_State *L, int n_args, struct hs_arg *arguments); -#define hs_parse_args(L, ...) \ - hs_parse_args_(L, VA_NARGS(__VA_ARGS__)/2, (struct hs_arg[]) { __VA_ARGS__ }) +#define hs_parse_args(L, ...) \ + hs_parse_args_(L, \ + VA_NARGS(__VA_ARGS__)/2, \ + (struct hs_arg[]) { __VA_ARGS__ }) #define hs_overload(...) VA_NARGS(__VA_ARGS__)/2, (struct hs_arg[]) { __VA_ARGS__ } @@ -99,7 +101,7 @@ struct hs_tbl_entry { lua_CFunction function; void *userdata; } value; -} +}; #define hs_bool_bool(key, value) \ { HS_BOOL, .key.boolean=key, HS_BOOL, .value.boolean=value } @@ -253,8 +255,20 @@ struct hs_tbl_entry { #define hs_light_light(key, value) \ { HS_LIGHT, .key.userdata=key, HS_LIGHT, .value.userdata=value } +int hs_create_table_(lua_State *L, int n_elements, struct hs_tbl_entry *elements); + +#define hs_create_table(L, ...) \ + hs_create_table_(L, \ + VA_NARGS(__VA_ARGS__)/4, \ + (struct hs_tbl_entry[]) { __VA_ARGS__ }) -int hs_create_table(lua_State *L, ...); + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * hs_process_table + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ void hs_process_table(lua_State *L, int table_index, void *data, ...); // default processors @@ -263,16 +277,37 @@ void hs_pt_set_integer(lua_Integer value, void *data); void hs_pt_set_number(lua_Number value, void *data); void hs_pt_set_string(const char *value, void *data); + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * hs_pushstring + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + void hs_vpushstring(lua_State *L, const char *format_string, va_list args); void hs_pushstring(lua_State *L, const char *format_string, ...); -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * error creation and handling + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ void hs_throw_error(lua_State *L, const char *format_string, ...); int hs_traceback(lua_State *L); int hs_call(lua_State *L, int nargs, int nret); + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * registry operations + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + #define hs_rstore(L) luaL_ref(L, LUA_REGISTRYINDEX); #define hs_rload(L, ref) lua_rawgeti(L, LUA_REGISTRYINDEX, ref) #define hs_rdel(L, ref) luaL_unref(L, LUA_REGISTRYINDEX, ref) diff --git a/src/hs_create_table.c b/src/hs_create_table.c new file mode 100644 index 0000000..a394f6e --- /dev/null +++ b/src/hs_create_table.c @@ -0,0 +1,10 @@ +#include "honeysuckle.h" + +int hs_create_table_(lua_State *L, + int n_elements, + struct hs_tbl_entry *elements) +{ + L=L; + n_elements = n_elements; + elements = elements; +} |