This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
honeysuckle [2021/09/14 19:43] sanine [hs_vpushstring] |
honeysuckle [2021/09/14 20:18] (current) sanine [hs_process_table] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== honeysuckle ====== | ====== honeysuckle ====== | ||
- | honeysuckle is a C library intended to make creating Lua bindings simpler. It was originally a core part of the honey code, but was split out into its own library because it is useful in many other contexts. It provides functions for argument parsing, table creation and processing, error throwing and handling, | + | honeysuckle is a C library intended to make creating Lua bindings simpler. It was originally a core part of the honey code, but was split out into its own library because it is useful in many other contexts. It provides functions for argument parsing, table creation and processing, error throwing and handling, string wrangling, and registry operations. |
===== hs_parse_args ===== | ===== hs_parse_args ===== | ||
Line 45: | Line 45: | ||
=== Example === | === Example === | ||
+ | |||
+ | The following would be used to create a Lua function that expects arguments like '' | ||
<code C> | <code C> | ||
Line 174: | Line 176: | ||
=== Stack Modifications === | === Stack Modifications === | ||
- | [-0, +0, -]< | + | [-0, +0, e]< |
=== Parameters === | === Parameters === | ||
Line 197: | Line 199: | ||
For the extremely common case of simply setting a variable, there are provided the functions '' | For the extremely common case of simply setting a variable, there are provided the functions '' | ||
+ | |||
+ | This function may throw an error if the provided index is not valid or is not a table. It may trigger metamethods in extracting values. | ||
=== Example === | === Example === | ||
Line 234: | Line 238: | ||
=== Stack Modifications === | === Stack Modifications === | ||
- | [-0, +1, -]< | + | [-0, +1, m]< |
=== Parameters === | === Parameters === | ||
Line 241: | Line 245: | ||
* '' | * '' | ||
* '' | * '' | ||
+ | |||
+ | === Return Value === | ||
+ | |||
+ | None. | ||
=== Description === | === Description === | ||
Line 266: | Line 274: | ||
=== Stack Modifications === | === Stack Modifications === | ||
- | [-0, +0, -]< | + | [-0, +0, m]< |
=== Parameters === | === Parameters === | ||
Line 273: | Line 281: | ||
* '' | * '' | ||
* '' | * '' | ||
+ | |||
+ | === Return Value === | ||
+ | |||
+ | None. | ||
=== Description === | === Description === | ||
Line 289: | Line 301: | ||
=== Stack Modifications === | === Stack Modifications === | ||
- | [-0, +0, -]< | + | [-0, +0, v]< |
=== Parameters === | === Parameters === | ||
Line 296: | Line 308: | ||
* '' | * '' | ||
* '' | * '' | ||
+ | |||
+ | === Return Value === | ||
+ | |||
+ | None, but by its nature this function will not return and instead makes a long jump to the current error handler. | ||
+ | |||
+ | === Description === | ||
+ | |||
+ | Similar to '' | ||
+ | |||
+ | ===== hs_traceback ===== | ||
+ | |||
+ | <code C> | ||
+ | void hs_traceback(lua_State *L); | ||
+ | </ | ||
+ | |||
+ | === Stack Modifications === | ||
+ | |||
+ | [-(0|1), +(0|1), -]< | ||
+ | |||
+ | === Parameters === | ||
+ | |||
+ | * '' | ||
+ | |||
+ | |||
+ | === Return Value === | ||
+ | |||
+ | None. | ||
+ | |||
+ | === Description === | ||
+ | |||
+ | This function produces a call traceback string to go with an error message provided to it, or keeps the "error message" | ||
+ | |||
+ | ===== hs_call ===== | ||
+ | |||
+ | <code C> | ||
+ | int hs_call( | ||
+ | lua_State *L, | ||
+ | int nargs, | ||
+ | int nret); | ||
+ | </ | ||
+ | |||
+ | === Stack Modifications === | ||
+ | |||
+ | [-(nargs+1), | ||
+ | |||
+ | === Parameters === | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | === Return Value === | ||
+ | |||
+ | 0 on success, or else one of the Lua error codes: '' | ||
+ | |||
+ | === Description === | ||
+ | |||
+ | This function is exactly the same as '' | ||
+ | |||
+ | ===== hs_rstore ===== | ||
+ | |||
+ | <code C> | ||
+ | int hs_rstore(lua_State *L); | ||
+ | </ | ||
+ | |||
+ | === Stack Modifications === | ||
+ | |||
+ | [-1, +0, m]< | ||
+ | |||
+ | === Parameters === | ||
+ | |||
+ | * '' | ||
+ | |||
+ | === Return Value === | ||
+ | |||
+ | The reference key. | ||
+ | |||
+ | === Description === | ||
+ | |||
+ | This is a macro wrapper around '' | ||
+ | |||
+ | ===== hs_rload ===== | ||
+ | |||
+ | <code C> | ||
+ | void hs_rload( | ||
+ | lua_State *L, | ||
+ | int reference); | ||
+ | </ | ||
+ | |||
+ | === Stack Modifications === | ||
+ | |||
+ | [-0, +1, -]< | ||
+ | |||
+ | === Parameters === | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | === Return Value === | ||
+ | |||
+ | None. | ||
+ | |||
+ | === Description === | ||
+ | |||
+ | This is a macro wrapper around '' | ||
+ | |||
+ | ===== hs_rdel ===== | ||
+ | |||
+ | <code C> | ||
+ | void hs_rdel( | ||
+ | lua_State *L, | ||
+ | int reference); | ||
+ | </ | ||
+ | |||
+ | === Stack Modifications === | ||
+ | |||
+ | [-0, +0, -]< | ||
+ | |||
+ | === Parameters === | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | === Return Value === | ||
+ | |||
+ | The reference key. | ||
=== Description === | === Description === | ||
- | Similar to '' | + | This is a macro wrapper around |