Mercurial > wow > reaction
changeset 29:9c89042bc328
deleting local copies of libraries that should be externals
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Wed, 02 Apr 2008 18:22:02 +0000 |
parents | 21bcaf8215ff |
children | 0d95ce7a9ec2 |
files | lib/AceAddon-3.0/AceAddon-3.0.lua lib/AceAddon-3.0/AceAddon-3.0.xml lib/AceDB-3.0/AceDB-3.0.lua lib/AceDB-3.0/AceDB-3.0.xml lib/AceEvent-3.0/AceEvent-3.0.lua lib/AceEvent-3.0/AceEvent-3.0.xml lib/AceLocale-3.0/AceLocale-3.0.lua lib/AceLocale-3.0/AceLocale-3.0.xml lib/CallbackHandler-1.0/CallbackHandler-1.0.lua lib/CallbackHandler-1.0/CallbackHandler-1.0.xml lib/LibStub/LibStub.lua |
diffstat | 11 files changed, 0 insertions(+), 1347 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/AceAddon-3.0/AceAddon-3.0.lua Mon Mar 17 18:24:53 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,412 +0,0 @@ ---[[ $Id: AceAddon-3.0.lua 63220 2008-02-29 11:29:58Z nevcairiel $ ]] -local MAJOR, MINOR = "AceAddon-3.0", 3 -local AceAddon, oldminor = LibStub:NewLibrary(MAJOR, MINOR) - -if not AceAddon then return end -- No Upgrade needed. - -AceAddon.frame = AceAddon.frame or CreateFrame("Frame", "AceAddon30Frame") -- Our very own frame -AceAddon.addons = AceAddon.addons or {} -- addons in general -AceAddon.statuses = AceAddon.statuses or {} -- statuses of addon. -AceAddon.initializequeue = AceAddon.initializequeue or {} -- addons that are new and not initialized -AceAddon.enablequeue = AceAddon.enablequeue or {} -- addons that are initialized and waiting to be enabled -AceAddon.embeds = AceAddon.embeds or setmetatable({}, {__index = function(tbl, key) tbl[key] = {} return tbl[key] end }) -- contains a list of libraries embedded in an addon - -local tinsert, tconcat = table.insert, table.concat -local fmt = string.format -local pairs, next, type = pairs, next, type - ---[[ - xpcall safecall implementation -]] -local xpcall = xpcall - -local function errorhandler(err) - return geterrorhandler()(err) -end - -local function CreateDispatcher(argCount) - local code = [[ - local xpcall, eh = ... - local method, ARGS - local function call() return method(ARGS) end - - local function dispatch(func, ...) - method = func - if not method then return end - ARGS = ... - return xpcall(call, eh) - end - - return dispatch - ]] - - local ARGS = {} - for i = 1, argCount do ARGS[i] = "arg"..i end - code = code:gsub("ARGS", tconcat(ARGS, ", ")) - return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler) -end - -local Dispatchers = setmetatable({}, {__index=function(self, argCount) - local dispatcher = CreateDispatcher(argCount) - rawset(self, argCount, dispatcher) - return dispatcher -end}) -Dispatchers[0] = function(func) - return xpcall(func, errorhandler) -end - -local function safecall(func, ...) - -- we check to see if the func is passed is actually a function here and don't error when it isn't - -- this safecall is used for optional functions like OnInitialize OnEnable etc. When they are not - -- present execution should continue without hinderance - if type(func) == "function" then - return Dispatchers[select('#', ...)](func, ...) - end -end - --- local functions that will be implemented further down -local Enable, Disable, EnableModule, DisableModule, Embed, NewModule, GetModule, GetName, SetDefaultModuleState, SetDefaultModuleLibraries, SetEnabledState, SetDefaultModulePrototype - --- used in the addon metatable -local function addontostring( self ) return self.name end - --- AceAddon:NewAddon( name, [lib, lib, lib, ...] ) --- name (string) - unique addon object name --- [lib] (string) - optional libs to embed in the addon object --- --- returns the addon object when succesful -function AceAddon:NewAddon(name, ...) - if type(name) ~= "string" then error(("Usage: NewAddon(name, [lib, lib, lib, ...]): 'name' - string expected got '%s'."):format(type(name)), 2) end - - if self.addons[name] then error(("Usage: NewAddon(name, [lib, lib, lib, ...]): 'name' - Addon '%s' already exists."):format(name), 2) end - - local addon = setmetatable( {name = name}, { __tostring = addontostring } ) - self.addons[name] = addon - addon.modules = {} - addon.defaultModuleLibraries = {} - Embed( addon ) -- embed NewModule, GetModule methods - self:EmbedLibraries(addon, ...) - - -- add to queue of addons to be initialized upon ADDON_LOADED - tinsert(self.initializequeue, addon) - return addon -end - --- AceAddon:GetAddon( name, [silent]) --- name (string) - unique addon object name --- silent (boolean) - if true, addon is optional, silently return nil if its not found --- --- throws an error if the addon object can not be found (except silent is set) --- returns the addon object if found -function AceAddon:GetAddon(name, silent) - if not silent and not self.addons[name] then - error(("Usage: GetAddon(name): 'name' - Cannot find an AceAddon '%s'."):format(tostring(name)), 2) - end - return self.addons[name] -end - --- AceAddon:EmbedLibraries( addon, [lib, lib, lib, ...] ) --- addon (object) - addon to embed the libs in --- [lib] (string) - optional libs to embed -function AceAddon:EmbedLibraries(addon, ...) - for i=1,select("#", ... ) do - local libname = select(i, ...) - self:EmbedLibrary(addon, libname, false, 4) - end -end - --- AceAddon:EmbedLibrary( addon, libname, silent, offset ) --- addon (object) - addon to embed the libs in --- libname (string) - lib to embed --- [silent] (boolean) - optional, marks an embed to fail silently if the library doesn't exist. --- [offset] (number) - will push the error messages back to said offset defaults to 2 -function AceAddon:EmbedLibrary(addon, libname, silent, offset) - local lib = LibStub:GetLibrary(libname, true) - if not lib and not silent then - error(("Usage: EmbedLibrary(addon, libname, silent, offset): 'libname' - Cannot find a library instance of %q."):format(tostring(libname)), offset or 2) - elseif lib and type(lib.Embed) == "function" then - lib:Embed(addon) - tinsert(self.embeds[addon], libname) - return true - elseif lib then - error(("Usage: EmbedLibrary(addon, libname, silent, offset): 'libname' - Library '%s' is not Embed capable"):format(libname), offset or 2) - end -end - --- addon:GetModule( name, [silent]) --- name (string) - unique module object name --- silent (boolean) - if true, module is optional, silently return nil if its not found --- --- throws an error if the addon object can not be found (except silent is set) --- returns the module object if found -function GetModule(self, name, silent) - if not self.modules[name] and not silent then - error(("Usage: GetModule(name, silent): 'name' - Cannot find module '%s'."):format(tostring(name)), 2) - end - return self.modules[name] -end - -local function IsModuleTrue(self) return true end - --- addon:NewModule( name, [prototype, [lib, lib, lib, ...] ) --- name (string) - unique module object name for this addon --- prototype (object) - object to derive this module from, methods and values from this table will be mixed into the module, if a string is passed a lib is assumed --- [lib] (string) - optional libs to embed in the addon object --- --- returns the addon object when succesful -function NewModule(self, name, prototype, ...) - if type(name) ~= "string" then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'name' - string expected got '%s'."):format(type(name)), 2) end - if type(prototype) ~= "string" and type(prototype) ~= "table" and type(prototype) ~= "nil" then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'prototype' - table (prototype), string (lib) or nil expected got '%s'."):format(type(prototype)), 2) end - - if self.modules[name] then error(("Usage: NewModule(name, [prototype, [lib, lib, lib, ...]): 'name' - Module '%s' already exists."):format(name), 2) end - - -- modules are basically addons. We treat them as such. They will be added to the initializequeue properly as well. - -- NewModule can only be called after the parent addon is present thus the modules will be initialized after their parent is. - local module = AceAddon:NewAddon(fmt("%s_%s", self.name or tostring(self), name)) - - module.IsModule = IsModuleTrue - module:SetEnabledState(self.defaultModuleState) - module.moduleName = name - - if type(prototype) == "string" then - AceAddon:EmbedLibraries(module, prototype, ...) - else - AceAddon:EmbedLibraries(module, ...) - end - AceAddon:EmbedLibraries(module, unpack(self.defaultModuleLibraries)) - - if not prototype or type(prototype) == "string" then - prototype = self.defaultModulePrototype or nil - end - - if type(prototype) == "table" then - local mt = getmetatable(module) - mt.__index = prototype - setmetatable(module, mt) -- More of a Base class type feel. - end - - safecall(self.OnModuleCreated, self, module) -- Was in Ace2 and I think it could be a cool thing to have handy. - self.modules[name] = module - - return module -end - ---addon:GetName() --- Returns the real name of the addon or module, without any prefix -function GetName(self) - return self.moduleName or self.name -end - ---addon:Enable() --- Enables the Addon if possible, return true or false depending on success -function Enable(self) - self:SetEnabledState(true) - return AceAddon:EnableAddon(self) -end - ---addon:Disable() --- Disables the Addon if possible, return true or false depending on success -function Disable(self) - self:SetEnabledState(false) - return AceAddon:DisableAddon(self) -end - --- addon:EnableModule( name ) --- name (string) - unique module object name --- --- Enables the Module if possible, return true or false depending on success -function EnableModule(self, name) - local module = self:GetModule( name ) - return module:Enable() -end - --- addon:DisableModule( name ) --- name (string) - unique module object name --- --- Disables the Module if possible, return true or false depending on success -function DisableModule(self, name) - local module = self:GetModule( name ) - return module:Disable() -end - --- addon:SetDefaultModuleLibraries( [lib, lib, lib, ...] ) --- [lib] (string) - libs to embed in every module -function SetDefaultModuleLibraries(self, ...) - if next(self.modules) then - error("Usage: SetDefaultModuleLibraries(...): cannot change the module defaults after a module has been registered.", 2) - end - self.defaultModuleLibraries = {...} -end - --- addon:SetDefaultModuleState( state ) --- state (boolean) - default state for new modules (enabled=true, disabled=false) -function SetDefaultModuleState(self, state) - if next(self.modules) then - error("Usage: SetDefaultModuleState(state): cannot change the module defaults after a module has been registered.", 2) - end - self.defaultModuleState = state -end - --- addon:SetDefaultModulePrototype( prototype ) --- prototype (string or table) - the default prototype to use if none is specified on module creation -function SetDefaultModulePrototype(self, prototype) - if next(self.modules) then - error("Usage: SetDefaultModulePrototype(prototype): cannot change the module defaults after a module has been registered.", 2) - end - if type(prototype) ~= "table" then - error(("Usage: SetDefaultModulePrototype(prototype): 'prototype' - table expected got '%s'."):format(type(prototype)), 2) - end - self.defaultModulePrototype = prototype -end - --- addon:SetEnabledState ( state ) --- state ( boolean ) - set the state of an addon or module (enabled=true, disabled=false) --- --- should only be called before any Enabling actually happend, aka in OnInitialize -function SetEnabledState(self, state) - self.enabledState = state -end - - -local function IterateModules(self) return pairs(self.modules) end -local function IterateEmbeds(self) return pairs(AceAddon.embeds[self]) end -local function IsEnabled(self) return self.enabledState end -local mixins = { - NewModule = NewModule, - GetModule = GetModule, - Enable = Enable, - Disable = Disable, - EnableModule = EnableModule, - DisableModule = DisableModule, - IsEnabled = IsEnabled, - SetDefaultModuleLibraries = SetDefaultModuleLibraries, - SetDefaultModuleState = SetDefaultModuleState, - SetDefaultModulePrototype = SetDefaultModulePrototype, - SetEnabledState = SetEnabledState, - IterateModules = IterateModules, - IterateEmbeds = IterateEmbeds, - GetName = GetName, -} -local function IsModule(self) return false end -local pmixins = { - defaultModuleState = true, - enabledState = true, - IsModule = IsModule, -} --- Embed( target ) --- target (object) - target object to embed aceaddon in --- --- this is a local function specifically since it's meant to be only called internally -function Embed(target) - for k, v in pairs(mixins) do - target[k] = v - end - for k, v in pairs(pmixins) do - target[k] = target[k] or v - end -end - - --- AceAddon:IntializeAddon( addon ) --- addon (object) - addon to intialize --- --- calls OnInitialize on the addon object if available --- calls OnEmbedInitialize on embedded libs in the addon object if available -function AceAddon:InitializeAddon(addon) - safecall(addon.OnInitialize, addon) - - local embeds = self.embeds[addon] - for i = 1, #embeds do - local lib = LibStub:GetLibrary(embeds[i], true) - if lib then safecall(lib.OnEmbedInitialize, lib, addon) end - end - - -- we don't call InitializeAddon on modules specifically, this is handled - -- from the event handler and only done _once_ -end - --- AceAddon:EnableAddon( addon ) --- addon (object) - addon to enable --- --- calls OnEnable on the addon object if available --- calls OnEmbedEnable on embedded libs in the addon object if available -function AceAddon:EnableAddon(addon) - if type(addon) == "string" then addon = AceAddon:GetAddon(addon) end - if self.statuses[addon.name] or not addon.enabledState then return false end - -- TODO: handle 'first'? Or let addons do it on their own? - safecall(addon.OnEnable, addon) - local embeds = self.embeds[addon] - for i = 1, #embeds do - local lib = LibStub:GetLibrary(embeds[i], true) - if lib then safecall(lib.OnEmbedEnable, lib, addon) end - end - self.statuses[addon.name] = addon.enabledState - - -- enable possible modules. - for name, module in pairs(addon.modules) do - self:EnableAddon(module) - end - - return true -end - --- AceAddon:DisableAddon( addon ) --- addon (object|string) - addon to disable --- --- calls OnDisable on the addon object if available --- calls OnEmbedDisable on embedded libs in the addon object if available -function AceAddon:DisableAddon(addon) - if type(addon) == "string" then addon = AceAddon:GetAddon(addon) end - if not self.statuses[addon.name] then return false end - safecall( addon.OnDisable, addon ) - local embeds = self.embeds[addon] - for i = 1, #embeds do - local lib = LibStub:GetLibrary(embeds[i], true) - if lib then safecall(lib.OnEmbedDisable, lib, addon) end - end - self.statuses[addon.name] = addon.enabledState - - -- disable possible modules. - for name, module in pairs(addon.modules) do - self:DisableAddon(module) - end - - return true -end - ---The next few funcs are just because no one should be reaching into the internal registries ---Thoughts? -function AceAddon:IterateAddons() return pairs(self.addons) end -function AceAddon:IterateEmbedsOnAddon(addon) return pairs(self.embeds[addon]) end -function AceAddon:IterateAddonStatus() return pairs(self.statuses) end -function AceAddon:IterateModulesOfAddon(addon) return pairs(addon.modules) end - --- Event Handling -local function onEvent(this, event, arg1) - if event == "ADDON_LOADED" or event == "PLAYER_LOGIN" then - -- if a addon loads another addon, recursion could happen here, so we need to validate the table on every iteration - while(#AceAddon.initializequeue > 0) do - local addon = tremove(AceAddon.initializequeue, 1) - -- this might be an issue with recursion - TODO: validate - if event == "ADDON_LOADED" then addon.baseName = arg1 end - AceAddon:InitializeAddon(addon) - tinsert(AceAddon.enablequeue, addon) - end - - if IsLoggedIn() then - while(#AceAddon.enablequeue > 0) do - local addon = tremove(AceAddon.enablequeue, 1) - AceAddon:EnableAddon(addon) - end - end - end -end - -AceAddon.frame:RegisterEvent("ADDON_LOADED") -AceAddon.frame:RegisterEvent("PLAYER_LOGIN") -AceAddon.frame:SetScript("OnEvent", onEvent) - --- upgrade embeded -for name, addon in pairs(AceAddon.addons) do - Embed(addon) -end
--- a/lib/AceAddon-3.0/AceAddon-3.0.xml Mon Mar 17 18:24:53 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -<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="AceAddon-3.0.lua"/> -</Ui> \ No newline at end of file
--- a/lib/AceDB-3.0/AceDB-3.0.lua Mon Mar 17 18:24:53 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,623 +0,0 @@ ---[[ $Id: AceDB-3.0.lua 63886 2008-03-08 12:43:31Z nevcairiel $ ]] -local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 5 -local AceDB, oldminor = LibStub:NewLibrary(ACEDB_MAJOR, ACEDB_MINOR) - -if not AceDB then return end -- No upgrade needed - -local type = type -local pairs, next = pairs, next -local rawget, rawset = rawget, rawset -local setmetatable = setmetatable - -AceDB.db_registry = AceDB.db_registry or {} -AceDB.frame = AceDB.frame or CreateFrame("Frame") - -local CallbackHandler -local CallbackDummy = { Fire = function() end } - -local DBObjectLib = {} - ---[[------------------------------------------------------------------------- - AceDB Utility Functions ----------------------------------------------------------------------------]] - --- Simple shallow copy for copying defaults -local function copyTable(src, dest) - if type(dest) ~= "table" then dest = {} end - if type(src) == "table" then - for k,v in pairs(src) do - if type(v) == "table" then - -- try to index the key first so that the metatable creates the defaults, if set, and use that table - v = copyTable(v, dest[k]) - end - dest[k] = v - end - end - return dest -end - --- Called to add defaults to a section of the database --- --- When a ["*"] default section is indexed with a new key, a table is returned --- and set in the host table. These tables must be cleaned up by removeDefaults --- in order to ensure we don't write empty default tables. -local function copyDefaults(dest, src) - -- this happens if some value in the SV overwrites our default value with a non-table - --if type(dest) ~= "table" then return end - for k, v in pairs(src) do - if k == "*" or k == "**" then - if type(v) == "table" then - -- This is a metatable used for table defaults - local mt = { - -- This handles the lookup and creation of new subtables - __index = function(t,k) - if k == nil then return nil end - local tbl = {} - copyDefaults(tbl, v) - rawset(t, k, tbl) - return tbl - end, - } - setmetatable(dest, mt) - -- handle already existing tables in the SV - for dk, dv in pairs(dest) do - if not rawget(src, dk) and type(dv) == "table" then - copyDefaults(dv, v) - end - end - else - -- Values are not tables, so this is just a simple return - local mt = {__index = function(t,k) return k~=nil and v or nil end} - setmetatable(dest, mt) - end - elseif type(v) == "table" then - if not rawget(dest, k) then rawset(dest, k, {}) end - if type(dest[k]) == "table" then - copyDefaults(dest[k], v) - if src['**'] then - copyDefaults(dest[k], src['**']) - end - end - else - if rawget(dest, k) == nil then - rawset(dest, k, v) - end - end - end -end - --- Called to remove all defaults in the default table from the database -local function removeDefaults(db, defaults, blocker) - for k,v in pairs(defaults) do - if k == "*" or k == "**" then - if type(v) == "table" then - -- Loop through all the actual k,v pairs and remove - for key, value in pairs(db) do - if type(value) == "table" then - -- if the key was not explicitly specified in the defaults table, just strip everything from * and ** tables - if defaults[key] == nil then - removeDefaults(value, v) - -- if the table is empty afterwards, remove it - if not next(value) then - db[key] = nil - end - -- if it was specified, only strip ** content, but block values which were set in the key table - elseif k == "**" then - removeDefaults(value, v, defaults[key]) - end - end - end - elseif k == "*" then - -- check for non-table default - for key, value in pairs(db) do - if defaults[key] == nil and v == value then - db[key] = nil - end - end - end - elseif type(v) == "table" and type(db[k]) == "table" then - -- if a blocker was set, dive into it, to allow multi-level defaults - removeDefaults(db[k], v, blocker and blocker[k]) - if not next(db[k]) then - db[k] = nil - end - else - -- check if the current value matches the default, and that its not blocked by another defaults table - if db[k] == defaults[k] and (not blocker or blocker[k] == nil) then - db[k] = nil - end - end - end - -- remove all metatables from the db - setmetatable(db, nil) -end - --- This is called when a table section is first accessed, to set up the defaults -local function initSection(db, section, svstore, key, defaults) - local sv = rawget(db, "sv") - - local tableCreated - if not sv[svstore] then sv[svstore] = {} end - if not sv[svstore][key] then - sv[svstore][key] = {} - tableCreated = true - end - - local tbl = sv[svstore][key] - - if defaults then - copyDefaults(tbl, defaults) - end - rawset(db, section, tbl) - - return tableCreated, tbl -end - --- Metatable to handle the dynamic creation of sections and copying of sections. -local dbmt = { - __index = function(t, section) - local keys = rawget(t, "keys") - local key = keys[section] - if key then - local defaultTbl = rawget(t, "defaults") - local defaults = defaultTbl and defaultTbl[section] - - if section == "profile" then - local new = initSection(t, section, "profiles", key, defaults) - if new then - -- Callback: OnNewProfile, database, newProfileKey - t.callbacks:Fire("OnNewProfile", t, key) - end - elseif section == "profiles" then - local sv = rawget(t, "sv") - if not sv.profiles then sv.profiles = {} end - rawset(t, "profiles", sv.profiles) - elseif section == "global" then - local sv = rawget(t, "sv") - if not sv.global then sv.global = {} end - if defaults then - copyDefaults(sv.global, defaults) - end - rawset(t, section, sv.global) - else - initSection(t, section, section, key, defaults) - end - end - - return rawget(t, section) - end -} - -local function validateDefaults(defaults, keyTbl, offset) - if not defaults then return end - offset = offset or 0 - for k in pairs(defaults) do - if not keyTbl[k] or k == "profiles" then - error(("Usage: AceDBObject:RegisterDefaults(defaults): '%s' is not a valid datatype."):format(k), 3 + offset) - end - end -end - -local preserve_keys = { - ["callbacks"] = true, - ["RegisterCallback"] = true, - ["UnregisterCallback"] = true, - ["UnregisterAllCallbacks"] = true, - ["children"] = true, -} - -local realmKey = GetRealmName() -local charKey = UnitName("player") .. " - " .. realmKey -local _, classKey = UnitClass("player") -local _, raceKey = UnitRace("player") -local factionKey = UnitFactionGroup("player") -local factionrealmKey = factionKey .. " - " .. realmKey --- Actual database initialization function -local function initdb(sv, defaults, defaultProfile, olddb, parent) - -- Generate the database keys for each section - - -- Make a container for profile keys - if not sv.profileKeys then sv.profileKeys = {} end - - -- Try to get the profile selected from the char db - local profileKey = sv.profileKeys[charKey] or defaultProfile or charKey - sv.profileKeys[charKey] = profileKey - - -- This table contains keys that enable the dynamic creation - -- of each section of the table. The 'global' and 'profiles' - -- have a key of true, since they are handled in a special case - local keyTbl= { - ["char"] = charKey, - ["realm"] = realmKey, - ["class"] = classKey, - ["race"] = raceKey, - ["faction"] = factionKey, - ["factionrealm"] = factionrealmKey, - ["profile"] = profileKey, - ["global"] = true, - ["profiles"] = true, - } - - validateDefaults(defaults, keyTbl, 1) - - -- This allows us to use this function to reset an entire database - -- Clear out the old database - if olddb then - for k,v in pairs(olddb) do if not preserve_keys[k] then olddb[k] = nil end end - end - - -- Give this database the metatable so it initializes dynamically - local db = setmetatable(olddb or {}, dbmt) - - if not rawget(db, "callbacks") then - -- try to load CallbackHandler-1.0 if it loaded after our library - if not CallbackHandler then CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0", true) end - db.callbacks = CallbackHandler and CallbackHandler:New(db) or CallbackDummy - end - - -- Copy methods locally into the database object, to avoid hitting - -- the metatable when calling methods - - if not parent then - for name, func in pairs(DBObjectLib) do - db[name] = func - end - else - -- hack this one in - db.RegisterDefaults = DBObjectLib.RegisterDefaults - end - - -- Set some properties in the database object - db.profiles = sv.profiles - db.keys = keyTbl - db.sv = sv - --db.sv_name = name - db.defaults = defaults - db.parent = parent - - -- store the DB in the registry - AceDB.db_registry[db] = true - - return db -end - --- handle PLAYER_LOGOUT --- strip all defaults from all databases -local function logoutHandler(frame, event) - if event == "PLAYER_LOGOUT" then - for db in pairs(AceDB.db_registry) do - db.callbacks:Fire("OnDatabaseShutdown", db) - for section, key in pairs(db.keys) do - if db.defaults and db.defaults[section] and rawget(db, section) then - removeDefaults(db[section], db.defaults[section]) - end - end - end - end -end - -AceDB.frame:RegisterEvent("PLAYER_LOGOUT") -AceDB.frame:SetScript("OnEvent", logoutHandler) - - ---[[------------------------------------------------------------------------- - AceDB Object Method Definitions ----------------------------------------------------------------------------]] - --- DBObject:RegisterDefaults(defaults) --- defaults (table) - A table of defaults for this database --- --- Sets the defaults table for the given database object by clearing any --- that are currently set, and then setting the new defaults. -function DBObjectLib:RegisterDefaults(defaults) - if defaults and type(defaults) ~= "table" then - error("Usage: AceDBObject:RegisterDefaults(defaults): 'defaults' - table or nil expected.", 2) - end - - validateDefaults(defaults, self.keys) - - -- Remove any currently set defaults - if self.defaults then - for section,key in pairs(self.keys) do - if self.defaults[section] and rawget(self, section) then - removeDefaults(self[section], self.defaults[section]) - end - end - end - - -- Set the DBObject.defaults table - self.defaults = defaults - - -- Copy in any defaults, only touching those sections already created - if defaults then - for section,key in pairs(self.keys) do - if defaults[section] and rawget(self, section) then - copyDefaults(self[section], defaults[section]) - end - end - end -end - --- DBObject:SetProfile(name) --- name (string) - The name of the profile to set as the current profile --- --- Changes the profile of the database and all of it's namespaces to the --- supplied named profile -function DBObjectLib:SetProfile(name) - if type(name) ~= "string" then - error("Usage: AceDBObject:SetProfile(name): 'name' - string expected.", 2) - end - - -- changing to the same profile, dont do anything - if name == self.keys.profile then return end - - local oldProfile = self.profile - local defaults = self.defaults and self.defaults.profile - - if oldProfile and defaults then - -- Remove the defaults from the old profile - removeDefaults(oldProfile, defaults) - end - - self.profile = nil - self.keys["profile"] = name - self.sv.profileKeys[charKey] = name - - -- Callback: OnProfileChanged, database, newProfileKey - self.callbacks:Fire("OnProfileChanged", self, name) - - -- populate to child namespaces - if self.children then - for _, db in pairs(self.children) do - DBObjectLib.SetProfile(db, name) - end - end -end - --- DBObject:GetProfiles(tbl) --- tbl (table) - A table to store the profile names in (optional) --- --- Returns a table with the names of the existing profiles in the database. --- You can optionally supply a table to re-use for this purpose. -function DBObjectLib:GetProfiles(tbl) - if tbl and type(tbl) ~= "table" then - error("Usage: AceDBObject:GetProfiles(tbl): 'tbl' - table or nil expected.", 2) - end - - -- Clear the container table - if tbl then - for k,v in pairs(tbl) do tbl[k] = nil end - else - tbl = {} - end - - local curProfile = self.keys.profile - - local i = 0 - for profileKey in pairs(self.profiles) do - i = i + 1 - tbl[i] = profileKey - if curProfile and profileKey == curProfile then curProfile = nil end - end - - -- Add the current profile, if it hasn't been created yet - if curProfile then - i = i + 1 - tbl[i] = curProfile - end - - return tbl, i -end - --- DBObject:GetCurrentProfile() --- --- Returns the current profile name used by the database -function DBObjectLib:GetCurrentProfile() - return self.keys.profile -end - --- DBObject:DeleteProfile(name) --- name (string) - The name of the profile to be deleted --- --- Deletes a named profile. This profile must not be the active profile. -function DBObjectLib:DeleteProfile(name, silent) - if type(name) ~= "string" then - error("Usage: AceDBObject:DeleteProfile(name): 'name' - string expected.", 2) - end - - if self.keys.profile == name then - error("Cannot delete the active profile in an AceDBObject.", 2) - end - - if not rawget(self.sv.profiles, name) and not silent then - error("Cannot delete profile '" .. name .. "'. It does not exist.", 2) - end - - self.sv.profiles[name] = nil - -- Callback: OnProfileDeleted, database, profileKey - self.callbacks:Fire("OnProfileDeleted", self, name) - - -- populate to child namespaces - if self.children then - for _, db in pairs(self.children) do - DBObjectLib.DeleteProfile(db, name, true) - end - end -end - --- DBObject:CopyProfile(name) --- name (string) - The name of the profile to be copied into the current profile --- --- Copies a named profile into the current profile, overwriting any conflicting --- settings. -function DBObjectLib:CopyProfile(name, silent) - if type(name) ~= "string" then - error("Usage: AceDBObject:CopyProfile(name): 'name' - string expected.", 2) - end - - if name == self.keys.profile then - error("Cannot have the same source and destination profiles.", 2) - end - - if not rawget(self.sv.profiles, name) and not silent then - error("Cannot copy profile '" .. name .. "'. It does not exist.", 2) - end - - -- Reset the profile before copying - DBObjectLib.ResetProfile(self) - - local profile = self.profile - local source = self.sv.profiles[name] - - copyTable(source, profile) - - -- Callback: OnProfileCopied, database, sourceProfileKey - self.callbacks:Fire("OnProfileCopied", self, name) - - -- populate to child namespaces - if self.children then - for _, db in pairs(self.children) do - DBObjectLib.CopyProfile(db, name, true) - end - end -end - --- DBObject:ResetProfile() --- --- Resets the current profile -function DBObjectLib:ResetProfile() - local profile = self.profile - - for k,v in pairs(profile) do - profile[k] = nil - end - - local defaults = self.defaults and self.defaults.profile - if defaults then - copyDefaults(profile, defaults) - end - - -- Callback: OnProfileReset, database - self.callbacks:Fire("OnProfileReset", self) - - -- populate to child namespaces - if self.children then - for _, db in pairs(self.children) do - DBObjectLib.ResetProfile(db) - end - end -end - --- DBObject:ResetDB(defaultProfile) --- defaultProfile (string) - The profile name to use as the default --- --- Resets the entire database, using the string defaultProfile as the default --- profile. -function DBObjectLib:ResetDB(defaultProfile) - if defaultProfile and type(defaultProfile) ~= "string" then - error("Usage: AceDBObject:ResetDB(defaultProfile): 'defaultProfile' - string or nil expected.", 2) - end - - local sv = self.sv - for k,v in pairs(sv) do - sv[k] = nil - end - - local parent = self.parent - - initdb(sv, self.defaults, defaultProfile, self) - - -- Callback: OnDatabaseReset, database - self.callbacks:Fire("OnDatabaseReset", self) - -- Callback: OnProfileChanged, database, profileKey - self.callbacks:Fire("OnProfileChanged", self, self.keys["profile"]) - - -- fix the child namespaces - if self.children then - if not sv.namespaces then sv.namespaces = {} end - for name, db in pairs(self.children) do - if not sv.namespaces[name] then sv.namespaces[name] = {} end - initdb(sv.namespaces[name], db.defaults, self.keys.profile, db, self) - end - end - - return self -end - --- DBObject:RegisterNamespace(name [, defaults]) --- name (string) - The name of the new namespace --- defaults (table) - A table of values to use as defaults --- --- Creates a new database namespace, directly tied to the database. This --- is a full scale database in it's own rights other than the fact that --- it cannot control its profile individually -function DBObjectLib:RegisterNamespace(name, defaults) - if type(name) ~= "string" then - error("Usage: AceDBObject:RegisterNamespace(name, defaults): 'name' - string expected.", 2) - end - if defaults and type(defaults) ~= "table" then - error("Usage: AceDBObject:RegisterNamespace(name, defaults): 'defaults' - table or nil expected.", 2) - end - if self.children and self.children[name] then - error ("Usage: AceDBObject:RegisterNamespace(name, defaults): 'name' - a namespace with that name already exists.", 2) - end - - local sv = self.sv - if not sv.namespaces then sv.namespaces = {} end - if not sv.namespaces[name] then - sv.namespaces[name] = {} - end - - local newDB = initdb(sv.namespaces[name], defaults, self.keys.profile, nil, self) - - if not self.children then self.children = {} end - self.children[name] = newDB - return newDB -end - ---[[------------------------------------------------------------------------- - AceDB Exposed Methods ----------------------------------------------------------------------------]] - --- AceDB:New(name, defaults, defaultProfile) --- name (table or string) - The name of variable, or table to use for the database --- defaults (table) - A table of database defaults --- defaultProfile (string) - The name of the default profile --- --- Creates a new database object that can be used to handle database settings --- and profiles. -function AceDB:New(tbl, defaults, defaultProfile) - if type(tbl) == "string" then - local name = tbl - tbl = getglobal(name) - if not tbl then - tbl = {} - setglobal(name, tbl) - end - end - - if type(tbl) ~= "table" then - error("Usage: AceDB:New(tbl, defaults, defaultProfile): 'tbl' - table expected.", 2) - end - - if defaults and type(defaults) ~= "table" then - error("Usage: AceDB:New(tbl, defaults, defaultProfile): 'defaults' - table expected.", 2) - end - - if defaultProfile and type(defaultProfile) ~= "string" then - error("Usage: AceDB:New(tbl, defaults, defaultProfile): 'defaultProfile' - string expected.", 2) - end - - return initdb(tbl, defaults, defaultProfile) -end - --- upgrade existing databases -for db in pairs(AceDB.db_registry) do - if not db.parent then - for name,func in pairs(DBObjectLib) do - db[name] = func - end - else - db.RegisterDefaults = DBObjectLib.RegisterDefaults - end -end
--- a/lib/AceDB-3.0/AceDB-3.0.xml Mon Mar 17 18:24:53 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -<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="AceDB-3.0.lua"/> -</Ui> \ No newline at end of file
--- a/lib/AceEvent-3.0/AceEvent-3.0.lua Mon Mar 17 18:24:53 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ ---[[ $Id: AceEvent-3.0.lua 60131 2008-02-03 13:03:56Z nevcairiel $ ]] -local MAJOR, MINOR = "AceEvent-3.0", 3 -local AceEvent = LibStub:NewLibrary(MAJOR, MINOR) - -if not AceEvent then return end - -local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0") - - -AceEvent.frame = AceEvent.frame or CreateFrame("Frame", "AceEvent30Frame") -- our event frame -AceEvent.embeds = AceEvent.embeds or {} -- what objects embed this lib - - --- APIs and registry for blizzard events, using CallbackHandler lib -if not AceEvent.events then - AceEvent.events = CallbackHandler:New(AceEvent, - "RegisterEvent", "UnregisterEvent", "UnregisterAllEvents") -end - -function AceEvent.events:OnUsed(target, eventname) - AceEvent.frame:RegisterEvent(eventname) -end - -function AceEvent.events:OnUnused(target, eventname) - AceEvent.frame:UnregisterEvent(eventname) -end - - --- APIs and registry for IPC messages, using CallbackHandler lib -if not AceEvent.messages then - AceEvent.messages = CallbackHandler:New(AceEvent, - "RegisterMessage", "UnregisterMessage", "UnregisterAllMessages" - ) - AceEvent.SendMessage = AceEvent.messages.Fire -end - ---- embedding and embed handling -local mixins = { - "RegisterEvent", "UnregisterEvent", - "RegisterMessage", "UnregisterMessage", - "SendMessage", - "UnregisterAllEvents", "UnregisterAllMessages", -} - --- AceEvent:Embed( target ) --- target (object) - target object to embed AceEvent in --- --- Embeds AceEvent into the target object making the functions from the mixins list available on target:.. -function AceEvent:Embed(target) - for k, v in pairs(mixins) do - target[v] = self[v] - end - self.embeds[target] = true - return target -end - --- AceEvent:OnEmbedDisable( target ) --- target (object) - target object that is being disabled --- --- Unregister all events messages etc when the target disables. --- this method should be called by the target manually or by an addon framework -function AceEvent:OnEmbedDisable(target) - target:UnregisterAllEvents() - target:UnregisterAllMessages() -end - --- Script to fire blizzard events into the event listeners -local events = AceEvent.events -AceEvent.frame:SetScript("OnEvent", function(this, event, ...) - events:Fire(event, ...) -end) - ---- Finally: upgrade our old embeds -for target, v in pairs(AceEvent.embeds) do - AceEvent:Embed(target) -end
--- a/lib/AceEvent-3.0/AceEvent-3.0.xml Mon Mar 17 18:24:53 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -<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="AceEvent-3.0.lua"/> -</Ui> \ No newline at end of file
--- a/lib/AceLocale-3.0/AceLocale-3.0.lua Mon Mar 17 18:24:53 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ ---[[ $Id: AceLocale-3.0.lua 60131 2008-02-03 13:03:56Z nevcairiel $ ]] -local MAJOR,MINOR = "AceLocale-3.0", 1 - -local AceLocale, oldminor = LibStub:NewLibrary(MAJOR, MINOR) - -if not AceLocale then return end -- no upgrade needed - -local gameLocale = GetLocale() -if gameLocale == "enGB" then - gameLocale = "enUS" -end - -AceLocale.apps = AceLocale.apps or {} -- array of ["AppName"]=localetableref -AceLocale.appnames = AceLocale.appnames or {} -- array of [localetableref]="AppName" - --- This metatable is used on all tables returned from GetLocale -local readmeta = { - __index = function(self, key) -- requesting totally unknown entries: fire off a nonbreaking error and return key - geterrorhandler()(MAJOR..": "..tostring(AceLocale.appnames[self])..": Missing entry for '"..tostring(key).."'") - rawset(self, key, key) -- only need to see the warning once, really - return key - end -} - --- Remember the locale table being registered right now (it gets set by :NewLocale()) -local registering - --- local assert false function -local assertfalse = function() assert(false) end - --- This metatable proxy is used when registering nondefault locales -local writeproxy = setmetatable({}, { - __newindex = function(self, key, value) - rawset(registering, key, value == true and key or value) -- assigning values: replace 'true' with key string - end, - __index = assertfalse -}) - --- This metatable proxy is used when registering the default locale. --- It refuses to overwrite existing values --- Reason 1: Allows loading locales in any order --- Reason 2: If 2 modules have the same string, but only the first one to be --- loaded has a translation for the current locale, the translation --- doesn't get overwritten. --- -local writedefaultproxy = setmetatable({}, { - __newindex = function(self, key, value) - if not rawget(registering, key) then - rawset(registering, key, value == true and key or value) - end - end, - __index = assertfalse -}) - --- AceLocale:NewLocale(application, locale, isDefault) --- --- application (string) - unique name of addon / module --- locale (string) - name of locale to register, e.g. "enUS", "deDE", etc... --- isDefault (string) - if this is the default locale being registered --- --- Returns a table where localizations can be filled out, or nil if the locale is not needed -function AceLocale:NewLocale(application, locale, isDefault) - - -- GAME_LOCALE allows translators to test translations of addons without having that wow client installed - -- Ammo: I still think this is a bad idea, for instance an addon that checks for some ingame string will fail, just because some other addon - -- gives the user the illusion that they can run in a different locale? Ditch this whole thing or allow a setting per 'application'. I'm of the - -- opinion to remove this. - local gameLocale = GAME_LOCALE or gameLocale - - if locale ~= gameLocale and not isDefault then - return -- nop, we don't need these translations - end - - local app = AceLocale.apps[application] - - if not app then - app = setmetatable({}, readmeta) - AceLocale.apps[application] = app - AceLocale.appnames[app] = application - end - - registering = app -- remember globally for writeproxy and writedefaultproxy - - if isDefault then - return writedefaultproxy - end - - return writeproxy -end - --- AceLocale:GetLocale(application [, silent]) --- --- application (string) - unique name of addon --- silent (boolean) - if true, the locale is optional, silently return nil if it's not found --- --- Returns localizations for the current locale (or default locale if translations are missing) --- Errors if nothing is registered (spank developer, not just a missing translation) -function AceLocale:GetLocale(application, silent) - if not silent and not AceLocale.apps[application] then - error("Usage: GetLocale(application[, silent]): 'application' - No locales registered for '"..tostring(application).."'", 2) - end - return AceLocale.apps[application] -end
--- a/lib/AceLocale-3.0/AceLocale-3.0.xml Mon Mar 17 18:24:53 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -<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="AceLocale-3.0.lua"/> -</Ui> \ No newline at end of file
--- a/lib/CallbackHandler-1.0/CallbackHandler-1.0.lua Mon Mar 17 18:24:53 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,239 +0,0 @@ ---[[ $Id: CallbackHandler-1.0.lua 60697 2008-02-09 16:51:20Z nevcairiel $ ]] -local MAJOR, MINOR = "CallbackHandler-1.0", 3 -local CallbackHandler = LibStub:NewLibrary(MAJOR, MINOR) - -if not CallbackHandler then return end -- No upgrade needed - -local meta = {__index = function(tbl, key) tbl[key] = {} return tbl[key] end} - -local type = type -local pcall = pcall -local pairs = pairs -local assert = assert -local concat = table.concat -local loadstring = loadstring -local next = next -local select = select -local type = type -local xpcall = xpcall - -local function errorhandler(err) - 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", concat(OLD_ARGS, ", ")):gsub("ARGS", concat(ARGS, ", ")) - return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(next, xpcall, errorhandler) -end - -local Dispatchers = setmetatable({}, {__index=function(self, argCount) - local dispatcher = CreateDispatcher(argCount) - rawset(self, argCount, dispatcher) - return dispatcher -end}) - --------------------------------------------------------------------------- --- CallbackHandler:New --- --- target - target object to embed public APIs in --- RegisterName - name of the callback registration API, default "RegisterCallback" --- 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") - - RegisterName = RegisterName or "RegisterCallback" - UnregisterName = UnregisterName or "UnregisterCallback" - if UnregisterAllName==nil then -- false is used to indicate "don't want this method" - UnregisterAllName = "UnregisterAllCallbacks" - end - - -- we declare all objects and exported APIs inside this closure to quickly gain access - -- to e.g. function names, the "target" parameter, etc - - - -- Create the registry object - local events = setmetatable({}, meta) - local registry = { recurse=0, events=events } - - -- registry:Fire() - fires the given event/message into the registry - function registry:Fire(eventname, ...) - if not rawget(events, eventname) or not next(events[eventname]) then return end - local oldrecurse = registry.recurse - registry.recurse = oldrecurse + 1 - - Dispatchers[select('#', ...) + 1](events[eventname], eventname, ...) - - registry.recurse = oldrecurse - - if registry.insertQueue and oldrecurse==0 then - -- Something in one of our callbacks wanted to register more callbacks; they got queued - for eventname,callbacks in pairs(registry.insertQueue) do - local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten. - for self,func in pairs(callbacks) do - events[eventname][self] = func - -- fire OnUsed callback? - if first and registry.OnUsed then - registry.OnUsed(registry, target, eventname) - first = nil - end - end - end - registry.insertQueue = nil - end - end - - -- Registration of a callback, handles: - -- self["method"], leads to self["method"](self, ...) - -- self with function ref, leads to functionref(...) - -- "addonId" (instead of self) with function ref, leads to functionref(...) - -- all with an optional arg, which, if present, gets passed as first argument (after self if present) - target[RegisterName] = function(self, eventname, method, ... --[[actually just a single arg]]) - if type(eventname) ~= "string" then - error("Usage: "..RegisterName.."(eventname, method[, arg]): 'eventname' - string expected.", 2) - end - - method = method or eventname - - local first = not rawget(events, eventname) or not next(events[eventname]) -- test for empty before. not test for one member after. that one member may have been overwritten. - - if type(method) ~= "string" and type(method) ~= "function" then - error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - string or function expected.", 2) - end - - local regfunc - - if type(method) == "string" then - -- self["method"] calling style - if type(self) ~= "table" then - error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): self was not a table?", 2) - elseif self==target then - error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): do not use Library:"..RegisterName.."(), use your own 'self'", 2) - elseif type(self[method]) ~= "function" then - error("Usage: "..RegisterName.."(\"eventname\", \"methodname\"): 'methodname' - method '"..tostring(method).."' not found on self.", 2) - end - - if select("#",...)>=1 then -- this is not the same as testing for arg==nil! - local arg=select(1,...) - regfunc = function(...) self[method](self,arg,...) end - else - regfunc = function(...) self[method](self,...) end - end - else - -- function ref with self=object or self="addonId" - if type(self)~="table" and type(self)~="string" then - error("Usage: "..RegisterName.."(self or \"addonId\", eventname, method): 'self or addonId': table or string expected.", 2) - end - - if select("#",...)>=1 then -- this is not the same as testing for arg==nil! - local arg=select(1,...) - regfunc = function(...) method(arg,...) end - else - regfunc = method - end - end - - - if events[eventname][self] or registry.recurse<1 then - -- if registry.recurse<1 then - -- we're overwriting an existing entry, or not currently recursing. just set it. - events[eventname][self] = regfunc - -- fire OnUsed callback? - if registry.OnUsed and first then - registry.OnUsed(registry, target, eventname) - end - else - -- we're currently processing a callback in this registry, so delay the registration of this new entry! - -- yes, we're a bit wasteful on garbage, but this is a fringe case, so we're picking low implementation overhead over garbage efficiency - registry.insertQueue = registry.insertQueue or setmetatable({},meta) - registry.insertQueue[eventname][self] = regfunc - end - end - - -- Unregister a callback - target[UnregisterName] = function(self, eventname) - if not self or self==target then - error("Usage: "..UnregisterName.."(eventname): bad 'self'", 2) - end - if type(eventname) ~= "string" then - error("Usage: "..UnregisterName.."(eventname): 'eventname' - string expected.", 2) - end - if rawget(events, eventname) and events[eventname][self] then - events[eventname][self] = nil - -- Fire OnUnused callback? - if registry.OnUnused and not next(events[eventname]) then - registry.OnUnused(registry, target, eventname) - end - end - if registry.insertQueue and rawget(registry.insertQueue, eventname) and registry.insertQueue[eventname][self] then - registry.insertQueue[eventname][self] = nil - end - end - - -- OPTIONAL: Unregister all callbacks for given selfs/addonIds - if UnregisterAllName then - target[UnregisterAllName] = function(...) - if select("#",...)<1 then - error("Usage: "..UnregisterAllName.."([whatFor]): missing 'self' or \"addonId\" to unregister events for.", 2) - end - if select("#",...)==1 and ...==target then - error("Usage: "..UnregisterAllName.."([whatFor]): supply a meaningful 'self' or \"addonId\"", 2) - end - - - for i=1,select("#",...) do - local self = select(i,...) - if registry.insertQueue then - for eventname, callbacks in pairs(registry.insertQueue) do - if callbacks[self] then - callbacks[self] = nil - end - end - end - for eventname, callbacks in pairs(events) do - if callbacks[self] then - callbacks[self] = nil - -- Fire OnUnused callback? - if registry.OnUnused and not next(callbacks) then - registry.OnUnused(registry, target, eventname) - end - end - end - end - end - end - - return registry -end - - --- CallbackHandler purposefully does NOT do explicit embedding. Nor does it --- try to upgrade old implicit embeds since the system is selfcontained and --- relies on closures to work. -
--- a/lib/CallbackHandler-1.0/CallbackHandler-1.0.xml Mon Mar 17 18:24:53 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -<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="CallbackHandler-1.0.lua"/> -</Ui> \ No newline at end of file
--- a/lib/LibStub/LibStub.lua Mon Mar 17 18:24:53 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ --- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info --- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke -local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! -local LibStub = _G[LIBSTUB_MAJOR] - -if not LibStub or LibStub.minor < LIBSTUB_MINOR then - LibStub = LibStub or {libs = {}, minors = {} } - _G[LIBSTUB_MAJOR] = LibStub - LibStub.minor = LIBSTUB_MINOR - - function LibStub:NewLibrary(major, minor) - assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") - minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") - - local oldminor = self.minors[major] - if oldminor and oldminor >= minor then return nil end - self.minors[major], self.libs[major] = minor, self.libs[major] or {} - return self.libs[major], oldminor - end - - function LibStub:GetLibrary(major, silent) - if not self.libs[major] and not silent then - error(("Cannot find a library instance of %q."):format(tostring(major)), 2) - end - return self.libs[major], self.minors[major] - end - - function LibStub:IterateLibraries() return pairs(self.libs) end - setmetatable(LibStub, { __call = LibStub.GetLibrary }) -end