Beispiel #1
0
void LuaHelper::releaseFunction(int refid)
{
    if (refid > 0) {
        toluafix_remove_function_by_refid(L, refid);
    }
    /// luaL_unref(L, LUA_REGISTRYINDEX, refid);
}
	inline void unhandle(){
		if(_handler > 0){
			toluafix_remove_function_by_refid(_lua, _handler);
			lua_unref(_lua, _handlerRef);
			_handlerRef = 0;
			_handler = 0;
		}
	}
int lua_cocos2dx_physics_PhysicsWorld_rayCast(lua_State* tolua_S)
{
    int argc = 0;
    cocos2d::PhysicsWorld* cobj = nullptr;
    bool ok  = true;
    
#if COCOS2D_DEBUG >= 1
    tolua_Error tolua_err;
#endif
    
#if COCOS2D_DEBUG >= 1
    if (!tolua_isusertype(tolua_S,1,"cc.PhysicsWorld",0,&tolua_err)) goto tolua_lerror;
#endif
    
    cobj = (cocos2d::PhysicsWorld*)tolua_tousertype(tolua_S,1,0);
    
#if COCOS2D_DEBUG >= 1
    if (!cobj)
    {
        tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics_PhysicsWorld_rayCast'", NULL);
        return 0;
    }
#endif
    
    argc = lua_gettop(tolua_S)-1;
    if (argc == 3)
    {
        std::function<bool (cocos2d::PhysicsWorld &, const cocos2d::PhysicsRayCastInfo &, void *)> arg0;
        cocos2d::Point arg1;
        cocos2d::Point arg2;
        LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 2, 0);
        do {
            arg0 = [handler, tolua_S](cocos2d::PhysicsWorld &world, const cocos2d::PhysicsRayCastInfo &info, void * data) -> bool
            {                
                tolua_pushusertype(tolua_S, (void*)(&world), getLuaTypeName(&world, "cc.PhysicsWorld"));
                physics_raycastinfo_to_luaval(tolua_S, info);
                return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
            };
        } while(0);
        
        ok &= luaval_to_point(tolua_S, 3, &arg1);
        ok &= luaval_to_point(tolua_S, 4, &arg2);
        if(!ok)
            return 0;
        cobj->rayCast(arg0, arg1, arg2, nullptr);
        toluafix_remove_function_by_refid(tolua_S, handler);
        return 0;
    }
    CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "rayCast",argc, 4);
    return 0;
    
#if COCOS2D_DEBUG >= 1
tolua_lerror:
    tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics_PhysicsWorld_rayCast'.",&tolua_err);
#endif
    
    return 0;
}
Beispiel #4
0
void LuaStack::removeScriptHandler(int nHandler)
{
    toluafix_remove_function_by_refid(_state, nHandler);
}
Beispiel #5
0
void CCLuaEngine::removeLuaHandler(LUA_HANDLE nHandler)
{
    toluafix_remove_function_by_refid(m_state, nHandler);
}
Beispiel #6
0
// @brief Remove Lua function reference
void LuaManager::RemoveScriptHandler(int nHandler)
{
	 toluafix_remove_function_by_refid(luaState, nHandler);
}
Beispiel #7
0
void CCLuaEngine::removeScriptHandler(int nHandler)
{
    toluafix_remove_function_by_refid(m_state, nHandler);
}