Software /
code /
prosody
Comparison
core/moduleapi.lua @ 5900:cb1103423aa7
core.moduleapi: Fix some global accesses.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Wed, 06 Nov 2013 14:38:51 -0500 |
parent | 5899:26f54b462601 |
child | 6168:3942630b4e35 |
comparison
equal
deleted
inserted
replaced
5899:26f54b462601 | 5900:cb1103423aa7 |
---|---|
14 local pluginloader = require "util.pluginloader"; | 14 local pluginloader = require "util.pluginloader"; |
15 local timer = require "util.timer"; | 15 local timer = require "util.timer"; |
16 | 16 |
17 local t_insert, t_remove, t_concat = table.insert, table.remove, table.concat; | 17 local t_insert, t_remove, t_concat = table.insert, table.remove, table.concat; |
18 local error, setmetatable, type = error, setmetatable, type; | 18 local error, setmetatable, type = error, setmetatable, type; |
19 local ipairs, pairs, select, unpack = ipairs, pairs, select, unpack; | 19 local ipairs, pairs, select = ipairs, pairs, select; |
20 local tonumber, tostring = tonumber, tostring; | 20 local tonumber, tostring = tonumber, tostring; |
21 local pack = table.pack or function(...) return {n=select("#",...), ...}; end -- table.pack is only in 5.2 | |
22 local unpack = table.unpack or unpack; -- renamed in 5.2 | |
21 | 23 |
22 local prosody = prosody; | 24 local prosody = prosody; |
23 local hosts = prosody.hosts; | 25 local hosts = prosody.hosts; |
24 | 26 |
25 -- FIXME: This assert() is to try and catch an obscure bug (2013-04-05) | 27 -- FIXME: This assert() is to try and catch an obscure bug (2013-04-05) |
362 local function timer_callback(now, id, t) | 364 local function timer_callback(now, id, t) |
363 if t.module_env.loaded == false then return; end | 365 if t.module_env.loaded == false then return; end |
364 return t.callback(now, unpack(t, 1, t.n)); | 366 return t.callback(now, unpack(t, 1, t.n)); |
365 end | 367 end |
366 | 368 |
367 local pack = table.pack or function(...) return {n=select("#",...), ...}; end | |
368 function api:add_timer(delay, callback, ...) | 369 function api:add_timer(delay, callback, ...) |
369 local t = pack(...) | 370 local t = pack(...) |
370 t.module_env = self; | 371 t.module_env = self; |
371 t.callback = callback; | 372 t.callback = callback; |
372 t.id = timer.add_task(delay, timer_callback, t); | 373 t.id = timer.add_task(delay, timer_callback, t); |