Merge pull request #29 from fortressforever/fix-class_info

Don't crash if class_info() is called on non-luabind objects
This commit is contained in:
Ryan Liptak 2015-03-26 19:14:39 -07:00
commit 4dac32dcf9

View file

@ -48,6 +48,20 @@ function baseclass:new (o)
end
-----------------------------------------------------------------------------
-- make luabind's class_info function safer
-- (don't crash if class_info() is called on non-luabind objects)
-----------------------------------------------------------------------------
local class_info_base = class_info
class_info = function(obj)
local obj_type = type(obj)
if obj_type == "userdata" and getmetatable(obj).__luabind_class then
return class_info_base(obj)
end
return {}
end
-----------------------------------------------------------------------------
-- reset everything
-----------------------------------------------------------------------------