コード例 #1
0
bool LuaStack::pushFunctionByHandler(int nHandler)
{
    toluafix_get_function_by_refid(_state, nHandler);                  /* L: ... func */
    if (!lua_isfunction(_state, -1))
    {
        CCLOG("[LUA ERROR] function refid '%d' does not reference a Lua function", nHandler);
        lua_pop(_state, 1);
        return false;
    }
    return true;
}
コード例 #2
0
ファイル: ge_lua_engine.cpp プロジェクト: AmbBAI/GameBits
int GELuaEngine::run_function( LUA_FUNCTION func_id, int args_cnt )
{
	if (lua_state_ == NULL) return false;

	toluafix_get_function_by_refid(lua_state_, func_id);
	if (!lua_isfunction(lua_state_, -1))
	{
		fprintf(stderr, "function refid '%d' does not reference a Lua function\n", func_id);
		lua_pop(lua_state_, 1);
		lua_settop(lua_state_, 0);
		return false;
	}

	if (args_cnt > 0)
	{
		lua_insert(lua_state_, -(args_cnt + 1));
	}
	int ret = _execute_function(args_cnt);

	lua_settop(lua_state_, 0);
	return ret;
}
コード例 #3
0
int lua_glue_auto_GlDisplayService_addWindowCloseListener(lua_State* L)
{
    display::GlDisplayService* cobj = (display::GlDisplayService*)tolua_tousertype(L, 1, 0);
    bool ok = true;

    std::function<void (int)> listener;

    int listenerFunc = toluafix_ref_function(L, 2, 0);
		
		listener = [=](int larg0) -> void {
		    toluafix_get_function_by_refid(L, listenerFunc);
		    tolua_pushnumber(L, (lua_Number)larg0);
		    LuaStack::executeFunction(L, 1);
		};

    if (!ok)
    {
        tolua_error(L, "invalid arguments in function 'lua_glue_auto_GlDisplayService_addWindowCloseListener'", nullptr);
        return 0;
    }
    int ret = cobj->addWindowCloseListener(listener);
    tolua_pushnumber(L, (lua_Number)ret);
    return 1;
}