allow multiple lua files to be used in lua_pictures
begin "stdlib" for skia in lua
add comments to scrape.lua



git-svn-id: http://skia.googlecode.com/svn/trunk@9206 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/lua/scrape.lua b/tools/lua/scrape.lua
index 839d3fe..de0be08 100644
--- a/tools/lua/scrape.lua
+++ b/tools/lua/scrape.lua
@@ -1,11 +1,19 @@
+-- just a helper function to dump the parameters, for debugging
 function tostr(t)
     local str = ""
     for k, v in next, t do
-        str = str .. tostring(k) .. " "
-        if type(v) == "table" then
-            str = str .. "{ " .. tostr(v) .. "} "
+        if #str > 0 then
+            str = str .. ", "
+        end
+        if type(k) == "number" then
+            str = str .. "[" .. k .. "] = "
         else
-            str = str .. tostring(v) .. " "
+            str = str .. tostring(k) .. " = "
+        end
+        if type(v) == "table" then
+            str = str .. "{ " .. tostr(v) .. " }"
+        else
+            str = str .. tostring(v)
         end
     end
     return str
@@ -14,30 +22,25 @@
 canvas = {}
 total = 0
 
+-- called with the parameters to each canvas.draw call
 function accumulate(t)
-    local verb = t.verb
-    t.verb = nil
-
     total = total + 1
-    local n = canvas[verb] or 0
-    n = n + 1
-    canvas[verb] = n
+    local n = canvas[t.verb] or 0
+    canvas[t.verb] = n + 1
 
-    io.write(verb, " ")
-    io.write(tostr(t), "\n")
+    -- enable to dump all of the parameters we were sent
+    if false then
+        -- dump the params in t, specifically showing the verb first, which we
+        -- then nil out so it doesn't appear in tostr()
+        io.write(t.verb, " ")
+        t.verb = nil
+        io.write(tostr(t), "\n")
+    end
 end
 
+-- lua_pictures will call this function after all of the files have been
+-- "accumulated"
 function summarize()
     io.write("total ", total, "\n", tostr(canvas), "\n")
 end
 
---[[
-function drawsomething()
-    local s = skia_newsurface(100, 100)
-    local c = s:getcanvas();
-    c:setColor(1, 0, 0, 1)
-    c:drawRect(10, 10, 50, 50)
-    s:saveImage("image.png")
-end
---]]
-