Mercurial > wow > reaction
annotate modules/FuBar_ReActionFu/lib/LibRock-1.0/LibStub/LibStub.lua @ 30:0d95ce7a9ec2
- added Ace3 externs
- converted ReAction_ConfigUI to use blizzard interface addons panel via AceConfigDialog-3.0
- partially converted FuBar module to LibRock, deprecated it (going to remove it entirely later)
- cleaned up a couple other tidbits
author | Flick <flickerstreak@gmail.com> |
---|---|
date | Wed, 02 Apr 2008 23:31:13 +0000 |
parents | |
children |
rev | line source |
---|---|
flickerstreak@30 | 1 -- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info |
flickerstreak@30 | 2 -- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke |
flickerstreak@30 | 3 local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! |
flickerstreak@30 | 4 local LibStub = _G[LIBSTUB_MAJOR] |
flickerstreak@30 | 5 |
flickerstreak@30 | 6 if not LibStub or LibStub.minor < LIBSTUB_MINOR then |
flickerstreak@30 | 7 LibStub = LibStub or {libs = {}, minors = {} } |
flickerstreak@30 | 8 _G[LIBSTUB_MAJOR] = LibStub |
flickerstreak@30 | 9 LibStub.minor = LIBSTUB_MINOR |
flickerstreak@30 | 10 |
flickerstreak@30 | 11 function LibStub:NewLibrary(major, minor) |
flickerstreak@30 | 12 assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") |
flickerstreak@30 | 13 minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") |
flickerstreak@30 | 14 |
flickerstreak@30 | 15 local oldminor = self.minors[major] |
flickerstreak@30 | 16 if oldminor and oldminor >= minor then return nil end |
flickerstreak@30 | 17 self.minors[major], self.libs[major] = minor, self.libs[major] or {} |
flickerstreak@30 | 18 return self.libs[major], oldminor |
flickerstreak@30 | 19 end |
flickerstreak@30 | 20 |
flickerstreak@30 | 21 function LibStub:GetLibrary(major, silent) |
flickerstreak@30 | 22 if not self.libs[major] and not silent then |
flickerstreak@30 | 23 error(("Cannot find a library instance of %q."):format(tostring(major)), 2) |
flickerstreak@30 | 24 end |
flickerstreak@30 | 25 return self.libs[major], self.minors[major] |
flickerstreak@30 | 26 end |
flickerstreak@30 | 27 |
flickerstreak@30 | 28 function LibStub:IterateLibraries() return pairs(self.libs) end |
flickerstreak@30 | 29 setmetatable(LibStub, { __call = LibStub.GetLibrary }) |
flickerstreak@30 | 30 end |