Commit 568fa806 authored by nevcairiel's avatar nevcairiel
Browse files

Cleaned upvalues and added comments for Mikk's FindGlobals script

git-svn-id: https://repos.wowace.com/wow/ace3/trunk@877 5debad98-a965-4143-8383-f471b3509dcf
parent 32727d05
......@@ -3,6 +3,9 @@
-- for now only /rl to reload your UI :)
-- note the complete overkill use of AceAddon and console, ain't it cool?
-- GLOBALS: next, loadstring, ReloadUI, geterrorhandler
-- GLOBALS: BINDING_HEADER_ACE3, BINDING_NAME_RELOADUI, Ace3, LibStub
-- BINDINGs labels
BINDING_HEADER_ACE3 = "Ace3"
BINDING_NAME_RELOADUI = "ReloadUI"
......@@ -39,6 +42,7 @@ end
local old_CloseSpecialWindows
-- GLOBALS: CloseSpecialWindows, next
function Ace3:Open()
if not old_CloseSpecialWindows then
old_CloseSpecialWindows = CloseSpecialWindows
......
......@@ -29,6 +29,7 @@
-- @class file
-- @name AceAddon-3.0.lua
-- @release $Id$
local MAJOR, MINOR = "AceAddon-3.0", 5
local AceAddon, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
......@@ -41,9 +42,18 @@ AceAddon.initializequeue = AceAddon.initializequeue or {} -- addons that are new
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
-- Lua APIs
local tinsert, tconcat, tremove = table.insert, table.concat, table.remove
local fmt, tostring = string.format, tostring
local select, pairs, next, type, unpack = select, pairs, next, type, unpack
local loadstring, assert, error = loadstring, assert, error
local setmetatable, getmetatable, rawset, rawget = setmetatable, getmetatable, rawset, rawget
-- WoW APIs
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: geterrorhandler, LibStub, IsLoggedIn
--[[
xpcall safecall implementation
......
......@@ -47,13 +47,17 @@ AceBucket.embeds = AceBucket.embeds or {}
-- the libraries will be lazyly bound later, to avoid errors due to loading order issues
local AceEvent, AceTimer
-- local upvalues
local type = type
local next = next
local pairs = pairs
local select = select
local tonumber = tonumber
local tostring = tostring
-- Lua APIs
local tconcat = table.concat
local type, next, pairs, select = type, next, pairs, select
local tonumber, tostring, rawset = tonumber, tostring, rawset
local assert, loadstring, error = assert, loadstring, error
-- WoW APIs
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: geterrorhandler, LibStub
local bucketCache = setmetatable({}, {__mode='k'})
......@@ -84,7 +88,7 @@ local function CreateDispatcher(argCount)
local ARGS = {}
for i = 1, argCount do ARGS[i] = "arg"..i end
code = code:gsub("ARGS", table.concat(ARGS, ", "))
code = code:gsub("ARGS", tconcat(ARGS, ", "))
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler)
end
......
......@@ -18,7 +18,7 @@ TODO: Time out old data rotting around from dead senders? Not a HUGE deal since
]]
local MAJOR, MINOR = "AceComm-3.0", 6
local AceComm,oldminor = LibStub:NewLibrary(MAJOR, MINOR)
if not AceComm then return end
......@@ -26,11 +26,17 @@ if not AceComm then return end
local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
local CTL = assert(ChatThrottleLib, "AceComm-3.0 requires ChatThrottleLib")
local type = type
local strsub = string.sub
local strfind = string.find
local tinsert = table.insert
local tconcat = table.concat
-- Lua APIs
local type, next, pairs, tostring = type, next, pairs, tostring
local strsub, strfind = string.sub, string.find
local tinsert, tconcat = table.insert, table.concat
local error, assert = error, assert
-- WoW APIs
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: geterrorhandler, LibStub, DEFAULT_CHAT_FRAME
AceComm.embeds = AceComm.embeds or {}
......
......@@ -17,12 +17,13 @@ local AceConfig = LibStub:NewLibrary(MAJOR, MINOR)
if not AceConfig then return end
local cfgreg = LibStub("AceConfigRegistry-3.0")
local cfgcmd = LibStub("AceConfigCmd-3.0")
local cfgdlg = LibStub("AceConfigDialog-3.0")
--TODO: local cfgdrp = LibStub("AceConfigDropdown-3.0")
-- Lua APIs
local pcall, error, type, pairs = pcall, error, type, pairs
-- -------------------------------------------------------------------
-- :RegisterOptionsTable(appName, options, slashcmd, persist)
......
......@@ -29,6 +29,20 @@ local cfgreg = LibStub("AceConfigRegistry-3.0")
local AceConsole -- LoD
local AceConsoleName = "AceConsole-3.0"
-- Lua APIs
local strsub, strsplit, strlower, strmatch, strtrim = string.sub, string.split, string.lower, string.match, string.trim
local format, tonumber, tostring = string.format, tonumber, tostring
local tsort, tinsert = table.sort, table.insert
local select, pairs, next, type = select, pairs, next, type
local error, assert = error, assert
-- WoW APIs
local _G = _G
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: LibStub, SELECTED_CHAT_FRAME, DEFAULT_CHAT_FRAME
local L = setmetatable({}, { -- TODO: replace with proper locale
__index = function(self,k) return k end
......@@ -179,12 +193,12 @@ local function showhelp(info, inputpos, tab, noHead)
for k,v in iterateargs(tab) do
if not refTbl[k] then -- a plugin overriding something in .args
table.insert(sortTbl, k)
tinsert(sortTbl, k)
refTbl[k] = v
end
end
table.sort(sortTbl, function(one, two)
tsort(sortTbl, function(one, two)
local o1 = refTbl[one].order or 100
local o2 = refTbl[two].order or 100
if type(o1) == "function" or type(o1) == "string" then
......@@ -208,7 +222,8 @@ local function showhelp(info, inputpos, tab, noHead)
return o1<o2
end)
for _,k in ipairs(sortTbl) do
for i = 1, #sortTbl do
local k = sortTbl[i]
local v = refTbl[k]
if not pickfirstset(v.cmdHidden, v.hidden, false) then
-- recursively show all inline groups
......@@ -327,7 +342,7 @@ local function handle(info, inputpos, tab, depth, retfalse)
if tab.plugins and type(tab.plugins)~="table" then err(info,inputpos) end
-- grab next arg from input
local _,nextpos,arg = string.find(info.input, " *([^ ]+) *", inputpos)
local _,nextpos,arg = (info.input):find(" *([^ ]+) *", inputpos)
if not arg then
showhelp(info, inputpos, tab)
return
......@@ -525,9 +540,9 @@ local function handle(info, inputpos, tab, depth, retfalse)
--parse for =on =off =default in the process
--table will be key = true for options that should toggle, key = [on|off|default] for options to be set
local sels = {}
for v in string.gmatch(str, "[^ ]+") do
for v in str:gmatch("[^ ]+") do
--parse option=on etc
local opt, val = string.match(v,'(.+)=(.+)')
local opt, val = v:match('(.+)=(.+)')
--get option if toggling
if not opt then
opt = v
......
......@@ -19,19 +19,22 @@ AceConfigDialog.frame.closing = AceConfigDialog.frame.closing or {}
local gui = LibStub("AceGUI-3.0")
local reg = LibStub("AceConfigRegistry-3.0")
local select = select
local pairs = pairs
local type = type
local assert = assert
local tinsert = tinsert
local tremove = tremove
local error = error
local table = table
local unpack = unpack
local string = string
local next = next
local math = math
local _
-- Lua APIs
local tconcat, tinsert, tsort, tremove = table.concat, table.insert, table.sort, table.remove
local strmatch, format = string.match, string.format
local assert, loadstring, error = assert, loadstring, error
local pairs, next, select, type, unpack = pairs, next, select, type, unpack
local rawset, tostring = rawset, tostring
local math_min, math_max, math_floor = math.min, math.max, math.floor
-- WoW APIs
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: NORMAL_FONT_COLOR, GameTooltip, geterrorhandler, StaticPopupDialogs, ACCEPT, CANCEL, StaticPopup_Show
-- GLOBALS: PlaySound, GameFontHighlight, GameFontHighlightSmall, GameFontHighlightLarge
-- GLOBALS: CloseSpecialWindows, InterfaceOptions_AddCategory
local emptyTbl = {}
--[[
......@@ -61,7 +64,7 @@ local function CreateDispatcher(argCount)
local ARGS = {}
for i = 1, argCount do ARGS[i] = "arg"..i end
code = code:gsub("ARGS", table.concat(ARGS, ", "))
code = code:gsub("ARGS", tconcat(ARGS, ", "))
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler)
end
......@@ -252,7 +255,7 @@ local function GetOptionsMemberValue(membername, option, options, path, appName,
if handler and handler[member] then
a,b,c,d = handler[member](handler, info, ...)
else
error(string.format("Method %s doesn't exist in handler for type %s", member, membername))
error(format("Method %s doesn't exist in handler for type %s", member, membername))
end
end
del(info)
......@@ -373,7 +376,7 @@ local function BuildSortedOptionsTable(group, keySort, opts, options, path, appN
end
end
table.sort(keySort, compareOptions)
tsort(keySort, compareOptions)
del(tempOrders)
del(tempNames)
......@@ -683,7 +686,7 @@ local function ActivateControl(widget, event, ...)
success, validated = safecall(handler[validate], handler, info, ...)
if not success then validated = false end
else
error(string.format("Method %s doesn't exist in handler for type execute", validate))
error(format("Method %s doesn't exist in handler for type execute", validate))
end
elseif type(validate) == "function" then
success, validated = safecall(validate, info, ...)
......@@ -734,7 +737,7 @@ local function ActivateControl(widget, event, ...)
confirm = false
end
else
error(string.format("Method %s doesn't exist in handler for type confirm", confirm))
error(format("Method %s doesn't exist in handler for type confirm", confirm))
end
elseif type(confirm) == "function" then
success, confirm = safecall(confirm, info, ...)
......@@ -774,7 +777,7 @@ local function ActivateControl(widget, event, ...)
if handler and handler[func] then
confirmPopup(user.appName, rootframe, basepath, info, confirmText, handler[func], handler, info, ...)
else
error(string.format("Method %s doesn't exist in handler for type func", func))
error(format("Method %s doesn't exist in handler for type func", func))
end
elseif type(func) == "function" then
confirmPopup(user.appName, rootframe, basepath, info, confirmText, func, info, ...)
......@@ -789,7 +792,7 @@ local function ActivateControl(widget, event, ...)
if handler and handler[func] then
safecall(handler[func],handler, info, ...)
else
error(string.format("Method %s doesn't exist in handler for type func", func))
error(format("Method %s doesn't exist in handler for type func", func))
end
elseif type(func) == "function" then
safecall(func,info, ...)
......@@ -836,9 +839,9 @@ local function ActivateSlider(widget, event, value)
local option = widget:GetUserData('option')
local min, max, step = option.min or 0, option.max or 100, option.step
if step then
value = math.floor((value - min) / step + 0.5) * step + min
value = math_floor((value - min) / step + 0.5) * step + min
else
value = math.max(math.min(value,max),min)
value = math_max(math_min(value,max),min)
end
ActivateControl(widget,event,value)
end
......@@ -1184,8 +1187,8 @@ local function FeedOptions(appName, options,container,rootframe,path,group,inlin
tinsert(valuesort, value)
end
end
table.sort(valuesort)
tsort(valuesort)
if controlType then
control = gui:Create(controlType)
if not control then
......@@ -1364,7 +1367,7 @@ local function TreeOnButtonEnter(widget, event, uniquevalue, button)
feedpath[i] = path[i]
end
BuildPath(feedpath, string.split("\001", uniquevalue))
BuildPath(feedpath, ("\001"):split(uniquevalue))
local group = options
for i = 1, #feedpath do
if not group then return end
......@@ -1376,9 +1379,9 @@ local function TreeOnButtonEnter(widget, event, uniquevalue, button)
GameTooltip:SetOwner(button, "ANCHOR_NONE")
if widget.type == "TabGroup" then
GameTooltip:SetPoint("BOTTOM",button,"TOP")
GameTooltip:SetPoint("BOTTOM",button,"TOP")
else
GameTooltip:SetPoint("LEFT",button,"RIGHT")
GameTooltip:SetPoint("LEFT",button,"RIGHT")
end
GameTooltip:SetText(name, 1, .82, 0, 1)
......@@ -1404,7 +1407,7 @@ local function GroupExists(appName, options, path, uniquevalue)
feedpath[i] = path[i]
end
BuildPath(feedpath, string.split("\001", uniquevalue))
BuildPath(feedpath, ("\001"):split(uniquevalue))
local group = options
for i = 1, #feedpath do
......@@ -1437,7 +1440,7 @@ local function GroupSelected(widget, event, uniquevalue)
feedpath[i] = path[i]
end
BuildPath(feedpath, string.split("\001", uniquevalue))
BuildPath(feedpath, ("\001"):split(uniquevalue))
local group = options
for i = 1, #feedpath do
group = GetSubOption(group, feedpath[i])
......
......@@ -22,6 +22,12 @@ if not AceConfigRegistry.callbacks then
AceConfigRegistry.callbacks = CallbackHandler:New(AceConfigRegistry)
end
-- Lua APIs
local tinsert, tconcat = table.insert, table.concat
local strfind, strmatch = string.find, string.match
local type, tostring, select, pairs = type, tostring, select, pairs
local error, assert = error, assert
-----------------------------------------------------------------------
-- Validating options table consistency:
......@@ -41,7 +47,7 @@ local function err(msg, errlvl, ...)
for i=select("#",...),1,-1 do
tinsert(t, (select(i, ...)))
end
error(MAJOR..":ValidateOptionsTable(): "..table.concat(t,".")..msg, errlvl+2)
error(MAJOR..":ValidateOptionsTable(): "..tconcat(t,".")..msg, errlvl+2)
end
......
......@@ -45,12 +45,16 @@ local AceDB, oldminor = LibStub:NewLibrary(ACEDB_MAJOR, ACEDB_MINOR)
if not AceDB then return end -- No upgrade needed
local _G = getfenv(0)
-- Lua APIs
local type, pairs, next, error = type, pairs, next, error
local setmetatable, getmetatable, rawset, rawget = setmetatable, getmetatable, rawset, rawget
local type = type
local pairs, next = pairs, next
local rawget, rawset = rawget, rawset
local setmetatable = setmetatable
-- WoW APIs
local _G = _G
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: LibStub
AceDB.db_registry = AceDB.db_registry or {}
AceDB.frame = AceDB.frame or CreateFrame("Frame")
......@@ -676,7 +680,7 @@ function AceDB:New(tbl, defaults, defaultProfile)
tbl = _G[name]
if not tbl then
tbl = {}
setglobal(name, tbl)
_G[name] = tbl
end
end
......
......@@ -7,6 +7,12 @@ local AceDBOptions, oldminor = LibStub:NewLibrary(ACEDBO_MAJOR, ACEDBO_MINOR)
if not AceDBOptions then return end -- No upgrade needed
-- Lua APIs
local pairs, next = pairs, next
-- WoW APIs
local UnitClass = UnitClass
AceDBOptions.optionTables = AceDBOptions.optionTables or {}
AceDBOptions.handlers = AceDBOptions.handlers or {}
......
......@@ -15,13 +15,14 @@ local AceEvent = LibStub:NewLibrary(MAJOR, MINOR)
if not AceEvent then return end
local CallbackHandler = LibStub:GetLibrary("CallbackHandler-1.0")
-- Lua APIs
local pairs = pairs
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,
......
......@@ -32,6 +32,9 @@ local AceGUI = LibStub("AceGUI-3.0")
Group Designed to be added to the bliz interface options panel
]]
-- WoW APIs
local CreateFrame = CreateFrame
do
local Type = "BlizOptionsGroup"
local Version = 10
......
local AceGUI = LibStub("AceGUI-3.0")
-- WoW APIs
local _G = _G
local CreateFrame, UIParent = CreateFrame, UIParent
--------------------------
-- Button --
--------------------------
......
local AceGUI = LibStub("AceGUI-3.0")
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: SetDesaturation, GameFontHighlight
--------------------------
-- Check Box --
--------------------------
......
local AceGUI = LibStub("AceGUI-3.0")
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: ShowUIPanel, HideUIPanel, ColorPickerFrame, OpacitySliderFrame
--------------------------
-- ColorPicker --
--------------------------
......
......@@ -2,6 +2,12 @@
local AceGUI = LibStub("AceGUI-3.0")
-- Lua APIs
local select, assert = select, assert
-- WoW APIs
local CreateFrame = CreateFrame
local function fixlevels(parent,...)
local i = 1
local child = select(i, ...)
......
--[[ $Id$ ]]--
local AceGUI = LibStub("AceGUI-3.0")
-- Lua APIs
local min, max, floor = math.min, math.max, math.floor
local select, pairs, ipairs = select, pairs, ipairs
local tsort = table.sort
local AceGUI = LibStub("AceGUI-3.0")
-- WoW APIs
local UIParent, CreateFrame = UIParent, CreateFrame
local _G = _G
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: CLOSE
local function fixlevels(parent,...)
local i = 1
......@@ -576,7 +587,7 @@ do
for v in pairs(list) do
sortlist[#sortlist + 1] = v
end
table.sort(sortlist)
tsort(sortlist)
for i, value in pairs(sortlist) do
AddListItem(self, value, list[value])
......
local AceGUI = LibStub("AceGUI-3.0")
-- Lua APIs
local assert, pairs, type = assert, pairs, type
-- WoW APIs
local CreateFrame = CreateFrame
--[[
Selection Group controls all have an interface to select a group for thier contents
None of them will auto size to thier contents, and should usually be used with a scrollframe
......
local AceGUI = LibStub("AceGUI-3.0")
-- Lua APIs
local tostring = tostring
-- WoW APIs
local GetCursorInfo, ClearCursor, GetSpellName = GetCursorInfo, ClearCursor, GetSpellName
local CreateFrame, UIParent = CreateFrame, UIParent
local _G = _G
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: AceGUIEditBoxInsertLink, ChatFontNormal, OKAY
local Type = "EditBox"
local Version = 12
local _G=_G
if not AceGUIEditBoxInsertLink then
-- upgradeable hook
hooksecurefunc("ChatEdit_InsertLink", function(...) return _G.AceGUIEditBoxInsertLink(...) end)
......
local AceGUI = LibStub("AceGUI-3.0")
-- Lua APIs
local pairs, assert, type = pairs, assert, type
-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent
-- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
-- List them here for Mikk's FindGlobals script
-- GLOBALS: CLOSE
----------------
-- Main Frame --
----------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment