Log:
Joker - bugfix with library names.
- inject :GetLibraryVersion() onto libraries (like how AceLibrary does it, only in a significantly less hackish way)
Modified:
trunk/Joker/Joker.lua
Modified: trunk/Joker/Joker.lua
==============================================================================
--- trunk/Joker/Joker.lua (original)
+++ trunk/Joker/Joker.lua Sat Jul 28 14:31:18 2007
@@ -121,7 +121,7 @@
local exportedMethods_library = self.exportedMethods[oldLib]
local mixinToObject_library = self.mixinToObject[oldLib]
- local library = { name = major }
+ local library = {}
if oldLib then
local tmp = library
for k, v in pairs(oldLib) do
@@ -132,6 +132,7 @@
library = oldLib
oldLib = tmp
end
+ library.name = major
self_libraries[major] = library
self_libraryVersions[library] = version
if exportedMethods_library and mixinToObject_library then
@@ -188,11 +189,22 @@
return not not self.libraries[major]
end
-function Joker:GetLibraryVersion(major)
- if type(major) ~= "string" then
- error(("Bad argument #2 to `HasLibrary'. Expected %q, got %q."):format("string", type(major)), 2)
+function Joker:GetLibraryVersion()
+ local major
+ if Joker.libraries[self.name] == self then
+ major = self.name
+ else
+ for k,v in pairs(Joker.libraries) do
+ if v == self then
+ major = k
+ break
+ end
+ end
+ if not major then
+ return nil, nil
+ end
end
- return self.libraryVersions[self.libraries[major]]
+ return major, Joker.libraryVersions[self]
end
function Joker:IterateLibraries()
@@ -295,4 +307,4 @@
return pairs(self.addons)
end
-Joker:SetExportedMethods("SetExportedMethods", "Embed")
+Joker:SetExportedMethods("SetExportedMethods", "Embed", "GetLibraryVersion")