Skip to content

Commit 7bfb3c2

Browse files
authored
Merge pull request #140 from natecraddock/readme-changes
readme: change dependency name from ziglua to lua_wrapper
2 parents 70cf5b7 + 13b778b commit 7bfb3c2

File tree

8 files changed

+205
-205
lines changed

8 files changed

+205
-205
lines changed

build.zig

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ pub fn build(b: *Build) void {
2424
}
2525

2626
// Zig module
27-
const ziglua = b.addModule("ziglua", .{
27+
const lua_wrapper = b.addModule("lua_wrapper", .{
2828
.root_source_file = b.path("src/lib.zig"),
2929
});
3030

3131
// Expose build configuration to the ziglua module
3232
const config = b.addOptions();
3333
config.addOption(Language, "lang", lang);
3434
config.addOption(bool, "luau_use_4_vector", luau_use_4_vector);
35-
ziglua.addOptions("config", config);
35+
lua_wrapper.addOptions("config", config);
3636

3737
if (lang == .luau) {
3838
const vector_size: usize = if (luau_use_4_vector) 4 else 3;
39-
ziglua.addCMacro("LUA_VECTOR_SIZE", b.fmt("{}", .{vector_size}));
39+
lua_wrapper.addCMacro("LUA_VECTOR_SIZE", b.fmt("{}", .{vector_size}));
4040
}
4141

4242
const upstream = b.dependency(@tagName(lang), .{});
@@ -53,15 +53,15 @@ pub fn build(b: *Build) void {
5353

5454
switch (lang) {
5555
.luau => {
56-
ziglua.addIncludePath(upstream.path("Common/include"));
57-
ziglua.addIncludePath(upstream.path("Compiler/include"));
58-
ziglua.addIncludePath(upstream.path("Ast/include"));
59-
ziglua.addIncludePath(upstream.path("VM/include"));
56+
lua_wrapper.addIncludePath(upstream.path("Common/include"));
57+
lua_wrapper.addIncludePath(upstream.path("Compiler/include"));
58+
lua_wrapper.addIncludePath(upstream.path("Ast/include"));
59+
lua_wrapper.addIncludePath(upstream.path("VM/include"));
6060
},
61-
else => ziglua.addIncludePath(upstream.path("src")),
61+
else => lua_wrapper.addIncludePath(upstream.path("src")),
6262
}
6363

64-
ziglua.linkLibrary(lib);
64+
lua_wrapper.linkLibrary(lib);
6565

6666
// lib must expose all headers included by these root headers
6767
const c_header_path = switch (lang) {
@@ -84,15 +84,15 @@ pub fn build(b: *Build) void {
8484
.link_libc = c_headers.link_libc,
8585
});
8686

87-
ziglua.addImport("c", ziglua_c);
87+
lua_wrapper.addImport("c", ziglua_c);
8888

8989
// Tests
9090
const tests = b.addTest(.{
9191
.root_source_file = b.path("src/tests.zig"),
9292
.target = target,
9393
.optimize = optimize,
9494
});
95-
tests.root_module.addImport("ziglua", ziglua);
95+
tests.root_module.addImport("lua_wrapper", lua_wrapper);
9696

9797
const run_tests = b.addRunArtifact(tests);
9898
const test_step = b.step("test", "Run ziglua tests");
@@ -115,7 +115,7 @@ pub fn build(b: *Build) void {
115115
.target = target,
116116
.optimize = optimize,
117117
});
118-
exe.root_module.addImport("ziglua", ziglua);
118+
exe.root_module.addImport("lua_wrapper", lua_wrapper);
119119

120120
const artifact = b.addInstallArtifact(exe, .{});
121121
const exe_step = b.step(b.fmt("install-example-{s}", .{example[0]}), b.fmt("Install {s} example", .{example[0]}));
@@ -151,7 +151,7 @@ pub fn build(b: *Build) void {
151151
.name = "define-zig-types",
152152
.target = target,
153153
});
154-
def_exe.root_module.addImport("ziglua", ziglua);
154+
def_exe.root_module.addImport("lua_wrapper", lua_wrapper);
155155
var run_def_exe = b.addRunArtifact(def_exe);
156156
run_def_exe.addFileArg(b.path("definitions.lua"));
157157

examples/define-exe.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const std = @import("std");
2-
const ziglua = @import("ziglua");
2+
const lua_wrapper = @import("lua_wrapper");
33

44
const T = struct { foo: i32 };
55
const MyEnum = enum { asdf, fdsa, qwer, rewq };
@@ -10,5 +10,5 @@ const Foo = struct { far: MyEnum, near: SubType };
1010

1111
pub fn main() !void {
1212
const output_file_path = std.mem.sliceTo(std.os.argv[1], 0);
13-
try ziglua.define(std.heap.c_allocator, output_file_path, &.{ T, TestType, Foo });
13+
try lua_wrapper.define(std.heap.c_allocator, output_file_path, &.{ T, TestType, Foo });
1414
}

examples/interpreter.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
const std = @import("std");
55

6-
// The ziglua module is made available in build.zig
7-
const ziglua = @import("ziglua");
6+
// The lua_wrapper module is made available in build.zig
7+
const lua_wrapper = @import("lua_wrapper");
88

99
pub fn main() anyerror!void {
1010
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
@@ -14,7 +14,7 @@ pub fn main() anyerror!void {
1414
// Initialize The Lua vm and get a reference to the main thread
1515
//
1616
// Passing a Zig allocator to the Lua state requires a stable pointer
17-
var lua = try ziglua.Lua.init(allocator);
17+
var lua = try lua_wrapper.Lua.init(allocator);
1818
defer lua.deinit();
1919

2020
// Open all Lua standard libraries

examples/luau-bytecode.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
const std = @import("std");
1010

11-
// The ziglua module is made available in build.zig
12-
const ziglua = @import("ziglua");
11+
// The lua_wrapper module is made available in build.zig
12+
const lua_wrapper = @import("lua_wrapper");
1313

1414
pub fn main() anyerror!void {
1515
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
@@ -19,15 +19,15 @@ pub fn main() anyerror!void {
1919
// Initialize The Lua vm and get a reference to the main thread
2020
//
2121
// Passing a Zig allocator to the Lua state requires a stable pointer
22-
var lua = try ziglua.Lua.init(allocator);
22+
var lua = try lua_wrapper.Lua.init(allocator);
2323
defer lua.deinit();
2424

2525
// Open all Lua standard libraries
2626
lua.openLibs();
2727

2828
// Load bytecode
2929
const src = @embedFile("./test.luau");
30-
const bc = try ziglua.compile(allocator, src, ziglua.CompileOptions{});
30+
const bc = try lua_wrapper.compile(allocator, src, lua_wrapper.CompileOptions{});
3131
defer allocator.free(bc);
3232

3333
try lua.loadBytecode("...", bc);

examples/zig-fn.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! Registering a Zig function to be called from Lua
22

33
const std = @import("std");
4-
const ziglua = @import("ziglua");
4+
const lua_wrapper = @import("lua_wrapper");
55

66
// It can be convenient to store a short reference to the Lua struct when
77
// it is used multiple times throughout a file.
8-
const Lua = ziglua.Lua;
8+
const Lua = lua_wrapper.Lua;
99

1010
// A Zig function called by Lua must accept a single *Lua parameter and must return an i32 (an error union is allowed)
1111
// This is the Zig equivalent of the lua_CFunction typedef int (*lua_CFunction) (lua_State *L) in the C API
@@ -26,10 +26,10 @@ pub fn main() anyerror!void {
2626
defer lua.deinit();
2727

2828
// Push the adder function to the Lua stack.
29-
// Here we use ziglua.wrap() to convert from a Zig function to the lua_CFunction required by Lua.
29+
// Here we use lua_wrapper.wrap() to convert from a Zig function to the lua_CFunction required by Lua.
3030
// This could be done automatically by pushFunction(), but that would require the parameter to be comptime-known.
31-
// The call to ziglua.wrap() is slightly more verbose, but has the benefit of being more flexible.
32-
lua.pushFunction(ziglua.wrap(adder));
31+
// The call to lua_wrapper.wrap() is slightly more verbose, but has the benefit of being more flexible.
32+
lua.pushFunction(lua_wrapper.wrap(adder));
3333

3434
// Push the arguments onto the stack
3535
lua.pushInteger(10);
@@ -47,7 +47,7 @@ pub fn main() anyerror!void {
4747
std.debug.print("the result: {}\n", .{lua.toInteger(-1) catch unreachable});
4848

4949
// We can also register the function to a global and run from a Lua "program"
50-
lua.pushFunction(ziglua.wrap(adder));
50+
lua.pushFunction(lua_wrapper.wrap(adder));
5151
lua.setGlobal("add");
5252

5353
// We need to open the base library so the global print() is available

readme.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ Then in your `build.zig` file you can use the dependency.
4646
pub fn build(b: *std.Build) void {
4747
// ... snip ...
4848
49-
const ziglua = b.dependency("ziglua", .{
49+
const lua_dep = b.dependency("lua_wrapper", .{
5050
.target = target,
5151
.optimize = optimize,
5252
});
5353
5454
// ... snip ...
5555
56-
// add the ziglua module and lua artifact
57-
exe.root_module.addImport("ziglua", ziglua.module("ziglua"));
56+
// add the lua_wrapper module and lua artifact
57+
exe.root_module.addImport("lua_wrapper", lua_dep.module("lua_wrapper"));
5858
5959
}
6060
```
@@ -70,21 +70,21 @@ There are currently three additional options that can be passed to `b.dependency
7070
For example, here is a `b.dependency()` call that and links against a shared Lua 5.2 library:
7171

7272
```zig
73-
const ziglua = b.dependency("ziglua", .{
73+
const lua_wrapper = b.dependency("lua_wrapper", .{
7474
.target = target,
7575
.optimize = optimize,
7676
.lang = .lua52,
7777
.shared = true,
7878
});
7979
``````
8080
81-
The `ziglua` module will now be available in your code. Here is a simple example that pushes and inspects an integer on the Lua stack:
81+
The `lua_wrapper` module will now be available in your code. Here is a simple example that pushes and inspects an integer on the Lua stack:
8282
8383
```zig
8484
const std = @import("std");
85-
const ziglua = @import("ziglua");
85+
const lua_wrapper = @import("lua_wrapper");
8686
87-
const Lua = ziglua.Lua;
87+
const Lua = lua_wrapper.Lua;
8888
8989
pub fn main() anyerror!void {
9090
// Create an allocator

src/lib.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Similar to the Lua C API documentation, each function has an indicator to describe how interacts with the stack and which errors it may return.
22
//!
3-
//! Instead of using the form `[-o, +p, x]`, Ziglua uses the words **Pops**, **Pushes**, and **Errors** for clarity.
3+
//! Instead of using the form `[-o, +p, x]`, Lua_wrapper uses the words **Pops**, **Pushes**, and **Errors** for clarity.
44
//!
55
//! * **Pops**: how many elements the function pops from the stack.
66
//! * **Pushes**: how many elements the function pushes onto the stack.
@@ -302,7 +302,7 @@ pub const DebugInfo = switch (lang) {
302302
.luau => DebugInfoLuau,
303303
};
304304

305-
/// The superset of all errors returned from ziglua
305+
/// The superset of all errors returned from lua_wrapper
306306
pub const Error = error{
307307
/// A generic failure (used when a function can only fail in one way)
308308
LuaError,
@@ -750,7 +750,7 @@ pub const Lua = opaque {
750750
/// * Finally you call `Lua.call()`
751751
/// * `args.args` is the number of arguments that you pushed onto the stack. When the function returns, all arguments and
752752
/// the function value are popped and the call results are pushed onto the stack.
753-
/// * The number of results is adjusted to `args.results`, unless `args.results` is `ziglua.mult_return`. In this case, all results from the function are pushed
753+
/// * The number of results is adjusted to `args.results`, unless `args.results` is `lua_wrapper.mult_return`. In this case, all results from the function are pushed
754754
/// * Lua takes care that the returned values fit into the stack space, but it does not ensure any extra space in the stack. The function results
755755
/// are pushed onto the stack in direct order (the first result is pushed first), so that after the call the last result is
756756
/// on the top of the stack.
@@ -4903,7 +4903,7 @@ pub const Buffer = struct {
49034903
}
49044904
};
49054905

4906-
// Helper functions to make the ziglua API easier to use
4906+
// Helper functions to make the lua_wrapper API easier to use
49074907

49084908
const Tuple = std.meta.Tuple;
49094909

0 commit comments

Comments
 (0)