mirror of https://github.com/axmolengine/axmol.git
Merge pull request #7532 from lite3/object_to_luaval
replace dynamic_cast to std::is_base_of
This commit is contained in:
commit
31af102f26
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue