summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2021-07-03 01:20:01 -0500
committersanine-a <sanine.not@pm.me>2021-07-03 01:20:01 -0500
commitf83e8d242b8a719733498181f4cad3fbb9c97ca7 (patch)
treeedc44f1e16499f0138d62ed45fb12bba42840570 /README.md
parentdb2b31a335b531d7e54ab3e7d494bbf33050ac60 (diff)
create hs_process_table_tests.c and add basic table processing test
Diffstat (limited to 'README.md')
-rw-r--r--README.md20
1 files changed, 10 insertions, 10 deletions
diff --git a/README.md b/README.md
index 55c1e5d..5953056 100644
--- a/README.md
+++ b/README.md
@@ -86,7 +86,7 @@ messages.
`HS_TBL`, `HS_FUNC`, `HS_NIL`, and `HS_ANY` take a pointer to an integer
that will be filled with the stack index of the argument.
-```C
+```c
int some_lua_binding(lua_State *L)
{
bool b;
@@ -116,7 +116,7 @@ each `HS_END` you may provide another argument list, and after the final
argument list you must provide another `HS_END`. This function throws an error
only if none of the argument lists match the provided arguments.
-```C
+```c
int overloaded_lua_binding(lua_State *L)
{
int i;
@@ -149,7 +149,7 @@ etc.) but `HS_FUNC` and `HS_TBL` expect an integer stack index. You cannot
use `HS_NIL` or `HS_ANY` with this function. `hs_create_table()`
automatically pops any stack indices provided to it.
-```C
+```c
int *ptr; // some pointer
hs_create_table(L,
@@ -173,7 +173,7 @@ literal to enum value and `hs_enum_to_string()` converts enums to strings. In
case the value does not exist, converting to a string results in NULL and
converting to an enum results in a negative value.
-```C
+```c
enum { VALUE_1, VALUE_2, VALUE_3 } example_t;
int index = hs_create_enum(L,
@@ -194,7 +194,7 @@ char *str = hs_enum_to_string(L, index, VALUE_3); // "three"
like `set_config{ debug=true, verbosity=2, logfile='run.log' }`. It can
only operate on stringly-keyed values.
-```C
+```c
void set_verbosity(int value, void *data) { // set verbosity level }
void set_debug(bool value, void *data) { // set debug }
void set_logfile(char *value, void *data) { // set log filename }
@@ -216,14 +216,14 @@ hs_process_table(L, tbl_index, NULL,
`hs_throw_error()` constructs and throws error messages like printf.
-```C
+```c
hs_throw_error(L, "ERROR: %d is not within range", 10);
```
`hs_traceback()` can be supplied to `lua_pcall()` to get a helpful stack
trace error message:
-```C
+```c
lua_pushcfunction(L, hs_traceback);
int tr_pos = lua_gettop();
@@ -238,7 +238,7 @@ which provides the same helpful, contained error messages as `hs_call()` but
takes arguments explicitly in the call for both function arguments and
returns:
-```C
+```c
// some_function accepts int, str and returns number, boolean
lua_pushcfunction(L, some_function);
@@ -256,7 +256,7 @@ hs_call_args(L,
`hs_pushstring()` allows you to push string values using printf format
strings.
-```C
+```c
hs_pushstring(L, "hello there, %s. I hear the current time is %d:%02d", "dylan", 10, 5);
```
@@ -269,7 +269,7 @@ rdel()` to make registry access easier. These are mostly just thin wrappers
around `luaL_ref()`, `luaL_unref()` and `lua_rawgeti()` but they come up
frequently enough that I think these are helpful.
-```C
+```c
lua_pushstring(L, "some string");
int my_string_ref = hs_rstore(L);
// ...