diff options
Diffstat (limited to 'src/common.h')
-rw-r--r-- | src/common.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/common.h b/src/common.h index ede67cd..1a56b56 100644 --- a/src/common.h +++ b/src/common.h @@ -74,4 +74,46 @@ void honey_error_set_string2(char* string); */ void honey_human_readable_error(char* error_string, honey_result error); +/* lua binding functions */ + +typedef enum { + HONEY_INT, + HONEY_NUM, + HONEY_STRING, + HONEY_FUNC +} honey_lua_type; + +/** @brief Wrap C objects for lua. */ +typedef struct { + char* name; + honey_lua_type type; + union { + int integer; + double number; + char* string; + int (*function)(lua_State*); + } data; +} honey_lua_element; + +/** @brief Push an element to the lua stack. + * + * @param[in] L The lua state to push the element to. + * @param[in] element The honey_lua_element to push to the stack. + * + * @returns Nothing. + */ +void honey_lua_push_element(lua_State* L, + honey_lua_element element); + +/** @brief Create a lua table populated with various elements. + * + * @param[in] L The lua state to push the table to. + * @param[in] elements Array of elements to populate the table. + * @param[in] n_elements The number of elements in the array. + * + * @returns Nothing. + */ +void honey_lua_create_table(lua_State* L, + honey_lua_element* elements, + unsigned int n_elements); #endif |