File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff 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 };
Original file line number Diff line number Diff 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+
26592663test "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 );
You can’t perform that action at this time.
0 commit comments