Remove dependency to AceLibrary and use LibStub instead #1


  • New
  • Patch
Open
Assigned to ckknight
  • Forge_User_17681748 created this issue Oct 12, 2008

    Patch to remove dependency to AceLibrary and use LibStub instead.

    Index: Libs/Deformat-2.0/Deformat-2.0.lua
    ===================================================================
    --- Libs/Deformat-2.0/Deformat-2.0.lua    (revision 49)
    +++ Libs/Deformat-2.0/Deformat-2.0.lua    (working copy)
    @@ -11,14 +11,11 @@
    ]]

    local MAJOR_VERSION = "Deformat-2.0"
    -local MINOR_VERSION = 90000 + tonumber(("$Revision$"):match("(%d+)"))
    +local MINOR_VERSION = tonumber(("$Revision$"):match("(%d+)"))

    +local lib, oldMinor = LibStub:NewLibrary(MAJOR_VERSION, MINOR_VERSION)
    +if not lib then return end

    -if not AceLibrary then error(MAJOR_VERSION .. " requires AceLibrary") end
    -if not AceLibrary:IsNewVersion(MAJOR_VERSION, MINOR_VERSION) then return end
    -
    -local Deformat = {}
    -
    do
         local sequences = {
             ["%d*d"] = "%%-?%%d+",
    @@ -199,7 +196,7 @@
             end
         end

    -    function Deformat:Deformat(text, a1, ...)
    +    function lib:Deformat(text, a1, ...)
             self:argCheck(text, 2, "string")
             self:argCheck(a1, 3, "string")
             local pattern = (''):join(a1, ...)
    @@ -211,8 +208,5 @@
    end

    local mt = getmetatable(Deformat) or {}
    -mt.__call = Deformat.Deformat
    -setmetatable(Deformat, mt)
    -
    -AceLibrary:Register(Deformat, MAJOR_VERSION, MINOR_VERSION)
    -Deformat = nil
    +mt.__call = lib.Deformat
    +setmetatable(lib, mt)

  • Forge_User_17681748 added the tags New Patch Oct 12, 2008
  • Forge_User_17681748 posted a comment Nov 8, 2008

    Poke.

  • Phanx posted a comment Mar 8, 2009
    These lines:
            self:argCheck(text, 2, "string")
            self:argCheck(a1, 3, "string")
    
    Need to be changed to:
            assert(type(text) == "string", "Bad argument #2 to :Deformat (string expected)")
            assert(type(a1) == "string", "Bad argument #3 to :Deformat (string expected)")
    
    Since LibStub does not provide an "argCheck" function as AceLibrary does.

To post a comment, please login or register a new account.