Skip to content

Commit

Permalink
Cleaned upvalues and added comments for Mikk's FindGlobals script
Browse files Browse the repository at this point in the history
  • Loading branch information
Nevcairiel committed Nov 2, 2009
1 parent c2f0fc9 commit a988d59
Show file tree
Hide file tree
Showing 38 changed files with 356 additions and 133 deletions.
4 changes: 4 additions & 0 deletions Ace3.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -39,6 +42,7 @@ end

local old_CloseSpecialWindows

-- GLOBALS: CloseSpecialWindows, next
function Ace3:Open()
if not old_CloseSpecialWindows then
old_CloseSpecialWindows = CloseSpecialWindows
Expand Down
16 changes: 13 additions & 3 deletions AceAddon-3.0/AceAddon-3.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down
20 changes: 12 additions & 8 deletions AceBucket-3.0/AceBucket-3.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'})

Expand Down Expand Up @@ -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

Expand Down
18 changes: 12 additions & 6 deletions AceComm-3.0/AceComm-3.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,25 @@ 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

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 {}

Expand Down
3 changes: 2 additions & 1 deletion AceConfig-3.0/AceConfig-3.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 21 additions & 6 deletions AceConfig-3.0/AceConfigCmd-3.0/AceConfigCmd-3.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
61 changes: 32 additions & 29 deletions AceConfig-3.0/AceConfigDialog-3.0/AceConfigDialog-3.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

--[[
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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, ...)
Expand Down Expand Up @@ -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, ...)
Expand Down Expand Up @@ -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, ...)
Expand All @@ -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, ...)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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


Expand Down
Loading

0 comments on commit a988d59

Please sign in to comment.