Removes these functions in favor of toNumber and toInteger. These
remaining functions error if the value cannot be returned as a number.
This makes the API safer, while also being a bit more cumbersome. But it
is better to be explicit than use the old toNumber and not know it
returns 0 silently on fail.
The Lua API has the concept of lstrings (length strings). These are used
when the contents may contain zeroes, or when it is useful to know the
length. Because this data is not necessarily a string, ziglua has
renamed these lstring functions to bytes functions.
The toString function returns a zero-terminated many item pointer which
is useful when you know the data is not zero-terminated.
The luaL_setfuncs function (macro) expects a C array so it can calculate
sizes with sizeof(). In Zig as a function it would be awkward to pass a
null-terminated array of FnReg values.
So we make things easier by just rewriting the auxlib function in Zig,
which has the benefit of accepting a slice rather than an array.
Adds a test to ensure it works.
This test makes it easy to confirm the correct signatures for all
functions. All functions have been checked and fixed at this point, and
in theory work just fine.
So "technically" 100% test coverage, but the functions should be used
before being really safe.
Adds tests that load the global table (_G) and inspect values in it. In
order to make this simple, the standard library packages are inspected.
This test led to discovering that the Lua.open() function wasn't working
properly as a replacement for openlibs(). Now it properly uses requireF
to load the desired standard library functions.
The various open* functions are still included, but are likely not very
useful in most common situations.
Adds a test to ensure each of the luaL_Buffer functions work. In
experimenting with this, I have found the Buffer code to be very touchy.
If you don't use it correctly things will break badly. Perhaps there is
something that can be added in the Zig layer for safety.
Requires to initialize a Buffer variable before calling init because the
structure keeps a pointer to an internal array so the struct cannot be
passed or returned by value.
This makes code cleaner (no need to prefix with Lua), and it makes
sense, as these constants are not necessarily associated with the Lua
state struct itself.