an experimental irc client

lua: expose channel:mark_read in lua api

+13
+13
src/lua.zig
··· 420 420 const fns = [_]ziglua.FnReg{ 421 421 .{ .name = "send_msg", .func = ziglua.wrap(Channel.sendMsg) }, 422 422 .{ .name = "name", .func = ziglua.wrap(Channel.name) }, 423 + .{ .name = "mark_read", .func = ziglua.wrap(Channel.markRead) }, 423 424 }; 424 425 lua.newLibTable(&fns); // [table] 425 426 lua.setFuncs(&fns, 0); // [table] ··· 463 464 lua.pop(2); // [] 464 465 _ = lua.pushString(channel.name); // [string] 465 466 return 1; 467 + } 468 + 469 + fn markRead(lua: *Lua) i32 { 470 + lua.argCheck(lua.isTable(1), 1, "expected a table"); // [table] 471 + const lua_type = lua.getField(1, "_ptr"); // [table, lightuserdata] 472 + lua.argCheck(lua_type == .light_userdata, 2, "expected lightuserdata"); 473 + const channel = lua.toUserdata(irc.Channel, 2) catch unreachable; 474 + channel.markRead() catch |err| { 475 + std.log.err("couldn't mark channel as read: {}", .{err}); 476 + }; 477 + lua.pop(2); // [] 478 + return 0; 466 479 } 467 480 }; 468 481