Skip to content

Commit

Permalink
Merge pull request #18 from Kirri777:Kirri777/issue15
Browse files Browse the repository at this point in the history
Update libs
  • Loading branch information
Kirri777 authored Oct 27, 2024
2 parents 2d88beb + e7a6288 commit 703dfa5
Show file tree
Hide file tree
Showing 15 changed files with 922 additions and 746 deletions.
11 changes: 9 additions & 2 deletions DoYouNeedThat.toc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Title: DoYouNeedThat?
## Author: Kraffs <Numinous-TarrenMill LootCouncil-TarrenMill>
## Version: 1.2.6
## Version: 1.2.7
## Notes: Pesters people for loot because Personal Loot is fun! (Kirri mod)
## OptionalDeps: CanIMogIt
## SavedVariables: DyntDB
Expand All @@ -13,4 +13,11 @@
## X-Website: https://github.com/Kirri777/DoYouNeedThat
## X-Feedback: https://github.com/Kirri777/DoYouNeedThat/issues

DoYouNeedThat.xml
DoYouNeedThat.xml

# Libs version
# LibStub-1.0 - v1.0.2, 2016-08-18
# CallbackHandler-1.0 - v1.0.9, 2022-12-12
# LibInspect - v0.3.7, 2020-11-19
# LibDataBroker-1.1 - v1.1.4, 2009-07-22
# LibDBIcon-1.0 - v11.0.0, 2024-08-02
10 changes: 5 additions & 5 deletions DoYouNeedThat.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<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="Libs\LibStub.lua"/>
<Script file="Libs\CallbackHandler-1.0.lua"/>
<Script file="Libs\LibInspect.lua"/>
<Script file="Libs\LibDataBroker-1.1.lua"/>
<Script file="Libs\LibDBIcon-1.0.lua"/>
<Script file="Libs\LibStub\LibStub.lua"/>
<Script file="Libs\CallbackHandler-1.0\CallbackHandler-1.0.lua"/>
<Script file="Libs\LibInspect\LibInspect.lua"/>
<Script file="Libs\LibDataBroker-1.1\LibDataBroker-1.1.lua"/>
<Script file="Libs\LibDBIcon-1.0\LibDBIcon-1.0.lua"/>

<Script file="init.lua" />
<Script file="Locales\enUS.lua"/>
Expand Down
24 changes: 24 additions & 0 deletions Libs/CallbackHandler-1.0/CHANGES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
------------------------------------------------------------------------
r27 | nevcairiel | 2022-12-12 15:10:22 +0000 (Mon, 12 Dec 2022) | 1 line
Changed paths:
M /trunk/CallbackHandler-1.0.toc

Update TOC
------------------------------------------------------------------------
r26 | nevcairiel | 2022-12-12 15:09:39 +0000 (Mon, 12 Dec 2022) | 5 lines
Changed paths:
M /trunk/CallbackHandler-1.0/CallbackHandler-1.0.lua

Use securecallfunction instead of xpcall

This allows error handlers to properly use debuglocals() when handling any potential errors in the callback.

Change contributed by Meorawr
------------------------------------------------------------------------
r25 | nevcairiel | 2022-12-12 15:02:36 +0000 (Mon, 12 Dec 2022) | 1 line
Changed paths:
M /trunk/CallbackHandler-1.0/CallbackHandler-1.0.lua

Sync up style changes with Ace3
------------------------------------------------------------------------

Original file line number Diff line number Diff line change
@@ -1,62 +1,26 @@
--[[ $Id: CallbackHandler-1.0.lua 18 2014-10-16 02:52:20Z mikk $ ]]
local MAJOR, MINOR = "CallbackHandler-1.0", 6
--[[ $Id: CallbackHandler-1.0.lua 26 2022-12-12 15:09:39Z nevcairiel $ ]]
local MAJOR, MINOR = "CallbackHandler-1.0", 8
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}

-- Lua APIs
local tconcat = table.concat
local assert, error, loadstring = assert, error, loadstring
local setmetatable, rawset, rawget = setmetatable, rawset, rawget
local securecallfunction, error = securecallfunction, error
local setmetatable, rawget = setmetatable, rawget
local next, select, pairs, type, tostring = next, select, pairs, type, tostring

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

local xpcall = xpcall

local function errorhandler(err)
return geterrorhandler()(err)
local function Dispatch(handlers, ...)
local index, method = next(handlers)
if not method then return end
repeat
securecallfunction(method, ...)
index, method = next(handlers, index)
until not method
end

local function CreateDispatcher(argCount)
local code = [[
local next, xpcall, eh = ...
local method, ARGS
local function call() method(ARGS) end
local function dispatch(handlers, ...)
local index
index, method = next(handlers)
if not method then return end
local OLD_ARGS = ARGS
ARGS = ...
repeat
xpcall(call, eh)
index, method = next(handlers, index)
until not method
ARGS = OLD_ARGS
end
return dispatch
]]

local ARGS, OLD_ARGS = {}, {}
for i = 1, argCount do ARGS[i], OLD_ARGS[i] = "arg"..i, "old_arg"..i end
code = code:gsub("OLD_ARGS", tconcat(OLD_ARGS, ", ")):gsub("ARGS", tconcat(ARGS, ", "))
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(next, xpcall, errorhandler)
end

local Dispatchers = setmetatable({}, {__index=function(self, argCount)
local dispatcher = CreateDispatcher(argCount)
rawset(self, argCount, dispatcher)
return dispatcher
end})

--------------------------------------------------------------------------
-- CallbackHandler:New
--
Expand All @@ -65,7 +29,7 @@ end})
-- 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)
function CallbackHandler.New(_self, target, RegisterName, UnregisterName, UnregisterAllName)

RegisterName = RegisterName or "RegisterCallback"
UnregisterName = UnregisterName or "UnregisterCallback"
Expand All @@ -87,19 +51,19 @@ function CallbackHandler:New(target, RegisterName, UnregisterName, UnregisterAll
local oldrecurse = registry.recurse
registry.recurse = oldrecurse + 1

Dispatchers[select('#', ...) + 1](events[eventname], eventname, ...)
Dispatch(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
for event,callbacks in pairs(registry.insertQueue) do
local first = not rawget(events, event) or not next(events[event]) -- test for empty before. not test for one member after. that one member may have been overwritten.
for object,func in pairs(callbacks) do
events[event][object] = func
-- fire OnUsed callback?
if first and registry.OnUsed then
registry.OnUsed(registry, target, eventname)
registry.OnUsed(registry, target, event)
first = nil
end
end
Expand Down
Loading

0 comments on commit 703dfa5

Please sign in to comment.