Inheritance: IDisposable
コード例 #1
0
ファイル: LuaSvr.cs プロジェクト: wlgys8/slua
        public void init(Action<int> tick,Action complete,LuaSvrFlag flag=LuaSvrFlag.LSF_BASIC)
        {
            LuaState luaState = new LuaState();

            IntPtr L = luaState.L;
            LuaObject.init(L);
            lgo.openDebug = (flag&LuaSvrFlag.LSF_DEBUG)!=0;

            // be caurefull here, doBind Run in another thread
            // any code access unity interface will cause deadlock.
            // if you want to debug bind code using unity interface, need call doBind directly, like:
            // doBind(L);
            ThreadPool.QueueUserWorkItem(doBind, L);

            lgo.StartCoroutine(waitForBind(tick, () =>
            {
                this.luaState = luaState;
                doinit(L,flag);
                if (lgo.openDebug)
                {
                    lgo.StartCoroutine(waitForDebugConnection(() =>
                    {
                        complete();
                        checkTop(L);
                    }));
                }
                else
                {
                    complete();
                    checkTop(L);
                }
            }));
        }
コード例 #2
0
ファイル: LuaSvr.cs プロジェクト: ChelseaLing/slua
        public void init(Action<int> tick,Action complete,bool debug=false)
        {
            LuaState luaState = new LuaState();

            IntPtr L = luaState.L;
            LuaObject.init(L);

            ThreadPool.QueueUserWorkItem(doBind, L);

            lgo.StartCoroutine(waitForBind(tick, () =>
            {
                this.luaState = luaState;
                doinit(L);
                if (debug)
                {
                    lgo.StartCoroutine(waitForDebugConnection(() =>
                    {
                        complete();
                        checkTop(L);
                    }));
                }
                else
                {
                    complete();
                    checkTop(L);
                }
            }));
        }
コード例 #3
0
ファイル: LuaMain.cs プロジェクト: liangxiegame/QFramework
		//初始化
		private void init()
		{
//			if (mLuaState != null) {
//				mLuaState.Dispose ();
//			}
			#if UNITY_EDITOR
				LuaFileUtils.Instance.beZip = UseAssetBundleLuaInEditor;
			#else
				LuaFileUtils.Instance.beZip = true;
			#endif
			mLuaState = new LuaState();
			mLuaState.LogGC = false;
			mLuaState.Start();
			LuaBinder.Bind(mLuaState);
			mLuaState.DoFile(LuaFileUtils.Instance.beZip?LuaEnterFile:LuaEnterDebugFile);

			//协程
			luaCoroutine = GameObject.Find ("LuaCoroutine");
			if (luaCoroutine == null) {
				luaCoroutine = new GameObject ();
				luaCoroutine.gameObject.name = "LuaCoroutine";
				luaCoroutine.AddComponent<LuaCoroutineComponent> ();
				UnityEngine.Object.DontDestroyOnLoad(luaCoroutine);
			}
			LuaCoroutine.Register(mLuaState, luaCoroutine.GetComponent<LuaCoroutineComponent>());

			addFunc(FuncName.createLuaFile);

		}
コード例 #4
0
        public ObjectTranslator(LuaState interpreter,IntPtr luaState)
        {
            this.interpreter=interpreter;
            typeChecker=new CheckType(this);
            metaFunctions=new MetaFunctions(this);
            assemblies=new List<Assembly>();
            assemblies.Add(Assembly.GetExecutingAssembly());

            importTypeFunction = new LuaCSFunction(ObjectTranslator.importType);
            loadAssemblyFunction = new LuaCSFunction(ObjectTranslator.loadAssembly);
            registerTableFunction = new LuaCSFunction(ObjectTranslator.registerTable);
            unregisterTableFunction = new LuaCSFunction(ObjectTranslator.unregisterTable);
            getMethodSigFunction = new LuaCSFunction(ObjectTranslator.getMethodSignature);
            getConstructorSigFunction = new LuaCSFunction(ObjectTranslator.getConstructorSignature);

            ctypeFunction = new LuaCSFunction(ObjectTranslator.ctype);
            enumFromIntFunction = new LuaCSFunction(ObjectTranslator.enumFromInt);

            createLuaObjectList(luaState);
            createIndexingMetaFunction(luaState);
            createBaseClassMetatable(luaState);
            createClassMetatable(luaState);
            createFunctionMetatable(luaState);
            setGlobalFunctions(luaState);
        }
コード例 #5
0
 // Use this for initialization
 void Awake() {
     loader = new LuaLoader();
     lua = new LuaState();
     this.InitLuaLibrary();
     LuaBinder.Bind(lua);
     LuaCoroutine.Register(lua, this);
 }
