static int set_reapplyDrivenProperties(IntPtr L)
    {
        try
        {
            EventObject arg0 = null;

            if (LuaDLL.lua_isuserdata(L, 2) != 0)
            {
                arg0 = (EventObject)ToLua.ToObject(L, 2);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "The event 'UnityEngine.RectTransform.reapplyDrivenProperties' can only appear on the left hand side of += or -= when used outside of the type 'UnityEngine.RectTransform'"));
            }

            if (arg0.op == EventOp.Add)
            {
                UnityEngine.RectTransform.ReapplyDrivenProperties ev = (UnityEngine.RectTransform.ReapplyDrivenProperties)DelegateFactory.CreateDelegate(typeof(UnityEngine.RectTransform.ReapplyDrivenProperties), arg0.func);
                UnityEngine.RectTransform.reapplyDrivenProperties += ev;
            }
            else if (arg0.op == EventOp.Sub)
            {
                UnityEngine.RectTransform.ReapplyDrivenProperties ev = (UnityEngine.RectTransform.ReapplyDrivenProperties)LuaMisc.GetEventHandler(null, typeof(UnityEngine.RectTransform), "reapplyDrivenProperties");
                Delegate[] ds    = ev.GetInvocationList();
                LuaState   state = LuaState.Get(L);

                for (int i = 0; i < ds.Length; i++)
                {
                    ev = (UnityEngine.RectTransform.ReapplyDrivenProperties)ds[i];
                    LuaDelegate ld = ev.Target as LuaDelegate;

                    if (ld != null && ld.func == arg0.func)
                    {
                        UnityEngine.RectTransform.reapplyDrivenProperties -= ev;
                        state.DelayDispose(ld.func);
                        break;
                    }
                }

                arg0.func.Dispose();
            }

            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 2
0
    static int set_textureRebuilt(IntPtr L)
    {
        try
        {
            EventObject arg0 = null;

            if (LuaDLL.lua_isuserdata(L, 2) != 0)
            {
                arg0 = (EventObject)ToLua.ToObject(L, 2);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "The event 'UnityEngine.Font.textureRebuilt' can only appear on the left hand side of += or -= when used outside of the type 'UnityEngine.Font'"));
            }

            if (arg0.op == EventOp.Add)
            {
                System.Action <UnityEngine.Font> ev = (System.Action <UnityEngine.Font>)DelegateFactory.CreateDelegate(typeof(System.Action <UnityEngine.Font>), arg0.func);
                UnityEngine.Font.textureRebuilt += ev;
            }
            else if (arg0.op == EventOp.Sub)
            {
                System.Action <UnityEngine.Font> ev = (System.Action <UnityEngine.Font>)LuaMisc.GetEventHandler(null, typeof(UnityEngine.Font), "textureRebuilt");
                Delegate[] ds    = ev.GetInvocationList();
                LuaState   state = LuaState.Get(L);

                for (int i = 0; i < ds.Length; i++)
                {
                    ev = (System.Action <UnityEngine.Font>)ds[i];
                    LuaDelegate ld = ev.Target as LuaDelegate;

                    if (ld != null && ld.func == arg0.func)
                    {
                        UnityEngine.Font.textureRebuilt -= ev;
                        state.DelayDispose(ld.func);
                        break;
                    }
                }

                arg0.func.Dispose();
            }

            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 3
