From 00abb7d9d32e30a67bc2f7c28aa653781b42edb2 Mon Sep 17 00:00:00 2001 From: Nathan Craddock Date: Sat, 1 Apr 2023 09:08:53 -0600 Subject: [PATCH] fix: argCheck flip boolean check Argcheck was incorrectly checking for `true` rather than `false` for raising an error. --- src/ziglua-5.1/lib.zig | 2 +- src/ziglua-5.1/tests.zig | 2 +- src/ziglua-5.2/lib.zig | 2 +- src/ziglua-5.2/tests.zig | 2 +- src/ziglua-5.3/lib.zig | 2 +- src/ziglua-5.3/tests.zig | 2 +- src/ziglua-5.4/lib.zig | 2 +- src/ziglua-5.4/tests.zig | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ziglua-5.1/lib.zig b/src/ziglua-5.1/lib.zig index 7d89d40..a67576e 100644 --- a/src/ziglua-5.1/lib.zig +++ b/src/ziglua-5.1/lib.zig @@ -1106,7 +1106,7 @@ pub const Lua = struct { /// See https://www.lua.org/manual/5.1/manual.html#luaL_argcheck pub fn argCheck(lua: *Lua, cond: bool, arg: i32, extra_msg: [:0]const u8) void { // translate-c failed - if (cond) lua.argError(arg, extra_msg); + if (!cond) lua.argError(arg, extra_msg); } /// Raises an error reporting a problem with argument `arg` of the C function that called it diff --git a/src/ziglua-5.1/tests.zig b/src/ziglua-5.1/tests.zig index a7ccb10..1938045 100644 --- a/src/ziglua-5.1/tests.zig +++ b/src/ziglua-5.1/tests.zig @@ -1134,7 +1134,7 @@ test "args and errors" { const argCheck = ziglua.wrap(struct { fn inner(l: *Lua) i32 { - l.argCheck(true, 1, "error!"); + l.argCheck(false, 1, "error!"); return 0; } }.inner); diff --git a/src/ziglua-5.2/lib.zig b/src/ziglua-5.2/lib.zig index a618efb..b8860d8 100644 --- a/src/ziglua-5.2/lib.zig +++ b/src/ziglua-5.2/lib.zig @@ -1298,7 +1298,7 @@ pub const Lua = struct { /// See https://www.lua.org/manual/5.2/manual.html#lua_argcheck pub fn argCheck(lua: *Lua, cond: bool, arg: i32, extra_msg: [:0]const u8) void { // translate-c failed - if (cond) lua.argError(arg, extra_msg); + if (!cond) lua.argError(arg, extra_msg); } /// Raises an error reporting a problem with argument `arg` of the C function that called it diff --git a/src/ziglua-5.2/tests.zig b/src/ziglua-5.2/tests.zig index 2808e7c..ff140c9 100644 --- a/src/ziglua-5.2/tests.zig +++ b/src/ziglua-5.2/tests.zig @@ -1274,7 +1274,7 @@ test "args and errors" { const argCheck = ziglua.wrap(struct { fn inner(l: *Lua) i32 { - l.argCheck(true, 1, "error!"); + l.argCheck(false, 1, "error!"); return 0; } }.inner); diff --git a/src/ziglua-5.3/lib.zig b/src/ziglua-5.3/lib.zig index cf48a5d..ffac350 100644 --- a/src/ziglua-5.3/lib.zig +++ b/src/ziglua-5.3/lib.zig @@ -1350,7 +1350,7 @@ pub const Lua = struct { /// See https://www.lua.org/manual/5.3/manual.html#luaL_argcheck pub fn argCheck(lua: *Lua, cond: bool, arg: i32, extra_msg: [:0]const u8) void { // translate-c failed - if (cond) lua.argError(arg, extra_msg); + if (!cond) lua.argError(arg, extra_msg); } /// Raises an error reporting a problem with argument `arg` of the C function that called it diff --git a/src/ziglua-5.3/tests.zig b/src/ziglua-5.3/tests.zig index 6954655..26c9948 100644 --- a/src/ziglua-5.3/tests.zig +++ b/src/ziglua-5.3/tests.zig @@ -1299,7 +1299,7 @@ test "args and errors" { const argCheck = ziglua.wrap(struct { fn inner(l: *Lua) i32 { - l.argCheck(true, 1, "error!"); + l.argCheck(false, 1, "error!"); return 0; } }.inner); diff --git a/src/ziglua-5.4/lib.zig b/src/ziglua-5.4/lib.zig index 2fd17b2..dc89ccd 100644 --- a/src/ziglua-5.4/lib.zig +++ b/src/ziglua-5.4/lib.zig @@ -1387,7 +1387,7 @@ pub const Lua = struct { /// See https://www.lua.org/manual/5.4/manual.html#lua_argcheck pub fn argCheck(lua: *Lua, cond: bool, arg: i32, extra_msg: [:0]const u8) void { // translate-c failed - if (cond) lua.argError(arg, extra_msg); + if (!cond) lua.argError(arg, extra_msg); } /// Raises an error reporting a problem with argument `arg` of the C function that called it diff --git a/src/ziglua-5.4/tests.zig b/src/ziglua-5.4/tests.zig index 60714fd..5a4ba4d 100644 --- a/src/ziglua-5.4/tests.zig +++ b/src/ziglua-5.4/tests.zig @@ -1384,7 +1384,7 @@ test "args and errors" { const argCheck = ziglua.wrap(struct { fn inner(l: *Lua) i32 { - l.argCheck(true, 1, "error!"); + l.argCheck(false, 1, "error!"); return 0; } }.inner);