Skip to content

Commit 320a91c

Browse files
robbielymannatecraddock
authored andcommitted
fix(examples): lua_wrapper -> zlua in examples
1 parent df26065 commit 320a91c

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

examples/define-exe.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const std = @import("std");
2-
const lua_wrapper = @import("lua_wrapper");
2+
const zlua = @import("zlua");
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 lua_wrapper.define(std.heap.c_allocator, output_file_path, &.{ T, TestType, Foo });
13+
try zlua.define(std.heap.c_allocator, output_file_path, &.{ T, TestType, Foo });
1414
}

examples/interpreter.zig

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

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

6-
// The lua_wrapper module is made available in build.zig
7-
const lua_wrapper = @import("lua_wrapper");
6+
// The zlua module is made available in build.zig
7+
const zlua = @import("zlua");
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 lua_wrapper.Lua.init(allocator);
17+
var lua = try zlua.Lua.init(allocator);
1818
defer lua.deinit();
1919

2020
// Open all Lua standard libraries

examples/luau-bytecode.zig

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

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

11-
// The lua_wrapper module is made available in build.zig
12-
const lua_wrapper = @import("lua_wrapper");
11+
// The zlua module is made available in build.zig
12+
const zlua = @import("zlua");
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 lua_wrapper.Lua.init(allocator);
22+
var lua = try zlua.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 lua_wrapper.compile(allocator, src, lua_wrapper.CompileOptions{});
30+
const bc = try zlua.compile(allocator, src, zlua.CompileOptions{});
3131
defer allocator.free(bc);
3232

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

examples/zig-fn.zig

+6-6
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 lua_wrapper = @import("lua_wrapper");
4+
const zlua = @import("zlua");
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 = lua_wrapper.Lua;
8+
const Lua = zlua.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 lua_wrapper.wrap() to convert from a Zig function to the lua_CFunction required by Lua.
29+
// Here we use zlua.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 lua_wrapper.wrap() is slightly more verbose, but has the benefit of being more flexible.
32-
lua.pushFunction(lua_wrapper.wrap(adder));
31+
// The call to zlua.wrap() is slightly more verbose, but has the benefit of being more flexible.
32+
lua.pushFunction(zlua.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(lua_wrapper.wrap(adder));
50+
lua.pushFunction(zlua.wrap(adder));
5151
lua.setGlobal("add");
5252

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

0 commit comments

Comments
 (0)