mirror of
https://github.com/MezzalunaWM/Mezzaluna.git
synced 2026-03-09 13:07:32 -04:00
clean up lua stuff a bit and add mez.inspect
This commit is contained in:
parent
1f2e333846
commit
ec8b86cbb7
6 changed files with 698 additions and 309 deletions
|
|
@ -1,25 +1,25 @@
|
|||
const Bridge = @This();
|
||||
|
||||
const std = @import("std");
|
||||
const Lua = @import("Lua.zig");
|
||||
const zlua = @import("zlua");
|
||||
|
||||
const gpa = std.heap.c_allocator;
|
||||
|
||||
pub fn getNestedField(L: *Lua, path: []u8) bool {
|
||||
pub fn getNestedField(L: *zlua.Lua, path: []u8) bool {
|
||||
var tokens = std.mem.tokenizeScalar(u8, path, '.');
|
||||
var first = true;
|
||||
|
||||
while (tokens.next()) |token| {
|
||||
const tok = gpa.dupeZ(u8, token) catch return false;
|
||||
if (first) {
|
||||
_ = L.state.getGlobal(tok) catch return false;
|
||||
_ = L.getGlobal(tok) catch return false;
|
||||
first = false;
|
||||
} else {
|
||||
_ = L.state.getField(-1, tok);
|
||||
L.state.remove(-2);
|
||||
_ = L.getField(-1, tok);
|
||||
L.remove(-2);
|
||||
}
|
||||
|
||||
if (L.state.isNil(-1)) {
|
||||
if (L.isNil(-1)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue