Mercurial > wow > reaction
comparison 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 |
comparison
equal
deleted
inserted
replaced
29:9c89042bc328 | 30:0d95ce7a9ec2 |
---|---|
1 -- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info | |
2 -- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke | |
3 local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! | |
4 local LibStub = _G[LIBSTUB_MAJOR] | |
5 | |
6 if not LibStub or LibStub.minor < LIBSTUB_MINOR then | |
7 LibStub = LibStub or {libs = {}, minors = {} } | |
8 _G[LIBSTUB_MAJOR] = LibStub | |
9 LibStub.minor = LIBSTUB_MINOR | |
10 | |
11 function LibStub:NewLibrary(major, minor) | |
12 assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") | |
13 minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") | |
14 | |
15 local oldminor = self.minors[major] | |
16 if oldminor and oldminor >= minor then return nil end | |
17 self.minors[major], self.libs[major] = minor, self.libs[major] or {} | |
18 return self.libs[major], oldminor | |
19 end | |
20 | |
21 function LibStub:GetLibrary(major, silent) | |
22 if not self.libs[major] and not silent then | |
23 error(("Cannot find a library instance of %q."):format(tostring(major)), 2) | |
24 end | |
25 return self.libs[major], self.minors[major] | |
26 end | |
27 | |
28 function LibStub:IterateLibraries() return pairs(self.libs) end | |
29 setmetatable(LibStub, { __call = LibStub.GetLibrary }) | |
30 end |