/tags/8.0.002/InFlight/libs/LibSharedMedia-3.0
------------------------------------------------------------------------ |
r104 | funkydude | 2018-07-21 16:34:03 +0000 (Sat, 21 Jul 2018) | 1 line |
Changed paths: |
M /trunk/CallbackHandler-1.0/CallbackHandler-1.0.lua |
Update CallbackHandler embed. |
------------------------------------------------------------------------ |
--[[ $Id: CallbackHandler-1.0.lua 14 2010-08-09 00:43:38Z mikk $ ]] |
local MAJOR, MINOR = "CallbackHandler-1.0", 6 |
--[[ $Id: CallbackHandler-1.0.lua 1186 2018-07-21 14:19:18Z nevcairiel $ ]] |
local MAJOR, MINOR = "CallbackHandler-1.0", 7 |
local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR) |
if not CallbackHandler then return end -- No upgrade needed |
return geterrorhandler()(err) |
end |
local function CreateDispatcher(argCount) |
local code = [[ |
local next, xpcall, eh = ... |
local method, ARGS |
local function call() method(ARGS) end |
local function dispatch(handlers, ...) |
local index |
index, method = next(handlers) |
if not method then return end |
local OLD_ARGS = ARGS |
ARGS = ... |
repeat |
xpcall(call, eh) |
index, method = next(handlers, index) |
until not method |
ARGS = OLD_ARGS |
end |
return dispatch |
]] |
local ARGS, OLD_ARGS = {}, {} |
for i = 1, argCount do ARGS[i], OLD_ARGS[i] = "arg"..i, "old_arg"..i end |
code = code:gsub("OLD_ARGS", tconcat(OLD_ARGS, ", ")):gsub("ARGS", tconcat(ARGS, ", ")) |
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(next, xpcall, errorhandler) |
local function Dispatch(handlers, ...) |
local index, method = next(handlers) |
if not method then return end |
repeat |
xpcall(method, errorhandler, ...) |
index, method = next(handlers, index) |
until not method |
end |
local Dispatchers = setmetatable({}, {__index=function(self, argCount) |
local dispatcher = CreateDispatcher(argCount) |
rawset(self, argCount, dispatcher) |
return dispatcher |
end}) |
-------------------------------------------------------------------------- |
-- CallbackHandler:New |
-- |
-- UnregisterName - name of the callback unregistration API, default "UnregisterCallback" |
-- UnregisterAllName - name of the API to unregister all callbacks, default "UnregisterAllCallbacks". false == don't publish this API. |
function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAllName, OnUsed, OnUnused) |
-- TODO: Remove this after beta has gone out |
assert(not OnUsed and not OnUnused, "ACE-80: OnUsed/OnUnused are deprecated. Callbacks are now done to registry.OnUsed and registry.OnUnused") |
function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAllName) |
RegisterName = RegisterName or "RegisterCallback" |
UnregisterName = UnregisterName or "UnregisterCallback" |
local oldrecurse = registry.recurse |
registry.recurse = oldrecurse + 1 |
Dispatchers[select('#', ...) + 1](events[eventname], eventname, ...) |
Dispatch(events[eventname], eventname, ...) |
registry.recurse = oldrecurse |
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ |
..\FrameXML\UI.xsd"> |
<Script file="LibSharedMedia-3.0.lua" /> |
</Ui> |
## Interface: 70100 |
## Interface: 80000 |
## LoadOnDemand: 1 |
## X-Curse-Packaged-Version: 7.1.0 |
## X-Curse-Project-Name: LibSharedMedia-3.0 |
## X-Curse-Project-ID: libsharedmedia-3-0 |
## X-Curse-Repository-ID: wow/libsharedmedia-3-0/mainline |
## Title: Lib: SharedMedia-3.0 |
## Notes: Shared handling of media data (fonts, sounds, textures, ...) between addons. |
## Author: Elkano |
## Version: 3.0-97 |
## Version: 3.0-104 |
## X-Website: http://www.wowace.com/projects/libsharedmedia-3-0/ |
## X-Category: Library |
## X-Revision: 97 |
## X-Date: 2016-10-25T23:54:36Z |
## X-Revision: 104 |
## X-Date: 2018-07-21T16:34:03Z |
LibStub\LibStub.lua |
CallbackHandler-1.0\CallbackHandler-1.0.lua |