User Tools

Site Tools


honeysuckle

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
honeysuckle [2021/09/14 20:00]
sanine [hs_pushstring]
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, and string wrangling.+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 176: Line 176:
 === Stack Modifications === === Stack Modifications ===
  
-[-0, +0, -]<sup>[//[[Stack Modification Indicator|?]]//]</sup>+[-0, +0, e]<sup>[//[[Stack Modification Indicator|?]]//]</sup>
  
 === Parameters === === Parameters ===
Line 199: Line 199:
  
 For the extremely common case of simply setting a variable, there are provided the functions ''hs_pt_set_bool'', ''hs_pt_set_int'', ''hs_pt_set_num'', and ''hs_pt_set_str'', which will cast the provided void pointer to ''bool'', ''lua_Integer'', ''lua_Number'', or ''const char *'', respectively, and then set that value to the value in the table. For the extremely common case of simply setting a variable, there are provided the functions ''hs_pt_set_bool'', ''hs_pt_set_int'', ''hs_pt_set_num'', and ''hs_pt_set_str'', which will cast the provided void pointer to ''bool'', ''lua_Integer'', ''lua_Number'', or ''const char *'', respectively, and then set that value to the value in the table.
 +
 +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 236: Line 238:
 === Stack Modifications === === Stack Modifications ===
  
-[-0, +1, -]<sup>[//[[Stack Modification Indicator|?]]//]</sup>+[-0, +1, m]<sup>[//[[Stack Modification Indicator|?]]//]</sup>
  
 === Parameters === === Parameters ===
Line 272: Line 274:
 === Stack Modifications === === Stack Modifications ===
  
-[-0, +0, -]<sup>[//[[Stack Modification Indicator|?]]//]</sup>+[-0, +0, m]<sup>[//[[Stack Modification Indicator|?]]//]</sup>
  
 === Parameters === === Parameters ===
Line 299: Line 301:
 === Stack Modifications === === Stack Modifications ===
  
-[-0, +0, -]<sup>[//[[Stack Modification Indicator|?]]//]</sup>+[-0, +0, v]<sup>[//[[Stack Modification Indicator|?]]//]</sup>
  
 === Parameters === === Parameters ===
Line 313: Line 315:
 === Description === === Description ===
  
-Similar to ''hs_pushstring()'' above, but pushes the string and then immediately throws an error with it. Useful for constructing complex error messages.+Similar to ''hs_pushstring()'' above, but pushes the string and then immediately throws an error with it. Useful for constructing complex error messages. This function may also throw a memory-related error if string creation fails.
  
 ===== hs_traceback ===== ===== hs_traceback =====
Line 364: Line 366:
  
 This function is exactly the same as ''lua_pcall'', with the same return values, except that it automatically pushes ''hs_traceback()'' to use as an error handler and does not accept a different error handler. This function is exactly the same as ''lua_pcall'', with the same return values, except that it automatically pushes ''hs_traceback()'' to use as an error handler and does not accept a different error handler.
 +
 +===== hs_rstore =====
 +
 +<code C>
 +int hs_rstore(lua_State *L);
 +</code>
 +
 +=== Stack Modifications ===
 +
 +[-1, +0, m]<sup>[//[[Stack Modification Indicator|?]]//]</sup>
 +
 +=== Parameters ===
 +
 +  * ''L'': the Lua state to operate on.
 +
 +=== Return Value ===
 +
 +The reference key.
 +
 +=== Description ===
 +
 +This is a macro wrapper around ''luaL_ref()'' that always uses the Lua registry table. It is provided for convenience.
 +
 +===== hs_rload =====
 +
 +<code C>
 +void hs_rload(
 +    lua_State *L,
 +    int reference);
 +</code>
 +
 +=== Stack Modifications ===
 +
 +[-0, +1, -]<sup>[//[[Stack Modification Indicator|?]]//]</sup>
 +
 +=== Parameters ===
 +
 +  * ''L'': the Lua state to operate on.
 +  * ''reference'': A reference key returned by ''hs_rstore()''.
 +
 +=== Return Value ===
 +
 +None.
 +
 +=== Description ===
 +
 +This is a macro wrapper around ''lua_rawgeti()'' that always gets values from the Lua registry table. It is provided for convenience.
 +
 +===== hs_rdel =====
 +
 +<code C>
 +void hs_rdel(
 +    lua_State *L,
 +    int reference);
 +</code>
 +
 +=== Stack Modifications ===
 +
 +[-0, +0, -]<sup>[//[[Stack Modification Indicator|?]]//]</sup>
 +
 +=== Parameters ===
 +
 +  * ''L'': the Lua state to operate on.
 +  * ''reference'': a reference key returned by ''hs_rstore()''.
 +
 +=== Return Value ===
 +
 +The reference key.
 +
 +=== Description ===
 +
 +This is a macro wrapper around ''luaL_unref()'' that always uses the Lua registry table. It is provided for convenience.
honeysuckle.1631649646.txt.gz ยท Last modified: 2021/09/14 20:00 by sanine