示例#1
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");            
        }
示例#2
0
        //LuaFunction _call = null;

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

            _add    = self.GetLuaFunction("Add");
            _remove = self.GetLuaFunction("Remove");
            //_call = self.GetLuaFunction("__call");
        }
示例#3
0
        public void AddRef()
        {
            ++count;
            //Debugger.Log("LuaDelegate {0} AddRef {1}", reference, count);
            func.AddRef();

            if (self != null)
            {
                self.AddRef();
            }
        }
示例#4
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");            
        }
        //LuaFunction _call = null;

        #region constructor

        public LuaBeatEvent(LuaTable table)
        {
            self = table;
            // 获取参数 table 的 luaState 字段的值
            luaState = table.GetLuaState();
            // 增加引用计数
            self.AddRef();

            // 获取 self 中的 Add 和 Remove 方法
            _add    = self.GetLuaFunction("Add");
            _remove = self.GetLuaFunction("Remove");
            //_call = self.GetLuaFunction("__call");
        }
示例#6
0
 public LuaDictTable(LuaTable table)
 {
     table.AddRef();
     this.table = table;
     this.state = table.GetLuaState();
 }
示例#7
0
 public LuaArrayTable(LuaTable table)
 {
     table.AddRef();
     this.table = table;
     this.state = table.GetGLuaState();
 }
示例#8
0
        public LuaTable GetTable(string fullPath, bool beLogMiss = true)
        {
            WeakReference weak = null;

            if (funcMap.TryGetValue(fullPath, out weak))
            {
                if (weak.IsAlive)
                {
                    LuaTable table = weak.Target as LuaTable;

                    if (table.IsAlive)
                    {
                        table.AddRef();
                        RemoveFromGCList(table.GetReference());
                        return(table);
                    }
                }

                funcMap.Remove(fullPath);
            }

            if (PushLuaTable(fullPath, false))
            {
                int      reference = ToLuaRef();
                LuaTable table     = null;

                if (funcRefMap.TryGetValue(reference, out weak))
                {
                    if (weak.IsAlive)
                    {
                        table = weak.Target as LuaTable;

                        if (table.IsAlive)
                        {
                            funcMap.Add(fullPath, weak);
                            table.AddRef();
                            RemoveFromGCList(reference);
                            return(table);
                        }
                    }

                    funcRefMap.Remove(reference);
                }

                table      = new LuaTable(reference, this);
                table.name = fullPath;
                funcMap.Add(fullPath, new WeakReference(table));
                funcRefMap.Add(reference, new WeakReference(table));
                if (LogGC)
                {
                    Debugger.Log("Alloc LuaTable name {0}, id {1}", fullPath, reference);
                }
                RemoveFromGCList(reference);
                return(table);
            }

            if (beLogMiss)
            {
                Debugger.LogWarning("Lua table {0} not exists", fullPath);
            }

            return(null);
        }