aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-10-16 22:03:32 +0100
committerMatthew Wild <mwild1@gmail.com>2009-10-16 22:03:32 +0100
commite442e6afe51ef2fef9ec06988333756bb6136031 (patch)
treeddac692b1ccc8943409a4a75339cf4f7f26a7f30 /util
parentfd9cf022178cbce84d643b38cbe77096319221f5 (diff)
downloadprosody-e442e6afe51ef2fef9ec06988333756bb6136031.tar.gz
prosody-e442e6afe51ef2fef9ec06988333756bb6136031.zip
util.helpers: Add get_upvalue(function, name) helper
Diffstat (limited to 'util')
-rw-r--r--util/helpers.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/util/helpers.lua b/util/helpers.lua
index c8434794..49540c21 100644
--- a/util/helpers.lua
+++ b/util/helpers.lua
@@ -24,4 +24,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;