util.helpers: Add get_upvalue(function, name) helper

This commit is contained in:
Matthew Wild 2009-10-16 22:03:32 +01:00
parent fd9cf02217
commit e442e6afe5

View file

@ -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;