updating to v2.0.1

This commit is contained in:
Enrique García Cota 2012-01-30 00:09:37 +01:00
parent 7095da9ed1
commit c36ed687bc

View File

@ -1,4 +1,4 @@
-- beholder.lua - v2.0.0 (2011-11) -- beholder.lua - v2.0.1 (2011-11)
-- Copyright (c) 2011 Enrique García Cota -- Copyright (c) 2011 Enrique García Cota
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
@ -11,6 +11,14 @@ local function copy(t)
return c return c
end end
local function hash2array(t)
local arr, i = {}, 0
for _,v in pairs(t) do
i = i+1
arr[i] = v
end
return arr, i
end
-- private Node class -- private Node class
local nodesById = nil local nodesById = nil
@ -43,12 +51,12 @@ local function findOrCreateDescendantNode(self, keys)
end end
local function invokeNodeCallbacks(self, params) local function invokeNodeCallbacks(self, params)
local counter = 0 -- copy the hash into an array, for safety (self-erasures)
for _,callback in pairs(self.callbacks) do local callbacks, count = hash2array(self.callbacks)
callback(unpack(params)) for i=1,#callbacks do
counter = counter + 1 callbacks[i](unpack(params))
end end
return counter return count
end end
local function invokeAllNodeCallbacksInSubTree(self, params) local function invokeAllNodeCallbacksInSubTree(self, params)