Skip to content

Commit 1479dd9

Browse files
committed
refactor: update lua.arith enum with more clear names
Renames idiv -> int_div and unm -> negate for arithmetic operations
1 parent 09516fd commit 1479dd9

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/tests.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,17 @@ test "arithmetic (lua_arith)" {
177177
lua.pushNumber(1);
178178
lua.arith(.add);
179179
lua.pushNumber(2);
180-
lua.arith(.idiv);
180+
lua.arith(.int_div);
181181
try expectEqual(@as(f64, 5), try lua.toNumber(1));
182182

183183
lua.pushNumber(2);
184184
lua.arith(.mod);
185185
try expectEqual(@as(f64, 1), try lua.toNumber(1));
186186

187-
lua.arith(.unm);
187+
lua.arith(.negate);
188188
try expectEqual(@as(f64, -1), try lua.toNumber(1));
189189

190-
lua.arith(.unm);
190+
lua.arith(.negate);
191191
lua.pushNumber(2);
192192
lua.arith(.shl);
193193
try expectEqual(@as(i64, 4), try lua.toInteger(1));

src/ziglua.zig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,15 @@ const Allocator = std.mem.Allocator;
2424
pub const AllocFn = fn (data: ?*anyopaque, ptr: ?*anyopaque, osize: usize, nsize: usize) callconv(.C) ?*anyopaque;
2525

2626
/// Operations supported by `Lua.arith()`
27-
/// TODO: use longer names
2827
pub const ArithOperator = enum(u4) {
2928
add = c.LUA_OPADD,
3029
sub = c.LUA_OPSUB,
3130
mul = c.LUA_OPMUL,
3231
div = c.LUA_OPDIV,
33-
idiv = c.LUA_OPIDIV,
32+
int_div = c.LUA_OPIDIV,
3433
mod = c.LUA_OPMOD,
3534
pow = c.LUA_OPPOW,
36-
unm = c.LUA_OPUNM,
35+
negate = c.LUA_OPUNM,
3736
bnot = c.LUA_OPBNOT,
3837
band = c.LUA_OPBAND,
3938
bor = c.LUA_OPBOR,

0 commit comments

Comments
 (0)