diff options
author | Kevin <[email protected]> | 2024-10-14 10:27:57 -0300 |
---|---|---|
committer | Kevin <[email protected]> | 2024-10-14 10:27:57 -0300 |
commit | 1426fc6df0fa09e1b4ecd54da7e79ba06474e1d5 (patch) | |
tree | ebb624a9e058653891713ed8a6b199b5e31652ea | |
parent | 906e9a30029e4547b73cf5bc566c98bd9198dc0e (diff) |
core: table.unpack compat in lua
-rw-r--r-- | core/lua/astal/application.lua | 13 | ||||
-rw-r--r-- | core/lua/astal/init.lua | 4 | ||||
-rw-r--r-- | core/lua/astal/variable.lua | 11 |
3 files changed, 7 insertions, 21 deletions
diff --git a/core/lua/astal/application.lua b/core/lua/astal/application.lua index 88650a8..663a457 100644 --- a/core/lua/astal/application.lua +++ b/core/lua/astal/application.lua @@ -4,15 +4,6 @@ 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) @@ -84,7 +75,7 @@ function Astal.Application:start(config) app.on_activate = function() if type(config.main) == "function" then - config.main(unpack(arg)) + config.main(table.unpack(arg)) end if config.hold then self:hold() @@ -94,7 +85,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, unpack(arg)) + end, table.unpack(arg)) end self:run(nil) diff --git a/core/lua/astal/init.lua b/core/lua/astal/init.lua index f56c3f5..7befc65 100644 --- a/core/lua/astal/init.lua +++ b/core/lua/astal/init.lua @@ -1,3 +1,7 @@ +if not table.unpack then + table.unpack = unpack +end + local lgi = require("lgi") local Astal = lgi.require("Astal", "0.1") local Gtk = lgi.require("Gtk", "3.0") diff --git a/core/lua/astal/variable.lua b/core/lua/astal/variable.lua index bd95edb..04cdeb2 100644 --- a/core/lua/astal/variable.lua +++ b/core/lua/astal/variable.lua @@ -5,15 +5,6 @@ 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 @@ -282,4 +273,4 @@ return setmetatable(Variable, { __call = function(_, v) return Variable.new(v) end, -}) +})
\ No newline at end of file |