vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 -- Inner cache metatable
2 local subMeta = {
3 -- Given a name, append it to the parent frame name, and then return
4 -- the result (cache it if it's found)
5 __index = function(t, name)
6 local tn = type(name);
7 if (tn == "string" or tn == "number") then
8 local realName = t._frameName .. name;
9 local realFrame = getglobal(realName);
10 if (realFrame) then
11 t[name] = realFrame;
12 end return realFrame;
13 end
14 end
15 };
16  
17 local topMeta = {
18 -- Given a frame or a frame name, create (or return) the subcache
19 -- for that frame.
20 __index = function(t, frame)
21 local tf = type(frame);
22 if (tf == "string") then
23 -- If we're passed a frame name, look up the frame behind
24 -- it and if it's found, get its subcache
25 local realFrame = getglobal(frame);
26 -- Prevent infinite looping
27 if (type(realFrame)=="table") then
28 local ret = t[realFrame];
29 if (ret) then
30 t[frame] = ret;
31 end
32 return ret;
33 end
34 elseif (tf == "table") then
35 -- Must create a new caching subtable if frame is an
36 -- actual Frame.
37 local gn = frame.GetName;
38 if (gn) then
39 local ret = {};
40 ret._frame = frame;
41 ret._frameName = gn(frame);
42 setmetatable(ret, subMeta);
43 t[frame] = ret;
44 return ret;
45 end
46 end
47 end
48 };
49 -- Create a fresh subframe cache and return it.
50 function CreateSubframeCache()
51 local ret = {};
52 setmetatable(ret, topMeta);
53 return ret;
54 end
55  
56 CT_RA_Cache = CreateSubframeCache();