[NTG-context] callback.register

Wolfgang Werners-Lucchini wwl at musensturm.de
Fri Apr 9 20:11:05 CEST 2010


> Hello,
> 
> Here a patch for luat-cbk.lua:
> 
> function callbacks.register(name,func,freeze)
>     if frozen[name] then
>         if trace_callbacks then
>             frozenmessage("registering",name)
>         end
>         return nil, name .. " is frozen"
>     elseif freeze then
>         frozen[name] = (type(freeze) == "string" and freeze) or
> "registered"
>         return register_callback(name,func)
>     else
>         return register_callback(name,func)
>     end
> end
> 
> function callback.register(name,func) -- original
>     if frozen[name] then
>         if trace_callbacks then
>             frozenmessage("registering",name)
>         end
>         return nil, name .. " is frozen"
>     else
>         return register_callback(name,func)
>     end
> end
> 
> (Untested...)
> 
> Cheers, Peter

and

function callbacks.report()
    local list = callback.list()
    for name, func in table.sortedpairs(list) do
        local str = frozen[name]
        if str then
            logs.report("callbacks","%s: %s -> 
%s",state(name),name,str)
        else
            logs.report("callbacks","%s: %s",state(name),name)
        end
    end
end

Wolfgang


More information about the ntg-context mailing list