Permalink
Browse files

Merge branches 'feature-sf-wrapfunction', 'fix-instance-deinitializat…

…ion-update' and 'fix-serialize-args' into develop
  • Loading branch information...
ColonelThirtyTwo committed Apr 16, 2012
3 parents 7361ffb + 9fbda43 + 765b014 commit 149d6fcd8981f2feed68346a2a2c6c7d5b660cae
@@ -36,6 +36,8 @@ function ENT:OnRestore()
end
function ENT:Compile(codetbl, mainfile)
+ if self.instance then self.instance:deinitialize() end
+
local ok, instance = SF.Compiler.Compile(codetbl,context,mainfile,self.owner)
if not ok then self:Error(instance) return end
self.instance = instance
@@ -73,6 +73,7 @@ function ENT:Error(msg)
end
function ENT:CodeSent(files, main, owner)
+ if self.instance then self.instance:deinitialize() end
self.owner = owner
local ok, instance = SF.Compiler.Compile(files,context,main,owner,{ent=self,screen={}})
if not ok then self:Error(instance) return end
@@ -51,6 +51,8 @@ function ENT:UpdateName(state)
end
function ENT:Compile(codetbl, mainfile)
+ if self.instance then self.instance:deinitialize() end
+
local ok, instance = SF.Compiler.Compile(codetbl,context,mainfile,self.owner)
if not ok then self:Error(instance) return end
self.instance = instance
View
@@ -225,30 +225,22 @@ local safe_types = {
function SF.Sanitize( ... )
-- Sanitize ALL the things.
local return_list = {}
- if not args then args = {...} end
+ local args = {...}
for key, value in pairs(args) do
local typ = type( value )
if safe_types[ typ ] then
return_list[key] = value
-
- elseif typ == "Entity" then
+ elseif typ == "Entity" or typ == "Player" or typ == "NPC" then
return_list[key] = SF.Entities.Wrap(value)
-
- elseif typ == "function" then
- return_list[key] = nil
-
- elseif typ == "table" and dgetmeta(value) ~= nil then
+ elseif typ == "table" and object_unwrappers[dgetmeta(value)] then
return_list[key] = SF.WrapObject(value)
-
elseif typ == "table" then
- local table = {}
+ local tbl = {}
for k,v in pairs(value) do
- table[SF.Sanitize(k)] = SF.Sanitize(v)
+ tbl[SF.Sanitize(k)] = SF.Sanitize(v)
end
-
- return_list[key] = table
-
+ return_list[key] = tbl
else
return_list[key] = nil
end
@@ -265,27 +257,19 @@ function SF.Unsanitize( ... )
local args = {...}
for key, value in pairs( args ) do
- if type(value) == "table" and dgetmeta(value) then
- local unwrapped = SF.UnwrapObject(value)
- if nil == unwrapped then
- unwrapped = value
- end
- return_list[key] = unwrapped
-
- elseif type(value) == "table" then
+ local typ = type(value)
+ if (typ == "table" and object_unwrappers[dgetmeta(value)]) then
+ return_list[key] = SF.UnwrapObject(value) or value
+ elseif typ == "table" then
for k,v in pairs(value) do
return_list[SF.Unsanitize(k)] = SF.Unsanitize(v)
end
-
- elseif type(value) == "Entity" then
- local unwrap = SF.Entities.Unwrap(value)
-
- return_list[key] = unwrap
-
else
return_list[key] = value
end
end
+
+ return unpack(args)
end
-- Library loading

0 comments on commit 149d6fc

Please sign in to comment.