diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-10-16 22:03:32 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-10-16 22:03:32 +0100 |
commit | e442e6afe51ef2fef9ec06988333756bb6136031 (patch) | |
tree | ddac692b1ccc8943409a4a75339cf4f7f26a7f30 | |
parent | fd9cf022178cbce84d643b38cbe77096319221f5 (diff) | |
download | prosody-e442e6afe51ef2fef9ec06988333756bb6136031.tar.gz prosody-e442e6afe51ef2fef9ec06988333756bb6136031.zip |
util.helpers: Add get_upvalue(function, name) helper
-rw-r--r-- | util/helpers.lua | 9 |
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; |