コード例 #6
0
ファイル: LuaEvent.cs プロジェクト: zlanr/tolua
 void Clear()
 {
     //_call = null;
     _add = null;
     _remove = null;
     self = null;            
     luaState = null;
 }
コード例 #7
0
 public LuaFunction(LuaCSFunction function, LuaState interpreter)
 {
     _Reference = 0;
     this.function = function;
     _Interpreter = interpreter;
     L = _Interpreter.L;
     translator = _Interpreter.translator;            
 }
コード例 #8
0
 public LuaFunction(int reference, LuaState interpreter)
 {            
     _Reference = reference;
     this.function = null;
     _Interpreter = interpreter;
     L = _Interpreter.L;
     translator = _Interpreter.translator;            
 }
コード例 #9
0
        public void Close()
        {
            loop.Destroy();
            loop = null;

            lua.Dispose();
            lua = null;
            loader = null;
        }
コード例 #10
0
        // Use this for initialization
        void Awake()
        {
            loader = new LuaLoader();
            lua = new LuaState();
            this.OpenLibs();
            lua.LuaSetTop(0);

            LuaBinder.Bind(lua);
            LuaCoroutine.Register(lua, this);
        }
コード例 #11
0
ファイル: LuaEvent.cs プロジェクト: benbon/tolua
        //LuaFunction _call = null;

        public LuaEvent(LuaTable table)            
        {
            self = table;
            luaState = table.GetLuaState();
            self.AddRef();

            _add = self.RawGetLuaFunction("Add");
            _remove = self.RawGetLuaFunction("Remove");
            //_call = self.RawGetLuaFunction("__call");            
        }
コード例 #12
0
ファイル: DebugInterface.cs プロジェクト: Ribosome2/uLui
		public DebugInterface(LuaState L)
		{
			state=L;
			instance=this;

			IntPtr l = L.L;
			getTypeTable(l, "LuaDebugger");
			addMember(l, output, false);
			addMember(l, onBreak, false);
			addMember(l, md5, false);
			createTypeMetatable(l, typeof(DebugInterface));
		}
コード例 #13
0
ファイル: LuaEvent.cs プロジェクト: zlanr/tolua
        //LuaFunction _call = null;

        public LuaEvent(LuaTable table)            
        {
            self = table;
            luaState = table.GetLuaState();
            self.AddRef();

            LuaTable meta = self.GetMetaTable();
            _add = meta.RawGetLuaFunction("Add");
            _remove = meta.RawGetLuaFunction("Remove");
            meta.Dispose();
            meta = null;
            //_call = self.RawGetLuaFunction("__call");            
        }
コード例 #14
0
ファイル: LuaBase.cs プロジェクト: sysuyedong/LuaForUnity
 public virtual void Dispose(bool disposeManagedResources)
 {
     if (!_Disposed)
     {
         if (disposeManagedResources)
         {
             if (_Reference != 0)
                 _Interpreter.dispose(_Reference);
         }
         _Interpreter = null;
         _Disposed = true;
     }
 }
