From 18df91b128f6ca8850e39cb53b8536a8207e1741 Mon Sep 17 00:00:00 2001 From: Kevin Date: Sun, 13 Oct 2024 12:57:37 -0300 Subject: core: lua compat 5.1/5.4/luajit --- core/lua/astal/application.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'core/lua/astal/application.lua') diff --git a/core/lua/astal/application.lua b/core/lua/astal/application.lua index 663a457..88650a8 100644 --- a/core/lua/astal/application.lua +++ b/core/lua/astal/application.lua @@ -4,6 +4,15 @@ local Astal = lgi.require("Astal", "0.1") local AstalLua = Astal.Application:derive("AstalLua") local request_handler +local function unpack(t, i) + i = i or 1 + if t[i] == nil then + return nil + else + return t[i], unpack(t, i + 1) + end +end + function AstalLua:do_request(msg, conn) if type(request_handler) == "function" then request_handler(msg, function(response) @@ -75,7 +84,7 @@ function Astal.Application:start(config) app.on_activate = function() if type(config.main) == "function" then - config.main(table.unpack(arg)) + config.main(unpack(arg)) end if config.hold then self:hold() @@ -85,7 +94,7 @@ function Astal.Application:start(config) if not app:acquire_socket() then return config.client(function(msg) return Astal.Application.send_message(self.instance_name, msg) - end, table.unpack(arg)) + end, unpack(arg)) end self:run(nil) -- cgit v1.2.3