0
    private static int Destroy(IntPtr L)
    {
        Delegate @delegate = ToLua.CheckObject(L, 1, typeof(Delegate)) as Delegate;

        Delegate[] invocationList = @delegate.GetInvocationList();
        for (int i = 0; i < invocationList.Length; i++)
        {
            LuaDelegate luaDelegate = invocationList[i].get_Target() as LuaDelegate;
            if (luaDelegate != null && luaDelegate.func != null)
            {
                luaDelegate.func.Dispose();
            }
        }
        return(0);
    }
    private static int set_onClickEvent(IntPtr L)
    {
        int result;

        try
        {
            TestEventListener testEventListener = (TestEventListener)ToLua.CheckObject(L, 1, typeof(TestEventListener));
            if (LuaDLL.lua_isuserdata(L, 2) != 0)
            {
                EventObject eventObject = (EventObject)ToLua.ToObject(L, 2);
                if (eventObject.op == EventOp.Add)
                {
                    TestEventListener.OnClick value = (TestEventListener.OnClick)DelegateFactory.CreateDelegate(typeof(TestEventListener.OnClick), eventObject.func);
                    testEventListener.onClickEvent += value;
                }
                else if (eventObject.op == EventOp.Sub)
                {
                    TestEventListener.OnClick onClick = (TestEventListener.OnClick)LuaMisc.GetEventHandler(testEventListener, typeof(TestEventListener), "onClickEvent");
                    Delegate[] invocationList         = onClick.GetInvocationList();
                    LuaState   luaState = LuaState.Get(L);
                    for (int i = 0; i < invocationList.Length; i++)
                    {
                        onClick = (TestEventListener.OnClick)invocationList[i];
                        LuaDelegate luaDelegate = onClick.Target as LuaDelegate;
                        if (luaDelegate != null && luaDelegate.func == eventObject.func)
                        {
                            testEventListener.onClickEvent -= onClick;
                            luaState.DelayDispose(luaDelegate.func);
                            break;
                        }
                    }
                    eventObject.func.Dispose();
                }
                result = 0;
            }
            else
            {
                result = LuaDLL.luaL_throw(L, "The event 'TestEventListener.onClickEvent' can only appear on the left hand side of += or -= when used outside of the type 'TestEventListener'");
            }
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Exemplo n.º 5
0
    public static Delegate RemoveDelegate(Delegate obj, LuaFunction func)
    {
        LuaState luaState = func.GetLuaState();

        Delegate[] invocationList = obj.GetInvocationList();
        for (int i = 0; i < invocationList.Length; i++)
        {
            LuaDelegate luaDelegate = invocationList[i].get_Target() as LuaDelegate;
            if (luaDelegate != null && luaDelegate.func == func)
            {
                obj = Delegate.Remove(obj, invocationList[i]);
                luaState.DelayDispose(luaDelegate.func);
                break;
            }
        }
        return(obj);
    }
    private static int set_reapplyDrivenProperties(IntPtr L)
    {
        int result;

        try
        {
            if (LuaDLL.lua_isuserdata(L, 2) != 0)
            {
                EventObject eventObject = (EventObject)ToLua.ToObject(L, 2);
                if (eventObject.op == EventOp.Add)
                {
                    RectTransform.ReapplyDrivenProperties value = (RectTransform.ReapplyDrivenProperties)DelegateFactory.CreateDelegate(typeof(RectTransform.ReapplyDrivenProperties), eventObject.func);
                    RectTransform.reapplyDrivenProperties += value;
                }
                else if (eventObject.op == EventOp.Sub)
                {
                    RectTransform.ReapplyDrivenProperties reapplyDrivenProperties = (RectTransform.ReapplyDrivenProperties)LuaMisc.GetEventHandler(null, typeof(RectTransform), "reapplyDrivenProperties");
                    Delegate[] invocationList = reapplyDrivenProperties.GetInvocationList();
                    LuaState   luaState       = LuaState.Get(L);
                    for (int i = 0; i < invocationList.Length; i++)
                    {
                        reapplyDrivenProperties = (RectTransform.ReapplyDrivenProperties)invocationList[i];
                        LuaDelegate luaDelegate = reapplyDrivenProperties.Target as LuaDelegate;
                        if (luaDelegate != null && luaDelegate.func == eventObject.func)
                        {
                            RectTransform.reapplyDrivenProperties -= reapplyDrivenProperties;
                            luaState.DelayDispose(luaDelegate.func);
                            break;
                        }
                    }
                    eventObject.func.Dispose();
                }
                result = 0;
            }
            else
            {
                result = LuaDLL.luaL_throw(L, "The event 'UnityEngine.RectTransform.reapplyDrivenProperties' can only appear on the left hand side of += or -= when used outside of the type 'UnityEngine.RectTransform'");
            }
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
    private static int set_logMessageReceivedThreaded(IntPtr L)
    {
        int result;

        try
        {
            if (LuaDLL.lua_isuserdata(L, 2) != 0)
            {
                EventObject eventObject = (EventObject)ToLua.ToObject(L, 2);
                if (eventObject.op == EventOp.Add)
                {
                    Application.LogCallback logCallback = (Application.LogCallback)DelegateFactory.CreateDelegate(typeof(Application.LogCallback), eventObject.func);
                    Application.add_logMessageReceivedThreaded(logCallback);
                }
                else if (eventObject.op == EventOp.Sub)
                {
                    Application.LogCallback logCallback2 = (Application.LogCallback)LuaMisc.GetEventHandler(null, typeof(Application), "logMessageReceivedThreaded");
                    Delegate[] invocationList            = logCallback2.GetInvocationList();
                    LuaState   luaState = LuaState.Get(L);
                    for (int i = 0; i < invocationList.Length; i++)
                    {
                        logCallback2 = (Application.LogCallback)invocationList[i];
                        LuaDelegate luaDelegate = logCallback2.get_Target() as LuaDelegate;
                        if (luaDelegate != null && luaDelegate.func == eventObject.func)
                        {
                            Application.remove_logMessageReceivedThreaded(logCallback2);
                            luaState.DelayDispose(luaDelegate.func);
                            break;
                        }
                    }
                    eventObject.func.Dispose();
                }
                result = 0;
            }
            else
            {
                result = LuaDLL.luaL_throw(L, "The event 'UnityEngine.Application.logMessageReceivedThreaded' can only appear on the left hand side of += or -= when used outside of the type 'UnityEngine.Application'");
            }
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
Exemplo n.º 8
0
    static int op_Subtraction(IntPtr L)
    {
        try
        {
            Delegate arg0 = (Delegate)ToLua.ToObject(L, 1);         //不能增加引用计数,否则自身包含的都会增加
            LuaTypes type = LuaDLL.lua_type(L, 2);

            if (type == LuaTypes.LUA_TFUNCTION)
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 2);
                Delegate[]  ds   = arg0.GetInvocationList();

                for (int i = 0; i < ds.Length; i++)
                {
                    LuaDelegate target = ds[i].Target as LuaDelegate;

                    if (target != null && target.func == func && target.self == null)
                    {
                        arg0 = Delegate.Remove(arg0, ds[i]);
                        if (arg0 != null)
                        {
                            arg0.AddRef();                                            //产生新的委托需要增加计数
                        }
                        break;
                    }
                }

                func.Dispose();
                ToLua.Push(L, arg0);
                return(1);
            }
            else
            {
                Delegate arg1 = (Delegate)ToLua.CheckObject(L, 2);
                arg0 = DelegateFactory.RemoveDelegate(arg0, arg1);
                ToLua.Push(L, arg0);

                return(1);
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Exemplo n.º 9
0
    static int Destroy(IntPtr L)
    {
        Delegate arg0 = ToLua.CheckObject(L, 1, typeof(Delegate)) as Delegate;

        Delegate[] ds = arg0.GetInvocationList();

        for (int i = 0; i < ds.Length; i++)
        {
            LuaDelegate ld = ds[i].Target as LuaDelegate;

            if (ld != null && ld.func != null)
            {
                ld.func.Dispose();
            }
        }

        return(0);
    }
Exemplo n.º 10
0
    static int Destroy(IntPtr L)
    {
        Delegate arg0 = (Delegate)ToLua.CheckObject <Delegate>(L, 1);

        Delegate[] ds = arg0.GetInvocationList();

        for (int i = 0; i < ds.Length; i++)
        {
            LuaDelegate ld = ds[i].Target as LuaDelegate;

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

        return(0);
    }
Exemplo n.º 11
0
    public static Delegate RemoveDelegate(Delegate obj, LuaFunction func)
    {
        LuaState state = func.GetLuaState();
        Delegate[] ds = obj.GetInvocationList();

        for (int i = 0; i < ds.Length; i++)
        {
            LuaDelegate ld = ds[i].Target as LuaDelegate;

            if (ld != null && ld.func == func)
            {
                obj = Delegate.Remove(obj, ds[i]);
                state.DelayDispose(ld.func);
                break;
            }
        }

        return obj;
    }
Exemplo n.º 12
0
    static int op_Subtraction(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 2);
            Delegate arg0 = (Delegate)ToLua.CheckObject(L, 1, typeof(Delegate));
            LuaTypes type = LuaDLL.lua_type(L, 2);

            if (type == LuaTypes.LUA_TFUNCTION)
            {
                LuaState    state = LuaState.Get(L);
                LuaFunction func  = ToLua.ToLuaFunction(L, 2);
                Delegate[]  ds    = arg0.GetInvocationList();

                for (int i = 0; i < ds.Length; i++)
                {
                    LuaDelegate ld = ds[i].Target as LuaDelegate;

                    if (ld != null && ld.func == func && ld.self == null)
                    {
                        arg0 = Delegate.Remove(arg0, ds[i]);
                        state.DelayDispose(ld.func);
                        break;
                    }
                }

                func.Dispose();
                ToLua.Push(L, arg0);
                return(1);
            }
            else
            {
                Delegate arg1 = (Delegate)ToLua.CheckObject(L, 2, typeof(Delegate));
                arg0 = DelegateFactory.RemoveDelegate(arg0, arg1);
                ToLua.Push(L, arg0);
                return(1);
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
    static int set_onClickEvent(IntPtr L)
    {
        TestEventListener obj  = (TestEventListener)ToLua.CheckObject(L, 1, typeof(TestEventListener));
        EventObject       arg0 = null;

        if (LuaDLL.lua_isuserdata(L, 2) != 0)
        {
            arg0 = (EventObject)ToLua.ToObject(L, 2);
        }
        else
        {
            return(LuaDLL.luaL_error(L, "The event 'TestEventListener.onClickEvent' can only appear on the left hand side of += or -= when used outside of the type 'TestEventListener'"));
        }

        if (arg0.op == EventOp.Add)
        {
            TestEventListener.OnClick ev = (TestEventListener.OnClick)DelegateFactory.CreateDelegate(typeof(TestEventListener.OnClick), arg0.func);
            obj.onClickEvent += ev;
        }
        else if (arg0.op == EventOp.Sub)
        {
            TestEventListener.OnClick ev = (TestEventListener.OnClick)LuaMisc.GetEventHandler(obj, typeof(TestEventListener), "onClickEvent");
            Delegate[] ds    = ev.GetInvocationList();
            LuaState   state = LuaState.Get(L);

            for (int i = 0; i < ds.Length; i++)
            {
                ev = (TestEventListener.OnClick)ds[i];
                LuaDelegate ld = ev.Target as LuaDelegate;

                if (ld != null && ld.func == arg0.func)
                {
                    obj.onClickEvent -= ev;
                    state.DelayDispose(ld.func);
                    break;
                }
            }

            arg0.func.Dispose();
        }

        return(0);
    }
Exemplo n.º 14
0
    static int set_StateChanged(IntPtr L)
    {
        MyFrameWork.BaseUI obj  = (MyFrameWork.BaseUI)ToLua.CheckObject(L, 1, typeof(MyFrameWork.BaseUI));
        EventObject        arg0 = null;

        if (LuaDLL.lua_isuserdata(L, 2) != 0)
        {
            arg0 = (EventObject)ToLua.ToObject(L, 2);
        }
        else
        {
            return(LuaDLL.luaL_error(L, "The event 'MyFrameWork.BaseUI.StateChanged' can only appear on the left hand side of += or -= when used outside of the type 'MyFrameWork.BaseUI'"));
        }

        if (arg0.op == EventOp.Add)
        {
            MyFrameWork.StateChangedEvent ev = (MyFrameWork.StateChangedEvent)DelegateFactory.CreateDelegate(typeof(MyFrameWork.StateChangedEvent), arg0.func);
            obj.StateChanged += ev;
        }
        else if (arg0.op == EventOp.Sub)
        {
            MyFrameWork.StateChangedEvent ev = (MyFrameWork.StateChangedEvent)LuaMisc.GetEventHandler(obj, typeof(MyFrameWork.BaseUI), "StateChanged");
            Delegate[] ds    = ev.GetInvocationList();
            LuaState   state = LuaState.Get(L);

            for (int i = 0; i < ds.Length; i++)
            {
                ev = (MyFrameWork.StateChangedEvent)ds[i];
                LuaDelegate ld = ev.Target as LuaDelegate;

                if (ld != null && ld.func == arg0.func)
                {
                    obj.StateChanged -= ev;
                    state.DelayDispose(ld.func);
                    break;
                }
            }

            arg0.func.Dispose();
        }

        return(0);
    }
Exemplo n.º 15
0
    private static int op_Subtraction(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 2);
            Delegate @delegate = (Delegate)ToLua.CheckObject(L, 1, typeof(Delegate));
            LuaTypes luaTypes  = LuaDLL.lua_type(L, 2);
            if (luaTypes == LuaTypes.LUA_TFUNCTION)
            {
                LuaState    luaState       = LuaState.Get(L);
                LuaFunction luaFunction    = ToLua.ToLuaFunction(L, 2);
                Delegate[]  invocationList = @delegate.GetInvocationList();
                for (int i = 0; i < invocationList.Length; i++)
                {
                    LuaDelegate luaDelegate = invocationList[i].get_Target() as LuaDelegate;
                    if (luaDelegate != null && luaDelegate.func == luaFunction)
                    {
                        @delegate = Delegate.Remove(@delegate, invocationList[i]);
                        luaState.DelayDispose(luaDelegate.func);
                        break;
                    }
                }
                luaFunction.Dispose();
                ToLua.Push(L, @delegate);
                result = 1;
            }
            else
            {
                Delegate delegate2 = (Delegate)ToLua.CheckObject(L, 2, typeof(Delegate));
                @delegate = Delegate.Remove(@delegate, delegate2);
                ToLua.Push(L, @delegate);
                result = 1;
            }
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
    static int set_logMessageReceivedThreaded(IntPtr L)
    {
        EventObject arg0 = null;

        if (LuaDLL.lua_isuserdata(L, 2) != 0)
        {
            arg0 = (EventObject)ToLua.ToObject(L, 2);
        }
        else
        {
            return(LuaDLL.luaL_error(L, "The event 'UnityEngine.Application.logMessageReceivedThreaded' can only appear on the left hand side of += or -= when used outside of the type 'UnityEngine.Application'"));
        }

        if (arg0.op == EventOp.Add)
        {
            UnityEngine.Application.LogCallback ev = (UnityEngine.Application.LogCallback)DelegateFactory.CreateDelegate(typeof(UnityEngine.Application.LogCallback), arg0.func);
            UnityEngine.Application.logMessageReceivedThreaded += ev;
        }
        else if (arg0.op == EventOp.Sub)
        {
            UnityEngine.Application.LogCallback ev = (UnityEngine.Application.LogCallback)LuaMisc.GetEventHandler(null, typeof(UnityEngine.Application), "logMessageReceivedThreaded");
            Delegate[] ds    = ev.GetInvocationList();
            LuaState   state = LuaState.Get(L);

            for (int i = 0; i < ds.Length; i++)
            {
                ev = (UnityEngine.Application.LogCallback)ds[i];
                LuaDelegate ld = ev.Target as LuaDelegate;

                if (ld != null && ld.func == arg0.func)
                {
                    UnityEngine.Application.logMessageReceivedThreaded -= ev;
                    state.DelayDispose(ld.func);
                    break;
                }
            }

            arg0.func.Dispose();
        }

        return(0);
    }
Exemplo n.º 17
0
    public static Delegate RemoveDelegate(Delegate obj, LuaFunction func)
    {
        Delegate[] ds = obj.GetInvocationList();

        for (int i = 0; i < ds.Length; i++)
        {
            LuaDelegate ld = ds[i].Target as LuaDelegate;

            if (ld != null && ld.func == func)
            {
                obj = Delegate.Remove(obj, ds[i]);
                if (obj != null)
                {
                    obj.AddRef();
                }
                break;
            }
        }

        return(obj);
    }
Exemplo n.º 18
0
    public static Delegate CreateDelegate(Type t, LuaFunction func, LuaTable self)
    {
        DelegateFactory.DelegateValue delegateValue = null;
        if (!DelegateFactory.dict.TryGetValue(t, out delegateValue))
        {
            throw new LuaException(string.Format("Delegate {0} not register", LuaMisc.GetTypeName(t)), null, 1);
        }
        if (!(func != null))
        {
            return(delegateValue(func, self, true));
        }
        LuaState    luaState    = func.GetLuaState();
        LuaDelegate luaDelegate = luaState.GetLuaDelegate(func, self);

        if (luaDelegate != null)
        {
            return(Delegate.CreateDelegate(t, luaDelegate, luaDelegate.method));
        }
        Delegate @delegate = delegateValue(func, self, true);

        luaDelegate = (@delegate.Target as LuaDelegate);
        luaState.AddLuaDelegate(luaDelegate, func, self);
        return(@delegate);
    }