changeset 44:8913e7d79cad

Refactoring some very simple items to a Utility file
author John@Yosemite-PC
date Thu, 15 Mar 2012 22:58:54 -0400
parents 4109683c3172
children 8d3187b12443
files Core.lua Lists.lua Utility.lua breuesk.toc
diffstat 4 files changed, 61 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/Core.lua	Thu Mar 15 22:27:51 2012 -0400
+++ b/Core.lua	Thu Mar 15 22:58:54 2012 -0400
@@ -38,19 +38,6 @@
 -- 4) table.remove() works ok if reverse iterating, terrible at anything else
 -- 5) pairs() does not have a guaranteed iteration order
 
--- These two functions properly format the call to AceConsole:Print(), which
--- needs a full object. Calling "Print" will call the mixed-in console functions
--- but without a self parameter because of the namespacing. I would disembed
--- console, except that it has handy OnDisable behavior to disable chat
--- commands.
-function print(...)
-    bsk:Print(...)
-end
-
-function printf(...)
-    bsk:Printf(...)
-end
-
 function OnInitialize()
 
     db = _G.LibStub("AceDB-3.0"):New("BskDB", defaults, "Default")
--- a/Lists.lua	Thu Mar 15 22:27:51 2012 -0400
+++ b/Lists.lua	Thu Mar 15 22:58:54 2012 -0400
@@ -105,21 +105,6 @@
     reserveIdP = {}
     personName2id = {}
 end
-function tcopy(to, from)
-  for k,v in pairs(from) do
-    if(type(v)=="table") then
-      to[k] = {}
-      tcopy(to[k], v);
-    else
-      to[k] = v;
-    end
-  end
-end
-local shallowCopy = function(t)
-  local u = { }
-  for k, v in pairs(t) do u[k] = v end
-  return setmetatable(u, getmetatable(t))
-end
 
 -- Debugging {{{
 function PrettyPrintList(listIndex)
@@ -150,28 +135,6 @@
         end
     end
 end
-function PrintTable(table, depth)
-    depth = depth or ""
-    if not table then return end
-    if #depth > 3*5 then print(depth.."Recursion too deep - stopping"); return end
-    for i,v in pairs(table) do 
-        if( type(v) == "string" ) then
-            print(depth .. i ..  " - " .. v) 
-        elseif( type(v) == "number" ) then
-            print(depth .. i .. " - " .. tostring(v))
-        elseif( type(v) == "table" ) then
-            print(depth .. i .." - ") 
-            PrintTable(v,depth.."   ")
-        elseif( type(v) == "boolean" ) then
-            print(depth .. i .. " - " .. tostring(v))
-        elseif( type(v) == "function" ) then
-            print(depth .. "function " .. i .. "()")
-        else
-            print(depth .. i .. " - not sure how to print type: " .. type(v) )
-        end
-    end
-end
-
 function PrintRaidAndReserve()
     print("RaidNameP")
     PrintTable(raidNameP)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Utility.lua	Thu Mar 15 22:58:54 2012 -0400
@@ -0,0 +1,59 @@
+local pairs=pairs
+local type=type
+local getmetatable=getmetatable
+local setmetatable=setmetatable
+
+setfenv(1,bsk)
+
+-- These two functions properly format the call to AceConsole:Print(), which
+-- needs a full object. Calling "Print" will call the mixed-in console functions
+-- but without a self parameter because of the namespacing. I would disembed
+-- console, except that it has handy OnDisable behavior to disable chat
+-- commands.
+function print(...)
+    bsk:Print(...)
+end
+
+function printf(...)
+    bsk:Printf(...)
+end
+
+function tcopy(to, from)
+  for k,v in pairs(from) do
+    if(type(v)=="table") then
+      to[k] = {}
+      tcopy(to[k], v);
+    else
+      to[k] = v;
+    end
+  end
+end
+
+function shallowCopy(t)
+  local u = { }
+  for k, v in pairs(t) do u[k] = v end
+  return setmetatable(u, getmetatable(t))
+end
+
+function PrintTable(table, depth)
+    depth = depth or ""
+    if not table then return end
+    if #depth > 3*5 then print(depth.."Recursion too deep - stopping"); return end
+    for i,v in pairs(table) do 
+        if( type(v) == "string" ) then
+            print(depth .. i ..  " - " .. v) 
+        elseif( type(v) == "number" ) then
+            print(depth .. i .. " - " .. tostring(v))
+        elseif( type(v) == "table" ) then
+            print(depth .. i .." - ") 
+            PrintTable(v,depth.."   ")
+        elseif( type(v) == "boolean" ) then
+            print(depth .. i .. " - " .. tostring(v))
+        elseif( type(v) == "function" ) then
+            print(depth .. "function " .. i .. "()")
+        else
+            print(depth .. i .. " - not sure how to print type: " .. type(v) )
+        end
+    end
+end
+
--- a/breuesk.toc	Thu Mar 15 22:27:51 2012 -0400
+++ b/breuesk.toc	Thu Mar 15 22:58:54 2012 -0400
@@ -30,3 +30,5 @@
 Lists.lua
 Gui.lua
 Options.lua
+Utility.lua
+