mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into developEventTrigger
This commit is contained in:
commit
52a0b906da
|
@ -194,6 +194,23 @@ extern bool luaval_to_ccvaluemap(lua_State* L, int lo, cocos2d::ValueMap* ret);
|
|||
extern bool luaval_to_ccvaluemapintkey(lua_State* L, int lo, cocos2d::ValueMapIntKey* ret);
|
||||
extern bool luaval_to_ccvaluevector(lua_State* L, int lo, cocos2d::ValueVector* ret);
|
||||
|
||||
template <class T>
|
||||
bool luaval_to_object(lua_State* L, int lo, const char* type, T** ret)
|
||||
{
|
||||
if(nullptr == L || lua_gettop(L) < lo)
|
||||
return false;
|
||||
|
||||
if (!luaval_is_usertype(L, lo, type, 0))
|
||||
return false;
|
||||
|
||||
*ret = static_cast<T*>(tolua_tousertype(L, lo, 0));
|
||||
|
||||
if (nullptr == ret)
|
||||
LUA_PRECONDITION(ret, "Invalid Native Object");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// from native
|
||||
extern void point_to_luaval(lua_State* L,const Point& pt);
|
||||
|
@ -276,4 +293,43 @@ void ccvalue_to_luaval(lua_State* L,const cocos2d::Value& inValue);
|
|||
void ccvaluemap_to_luaval(lua_State* L,const cocos2d::ValueMap& inValue);
|
||||
void ccvaluemapintkey_to_luaval(lua_State* L, const cocos2d::ValueMapIntKey& inValue);
|
||||
void ccvaluevector_to_luaval(lua_State* L, const cocos2d::ValueVector& inValue);
|
||||
|
||||
template <class T>
|
||||
void object_to_luaval(lua_State* L,const char* type, T* ret)
|
||||
{
|
||||
if(nullptr != ret)
|
||||
{
|
||||
/**
|
||||
Because all override functions wouldn't be bound,so we must use `typeid` to get the real class name
|
||||
*/
|
||||
std::string hashName = typeid(*ret).name();
|
||||
auto iter = g_luaType.find(hashName);
|
||||
std::string className = "";
|
||||
if(g_luaType.end() != iter)
|
||||
{
|
||||
className = iter->second.c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
className = type;
|
||||
}
|
||||
|
||||
cocos2d::Object* dynObject = dynamic_cast<cocos2d::Object *>(ret);
|
||||
if (nullptr != dynObject)
|
||||
{
|
||||
int ID = (int)(dynObject->_ID) ;
|
||||
int* luaID = &(dynObject->_luaID);
|
||||
toluafix_pushusertype_ccobject(L,ID, luaID, (void*)ret,className.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
tolua_pushusertype(L,(void*)ret,className.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushnil(L);
|
||||
}
|
||||
}
|
||||
|
||||
#endif //__COCOS2DX_SCRIPTING_LUA_COCOS2DXSUPPORT_LUABAISCCONVERSIONS_H__
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 47343067f0d13240ea813cdb406de973ca5aa4e0
|
||||
Subproject commit 14dab059dc8a20992c6e76ba8296a67601078d5b
|
Loading…
Reference in New Issue