Skip to content

Commit d3b9528

Browse files
challengeenatecraddock
authored andcommitted
fix pushAutoFunction to use lowercased pointer size
This was changed in commit ziglang/zig@af6bad4
1 parent 320a91c commit d3b9528

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/lib.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4699,7 +4699,7 @@ pub const Lua = opaque {
46994699
inline for (info.@"fn".params, 0..) |param, i| {
47004700
const param_info = @typeInfo(param.type.?);
47014701
//only use the overhead of creating the arena allocator if needed
4702-
if (comptime param_info == .pointer and param_info.pointer.size != .One) {
4702+
if (comptime param_info == .pointer and param_info.pointer.size != .one) {
47034703
const parsed = lua.toAnyAlloc(param.type.?, (i + 1)) catch |err| {
47044704
lua.raiseErrorStr(@errorName(err), .{});
47054705
};

src/tests.zig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2656,6 +2656,10 @@ fn bar(a: i32, b: i32) !i32 {
26562656
return a + b;
26572657
}
26582658

2659+
fn baz(a: []const u8) usize {
2660+
return a.len;
2661+
}
2662+
26592663
test "autoPushFunction" {
26602664
var lua = try Lua.init(testing.allocator);
26612665
defer lua.deinit();
@@ -2667,17 +2671,25 @@ test "autoPushFunction" {
26672671
lua.autoPushFunction(bar);
26682672
lua.setGlobal("bar");
26692673

2674+
lua.autoPushFunction(baz);
2675+
lua.setGlobal("baz");
2676+
26702677
try lua.doString(
26712678
\\result = foo(1, 2)
26722679
);
26732680
try lua.doString(
26742681
\\local status, result = pcall(bar, 1, 2)
26752682
);
26762683

2684+
try lua.doString(
2685+
\\result = baz("test")
2686+
);
2687+
26772688
//automatic api construction
26782689
const my_api = .{
26792690
.foo = foo,
26802691
.bar = bar,
2692+
.baz = baz,
26812693
};
26822694

26832695
try lua.pushAny(my_api);

0 commit comments

Comments
 (0)