static int lua_replaceDefinition(lua_State* L)
{
    return cclua::obj_call(L,
                           [=](fla::MoviePart* part, cclua::Index idx)
                           {
                               fla::Definition* definition;
                               if (!luaval_to_object(L, idx.val, "fla.Definition", &definition))
                               {
                                   return;
                               }
                               part->replaceDefinition(definition);
                           });
}
int lua_glue_auto_GlDisplayService_getWindowHandle(lua_State* L)
{
    display::GlDisplayService* cobj = (display::GlDisplayService*)tolua_tousertype(L, 1, 0);
    bool ok = true;

    GLFWwindow* window;

    ok &= luaval_to_object(L, 2, "glfw.GLFWwindow", &window, "display.GlDisplayService:getWindowHandle");

    if (!ok)
    {
        tolua_error(L, "invalid arguments in function 'lua_glue_auto_GlDisplayService_getWindowHandle'", nullptr);
        return 0;
    }
    int ret = cobj->getWindowHandle(window);
    tolua_pushnumber(L, (lua_Number)ret);
    return 1;
}
int lua_cocos2dx_physics3d_Physics3DShape_createCompoundShape(lua_State* L)
{
    int argc = 0;
    bool ok  = true;
    
    tolua_Error tolua_err;
    
#if COCOS2D_DEBUG >= 1
    if (!tolua_isusertable(L,1,"cc.Physics3DShape",0,&tolua_err)) goto tolua_lerror;
#endif
    
    argc = lua_gettop(L) - 1;
    
    if (argc == 1)
    {
        
        std::vector<std::pair<cocos2d::Physics3DShape *, cocos2d::Mat4>> shapes;
        if (!tolua_istable(L, 2, 0, &tolua_err) )
        {
#if COCOS2D_DEBUG >=1
            luaval_to_native_err(L,"#ferror:",&tolua_err,"cc.Physics3DShape:createCompoundShape");
#endif
            ok = false;
        }
        
        if (ok)
        {
            size_t len = lua_objlen(L, 2);
            cocos2d::Physics3DShape* shape = nullptr;
            cocos2d::Mat4 mat;
            for (size_t i = 0; i < len; i++)
            {
                lua_pushnumber(L,i + 1);
                lua_gettable(L,2);
                if (lua_istable(L, -1))
                {
                    lua_pushnumber(L, 1);
                    lua_gettable(L, -2);
                    luaval_to_object(L, lua_gettop(L), "cc.Physics3DShape", &shape);
                    lua_pop(L,1);
                    
                    lua_pushnumber(L, 2);
                    lua_gettable(L, -2);
                    luaval_to_mat4(L, lua_gettop(L), &mat);
                    lua_pop(L,1);
                    
                    shapes.push_back(std::make_pair(shape, mat));
                }
                lua_pop(L, 1);
            }
        }

        cocos2d::Physics3DShape* ret = cocos2d::Physics3DShape::createCompoundShape(shapes);
        object_to_luaval<cocos2d::Physics3DShape>(L, "cc.Physics3DShape",(cocos2d::Physics3DShape*)ret);
        return 1;
    }
    luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Physics3DShape:createCompoundShape",argc, 1);
    return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
    tolua_error(L,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DShape_createCompoundShape'.",&tolua_err);
#endif
    return 0;
}