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); } })); }
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); } })); }
//初始化 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); }
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); }
// Use this for initialization void Awake() { loader = new LuaLoader(); lua = new LuaState(); this.InitLuaLibrary(); LuaBinder.Bind(lua); LuaCoroutine.Register(lua, this); }
void Clear() { //_call = null; _add = null; _remove = null; self = null; luaState = null; }
public LuaFunction(LuaCSFunction function, LuaState interpreter) { _Reference = 0; this.function = function; _Interpreter = interpreter; L = _Interpreter.L; translator = _Interpreter.translator; }
public LuaFunction(int reference, LuaState interpreter) { _Reference = reference; this.function = null; _Interpreter = interpreter; L = _Interpreter.L; translator = _Interpreter.translator; }
public void Close() { loop.Destroy(); loop = null; lua.Dispose(); lua = null; loader = null; }
// Use this for initialization void Awake() { loader = new LuaLoader(); lua = new LuaState(); this.OpenLibs(); lua.LuaSetTop(0); LuaBinder.Bind(lua); LuaCoroutine.Register(lua, this); }
//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"); }
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)); }
//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"); }
public virtual void Dispose(bool disposeManagedResources) { if (!_Disposed) { if (disposeManagedResources) { if (_Reference != 0) _Interpreter.dispose(_Reference); } _Interpreter = null; _Disposed = true; } }
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)); } }
// 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; } }
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)); } }
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)); } }
public virtual void Dispose(bool disposeManagedResources) { if (!beDisposed) { beDisposed = true; if (reference > 0 && luaState != null) { luaState.CollectRef(reference, name, !disposeManagedResources); } reference = 0; luaState = null; } }
/// <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); } }
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")); } }
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")); } }
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"); } }
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")); } }
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)); } }
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); } }
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; } }
//internal int reference; public LuaFunction(int reference, LuaState interpreter) { _Reference = reference; this.function = null; _Interpreter = interpreter; }
//internal int _Reference; //private Lua _Interpreter; public LuaTable(int reference, LuaState interpreter) { _Reference = reference; _Interpreter = interpreter; }
public static void Bind(LuaState state) {}
// Use this for initialization void Awake() { loader = new LuaLoader(); lua = new LuaState(); LuaBinder.Bind(lua); }
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 ); }
public LuaThread(int reference, LuaState state) { this.luaState = state; this.reference = reference; }
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; }
public LuaFunction(LuaCSFunction function, LuaState interpreter) { _Reference = 0; this.function = function; _Interpreter = interpreter; }
//internal int _Reference; //private Lua _Interpreter; public LuaUserData(int reference, LuaState interpreter) { _Reference = reference; _Interpreter = interpreter; }
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 }
public LuaSvr() { LuaState luaState = new LuaState(); this.luaState = luaState; }
public ObjectTranslator(LuaState interpreter,IntPtr luaState) { this.interpreter=interpreter; }
public LuaThread(int reference, LuaState state) { this.luaState = state; this.reference = reference; }
public LuaFunction(int reference, LuaState state) { this.reference = reference; this.luaState = state; }