summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/lua/astal/application.lua13
-rw-r--r--core/lua/astal/variable.lua9
2 files changed, 20 insertions, 2 deletions
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)
diff --git a/core/lua/astal/variable.lua b/core/lua/astal/variable.lua
index 662eee7..bd95edb 100644
--- a/core/lua/astal/variable.lua
+++ b/core/lua/astal/variable.lua
@@ -5,6 +5,15 @@ local Binding = require("astal.binding")
local Time = require("astal.time")
local Process = require("astal.process")
+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
+
---@class Variable
---@field private variable table
---@field private err_handler? function