mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-07 19:49:53 -05:00
switch to luajit
This commit is contained in:
parent
7537778e23
commit
da4629a871
5 changed files with 33 additions and 13 deletions
|
|
@ -24,3 +24,22 @@ pub fn coerceInteger(comptime x: type, number: zlua.Integer) error{InvalidIntege
|
|||
else => @compileError("unsupported type"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn newLib(L: *zlua.Lua, f: []const zlua.FnReg) void {
|
||||
L.newLibTable(f); // documented as being unavailable, but it is.
|
||||
for (f) |value| {
|
||||
if (value.func == null) continue;
|
||||
L.pushClosure(value.func.?, 0);
|
||||
L.setField(-2, value.name);
|
||||
}
|
||||
}
|
||||
|
||||
/// makes a best effort to convert the value at the top of the stack to a string
|
||||
/// if we're unable to do so return "nil"
|
||||
pub fn toStringEx(L: *zlua.Lua) [:0]const u8 {
|
||||
const errstr = "nil";
|
||||
_ = L.getGlobal("tostring") catch return errstr;
|
||||
L.insert(1);
|
||||
L.protectedCall(.{ .args = 1, .results = 1 }) catch return errstr;
|
||||
return L.toString(-1) catch errstr;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue