Commit Graph

13 Commits

Author SHA1 Message Date
Nathan Craddock
d760af7c46
tests: add tests for Lua.typeOf
Adds the beginnings of tests. There are some missing types, but those
will be gotten to eventually.
2022-06-01 21:04:48 -06:00
Nathan Craddock
419cdd787c
add type and typename functions
Because type is a Zig primitive, this adds typeOf as a workaround.
2022-06-01 20:33:14 -06:00
Nathan Craddock
68dedb550a
add remaining lua_to* functions
Again, not yet tested, but added the definitions. Now that all these
functions are done it will be easier to add tests (hard to test these
functions in isolation).
2022-06-01 19:56:37 -06:00
Nathan Craddock
0e7e3da07d
add lua_is* functions
Adds function definitions for all lua_is* functions. Not all are tested,
but will be soon.
2022-06-01 19:34:34 -06:00
Nathan Craddock
f05498164d
fix: use != 0 rather than == 1
Booleans are guaranteed to use 0 for false, but not so for 1, so it is
safer to check != 0 in returns from Lua.
2022-06-01 19:12:34 -06:00
Nathan Craddock
3a34c88ac4
cleanup: reorder types into own section
Declare all types in a section to make it easier to find them

Also renames AllocFn -> AllocFunction to make it more consistent with
CFunction (which did not look good as CFn).
2022-06-01 19:06:05 -06:00
Nathan Craddock
7495530f03
add all lua_push* functions
Not all are functional yet, but at least the definitions are there
2022-06-01 19:01:10 -06:00
Nathan Craddock
7090df6e24
add lua_arith and test
Adds Lua.arith for mathematical operations on the stack. Includes a test
where each operator is used at least once. The Zig wrapper uses an enum
to ensure no invalid operators are attempted.

A few other functions are included as needed for testing, but will be
tested individually later on.
2022-06-01 15:51:56 -06:00
Nathan Craddock
e49441220a
fix: prefix openLibs with aux
This is technically an auxiliary library based on its naming convention
2022-05-31 21:27:14 -06:00
Nathan Craddock
72b461992c
fix: allow newState data to be null
The pointer passed to lua_newstate is nullable
2022-05-31 21:18:04 -06:00
Nathan Craddock
1188fe6466
rename LICENSE -> license
I just like lowercase better :)
2022-05-31 21:08:16 -06:00
Nathan Craddock
6e178770c1
add standard library opening functions
Exposes the luaopen_* and luaL_openlibs. Also adds a Ziggified wrapper
function that takes a packed struct as input to specify which libs to
load.

After looking at rlua (a rust lua library) and the lua reference manual,
it seems that these library loading functions have the possibility of
failure. Not sure how to address this yet, but have left a todo.
2022-05-31 20:04:13 -06:00
Nathan Craddock
aa686e39a4
initial commit: basic library framework
This first commit includes the LICENSE and the .gitignore in addition to
the beginnings of the zlua (name tbd) library.

At this stage src/zlua.zig contains a very basic wrapper around the Lua
C API. The goal is to expose every function in a Zig fashion.

The build.zig script contains a single entry point `zig build test` to
run tests.

The intended use of this library will be to include in other projects
and link as a package/library.
2022-05-31 19:09:27 -06:00