コード例 #15
0
ファイル: LuaLogWrap.cs プロジェクト: Klanly/u3dgame
 static int OpenLibs(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         LuaInterface.LuaState arg0 = (LuaInterface.LuaState)ToLua.CheckObject <LuaInterface.LuaState>(L, 1);
         LuaLog.OpenLibs(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #16
0
        // make sure lua state finalize at last
        // make sure LuaSvrGameObject excute order is max(9999)
        void OnDestroy()
        {
            if (state != null)
            {
                if (di != null)
                {
                    di.close();
                    di = null;
                }

                state.Dispose();
                state = null;
            }
        }
コード例 #17
0
 static int SetMainLuaEnv(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         LuaInterface.LuaState arg0 = (LuaInterface.LuaState)ToLua.CheckObject <LuaInterface.LuaState>(L, 1);
         MikuLuaProfiler.LuaProfiler.SetMainLuaEnv(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #18
0
 static int GetLuaState(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         LuaFramework.LuaManager obj = (LuaFramework.LuaManager)ToLua.CheckObject <LuaFramework.LuaManager>(L, 1);
         LuaInterface.LuaState   o   = obj.GetLuaState();
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #19
0
ファイル: LuaBaseRef.cs プロジェクト: benbon/tolua
        public virtual void Dispose(bool disposeManagedResources)
        {
            if (!beDisposed)
            {
                beDisposed = true;   

                if (reference > 0 && luaState != null)
                {
                    luaState.CollectRef(reference, name, !disposeManagedResources);
                }
                
                reference = 0;
                luaState = null;                             
            }            
        }
コード例 #20
0
    /// <summary>
    /// Initializes a new instance of the <see cref="UniWebViewMessage"/> struct.
    /// </summary>
    /// <param name="rawMessage">Raw message which will be parsed to a UniWebViewMessage.</param>
    public UniWebViewMessage(string rawMessage) : this()
    {
        this.rawMessage = rawMessage;
        string[] schemeSplit = rawMessage.Split(new string[] { "://" }, System.StringSplitOptions.None);
        if (schemeSplit.Length >= 2)
        {
            this.scheme = schemeSplit[0];
            string pathAndArgsString = "";
            int    index             = 1;
            while (index < schemeSplit.Length)
            {
                pathAndArgsString = string.Concat(pathAndArgsString, schemeSplit[index]);
                index++;
            }

            string[] split = pathAndArgsString.Split("?"[0]);

            this.path = split[0].TrimEnd('/');
            this.args = new Dictionary <string, string>();
            if (split.Length > 1)
            {
                foreach (string pair in split[1].Split("&"[0]))
                {
                    string[] elems = pair.Split("="[0]);
                    if (elems.Length > 1)
                    {
                        args[elems[0]] = WWW.UnEscapeURL(elems[1]);
                    }
                }
            }

            LuaInterface.LuaState luastate = LuaClient.GetMainState();
            table               = luastate.GetTable(2);
            table["scheme"]     = this.scheme;
            table["path"]       = this.path;
            table["rawMessage"] = this.rawMessage;
            foreach (KeyValuePair <string, string> kvp in args)
            {
                //Debug.Log(kvp.Key);
                //Debug.Log(kvp.Value);
                table[kvp.Key] = kvp.Value;
            }
        }
        else
        {
            Debug.LogError("Bad url scheme. Can not be parsed to UniWebViewMessage: " + rawMessage);
        }
    }
コード例 #21
0
    static int get_luaState(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            LuaLooper             obj = (LuaLooper)o;
            LuaInterface.LuaState ret = obj.luaState;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index luaState on a nil value"));
        }
    }
コード例 #22
0
    static int get_mainLua(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            LuaFramework.LuaManager obj = (LuaFramework.LuaManager)o;
            LuaInterface.LuaState   ret = obj.mainLua;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index mainLua on a nil value"));
        }
    }
コード例 #23
0
	static int get_Lua(IntPtr L)
	{
		object o = null;

		try
		{
			o = ToLua.ToObject(L, 1);
			LuaRoot obj = (LuaRoot)o;
			LuaInterface.LuaState ret = obj.Lua;
			ToLua.PushObject(L, ret);
			return 1;
		}
		catch(Exception e)
		{
			return LuaDLL.toluaL_exception(L, e, o, "attempt to index Lua on a nil value");
		}
	}
コード例 #24
0
    static int set_luaState(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            LuaLooper             obj  = (LuaLooper)o;
            LuaInterface.LuaState arg0 = (LuaInterface.LuaState)ToLua.CheckObject <LuaInterface.LuaState>(L, 2);
            obj.luaState = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index luaState on a nil value"));
        }
    }
コード例 #25
0
    static int get_LuaState(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityGameFramework.Runtime.Lua.LuaComponent obj = (UnityGameFramework.Runtime.Lua.LuaComponent)o;
            LuaInterface.LuaState ret = obj.LuaState;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index LuaState on a nil value" : e.Message));
        }
    }
コード例 #26
0
ファイル: LuaSvr.cs プロジェクト: huangkumao/slua
        public LuaSvr(string main)
        {
            luaState = new LuaState();

            GameObject go = new GameObject("LuaSvrProxy");
            lgo = go.AddComponent<LuaSvrGameObject>();
            GameObject.DontDestroyOnLoad(go);
            lgo.state = luaState;
            lgo.onUpdate = this.tick;

            LuaState.pcall(luaState.L, init);

            start(main);

            if (LuaDLL.lua_gettop(luaState.L) != errorReported)
            {
                Debug.LogError("Some function not remove temp value from lua stack. You should fix it.");
                errorReported = LuaDLL.lua_gettop(luaState.L);
            }
        }
コード例 #27
0
ファイル: LuaBase.cs プロジェクト: ylyking/UnityHotUpdate
        public virtual void Dispose(bool disposeManagedResources)
        {
            if (!_Disposed)
            {
                if (_Reference != 0 && _Interpreter != null)
                {
                    if (disposeManagedResources)
                    {
                        _Interpreter.dispose(_Reference);
                        _Reference = 0;
                    }
                    else if (_Interpreter.L != IntPtr.Zero)
                    {
                        LuaScriptMgr.refGCList.Enqueue(new LuaRef(_Interpreter.L, _Reference));
                        _Reference = 0;
                    }
                }

                _Interpreter = null;
                _Disposed = true;
            }
        }
コード例 #28
0
ファイル: LuaFunction.cs プロジェクト: sysuyedong/LuaForUnity
 //internal int reference;
 public LuaFunction(int reference, LuaState interpreter)
 {
     _Reference = reference;
     this.function = null;
     _Interpreter = interpreter;
 }
コード例 #29
0
 //internal int _Reference;
 //private Lua _Interpreter;
 public LuaTable(int reference, LuaState interpreter)
 {
     _Reference   = reference;
     _Interpreter = interpreter;
 }
コード例 #30
0
		public static void Bind(LuaState state) {}
コード例 #31
0
ファイル: LuaManager.cs プロジェクト: fanyc/LuaFramework_UGUI
 // Use this for initialization
 void Awake() {
     loader = new LuaLoader();
     lua = new LuaState();
     LuaBinder.Bind(lua);
 }
コード例 #32
0
ファイル: Lua.cs プロジェクト: ylyking/UnityHotUpdate
        public LuaThread( LuaState parentState, LuaFunction threadFunc )
        {
			// Copy from parent
			this.tracebackFunction = parentState.tracebackFunction;			
			this.translator = parentState.translator;
			this.translator.interpreter = this;
			
			this.panicCallback = parentState.panicCallback;

			this.printFunction = parentState.printFunction;
			this.loadfileFunction = parentState.loadfileFunction;
			this.loaderFunction = parentState.loaderFunction;
			this.dofileFunction = parentState.dofileFunction;
			
            // Assign to store
            func = threadFunc;
            parent = parentState;

            // Create Thread
            L = LuaDLL.lua_newthread( parent.L );

            // Store thread in registry
            threadRef = LuaDLL.luaL_ref( parent.L, LuaIndexes.LUA_REGISTRYINDEX );
        }
コード例 #33
0
ファイル: LuaThread.cs プロジェクト: RuYi51/LuaFramework_NGUI
 public LuaThread(int reference, LuaState state)
 {
     this.luaState = state;
     this.reference = reference;
 }
コード例 #34
0
        public void Close() {
            SafeRelease(ref updateFunc);
            SafeRelease(ref lateUpdateFunc);
            SafeRelease(ref fixedUpdateFunc);

            if (UpdateEvent != null) {
                UpdateEvent.Dispose();
                UpdateEvent = null;
            }

            if (LateUpdateEvent != null) {
                LateUpdateEvent.Dispose();
                LateUpdateEvent = null;
            }

            if (FixedUpdateEvent != null) {
                FixedUpdateEvent.Dispose();
                FixedUpdateEvent = null;
            }
            lua.Dispose();
            lua = null;
            loader = null;
        }
コード例 #35
0
ファイル: LuaFunction.cs プロジェクト: sysuyedong/LuaForUnity
 public LuaFunction(LuaCSFunction function, LuaState interpreter)
 {
     _Reference = 0;
     this.function = function;
     _Interpreter = interpreter;
 }
コード例 #36
0
ファイル: LuaUserData.cs プロジェクト: sysuyedong/LuaForUnity
 //internal int _Reference;
 //private Lua _Interpreter;
 public LuaUserData(int reference, LuaState interpreter)
 {
     _Reference = reference;
     _Interpreter = interpreter;
 }
コード例 #37
0
ファイル: LuaSvr.cs プロジェクト: xclouder/godbattle
		public void init(Action<int> tick,Action complete,LuaSvrFlag flag=LuaSvrFlag.LSF_3RDDLL)
        {
			LuaState luaState = new LuaState();

			IntPtr L = luaState.L;
			LuaObject.init(L);

#if SLUA_STANDALONE
            doBind(L);
		    this.luaState = luaState;
            doinit(L, flag);
		    complete();
            checkTop(L);
#else
			

			// be caurefull here, doBind Run in another thread
			// any code access unity interface will cause deadlock.
			// if you want to debug bind code using unity interface, need call doBind directly, like:
			// doBind(L);
			ThreadPool.QueueUserWorkItem(doBind, L);

			lgo.StartCoroutine(waitForBind(tick, () =>
			{
				this.luaState = luaState;
				doinit(L,flag);
				complete();
				checkTop(L);
			}));
#endif
        }
コード例 #38
0
ファイル: LuaSvr.cs プロジェクト: tenvick/hugula
 public LuaSvr()
 {
     LuaState luaState = new LuaState();
     this.luaState = luaState;
 }
コード例 #39
0
ファイル: ObjectTranslator.cs プロジェクト: fengqk/Art
		public ObjectTranslator(LuaState interpreter,IntPtr luaState)
		{	
			this.interpreter=interpreter;
		}
コード例 #40
0
 public LuaThread(int reference, LuaState state)
 {
     this.luaState  = state;
     this.reference = reference;
 }
コード例 #41
0
ファイル: LuaFunction.cs プロジェクト: woshihuo12/UnityHello
 public LuaFunction(int reference, LuaState state)
 {
     this.reference = reference;
     this.luaState = state;
 }