示例#1
0
        public LuaRuntime(object mark)
        {
            _mark = mark;
            var that = this;

            Script    = string.Empty;
            _disposer = new RuntimeDisposer(() =>
            {
                Script = string.Empty;
                that._hookManager.RemoveHook();
                HookManagerPool.Remove(that.State);
                LuaCore.Close(that.State);
                LuaRuntimePool.Remove(that.State);
                ObjectMgr.Dispose();
                ClassMgr.Dispose();
            });
            _luaState      = LuaCore.Initialze();
            _funcMgr       = new FunctionManager(_luaState);
            _classMgr      = new ClassManager(_luaState);
            _objectManager = new ObjectManager();

            LuaCore.Atpanic(State, ShowError);
            LuaRuntimePool.Add(_luaState, this);

            _hookManager = new HookManager(that);
            _hookManager.SetHook(EventMasks.All, 0);

            HookManagerPool.SetGlobalHookCallback();
            HookManagerPool.Add(_luaState, _hookManager);
        }