Merge pull request #7532 from lite3/object_to_luaval

replace dynamic_cast to std::is_base_of
This commit is contained in:
minggo 2014-07-25 23:11:55 +08:00
commit 31af102f26
1 changed files with 3 additions and 4 deletions

View File

@ -361,11 +361,10 @@ void object_to_luaval(lua_State* L,const char* type, T* ret)
{
if(nullptr != ret)
{
cocos2d::Ref* dynObject = dynamic_cast<cocos2d::Ref *>(ret);
if (nullptr != dynObject)
if (std::is_base_of<cocos2d::Ref, T>::value)
{
// use c style cast, T may not polymorphic
cocos2d::Ref* dynObject = (cocos2d::Ref*)(ret);
int ID = (int)(dynObject->_ID) ;
int* luaID = &(dynObject->_luaID);
toluafix_pushusertype_ccobject(L,ID, luaID, (void*)ret,type);