diff options
Diffstat (limited to 'util/helpers.lua')
-rw-r--r-- | util/helpers.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/util/helpers.lua b/util/helpers.lua index 80f72b3b..e69f1d98 100644 --- a/util/helpers.lua +++ b/util/helpers.lua @@ -1,3 +1,10 @@ +-- Prosody IM +-- Copyright (C) 2008-2009 Matthew Wild +-- Copyright (C) 2008-2009 Waqas Hussain +-- +-- This project is MIT/X11 licensed. Please see the +-- COPYING file in the source package for more information. +-- module("helpers", package.seeall); @@ -14,6 +21,7 @@ function log_events(events, name, logger) name = name or tostring(events); function events.fire_event(event, ...) logger("debug", "%s firing event: %s", name, event); + return f(event, ...); end events[events.fire_event] = f; return events; @@ -23,4 +31,13 @@ function revert_log_events(events) events.fire_event, events[events.fire_event] = events[events.fire_event], nil; -- :) end +function get_upvalue(f, get_name) + local i, name, value = 0; + repeat + i = i + 1; + name, value = debug.getupvalue(f, i); + until name == get_name or name == nil; + return value; +end + return _M; |