Merge pull request #7937 from samuele3hu/v3_template_fix

Fix the crash of project which was created by the lua-template-runtime
This commit is contained in:
minggo 2014-09-03 15:12:36 +08:00
commit 5fa3e11613
3 changed files with 7 additions and 12 deletions

View File

@ -1995,23 +1995,23 @@ void vec3_to_luaval(lua_State* L,const cocos2d::Vec3& vec3)
lua_rawset(L, -3);
}
void vec4_to_luaval(lua_State* L,const cocos2d::Vec4& vec3)
void vec4_to_luaval(lua_State* L,const cocos2d::Vec4& vec4)
{
if (NULL == L)
return;
lua_newtable(L); /* L: table */
lua_pushstring(L, "x"); /* L: table key */
lua_pushnumber(L, (lua_Number) vec3.x); /* L: table key value*/
lua_pushnumber(L, (lua_Number) vec4.x); /* L: table key value*/
lua_rawset(L, -3); /* table[key] = value, L: table */
lua_pushstring(L, "y"); /* L: table key */
lua_pushnumber(L, (lua_Number) vec3.y); /* L: table key value*/
lua_pushnumber(L, (lua_Number) vec4.y); /* L: table key value*/
lua_rawset(L, -3);
lua_pushstring(L, "z"); /* L: table key */
lua_pushnumber(L, (lua_Number) vec3.z); /* L: table key value*/
lua_pushnumber(L, (lua_Number) vec4.z); /* L: table key value*/
lua_rawset(L, -3);
lua_pushstring(L, "w"); /* L: table key */
lua_pushnumber(L, (lua_Number) vec3.z); /* L: table key value*/
lua_pushnumber(L, (lua_Number) vec4.w); /* L: table key value*/
lua_rawset(L, -3);
}

View File

@ -240,7 +240,7 @@ extern bool luaval_to_std_vector_ushort(lua_State* L, int lo, std::vector<unsign
// from native
extern void vec2_to_luaval(lua_State* L,const cocos2d::Vec2& vec2);
extern void vec3_to_luaval(lua_State* L,const cocos2d::Vec3& vec3);
extern void vec4_to_luaval(lua_State* L,const cocos2d::Vec4& vec3);
extern void vec4_to_luaval(lua_State* L,const cocos2d::Vec4& vec4);
extern void vec2_array_to_luaval(lua_State* L,const cocos2d::Vec2* points, int count);
extern void size_to_luaval(lua_State* L,const Size& sz);
extern void rect_to_luaval(lua_State* L,const Rect& rt);

View File

@ -65,12 +65,7 @@ bool AppDelegate::applicationDidFinishLaunching()
auto engine = LuaEngine::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(engine);
lua_State* L = engine->getLuaStack()->getLuaState();
lua_getglobal(L, "_G");
if (lua_istable(L,-1))//stack:...,_G,
{
lua_module_register(L);
}
lua_pop(L, 1);//statck:...
lua_module_register(L);
LuaStack* stack = engine->getLuaStack();
stack->setXXTEAKeyAndSign("2dxLua", strlen("2dxLua"), "XXTEA", strlen("XXTEA"));