flickerstreak@1: --[[ flickerstreak@1: Name: AceHook-2.0 flickerstreak@1: Revision: $Rev: 18708 $ flickerstreak@1: Developed by: The Ace Development Team (http://www.wowace.com/index.php/The_Ace_Development_Team) flickerstreak@1: Inspired By: Ace 1.x by Turan (turan@gryphon.com) flickerstreak@1: Website: http://www.wowace.com/ flickerstreak@1: Documentation: http://www.wowace.com/index.php/AceHook-2.0 flickerstreak@1: SVN: http://svn.wowace.com/root/trunk/Ace2/AceHook-2.0 flickerstreak@1: Description: Mixin to allow for safe hooking of functions, methods, and scripts. flickerstreak@1: Dependencies: AceLibrary, AceOO-2.0 flickerstreak@1: ]] flickerstreak@1: flickerstreak@1: local MAJOR_VERSION = "AceHook-2.0" flickerstreak@1: local MINOR_VERSION = "$Revision: 18708 $" flickerstreak@1: flickerstreak@1: -- This ensures the code is only executed if the libary doesn't already exist, or is a newer version flickerstreak@1: if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary.") end flickerstreak@1: if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end flickerstreak@1: flickerstreak@1: local lua51 = loadstring("return function(...) return ... end") and true or false flickerstreak@1: flickerstreak@1: if not AceLibrary:HasInstance("AceOO-2.0") then error(MAJOR_VERSION .. " requires AceOO-2.0") end flickerstreak@1: flickerstreak@1: --[[--------------------------------------------------------------------------------- flickerstreak@1: Create the library object flickerstreak@1: ----------------------------------------------------------------------------------]] flickerstreak@1: flickerstreak@1: local AceOO = AceLibrary:GetInstance("AceOO-2.0") flickerstreak@1: local AceHook = AceOO.Mixin { flickerstreak@1: "Hook", flickerstreak@1: "Unhook", flickerstreak@1: "UnhookAll", flickerstreak@1: "HookReport", flickerstreak@1: "IsHooked", flickerstreak@1: "HookScript", flickerstreak@1: } flickerstreak@1: flickerstreak@1: local table_setn = lua51 and function() end or table.setn flickerstreak@1: flickerstreak@1: if lua51 then flickerstreak@1: AceHook.__deprecated = MAJOR_VERSION .. " is deprecated in WoW 2.0" flickerstreak@1: end flickerstreak@1: flickerstreak@1: --[[--------------------------------------------------------------------------------- flickerstreak@1: Library Definitions flickerstreak@1: ----------------------------------------------------------------------------------]] flickerstreak@1: flickerstreak@1: local protFuncs = { flickerstreak@1: CameraOrSelectOrMoveStart = true, CameraOrSelectOrMoveStop = true, flickerstreak@1: TurnOrActionStart = true, TurnOrActionStop = true, flickerstreak@1: PitchUpStart = true, PitchUpStop = true, flickerstreak@1: PitchDownStart = true, PitchDownStop = true, flickerstreak@1: MoveBackwardStart = true, MoveBackwardStop = true, flickerstreak@1: MoveForwardStart = true, MoveForwardStop = true, flickerstreak@1: Jump = true, StrafeLeftStart = true, flickerstreak@1: StrafeLeftStop = true, StrafeRightStart = true, flickerstreak@1: StrafeRightStop = true, ToggleMouseMove = true, flickerstreak@1: ToggleRun = true, TurnLeftStart = true, flickerstreak@1: TurnLeftStop = true, TurnRightStart = true, flickerstreak@1: TurnRightStop = true, flickerstreak@1: } flickerstreak@1: flickerstreak@1: local _G = getfenv(0) flickerstreak@1: flickerstreak@1: local handlers, funcs, scripts, actives flickerstreak@1: flickerstreak@1: --[[--------------------------------------------------------------------------------- flickerstreak@1: Private definitions (Not exposed) flickerstreak@1: ----------------------------------------------------------------------------------]] flickerstreak@1: flickerstreak@1: --[[---------------------------------------------------------------------- flickerstreak@1: _debug - Internal Method flickerstreak@1: -------------------------------------------------------------------------]] flickerstreak@1: local function print(text) flickerstreak@1: DEFAULT_CHAT_FRAME:AddMessage(text) flickerstreak@1: end flickerstreak@1: flickerstreak@1: local function _debug(self, msg) flickerstreak@1: local name = self.hooks.name flickerstreak@1: if name then flickerstreak@1: print(string.format("[%s]: %s", name, msg)) flickerstreak@1: else flickerstreak@1: print(msg) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local new, del flickerstreak@1: do flickerstreak@1: local list = setmetatable({}, {__mode = "k"}) flickerstreak@1: function new() flickerstreak@1: local t = next(list) flickerstreak@1: if not t then flickerstreak@1: return {} flickerstreak@1: end flickerstreak@1: list[t] = nil flickerstreak@1: return t flickerstreak@1: end flickerstreak@1: flickerstreak@1: function del(t) flickerstreak@1: setmetatable(t, nil) flickerstreak@1: table_setn(t, 0) flickerstreak@1: for k in pairs(t) do flickerstreak@1: t[k] = nil flickerstreak@1: end flickerstreak@1: list[t] = true flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: local origMetatable = { flickerstreak@1: __call = function(self, ...) flickerstreak@1: return self.orig(...) flickerstreak@1: end flickerstreak@1: } flickerstreak@1: flickerstreak@1: --[[---------------------------------------------------------------------- flickerstreak@1: AceHook:_getFunctionHook- internal method flickerstreak@1: -------------------------------------------------------------------------]] flickerstreak@1: flickerstreak@1: local function _getFunctionHook(self, func, handler, orig) flickerstreak@1: if type(handler) == "string" then flickerstreak@1: -- The handler is a method, need to self it flickerstreak@1: return function(...) flickerstreak@1: if actives[orig] then flickerstreak@1: return self[handler](self, ...) flickerstreak@1: else flickerstreak@1: return orig(...) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: else flickerstreak@1: -- The handler is a function, just call it flickerstreak@1: return function(...) flickerstreak@1: if actives[orig] then flickerstreak@1: return handler(...) flickerstreak@1: else flickerstreak@1: return orig(...) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: --[[---------------------------------------------------------------------- flickerstreak@1: AceHook:_getMethodHook - Internal Method flickerstreak@1: -------------------------------------------------------------------------]] flickerstreak@1: local function _getMethodHook(self, object, method, handler, orig, script) flickerstreak@1: if type(handler) == "string" then flickerstreak@1: -- The handler is a method, need to self it flickerstreak@1: if script then flickerstreak@1: return function() flickerstreak@1: if actives[orig] then flickerstreak@1: return self[handler](self, object) flickerstreak@1: else flickerstreak@1: return orig() flickerstreak@1: end flickerstreak@1: end flickerstreak@1: else flickerstreak@1: return function(obj,...) flickerstreak@1: if actives[orig] then flickerstreak@1: return self[handler](self, obj, ...) flickerstreak@1: else flickerstreak@1: return orig(obj, ...) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: else flickerstreak@1: -- The handler is a function, just call it flickerstreak@1: if script then flickerstreak@1: return function() flickerstreak@1: if actives[orig] then flickerstreak@1: return handler(object) flickerstreak@1: else flickerstreak@1: return orig() flickerstreak@1: end flickerstreak@1: end flickerstreak@1: else flickerstreak@1: return function(obj, ...) flickerstreak@1: if actives[orig] then flickerstreak@1: return handler(obj, ...) flickerstreak@1: else flickerstreak@1: return orig(obj, ...) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: --[[---------------------------------------------------------------------- flickerstreak@1: AceHook:HookFunc - internal method. flickerstreak@1: o You can only hook each function once from each source. flickerstreak@1: o If there is an inactive hook for this func/handler pair, we reactivate it flickerstreak@1: o If there is an inactive hook for another handler, we error out. flickerstreak@1: o Looks for handler as a method of the calling class, error if not available flickerstreak@1: o If handler is a function, it just uses it directly through the wrapper flickerstreak@1: -------------------------------------------------------------------------]] flickerstreak@1: local function _hookFunc(self, func, handler) flickerstreak@1: local orig = _G[func] flickerstreak@1: flickerstreak@1: if not orig or type(orig) ~= "function" then flickerstreak@1: _debug(self, string.format("Attempt to hook a non-existant function %q", func),3) flickerstreak@1: return flickerstreak@1: end flickerstreak@1: flickerstreak@1: if not handler then handler = func end flickerstreak@1: flickerstreak@1: if self.hooks[func] then flickerstreak@1: local orig = self.hooks[func].orig flickerstreak@1: -- We have an active hook from this source. Don't multi-hook flickerstreak@1: if actives[orig] then flickerstreak@1: _debug(self, string.format("%q already has an active hook from this source.", func)) flickerstreak@1: return flickerstreak@1: end flickerstreak@1: -- The hook is inactive, so reactivate it flickerstreak@1: if handlers[orig] == handler then flickerstreak@1: actives[orig] = true flickerstreak@1: return flickerstreak@1: else flickerstreak@1: AceHook:error("There is a stale hook for %q can't hook or reactivate.", func) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: if type(handler) == "string" then flickerstreak@1: if type(self[handler]) ~= "function" then flickerstreak@1: AceHook:error("Could not find the the handler %q when hooking function %q", handler, func) flickerstreak@1: end flickerstreak@1: elseif type(handler) ~= "function" then flickerstreak@1: AceHook:error("Could not find the handler you supplied when hooking %q", func) flickerstreak@1: end flickerstreak@1: flickerstreak@1: local t = setmetatable(new(), origMetatable) flickerstreak@1: self.hooks[func] = t flickerstreak@1: t.orig = orig flickerstreak@1: flickerstreak@1: actives[orig] = true flickerstreak@1: handlers[orig] = handler flickerstreak@1: local newFunc = _getFunctionHook(self, func, handler, orig) flickerstreak@1: funcs[orig] = newFunc flickerstreak@1: flickerstreak@1: _G[func] = newFunc flickerstreak@1: end flickerstreak@1: flickerstreak@1: --[[---------------------------------------------------------------------- flickerstreak@1: AceHook:UnhookFunc - internal method flickerstreak@1: o If you attempt to unhook a function that has never been hooked, or to unhook in a flickerstreak@1: system that has never had a hook before, the system will error with a stack trace flickerstreak@1: o If we own the global function, then put the original back in its place and remove flickerstreak@1: all references to the Hooks[func] structure. flickerstreak@1: o If we don't own the global function (we've been hooked) we deactivate the hook, flickerstreak@1: forcing the handler to passthrough. flickerstreak@1: -------------------------------------------------------------------------]] flickerstreak@1: local function _unhookFunc(self, func) flickerstreak@1: if not self.hooks[func] or not funcs[self.hooks[func].orig] then flickerstreak@1: _debug(self, string.format("Tried to unhook %q which is not currently hooked.", func)) flickerstreak@1: return flickerstreak@1: end flickerstreak@1: flickerstreak@1: local orig = self.hooks[func].orig flickerstreak@1: flickerstreak@1: if actives[orig] then flickerstreak@1: -- See if we own the global function flickerstreak@1: if _G[func] == funcs[orig] then flickerstreak@1: _G[func] = orig flickerstreak@1: self.hooks[func] = del(self.hooks[func]) flickerstreak@1: handlers[orig] = nil flickerstreak@1: funcs[orig] = nil flickerstreak@1: scripts[orig] = nil flickerstreak@1: actives[orig] = nil flickerstreak@1: -- Magically all-done flickerstreak@1: else flickerstreak@1: actives[orig] = nil flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: --[[---------------------------------------------------------------------- flickerstreak@1: AceHook:HookMeth - Takes an optional fourth argument flickerstreak@1: o script - Signifies whether this is a script hook or not flickerstreak@1: -------------------------------------------------------------------------]] flickerstreak@1: flickerstreak@1: local function _hookMeth(self, obj, method, handler, script) flickerstreak@1: if not handler then handler = method end flickerstreak@1: if (not obj or type(obj) ~= "table") then flickerstreak@1: AceHook:error("The object you supplied could not be found, or isn't a table.") flickerstreak@1: end flickerstreak@1: flickerstreak@1: if self.hooks[obj] and self.hooks[obj][method] then flickerstreak@1: local orig = self.hooks[obj][method].orig flickerstreak@1: -- We have an active hook from this source. Don't multi-hook flickerstreak@1: if actives[orig] then flickerstreak@1: _debug(self, string.format("%q already has an active hook from this source.", method)) flickerstreak@1: return flickerstreak@1: end flickerstreak@1: -- The hook is inactive, so reactivate it. flickerstreak@1: if handlers[orig] == handler then flickerstreak@1: actives[orig] = true flickerstreak@1: return flickerstreak@1: else flickerstreak@1: AceHook:error("There is a stale hook for %q can't hook or reactivate.", method) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: -- We're clear to try the hook, let's make some checks first flickerstreak@1: if type(handler) == "string" then flickerstreak@1: if type(self[handler]) ~= "function" then flickerstreak@1: AceHook:error("Could not find the handler %q you supplied when hooking method %q", handler, method) flickerstreak@1: end flickerstreak@1: elseif type(handler) ~= "function" then flickerstreak@1: AceHook:error("Could not find the handler you supplied when hooking method %q", method) flickerstreak@1: end flickerstreak@1: -- Handler has been found, so now try to find the method we're trying to hook flickerstreak@1: local orig flickerstreak@1: -- Script flickerstreak@1: if script then flickerstreak@1: if not obj.GetScript then flickerstreak@1: AceHook:error("The object you supplied does not have a GetScript method.") flickerstreak@1: end flickerstreak@1: if not obj:HasScript(method) then flickerstreak@1: AceHook:error("The object you supplied doesn't allow the %q method.", method) flickerstreak@1: end flickerstreak@1: -- Sometimes there is not a original function for a script. flickerstreak@1: orig = obj:GetScript(method) flickerstreak@1: if not orig then flickerstreak@1: orig = function() end flickerstreak@1: end flickerstreak@1: -- Method flickerstreak@1: else flickerstreak@1: orig = obj[method] flickerstreak@1: end flickerstreak@1: if not orig then flickerstreak@1: AceHook:error("Could not find the method or script %q you are trying to hook.", method) flickerstreak@1: end flickerstreak@1: if not self.hooks[obj] then flickerstreak@1: self.hooks[obj] = new() flickerstreak@1: end flickerstreak@1: local t = setmetatable(new(), origMetatable) flickerstreak@1: self.hooks[obj][method] = t flickerstreak@1: t.orig = orig flickerstreak@1: flickerstreak@1: actives[orig] = true flickerstreak@1: handlers[orig] = handler flickerstreak@1: scripts[orig] = script and true or nil flickerstreak@1: local newFunc = _getMethodHook(self, obj, method, handler, orig, script) flickerstreak@1: funcs[orig] = newFunc flickerstreak@1: flickerstreak@1: if script then flickerstreak@1: obj:SetScript(method, newFunc) flickerstreak@1: else flickerstreak@1: obj[method] = newFunc flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: --[[---------------------------------------------------------------------- flickerstreak@1: AceHook:UnhookMeth - Internal method flickerstreak@1: o If you attempt to unhook a method that has never been hooked, or to unhook in a flickerstreak@1: system that has never had a hook before, the system will error with a stack trace flickerstreak@1: o If we own the global method, then put the original back in its place and remove flickerstreak@1: all references to the Hooks[obj][method] structure. flickerstreak@1: o If we don't own the global method (we've been hooked) we deactivate the hook, flickerstreak@1: forcing the handler to passthrough. flickerstreak@1: -------------------------------------------------------------------------]] flickerstreak@1: local function _unhookMeth(self, obj, method) flickerstreak@1: if not self.hooks[obj] or not self.hooks[obj][method] or not funcs[self.hooks[obj][method].orig] then flickerstreak@1: _debug(self, string.format("Attempt to unhook a method %q that is not currently hooked.", method)) flickerstreak@1: return flickerstreak@1: end flickerstreak@1: flickerstreak@1: local orig = self.hooks[obj][method].orig flickerstreak@1: flickerstreak@1: if actives[orig] then flickerstreak@1: -- If this is a script flickerstreak@1: if scripts[orig] then flickerstreak@1: if obj:GetScript(method) == funcs[orig] then flickerstreak@1: -- We own the script. Kill it. flickerstreak@1: obj:SetScript(method, orig) flickerstreak@1: self.hooks[obj][method] = del(self.hooks[obj][method]) flickerstreak@1: handlers[orig] = nil flickerstreak@1: funcs[orig] = nil flickerstreak@1: scripts[orig] = nil flickerstreak@1: actives[orig] = nil flickerstreak@1: else flickerstreak@1: actives[orig] = nil flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if obj[method] == funcs[orig] then flickerstreak@1: -- We own the method. Kill it. flickerstreak@1: obj[method] = orig flickerstreak@1: self.hooks[obj][method] = del(self.hooks[obj][method]) flickerstreak@1: handlers[orig] = nil flickerstreak@1: funcs[orig] = nil flickerstreak@1: scripts[orig] = nil flickerstreak@1: actives[orig] = nil flickerstreak@1: else flickerstreak@1: actives[orig] = nil flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: if not next(self.hooks[obj]) then flickerstreak@1: -- Spank the table flickerstreak@1: self.hooks[obj] = del(self.hooks[obj]) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: function AceHook:OnInstanceInit(object) flickerstreak@1: if not object.hooks then flickerstreak@1: object.hooks = new() flickerstreak@1: end flickerstreak@1: flickerstreak@1: local name flickerstreak@1: flickerstreak@1: if type(rawget(object, 'GetLibraryVersion')) == "function" then flickerstreak@1: name = object:GetLibraryVersion() flickerstreak@1: end flickerstreak@1: if not name and type(object.GetName) == "function" then flickerstreak@1: name = object:GetName() flickerstreak@1: end flickerstreak@1: if not name and type(object.name) == "string" then flickerstreak@1: name = object.name flickerstreak@1: end flickerstreak@1: if not name then flickerstreak@1: for k,v in pairs(_G) do flickerstreak@1: if v == object then flickerstreak@1: name = tostring(k) flickerstreak@1: break flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: object.hooks.name = name flickerstreak@1: end flickerstreak@1: flickerstreak@1: AceHook.OnManualEmbed = AceHook.OnInstanceInit flickerstreak@1: flickerstreak@1: --[[---------------------------------------------------------------------- flickerstreak@1: AceHook:Hook flickerstreak@1: self:Hook("functionName", ["handlerName" | handler]) flickerstreak@1: self:Hook(ObjectName, "Method", ["Handler" | handler]) flickerstreak@1: -------------------------------------------------------------------------]] flickerstreak@1: function AceHook:Hook(arg1, arg2, arg3) flickerstreak@1: if type(arg1)== "string" then flickerstreak@1: if protFuncs[arg1] then flickerstreak@1: if self.hooks.name then flickerstreak@1: AceHook:error("%s tried to hook %q, which is a Blizzard protected function.", self.hooks.name, arg1) flickerstreak@1: else flickerstreak@1: _debug(self, string.format("An Addon tried to hook %q, which is a Blizzard protected function.", arg1)) flickerstreak@1: end flickerstreak@1: else flickerstreak@1: _hookFunc(self, arg1, arg2) flickerstreak@1: end flickerstreak@1: else flickerstreak@1: _hookMeth(self, arg1, arg2, arg3) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: function AceHook:HookScript(arg1, arg2, arg3) flickerstreak@1: _hookMeth(self, arg1, arg2, arg3, true) flickerstreak@1: end flickerstreak@1: flickerstreak@1: --[[---------------------------------------------------------------------- flickerstreak@1: AceHook:IsHooked() flickerstreak@1: self:Hook("functionName") flickerstreak@1: self:Hook(ObjectName, "Method") flickerstreak@1: flickerstreak@1: Returns whether or not the given function is hooked in the current flickerstreak@1: namespace. A hooked, but inactive function is considered NOT flickerstreak@1: hooked in this context. flickerstreak@1: -------------------------------------------------------------------------]] flickerstreak@1: function AceHook:IsHooked(obj, method) flickerstreak@1: if method and obj then flickerstreak@1: if self.hooks and self.hooks[obj] and self.hooks[obj][method] and actives[self.hooks[obj][method].orig] then flickerstreak@1: return true, handlers[self.hooks[obj][method].orig] flickerstreak@1: end flickerstreak@1: else flickerstreak@1: if self.hooks and self.hooks[obj] and actives[self.hooks[obj].orig] then flickerstreak@1: return true, handlers[self.hooks[obj].orig] flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: return false, nil flickerstreak@1: end flickerstreak@1: flickerstreak@1: --[[---------------------------------------------------------------------- flickerstreak@1: AceHook:Unhook flickerstreak@1: self:Unhook("functionName") flickerstreak@1: self:Unhook(ObjectName, "Method") flickerstreak@1: -------------------------------------------------------------------------]] flickerstreak@1: function AceHook:Unhook(arg1, arg2) flickerstreak@1: if type(arg1) == "string" then flickerstreak@1: _unhookFunc(self, arg1) flickerstreak@1: else flickerstreak@1: _unhookMeth(self, arg1, arg2) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: --[[---------------------------------------------------------------------- flickerstreak@1: AceHook:UnhookAll - Unhooks all active hooks from the calling source flickerstreak@1: -------------------------------------------------------------------------]] flickerstreak@1: function AceHook:UnhookAll() flickerstreak@1: for key, value in pairs(self.hooks) do flickerstreak@1: if type(key) == "table" then flickerstreak@1: for method in pairs(value) do flickerstreak@1: self:Unhook(key, method) flickerstreak@1: end flickerstreak@1: else flickerstreak@1: self:Unhook(key) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: flickerstreak@1: function AceHook:OnEmbedDisable(target) flickerstreak@1: self.UnhookAll(target) flickerstreak@1: end flickerstreak@1: flickerstreak@1: --[[---------------------------------------------------------------------- flickerstreak@1: AceHook:HookReport - Lists registered hooks from this source flickerstreak@1: -------------------------------------------------------------------------]] flickerstreak@1: flickerstreak@1: function AceHook:HookReport() flickerstreak@1: _debug(self, "This is a list of all active hooks for this object:") flickerstreak@1: if not self.hooks then _debug(self, "No registered hooks.") return end flickerstreak@1: flickerstreak@1: for key, value in pairs(self.hooks) do flickerstreak@1: if type(value) == "table" then flickerstreak@1: for method in pairs(value) do flickerstreak@1: _debug(self, string.format("key: %s method: %q |cff%s|r", tostring(key), method, self.hooks[key][method].active and "00ff00Active" or "ffff00Inactive")) flickerstreak@1: end flickerstreak@1: else flickerstreak@1: _debug(self, string.format("key: %s value: %q |cff%s|r", tostring(key), tostring(value), self.hooks[key].active and "00ff00Active" or "ffff00Inactive")) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: --[[--------------------------------------------------------------------------------- flickerstreak@1: Stub and Library registration flickerstreak@1: ----------------------------------------------------------------------------------]] flickerstreak@1: flickerstreak@1: local function activate(self, oldLib, oldDeactivate) flickerstreak@1: AceHook = self flickerstreak@1: flickerstreak@1: self.handlers = oldLib and oldLib.handlers or {} flickerstreak@1: self.funcs = oldLib and oldLib.funcs or {} flickerstreak@1: self.scripts = oldLib and oldLib.scripts or {} flickerstreak@1: self.actives = oldLib and oldLib.actives or {} flickerstreak@1: flickerstreak@1: handlers = self.handlers flickerstreak@1: funcs = self.funcs flickerstreak@1: scripts = self.scripts flickerstreak@1: actives = self.actives flickerstreak@1: flickerstreak@1: self:activate(oldLib, oldDeactivate) flickerstreak@1: flickerstreak@1: if oldDeactivate then flickerstreak@1: oldDeactivate(oldLib) flickerstreak@1: end flickerstreak@1: end flickerstreak@1: flickerstreak@1: AceLibrary:Register(AceHook, MAJOR_VERSION, MINOR_VERSION, activate)