You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs.md
+6-5Lines changed: 6 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,13 @@
4
4
5
5
This documentation provides
6
6
7
-
* An overview of ziglua's structure
7
+
* An overview of ziglua's structure and changes from the C API
8
8
* Safety considerations
9
-
* API Differences
10
9
*`build.zig` documentation
11
10
* Example code
12
11
12
+
Documentation on each individual function is found in the [ziglua.zig](https://github.com/natecraddock/ziglua/blob/master/src/ziglua.zig) source code.
13
+
13
14
## Moving from the C API to Zig
14
15
15
16
While efforts have been made to keep the ziglua API similar to the C API, many changes have been made including:
@@ -28,13 +29,13 @@ In the few cases when the [auxiliary library](https://www.lua.org/manual/5.4/man
28
29
29
30
For example, the functions `lua_newstate` and `luaL_newstate` are translated to `Lua.newState` and `Lua.newStateAux` respectively.
30
31
31
-
Because Zig optimizes for readability, some abbreviations are expanded to make names more clear, like renaming `pcall` to `protectedCall`.
32
+
Because Zig best practice is to communicate intent precisely, some abbreviations are expanded to make names more clear, like renaming `pcall` to `protectedCall`.
32
33
33
34
### Lua Initialization
34
35
35
36
In the C API, there are two functions provided to initialize the main Lua state: `lua_newstate` and `luaL_newstate`. The former requires passing an allocator function to be used by Lua for all memory allocations, while the latter uses the default libc allocator.
36
37
37
-
Ziglua provides a third option with the `Lua.init(Allocator)` function, which accepts a traditional Zig allocator. All three functions are available depending on your needs, but most likely you will want to use the `init` function. If you have special requirements for allocation, then `Lua.newState` would be useful. `Lua.newStateAux` is available, but Zig cannot track allocations made by libc so this is less safe.
38
+
Ziglua provides a third option with the `Lua.init(Allocator)` function, which accepts a traditional Zig allocator. All three functions are available depending on your needs, but most likely you will want to use the `Lua.init(Allocator)` function. If you have special requirements for allocation, then `Lua.newState` would be useful. `Lua.newStateAux` is available if you wish to use the default libc allocator.
38
39
39
40
## Safety
40
41
@@ -60,7 +61,7 @@ The slices are typed to indicate the contents (zero-terminated, raw bytes, etc)
60
61
61
62
### Enums
62
63
63
-
ziglua uses enums instead of enumerated integer codes to ensure all cases are handled, and to prevent passing an invalid integer type to a function.
64
+
ziglua uses enums instead of integer codes or strings to prevent passing an invalid value to a function.
0 commit comments