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 {
4699
4699
inline for (info .@"fn" .params , 0.. ) | param , i | {
4700
4700
const param_info = @typeInfo (param .type .? );
4701
4701
//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 ) {
4703
4703
const parsed = lua .toAnyAlloc (param .type .? , (i + 1 )) catch | err | {
4704
4704
lua .raiseErrorStr (@errorName (err ), .{});
4705
4705
};
Original file line number Diff line number Diff line change @@ -2656,6 +2656,10 @@ fn bar(a: i32, b: i32) !i32 {
2656
2656
return a + b ;
2657
2657
}
2658
2658
2659
+ fn baz (a : []const u8 ) usize {
2660
+ return a .len ;
2661
+ }
2662
+
2659
2663
test "autoPushFunction" {
2660
2664
var lua = try Lua .init (testing .allocator );
2661
2665
defer lua .deinit ();
@@ -2667,17 +2671,25 @@ test "autoPushFunction" {
2667
2671
lua .autoPushFunction (bar );
2668
2672
lua .setGlobal ("bar" );
2669
2673
2674
+ lua .autoPushFunction (baz );
2675
+ lua .setGlobal ("baz" );
2676
+
2670
2677
try lua .doString (
2671
2678
\\result = foo(1, 2)
2672
2679
);
2673
2680
try lua .doString (
2674
2681
\\local status, result = pcall(bar, 1, 2)
2675
2682
);
2676
2683
2684
+ try lua .doString (
2685
+ \\result = baz("test")
2686
+ );
2687
+
2677
2688
//automatic api construction
2678
2689
const my_api = .{
2679
2690
.foo = foo ,
2680
2691
.bar = bar ,
2692
+ .baz = baz ,
2681
2693
};
2682
2694
2683
2695
try lua .pushAny (my_api );
You can’t perform that action at this time.
0 commit comments