コード例 #1
0
 // Throws an exception at the end of analysis if there is a problem
 // with types or references.
 public bool RunCheck()
 {
     var success = true;
     success &= new ReferenceChecker(this).RunCheck();
     success &= new TypeChecker(this).RunCheck();
     return success;
 }
コード例 #2
0
 public RoslynCodeGenVisitor(Logger log, INativeTypeMapper mapper, Options options, RoslynCompiler.State state, TypeChecker tc)
 {
     _log = log;
     _mapper = mapper;
     _options = options;
     _state = state;
     _tc = tc;
 }
コード例 #3
0
        public void TestStringConcationation()
        {
            // Arrange
            var controller = new QLController();
            var form = controller.ParseQLString("name = \"What's your name?\" string = \"Piet\" + \"Jansen\"");
            var typeChecker = new TypeChecker();
            var report = new ValidationReport();

            // Act
            typeChecker.Validate(form, report);

            // Assert
            Assert.AreEqual<int>(0, report.NrOfErrors);
        }
コード例 #4
0
        private void OnCompletion(object root)
        {
            TypeChecker<CheckMathExpressions, CheckStatements<CheckMathExpressions>> tc
                = new TypeChecker<CheckMathExpressions, CheckStatements<CheckMathExpressions>>();

            if (tc.Check((IASTNode)root))
            {
                foreach (Tuple<string, bool> msg in tc.Errors)
                {
                    Console.ForegroundColor = msg.Item2 ? ConsoleColor.Red : ConsoleColor.Yellow;
                    Console.WriteLine(msg.Item1);
                }

                Console.ResetColor();
            }

            Console.WriteLine("PARSING COMPLETED!");
        }
コード例 #5
0
        public void TestNegatedIfStatement()
        {
            // Arrange
            var ql = new StringBuilder();
            ql.AppendLine("isHappy \"Are you happy?\" bool");
            ql.AppendLine("if(!isHappy)");
            ql.AppendLine("{ }");

            var controller = new QLController();
            var form = controller.ParseQLString(ql.ToString());
            var typeChecker = new TypeChecker();
            var report = new ValidationReport();

            // Act
            typeChecker.Validate(form, report);

            // Assert
            Assert.AreEqual<int>(0, report.NrOfErrors);
        }
コード例 #6
0
 static bool CheckType(IntPtr L, int pos)
 {
     return(TypeChecker.CheckEnumType(typeof(UnityEngine.Space), L, pos));
 }
コード例 #7
0
    static int Rotate(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                UnityEngine.Transform obj  = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 1);
                UnityEngine.Vector3   arg0 = ToLua.ToVector3(L, 2);
                obj.Rotate(arg0);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes <float>(L, 3))
            {
                UnityEngine.Transform obj  = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 1);
                UnityEngine.Vector3   arg0 = ToLua.ToVector3(L, 2);
                float arg1 = (float)LuaDLL.lua_tonumber(L, 3);
                obj.Rotate(arg0, arg1);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes <UnityEngine.Space>(L, 3))
            {
                UnityEngine.Transform obj  = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 1);
                UnityEngine.Vector3   arg0 = ToLua.ToVector3(L, 2);
                UnityEngine.Space     arg1 = (UnityEngine.Space)ToLua.ToObject(L, 3);
                obj.Rotate(arg0, arg1);
                return(0);
            }
            else if (count == 4 && TypeChecker.CheckTypes <float, float, float>(L, 2))
            {
                UnityEngine.Transform obj = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 1);
                float arg0 = (float)LuaDLL.lua_tonumber(L, 2);
                float arg1 = (float)LuaDLL.lua_tonumber(L, 3);
                float arg2 = (float)LuaDLL.lua_tonumber(L, 4);
                obj.Rotate(arg0, arg1, arg2);
                return(0);
            }
            else if (count == 4 && TypeChecker.CheckTypes <UnityEngine.Vector3, float, UnityEngine.Space>(L, 2))
            {
                UnityEngine.Transform obj  = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 1);
                UnityEngine.Vector3   arg0 = ToLua.ToVector3(L, 2);
                float             arg1     = (float)LuaDLL.lua_tonumber(L, 3);
                UnityEngine.Space arg2     = (UnityEngine.Space)ToLua.ToObject(L, 4);
                obj.Rotate(arg0, arg1, arg2);
                return(0);
            }
            else if (count == 5)
            {
                UnityEngine.Transform obj = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 1);
                float             arg0    = (float)LuaDLL.luaL_checknumber(L, 2);
                float             arg1    = (float)LuaDLL.luaL_checknumber(L, 3);
                float             arg2    = (float)LuaDLL.luaL_checknumber(L, 4);
                UnityEngine.Space arg3    = (UnityEngine.Space)ToLua.CheckObject(L, 5, TypeTraits <UnityEngine.Space> .type);
                obj.Rotate(arg0, arg1, arg2, arg3);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Transform.Rotate"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #8
0
 bool Check_UIWidget_OnDimensionsChanged(IntPtr L, int pos)
 {
     return(TypeChecker.CheckDelegateType(typeof(UIWidget.OnDimensionsChanged), L, pos));
 }
コード例 #9
0
    static int Instantiate(IntPtr L)
    {
        IntPtr L0 = LuaException.L;

        try
        {
            ++LuaException.InstantiateCount;
            LuaException.L = L;
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                UnityEngine.Object arg0 = (UnityEngine.Object)ToLua.CheckObject <UnityEngine.Object>(L, 1);
                UnityEngine.Object o    = UnityEngine.Object.Instantiate(arg0);

                if (LuaDLL.lua_toboolean(L, LuaDLL.lua_upvalueindex(1)))
                {
                    string error = LuaDLL.lua_tostring(L, -1);
                    LuaDLL.lua_pop(L, 1);
                    throw new LuaException(error, LuaException.GetLastError());
                }
                else
                {
                    ToLua.Push(L, o);
                }

                LuaException.L = L0;
                --LuaException.InstantiateCount;
                return(1);
            }
#if UNITY_5_4_OR_NEWER
            else if (count == 2)
            {
                UnityEngine.Object    arg0 = (UnityEngine.Object)ToLua.CheckObject <UnityEngine.Object>(L, 1);
                UnityEngine.Transform arg1 = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 2);
                UnityEngine.Object    o    = UnityEngine.Object.Instantiate(arg0, arg1);

                if (LuaDLL.lua_toboolean(L, LuaDLL.lua_upvalueindex(1)))
                {
                    string error = LuaDLL.lua_tostring(L, -1);
                    LuaDLL.lua_pop(L, 1);
                    throw new LuaException(error, LuaException.GetLastError());
                }
                else
                {
                    ToLua.Push(L, o);
                }

                LuaException.L = L0;
                --LuaException.InstantiateCount;
                return(1);
            }
#endif
            else if (count == 3 && TypeChecker.CheckTypes <UnityEngine.Vector3, UnityEngine.Quaternion>(L, 2))
            {
                UnityEngine.Object     arg0 = (UnityEngine.Object)ToLua.CheckObject <UnityEngine.Object>(L, 1);
                UnityEngine.Vector3    arg1 = ToLua.ToVector3(L, 2);
                UnityEngine.Quaternion arg2 = ToLua.ToQuaternion(L, 3);
                UnityEngine.Object     o    = UnityEngine.Object.Instantiate(arg0, arg1, arg2);

                if (LuaDLL.lua_toboolean(L, LuaDLL.lua_upvalueindex(1)))
                {
                    string error = LuaDLL.lua_tostring(L, -1);
                    LuaDLL.lua_pop(L, 1);
                    throw new LuaException(error, LuaException.GetLastError());
                }
                else
                {
                    ToLua.Push(L, o);
                }

                LuaException.L = L0;
                --LuaException.InstantiateCount;
                return(1);
            }
#if UNITY_5_4_OR_NEWER
            else if (count == 3 && TypeChecker.CheckTypes <UnityEngine.Transform, bool>(L, 2))
            {
                UnityEngine.Object    arg0 = (UnityEngine.Object)ToLua.CheckObject <UnityEngine.Object>(L, 1);
                UnityEngine.Transform arg1 = (UnityEngine.Transform)ToLua.ToObject(L, 2);
                bool arg2            = LuaDLL.lua_toboolean(L, 3);
                UnityEngine.Object o = UnityEngine.Object.Instantiate(arg0, arg1, arg2);

                if (LuaDLL.lua_toboolean(L, LuaDLL.lua_upvalueindex(1)))
                {
                    string error = LuaDLL.lua_tostring(L, -1);
                    LuaDLL.lua_pop(L, 1);
                    throw new LuaException(error, LuaException.GetLastError());
                }
                else
                {
                    ToLua.Push(L, o);
                }

                LuaException.L = L0;
                --LuaException.InstantiateCount;
                return(1);
            }
            else if (count == 4)
            {
                UnityEngine.Object     arg0 = (UnityEngine.Object)ToLua.CheckObject <UnityEngine.Object>(L, 1);
                UnityEngine.Vector3    arg1 = ToLua.CheckVector3(L, 2);
                UnityEngine.Quaternion arg2 = ToLua.CheckQuaternion(L, 3);
                UnityEngine.Transform  arg3 = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 4);
                UnityEngine.Object     o    = UnityEngine.Object.Instantiate(arg0, arg1, arg2, arg3);

                if (LuaDLL.lua_toboolean(L, LuaDLL.lua_upvalueindex(1)))
                {
                    string error = LuaDLL.lua_tostring(L, -1);
                    LuaDLL.lua_pop(L, 1);
                    throw new LuaException(error, LuaException.GetLastError());
                }
                else
                {
                    ToLua.Push(L, o);
                }

                LuaException.L = L0;
                --LuaException.InstantiateCount;
                return(1);
            }
#endif
            else
            {
                LuaException.L = L0;
                --LuaException.InstantiateCount;
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Object.Instantiate"));
            }
        }
        catch (Exception e)
        {
            LuaException.L = L0;
            --LuaException.InstantiateCount;
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #10
0
ファイル: System_ArrayWrap.cs プロジェクト: zs9024/tolua
    static int Sort(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(System.Array)))
            {
                System.Array arg0 = (System.Array)ToLua.ToObject(L, 1);
                System.Array.Sort(arg0);
                return(0);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(System.Array), typeof(System.Collections.IComparer)))
            {
                System.Array arg0 = (System.Array)ToLua.ToObject(L, 1);
                System.Collections.IComparer arg1 = (System.Collections.IComparer)ToLua.ToObject(L, 2);
                System.Array.Sort(arg0, arg1);
                return(0);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(System.Array), typeof(System.Array)))
            {
                System.Array arg0 = (System.Array)ToLua.ToObject(L, 1);
                System.Array arg1 = (System.Array)ToLua.ToObject(L, 2);
                System.Array.Sort(arg0, arg1);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(System.Array), typeof(System.Array), typeof(System.Collections.IComparer)))
            {
                System.Array arg0 = (System.Array)ToLua.ToObject(L, 1);
                System.Array arg1 = (System.Array)ToLua.ToObject(L, 2);
                System.Collections.IComparer arg2 = (System.Collections.IComparer)ToLua.ToObject(L, 3);
                System.Array.Sort(arg0, arg1, arg2);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(System.Array), typeof(int), typeof(int)))
            {
                System.Array arg0 = (System.Array)ToLua.ToObject(L, 1);
                int          arg1 = (int)LuaDLL.lua_tonumber(L, 2);
                int          arg2 = (int)LuaDLL.lua_tonumber(L, 3);
                System.Array.Sort(arg0, arg1, arg2);
                return(0);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(System.Array), typeof(int), typeof(int), typeof(System.Collections.IComparer)))
            {
                System.Array arg0 = (System.Array)ToLua.ToObject(L, 1);
                int          arg1 = (int)LuaDLL.lua_tonumber(L, 2);
                int          arg2 = (int)LuaDLL.lua_tonumber(L, 3);
                System.Collections.IComparer arg3 = (System.Collections.IComparer)ToLua.ToObject(L, 4);
                System.Array.Sort(arg0, arg1, arg2, arg3);
                return(0);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(System.Array), typeof(System.Array), typeof(int), typeof(int)))
            {
                System.Array arg0 = (System.Array)ToLua.ToObject(L, 1);
                System.Array arg1 = (System.Array)ToLua.ToObject(L, 2);
                int          arg2 = (int)LuaDLL.lua_tonumber(L, 3);
                int          arg3 = (int)LuaDLL.lua_tonumber(L, 4);
                System.Array.Sort(arg0, arg1, arg2, arg3);
                return(0);
            }
            else if (count == 5 && TypeChecker.CheckTypes(L, 1, typeof(System.Array), typeof(System.Array), typeof(int), typeof(int), typeof(System.Collections.IComparer)))
            {
                System.Array arg0 = (System.Array)ToLua.ToObject(L, 1);
                System.Array arg1 = (System.Array)ToLua.ToObject(L, 2);
                int          arg2 = (int)LuaDLL.lua_tonumber(L, 3);
                int          arg3 = (int)LuaDLL.lua_tonumber(L, 4);
                System.Collections.IComparer arg4 = (System.Collections.IComparer)ToLua.ToObject(L, 5);
                System.Array.Sort(arg0, arg1, arg2, arg3, arg4);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: System.Array.Sort"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #11
0
ファイル: System_ArrayWrap.cs プロジェクト: zs9024/tolua
    static int SetValue(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(System.Array), typeof(object), typeof(long)))
            {
                System.Array obj  = (System.Array)ToLua.ToObject(L, 1);
                object       arg0 = ToLua.ToVarObject(L, 2);
                long         arg1 = (long)LuaDLL.lua_tonumber(L, 3);
                obj.SetValue(arg0, arg1);
                return(0);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(System.Array), typeof(object), typeof(int), typeof(int)))
            {
                System.Array obj  = (System.Array)ToLua.ToObject(L, 1);
                object       arg0 = ToLua.ToVarObject(L, 2);
                int          arg1 = (int)LuaDLL.lua_tonumber(L, 3);
                int          arg2 = (int)LuaDLL.lua_tonumber(L, 4);
                obj.SetValue(arg0, arg1, arg2);
                return(0);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(System.Array), typeof(object), typeof(long), typeof(long)))
            {
                System.Array obj  = (System.Array)ToLua.ToObject(L, 1);
                object       arg0 = ToLua.ToVarObject(L, 2);
                long         arg1 = (long)LuaDLL.lua_tonumber(L, 3);
                long         arg2 = (long)LuaDLL.lua_tonumber(L, 4);
                obj.SetValue(arg0, arg1, arg2);
                return(0);
            }
            else if (count == 5 && TypeChecker.CheckTypes(L, 1, typeof(System.Array), typeof(object), typeof(int), typeof(int), typeof(int)))
            {
                System.Array obj  = (System.Array)ToLua.ToObject(L, 1);
                object       arg0 = ToLua.ToVarObject(L, 2);
                int          arg1 = (int)LuaDLL.lua_tonumber(L, 3);
                int          arg2 = (int)LuaDLL.lua_tonumber(L, 4);
                int          arg3 = (int)LuaDLL.lua_tonumber(L, 5);
                obj.SetValue(arg0, arg1, arg2, arg3);
                return(0);
            }
            else if (count == 5 && TypeChecker.CheckTypes(L, 1, typeof(System.Array), typeof(object), typeof(long), typeof(long), typeof(long)))
            {
                System.Array obj  = (System.Array)ToLua.ToObject(L, 1);
                object       arg0 = ToLua.ToVarObject(L, 2);
                long         arg1 = (long)LuaDLL.lua_tonumber(L, 3);
                long         arg2 = (long)LuaDLL.lua_tonumber(L, 4);
                long         arg3 = (long)LuaDLL.lua_tonumber(L, 5);
                obj.SetValue(arg0, arg1, arg2, arg3);
                return(0);
            }
            else if (TypeChecker.CheckTypes(L, 1, typeof(System.Array), typeof(object)) && TypeChecker.CheckParamsType(L, typeof(long), 3, count - 2))
            {
                System.Array obj  = (System.Array)ToLua.ToObject(L, 1);
                object       arg0 = ToLua.ToVarObject(L, 2);
                long[]       arg1 = ToLua.ToParamsNumber <long>(L, 3, count - 2);
                obj.SetValue(arg0, arg1);
                return(0);
            }
            else if (TypeChecker.CheckTypes(L, 1, typeof(System.Array), typeof(object)) && TypeChecker.CheckParamsType(L, typeof(int), 3, count - 2))
            {
                System.Array obj  = (System.Array)ToLua.ToObject(L, 1);
                object       arg0 = ToLua.ToVarObject(L, 2);
                int[]        arg1 = ToLua.ToParamsNumber <int>(L, 3, count - 2);
                obj.SetValue(arg0, arg1);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: System.Array.SetValue"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #12
0
    static int _RepeatEveryFrame(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(Lit.Unity.LitBehaviour), typeof(int), typeof(Lit.Unity._D_Void)))
            {
                Lit.Unity.LitBehaviour obj = (Lit.Unity.LitBehaviour)ToLua.ToObject(L, 1);
                int arg0 = (int)LuaDLL.lua_tonumber(L, 2);
                Lit.Unity._D_Void arg1      = null;
                LuaTypes          funcType3 = LuaDLL.lua_type(L, 3);

                if (funcType3 != LuaTypes.LUA_TFUNCTION)
                {
                    arg1 = (Lit.Unity._D_Void)ToLua.ToObject(L, 3);
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 3);
                    arg1 = DelegateFactory.CreateDelegate(typeof(Lit.Unity._D_Void), func) as Lit.Unity._D_Void;
                }

                System.Collections.IEnumerator o = obj._RepeatEveryFrame(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(Lit.Unity.LitBehaviour), typeof(int), typeof(System.Action <int>), typeof(int)))
            {
                Lit.Unity.LitBehaviour obj = (Lit.Unity.LitBehaviour)ToLua.ToObject(L, 1);
                int arg0 = (int)LuaDLL.lua_tonumber(L, 2);
                System.Action <int> arg1      = null;
                LuaTypes            funcType3 = LuaDLL.lua_type(L, 3);

                if (funcType3 != LuaTypes.LUA_TFUNCTION)
                {
                    arg1 = (System.Action <int>)ToLua.ToObject(L, 3);
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 3);
                    arg1 = DelegateFactory.CreateDelegate(typeof(System.Action <int>), func) as System.Action <int>;
                }

                int arg2 = (int)LuaDLL.lua_tonumber(L, 4);
                System.Collections.IEnumerator o = obj._RepeatEveryFrame(arg0, arg1, arg2);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(Lit.Unity.LitBehaviour), typeof(int), typeof(System.Action), typeof(int)))
            {
                Lit.Unity.LitBehaviour obj = (Lit.Unity.LitBehaviour)ToLua.ToObject(L, 1);
                int           arg0         = (int)LuaDLL.lua_tonumber(L, 2);
                System.Action arg1         = null;
                LuaTypes      funcType3    = LuaDLL.lua_type(L, 3);

                if (funcType3 != LuaTypes.LUA_TFUNCTION)
                {
                    arg1 = (System.Action)ToLua.ToObject(L, 3);
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 3);
                    arg1 = DelegateFactory.CreateDelegate(typeof(System.Action), func) as System.Action;
                }

                int arg2 = (int)LuaDLL.lua_tonumber(L, 4);
                System.Collections.IEnumerator o = obj._RepeatEveryFrame(arg0, arg1, arg2);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(Lit.Unity.LitBehaviour), typeof(int), typeof(Lit.Unity._D_Void), typeof(Lit.Unity._D_OuterBool)))
            {
                Lit.Unity.LitBehaviour obj = (Lit.Unity.LitBehaviour)ToLua.ToObject(L, 1);
                int arg0 = (int)LuaDLL.lua_tonumber(L, 2);
                Lit.Unity._D_Void arg1      = null;
                LuaTypes          funcType3 = LuaDLL.lua_type(L, 3);

                if (funcType3 != LuaTypes.LUA_TFUNCTION)
                {
                    arg1 = (Lit.Unity._D_Void)ToLua.ToObject(L, 3);
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 3);
                    arg1 = DelegateFactory.CreateDelegate(typeof(Lit.Unity._D_Void), func) as Lit.Unity._D_Void;
                }

                Lit.Unity._D_OuterBool arg2 = null;
                LuaTypes funcType4          = LuaDLL.lua_type(L, 4);

                if (funcType4 != LuaTypes.LUA_TFUNCTION)
                {
                    arg2 = (Lit.Unity._D_OuterBool)ToLua.ToObject(L, 4);
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 4);
                    arg2 = DelegateFactory.CreateDelegate(typeof(Lit.Unity._D_OuterBool), func) as Lit.Unity._D_OuterBool;
                }

                System.Collections.IEnumerator o = obj._RepeatEveryFrame(arg0, arg1, arg2);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: Lit.Unity.LitBehaviour._RepeatEveryFrame"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #13
0
 bool Check_System_Comparison_int(IntPtr L, int pos)
 {
     return(TypeChecker.CheckDelegateType(typeof(System.Comparison <int>), L, pos));
 }
コード例 #14
0
 bool Check_System_Predicate_int(IntPtr L, int pos)
 {
     return(TypeChecker.CheckDelegateType(typeof(System.Predicate <int>), L, pos));
 }
コード例 #15
0
 bool Check_UnityEngine_Events_UnityAction(IntPtr L, int pos)
 {
     return(TypeChecker.CheckDelegateType(typeof(UnityEngine.Events.UnityAction), L, pos));
 }
コード例 #16
0
 bool Check_System_Action_NotiData(IntPtr L, int pos)
 {
     return(TypeChecker.CheckDelegateType(typeof(System.Action <NotiData>), L, pos));
 }
コード例 #17
0
 bool Check_UnityEngine_RectTransform_ReapplyDrivenProperties(IntPtr L, int pos)
 {
     return(TypeChecker.CheckDelegateType(typeof(UnityEngine.RectTransform.ReapplyDrivenProperties), L, pos));
 }
コード例 #18
0
 bool Check_System_Action_UnityEngine_AsyncOperation(IntPtr L, int pos)
 {
     return(TypeChecker.CheckDelegateType(typeof(System.Action <UnityEngine.AsyncOperation>), L, pos));
 }
コード例 #19
0
 bool Check_UnityEngine_AudioClip_PCMSetPositionCallback(IntPtr L, int pos)
 {
     return(TypeChecker.CheckDelegateType(typeof(UnityEngine.AudioClip.PCMSetPositionCallback), L, pos));
 }
コード例 #20
0
    static int SetEase(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(DG.Tweening.Tween), typeof(DG.Tweening.Ease)))
            {
                DG.Tweening.Tweener obj  = (DG.Tweening.Tweener)ToLua.ToObject(L, 1);
                DG.Tweening.Ease    arg0 = (DG.Tweening.Ease)ToLua.ToObject(L, 2);
                DG.Tweening.Tween   o    = obj.SetEase(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(DG.Tweening.Tween), typeof(UnityEngine.AnimationCurve)))
            {
                DG.Tweening.Tweener        obj  = (DG.Tweening.Tweener)ToLua.ToObject(L, 1);
                UnityEngine.AnimationCurve arg0 = (UnityEngine.AnimationCurve)ToLua.ToObject(L, 2);
                DG.Tweening.Tween          o    = obj.SetEase(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(DG.Tweening.Tween), typeof(DG.Tweening.EaseFunction)))
            {
                DG.Tweening.Tweener      obj  = (DG.Tweening.Tweener)ToLua.ToObject(L, 1);
                DG.Tweening.EaseFunction arg0 = null;
                LuaTypes funcType2            = LuaDLL.lua_type(L, 2);

                if (funcType2 != LuaTypes.LUA_TFUNCTION)
                {
                    arg0 = (DG.Tweening.EaseFunction)ToLua.ToObject(L, 2);
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 2);
                    arg0 = DelegateFactory.CreateDelegate(typeof(DG.Tweening.EaseFunction), func) as DG.Tweening.EaseFunction;
                }

                DG.Tweening.Tween o = obj.SetEase(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(DG.Tweening.Tween), typeof(DG.Tweening.Ease), typeof(float)))
            {
                DG.Tweening.Tweener obj  = (DG.Tweening.Tweener)ToLua.ToObject(L, 1);
                DG.Tweening.Ease    arg0 = (DG.Tweening.Ease)ToLua.ToObject(L, 2);
                float             arg1   = (float)LuaDLL.lua_tonumber(L, 3);
                DG.Tweening.Tween o      = obj.SetEase(arg0, arg1);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(DG.Tweening.Tween), typeof(DG.Tweening.Ease), typeof(float), typeof(float)))
            {
                DG.Tweening.Tweener obj  = (DG.Tweening.Tweener)ToLua.ToObject(L, 1);
                DG.Tweening.Ease    arg0 = (DG.Tweening.Ease)ToLua.ToObject(L, 2);
                float             arg1   = (float)LuaDLL.lua_tonumber(L, 3);
                float             arg2   = (float)LuaDLL.lua_tonumber(L, 4);
                DG.Tweening.Tween o      = obj.SetEase(arg0, arg1, arg2);
                ToLua.PushObject(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: DG.Tweening.Tweener.SetEase"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #21
0
    static int WaitFor(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(Lit.Unity.LitBehaviour), typeof(Lit.Unity._D_OuterBool), typeof(Lit.Unity._D_Void)))
            {
                Lit.Unity.LitBehaviour obj  = (Lit.Unity.LitBehaviour)ToLua.ToObject(L, 1);
                Lit.Unity._D_OuterBool arg0 = null;
                LuaTypes funcType2          = LuaDLL.lua_type(L, 2);

                if (funcType2 != LuaTypes.LUA_TFUNCTION)
                {
                    arg0 = (Lit.Unity._D_OuterBool)ToLua.ToObject(L, 2);
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 2);
                    arg0 = DelegateFactory.CreateDelegate(typeof(Lit.Unity._D_OuterBool), func) as Lit.Unity._D_OuterBool;
                }

                Lit.Unity._D_Void arg1      = null;
                LuaTypes          funcType3 = LuaDLL.lua_type(L, 3);

                if (funcType3 != LuaTypes.LUA_TFUNCTION)
                {
                    arg1 = (Lit.Unity._D_Void)ToLua.ToObject(L, 3);
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 3);
                    arg1 = DelegateFactory.CreateDelegate(typeof(Lit.Unity._D_Void), func) as Lit.Unity._D_Void;
                }

                UnityEngine.Coroutine o = obj.WaitFor(arg0, arg1);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(Lit.Unity.LitBehaviour), typeof(float), typeof(Lit.Unity._D_Void)))
            {
                Lit.Unity.LitBehaviour obj  = (Lit.Unity.LitBehaviour)ToLua.ToObject(L, 1);
                float             arg0      = (float)LuaDLL.lua_tonumber(L, 2);
                Lit.Unity._D_Void arg1      = null;
                LuaTypes          funcType3 = LuaDLL.lua_type(L, 3);

                if (funcType3 != LuaTypes.LUA_TFUNCTION)
                {
                    arg1 = (Lit.Unity._D_Void)ToLua.ToObject(L, 3);
                }
                else
                {
                    LuaFunction func = ToLua.ToLuaFunction(L, 3);
                    arg1 = DelegateFactory.CreateDelegate(typeof(Lit.Unity._D_Void), func) as Lit.Unity._D_Void;
                }

                UnityEngine.Coroutine o = obj.WaitFor(arg0, arg1);
                ToLua.PushObject(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: Lit.Unity.LitBehaviour.WaitFor"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #22
0
 bool Check_UnityEngine_Camera_CameraCallback(IntPtr L, int pos)
 {
     return(TypeChecker.CheckDelegateType(typeof(UnityEngine.Camera.CameraCallback), L, pos));
 }
コード例 #23
0
 static bool CheckType(IntPtr L, int pos)
 {
     return(TypeChecker.CheckEnumType(typeof(GameFramework.UILayers), L, pos));
 }
コード例 #24
0
 bool Check_UnityEngine_Application_AdvertisingIdentifierCallback(IntPtr L, int pos)
 {
     return(TypeChecker.CheckDelegateType(typeof(UnityEngine.Application.AdvertisingIdentifierCallback), L, pos));
 }
コード例 #25
0
ファイル: System_ArrayWrap.cs プロジェクト: zs9024/tolua
    static int CreateInstance(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(System.Type), typeof(int)))
            {
                System.Type  arg0 = (System.Type)ToLua.ToObject(L, 1);
                int          arg1 = (int)LuaDLL.lua_tonumber(L, 2);
                System.Array o    = System.Array.CreateInstance(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(System.Type), typeof(int[]), typeof(int[])))
            {
                System.Type  arg0 = (System.Type)ToLua.ToObject(L, 1);
                int[]        arg1 = ToLua.CheckNumberArray <int>(L, 2);
                int[]        arg2 = ToLua.CheckNumberArray <int>(L, 3);
                System.Array o    = System.Array.CreateInstance(arg0, arg1, arg2);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(System.Type), typeof(int), typeof(int)))
            {
                System.Type  arg0 = (System.Type)ToLua.ToObject(L, 1);
                int          arg1 = (int)LuaDLL.lua_tonumber(L, 2);
                int          arg2 = (int)LuaDLL.lua_tonumber(L, 3);
                System.Array o    = System.Array.CreateInstance(arg0, arg1, arg2);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(System.Type), typeof(int), typeof(int), typeof(int)))
            {
                System.Type  arg0 = (System.Type)ToLua.ToObject(L, 1);
                int          arg1 = (int)LuaDLL.lua_tonumber(L, 2);
                int          arg2 = (int)LuaDLL.lua_tonumber(L, 3);
                int          arg3 = (int)LuaDLL.lua_tonumber(L, 4);
                System.Array o    = System.Array.CreateInstance(arg0, arg1, arg2, arg3);
                ToLua.Push(L, o);
                return(1);
            }
            else if (TypeChecker.CheckTypes(L, 1, typeof(System.Type)) && TypeChecker.CheckParamsType(L, typeof(long), 2, count - 1))
            {
                System.Type  arg0 = (System.Type)ToLua.ToObject(L, 1);
                long[]       arg1 = ToLua.ToParamsNumber <long>(L, 2, count - 1);
                System.Array o    = System.Array.CreateInstance(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else if (TypeChecker.CheckTypes(L, 1, typeof(System.Type)) && TypeChecker.CheckParamsType(L, typeof(int), 2, count - 1))
            {
                System.Type  arg0 = (System.Type)ToLua.ToObject(L, 1);
                int[]        arg1 = ToLua.ToParamsNumber <int>(L, 2, count - 1);
                System.Array o    = System.Array.CreateInstance(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: System.Array.CreateInstance"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #26
0
 bool Check_UnityEngine_Application_LogCallback(IntPtr L, int pos)
 {
     return(TypeChecker.CheckDelegateType(typeof(UnityEngine.Application.LogCallback), L, pos));
 }
コード例 #27
0
    static int Parabola(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 5)
            {
                float arg0 = (float)LuaDLL.luaL_checknumber(L, 1);
                UnityEngine.Transform arg1 = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 2);
                UnityEngine.Vector3   arg2 = ToLua.ToVector3(L, 3);
                float arg3 = (float)LuaDLL.luaL_checknumber(L, 4);
                float arg4 = (float)LuaDLL.luaL_checknumber(L, 5);
                ToLuaUIFramework.BTween.Parabola(arg0, arg1, arg2, arg3, arg4);
                return(0);
            }
            else if (count == 6)
            {
                float arg0 = (float)LuaDLL.luaL_checknumber(L, 1);
                UnityEngine.Transform arg1 = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 2);
                UnityEngine.Vector3   arg2 = ToLua.ToVector3(L, 3);
                float arg3 = (float)LuaDLL.luaL_checknumber(L, 4);
                float arg4 = (float)LuaDLL.luaL_checknumber(L, 5);
                bool  arg5 = LuaDLL.luaL_checkboolean(L, 6);
                ToLuaUIFramework.BTween.Parabola(arg0, arg1, arg2, arg3, arg4, arg5);
                return(0);
            }
            else if (count == 7)
            {
                float arg0 = (float)LuaDLL.luaL_checknumber(L, 1);
                UnityEngine.Transform arg1 = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 2);
                UnityEngine.Vector3   arg2 = ToLua.ToVector3(L, 3);
                float arg3 = (float)LuaDLL.luaL_checknumber(L, 4);
                float arg4 = (float)LuaDLL.luaL_checknumber(L, 5);
                bool  arg5 = LuaDLL.luaL_checkboolean(L, 6);
                float arg6 = (float)LuaDLL.luaL_checknumber(L, 7);
                ToLuaUIFramework.BTween.Parabola(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
                return(0);
            }
            else if (count == 8 && TypeChecker.CheckTypes <System.Action>(L, 8))
            {
                float arg0 = (float)LuaDLL.luaL_checknumber(L, 1);
                UnityEngine.Transform arg1 = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 2);
                UnityEngine.Vector3   arg2 = ToLua.ToVector3(L, 3);
                float         arg3         = (float)LuaDLL.luaL_checknumber(L, 4);
                float         arg4         = (float)LuaDLL.luaL_checknumber(L, 5);
                bool          arg5         = LuaDLL.luaL_checkboolean(L, 6);
                float         arg6         = (float)LuaDLL.luaL_checknumber(L, 7);
                System.Action arg7         = (System.Action)ToLua.ToObject(L, 8);
                ToLuaUIFramework.BTween.Parabola(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
                return(0);
            }
            else if (count == 8 && TypeChecker.CheckTypes <ToLuaUIFramework.TweenEvent>(L, 8))
            {
                float arg0 = (float)LuaDLL.luaL_checknumber(L, 1);
                UnityEngine.Transform arg1 = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 2);
                UnityEngine.Vector3   arg2 = ToLua.ToVector3(L, 3);
                float arg3 = (float)LuaDLL.luaL_checknumber(L, 4);
                float arg4 = (float)LuaDLL.luaL_checknumber(L, 5);
                bool  arg5 = LuaDLL.luaL_checkboolean(L, 6);
                float arg6 = (float)LuaDLL.luaL_checknumber(L, 7);
                ToLuaUIFramework.TweenEvent arg7 = (ToLuaUIFramework.TweenEvent)ToLua.ToObject(L, 8);
                ToLuaUIFramework.BTween.Parabola(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
                return(0);
            }
            else if (count == 9 && TypeChecker.CheckTypes <System.Action, System.Action>(L, 8))
            {
                float arg0 = (float)LuaDLL.luaL_checknumber(L, 1);
                UnityEngine.Transform arg1 = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 2);
                UnityEngine.Vector3   arg2 = ToLua.ToVector3(L, 3);
                float         arg3         = (float)LuaDLL.luaL_checknumber(L, 4);
                float         arg4         = (float)LuaDLL.luaL_checknumber(L, 5);
                bool          arg5         = LuaDLL.luaL_checkboolean(L, 6);
                float         arg6         = (float)LuaDLL.luaL_checknumber(L, 7);
                System.Action arg7         = (System.Action)ToLua.ToObject(L, 8);
                System.Action arg8         = (System.Action)ToLua.ToObject(L, 9);
                ToLuaUIFramework.BTween.Parabola(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
                return(0);
            }
            else if (count == 9 && TypeChecker.CheckTypes <ToLuaUIFramework.TweenEvent, ToLuaUIFramework.TweenEvent>(L, 8))
            {
                float arg0 = (float)LuaDLL.luaL_checknumber(L, 1);
                UnityEngine.Transform arg1 = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 2);
                UnityEngine.Vector3   arg2 = ToLua.ToVector3(L, 3);
                float arg3 = (float)LuaDLL.luaL_checknumber(L, 4);
                float arg4 = (float)LuaDLL.luaL_checknumber(L, 5);
                bool  arg5 = LuaDLL.luaL_checkboolean(L, 6);
                float arg6 = (float)LuaDLL.luaL_checknumber(L, 7);
                ToLuaUIFramework.TweenEvent arg7 = (ToLuaUIFramework.TweenEvent)ToLua.ToObject(L, 8);
                ToLuaUIFramework.TweenEvent arg8 = (ToLuaUIFramework.TweenEvent)ToLua.ToObject(L, 9);
                ToLuaUIFramework.BTween.Parabola(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
                return(0);
            }
            else if (count == 11)
            {
                float arg0 = (float)LuaDLL.luaL_checknumber(L, 1);
                UnityEngine.Transform arg1        = (UnityEngine.Transform)ToLua.CheckObject <UnityEngine.Transform>(L, 2);
                UnityEngine.Vector3   arg2        = ToLua.ToVector3(L, 3);
                float         arg3                = (float)LuaDLL.luaL_checknumber(L, 4);
                float         arg4                = (float)LuaDLL.luaL_checknumber(L, 5);
                bool          arg5                = LuaDLL.luaL_checkboolean(L, 6);
                float         arg6                = (float)LuaDLL.luaL_checknumber(L, 7);
                System.Action arg7                = (System.Action)ToLua.CheckDelegate <System.Action>(L, 8);
                ToLuaUIFramework.TweenEvent arg8  = (ToLuaUIFramework.TweenEvent)ToLua.CheckDelegate <ToLuaUIFramework.TweenEvent>(L, 9);
                System.Action arg9                = (System.Action)ToLua.CheckDelegate <System.Action>(L, 10);
                ToLuaUIFramework.TweenEvent arg10 = (ToLuaUIFramework.TweenEvent)ToLua.CheckDelegate <ToLuaUIFramework.TweenEvent>(L, 11);
                ToLuaUIFramework.BTween.Parabola(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: ToLuaUIFramework.BTween.Parabola"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #28
0
 bool Check_System_Action_bool(IntPtr L, int pos)
 {
     return(TypeChecker.CheckDelegateType(typeof(System.Action <bool>), L, pos));
 }
コード例 #29
0
    static int SendMessageUpwards(IntPtr L)
    {
        IntPtr L0 = LuaException.L;

        try
        {
            ++LuaException.SendMsgCount;
            LuaException.L = L;
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes <string>(L, 2))
            {
                UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
                string arg0 = ToLua.ToString(L, 2);
                obj.SendMessageUpwards(arg0);

                if (LuaDLL.lua_toboolean(L, LuaDLL.lua_upvalueindex(1)))
                {
                    string error = LuaDLL.lua_tostring(L, -1);
                    LuaDLL.lua_pop(L, 1);
                    throw new LuaException(error, LuaException.GetLastError());
                }

                --LuaException.SendMsgCount;
                LuaException.L = L0;
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes <string, UnityEngine.SendMessageOptions>(L, 2))
            {
                UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
                string arg0 = ToLua.ToString(L, 2);
                UnityEngine.SendMessageOptions arg1 = (UnityEngine.SendMessageOptions)ToLua.ToObject(L, 3);
                obj.SendMessageUpwards(arg0, arg1);

                if (LuaDLL.lua_toboolean(L, LuaDLL.lua_upvalueindex(1)))
                {
                    string error = LuaDLL.lua_tostring(L, -1);
                    LuaDLL.lua_pop(L, 1);
                    throw new LuaException(error, LuaException.GetLastError());
                }

                --LuaException.SendMsgCount;
                LuaException.L = L0;
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes <string, object>(L, 2))
            {
                UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
                string arg0 = ToLua.ToString(L, 2);
                object arg1 = ToLua.ToVarObject(L, 3);
                obj.SendMessageUpwards(arg0, arg1);

                if (LuaDLL.lua_toboolean(L, LuaDLL.lua_upvalueindex(1)))
                {
                    string error = LuaDLL.lua_tostring(L, -1);
                    LuaDLL.lua_pop(L, 1);
                    throw new LuaException(error, LuaException.GetLastError());
                }

                --LuaException.SendMsgCount;
                LuaException.L = L0;
                return(0);
            }
            else if (count == 4 && TypeChecker.CheckTypes <string, object, UnityEngine.SendMessageOptions>(L, 2))
            {
                UnityEngine.GameObject obj = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
                string arg0 = ToLua.ToString(L, 2);
                object arg1 = ToLua.ToVarObject(L, 3);
                UnityEngine.SendMessageOptions arg2 = (UnityEngine.SendMessageOptions)ToLua.ToObject(L, 4);
                obj.SendMessageUpwards(arg0, arg1, arg2);

                if (LuaDLL.lua_toboolean(L, LuaDLL.lua_upvalueindex(1)))
                {
                    string error = LuaDLL.lua_tostring(L, -1);
                    LuaDLL.lua_pop(L, 1);
                    throw new LuaException(error, LuaException.GetLastError());
                }

                --LuaException.SendMsgCount;
                LuaException.L = L0;
                return(0);
            }
            else
            {
                --LuaException.SendMsgCount;
                LuaException.L = L0;
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.GameObject.SendMessageUpwards"));
            }
        }
        catch (Exception e)
        {
            --LuaException.SendMsgCount;
            LuaException.L = L0;
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #30
0
        public void Check()
        {
            var typechecker = new TypeChecker (this);
            foreach (var spec in specs.Values)
            {
                spec.Spec.Walk (typechecker);
            }

            var refchecker = new RefChecker (this);
            foreach (var spec in specs.Values)
            {
                spec.Spec.Walk (refchecker, new [] { spec.Table });
            }
        }
コード例 #31
0
        /// <summary>
        /// Creates a hover response that represents the type related to the symbol and node specified.
        /// </summary>
        private Result <Hover, ResponseError> CreateHoverBasedOnTypeInformation(ISymbol symbol, INode node, string symbolAsString)
        {
            // If the node is an expression, then use the contextual type as it will contain
            // better type information.
            // For example:
            // Asking for the contextual type on a node like:
            // const myStringLiteral : MyStringLiteralType = "String Literal A"
            // will actually give you back the type "MyStringLiteralType" and hence hover will show
            // you all the options. The type checker is giving you the best type available given the
            // context.
            //
            // Whereas asking for type at location will give you "String Literal Type" and the only
            // string literal "String Literal A" for hover. The type checker is giving you the type
            // it can deduce solely based on the single node.
            var typeAsExpression = node.As <IExpression>();
            var typeAtLocation   = typeAsExpression != null?TypeChecker.GetContextualType(typeAsExpression) : TypeChecker.GetTypeAtLocation(node);

            // If GetContextualType does not return a valid type, getting the type at location is better than displaying
            // nothing
            if (typeAtLocation == null)
            {
                typeAtLocation = TypeChecker.GetTypeAtLocation(node);
            }

            var typeAsString = typeAtLocation != null?CreateStringFromType(typeAtLocation) : string.Empty;

            if (string.IsNullOrEmpty(typeAsString) &&
                string.IsNullOrEmpty(symbolAsString))
            {
                return(Result <Hover, ResponseError> .Success(null));
            }

            string finalTypeString;

            if (string.IsNullOrEmpty(typeAsString) || string.IsNullOrEmpty(symbolAsString))
            {
                finalTypeString = string.Format(
                    BuildXL.Ide.LanguageServer.Strings.HoverJustSymbolOrTypeFormat,
                    string.IsNullOrEmpty(symbolAsString) ? typeAsString : symbolAsString);
            }
            else
            {
                finalTypeString = string.Format(BuildXL.Ide.LanguageServer.Strings.HoverSymbolAndStringFormat, symbolAsString, typeAsString);
            }

            return(CreateScriptHoverWithCodeSnippetAndDocumentation(symbol, node, finalTypeString));
        }
コード例 #32
0
    private static int GetTemporary(IntPtr L)
    {
        int result;

        try
        {
            int num = LuaDLL.lua_gettop(L);
            if (num == 2 && TypeChecker.CheckTypes(L, 1, typeof(int), typeof(int)))
            {
                int           num2      = (int)LuaDLL.lua_tonumber(L, 1);
                int           num3      = (int)LuaDLL.lua_tonumber(L, 2);
                RenderTexture temporary = RenderTexture.GetTemporary(num2, num3);
                ToLua.Push(L, temporary);
                result = 1;
            }
            else if (num == 3 && TypeChecker.CheckTypes(L, 1, typeof(int), typeof(int), typeof(int)))
            {
                int           num4       = (int)LuaDLL.lua_tonumber(L, 1);
                int           num5       = (int)LuaDLL.lua_tonumber(L, 2);
                int           num6       = (int)LuaDLL.lua_tonumber(L, 3);
                RenderTexture temporary2 = RenderTexture.GetTemporary(num4, num5, num6);
                ToLua.Push(L, temporary2);
                result = 1;
            }
            else if (num == 4 && TypeChecker.CheckTypes(L, 1, typeof(int), typeof(int), typeof(int), typeof(RenderTextureFormat)))
            {
                int num7 = (int)LuaDLL.lua_tonumber(L, 1);
                int num8 = (int)LuaDLL.lua_tonumber(L, 2);
                int num9 = (int)LuaDLL.lua_tonumber(L, 3);
                RenderTextureFormat renderTextureFormat = (int)ToLua.ToObject(L, 4);
                RenderTexture       temporary3          = RenderTexture.GetTemporary(num7, num8, num9, renderTextureFormat);
                ToLua.Push(L, temporary3);
                result = 1;
            }
            else if (num == 5 && TypeChecker.CheckTypes(L, 1, typeof(int), typeof(int), typeof(int), typeof(RenderTextureFormat), typeof(RenderTextureReadWrite)))
            {
                int num10 = (int)LuaDLL.lua_tonumber(L, 1);
                int num11 = (int)LuaDLL.lua_tonumber(L, 2);
                int num12 = (int)LuaDLL.lua_tonumber(L, 3);
                RenderTextureFormat    renderTextureFormat2   = (int)ToLua.ToObject(L, 4);
                RenderTextureReadWrite renderTextureReadWrite = (int)ToLua.ToObject(L, 5);
                RenderTexture          temporary4             = RenderTexture.GetTemporary(num10, num11, num12, renderTextureFormat2, renderTextureReadWrite);
                ToLua.Push(L, temporary4);
                result = 1;
            }
            else if (num == 6 && TypeChecker.CheckTypes(L, 1, typeof(int), typeof(int), typeof(int), typeof(RenderTextureFormat), typeof(RenderTextureReadWrite), typeof(int)))
            {
                int num13 = (int)LuaDLL.lua_tonumber(L, 1);
                int num14 = (int)LuaDLL.lua_tonumber(L, 2);
                int num15 = (int)LuaDLL.lua_tonumber(L, 3);
                RenderTextureFormat    renderTextureFormat3    = (int)ToLua.ToObject(L, 4);
                RenderTextureReadWrite renderTextureReadWrite2 = (int)ToLua.ToObject(L, 5);
                int           num16      = (int)LuaDLL.lua_tonumber(L, 6);
                RenderTexture temporary5 = RenderTexture.GetTemporary(num13, num14, num15, renderTextureFormat3, renderTextureReadWrite2, num16);
                ToLua.Push(L, temporary5);
                result = 1;
            }
            else
            {
                result = LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.RenderTexture.GetTemporary");
            }
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
コード例 #33
0
 bool Check_System_Func_bool(IntPtr L, int pos)
 {
     return(TypeChecker.CheckDelegateType(typeof(System.Func <bool>), L, pos));
 }
コード例 #34
0
 bool Check_UIWidget_HitCheck(IntPtr L, int pos)
 {
     return(TypeChecker.CheckDelegateType(typeof(UIWidget.HitCheck), L, pos));
 }
コード例 #35
0
 static bool CheckType(IntPtr L, int pos)
 {
     return(TypeChecker.CheckEnumType(typeof(UnityEngine.NetworkReachability), L, pos));
 }
コード例 #36
0
        /// <summary>
        /// Implements the "textDocument/hover" portion of the language server protocol.
        /// </summary>
        public Result <Hover, ResponseError> Hover(TextDocumentPositionParams positionParams, CancellationToken token)
        {
            // TODO: support cancellation
            Contract.Requires(positionParams.Position != null);

            if (!TryFindNode(positionParams, out var node))
            {
                return(Result <Hover, ResponseError> .Success(null));
            }

            // Label names are things such as "break", "continue", "jump" for which
            // we do not need to provide any hover.
            if (DScriptUtilities.IsLabelName(node))
            {
                return(Result <Hover, ResponseError> .Success(null));
            }

            // Attempt to get the type from the node
            var typeAtLocation = TypeChecker.GetTypeAtLocation(node);

            if ((typeAtLocation.Flags & TypeFlags.Any) != TypeFlags.None && node.Kind == SyntaxKind.Identifier)
            {
                // Now if we are likely to return any (unknown), and we are on an identifier
                // its parent is a type-reference then let's display that instead.
                // An example of this is "someTemplateVariable.merge<>"
                if (node.Parent?.Kind == SyntaxKind.TypeReference)
                {
                    node = node.Parent;
                }
                else if (node.Parent?.Kind == SyntaxKind.QualifiedName)
                {
                    // The same type of thing can happen with values referenced
                    // from an imported value (i.e. qualified name) such as
                    // import "A" from "SomeModule";
                    // let z = A.B.C.value;
                    // "value" is the identifier and "A.B.C" are the qualified names.
                    // As you walk up the chain, you will eventually find "A" which is
                    // a type-reference.

                    var nodeWalk = node.Parent;
                    while (nodeWalk != null && nodeWalk.Kind == SyntaxKind.QualifiedName)
                    {
                        nodeWalk = nodeWalk.Parent;
                    }

                    if (nodeWalk.Kind == SyntaxKind.TypeReference)
                    {
                        node = nodeWalk;
                    }
                }
            }

            // TODO: Not sure why GetSymbolAtLocation isn't enough
            var symbol = TypeChecker.GetSymbolAtLocation(node) ?? node.Symbol ?? node.ResolvedSymbol;

            // Find the first declaration. We will use it to special case a few things below.
            var firstDeclaration = symbol?.GetFirstDeclarationOrDefault();

            // Grab the symbol name from the first declaration.
            string symbolAsString = firstDeclaration?.Name?.Text;

            // Handle a few special cases before we default to showing the type.
            // Typically these special cases are where hover is performed on a declaration of
            // things such as an enum, import statement (and eventually others)
            if (firstDeclaration != null && symbolAsString != null)
            {
                // Special case import * from "" and import {} from "" and import {x as y} from ""
                // So we can show the user a hover that says "import {} from 'module' so they can easily
                // see where it is coming from.
                if (firstDeclaration.Kind == SyntaxKind.ImportSpecifier || firstDeclaration.Kind == SyntaxKind.NamespaceImport)
                {
                    IImportClause importClause;
                    if (firstDeclaration.Kind == SyntaxKind.ImportSpecifier)
                    {
                        var importSpecifier = firstDeclaration.Cast <IImportSpecifier>();
                        var namedImports    = importSpecifier.Parent.Cast <INamedImports>();
                        importClause = namedImports.Parent.Cast <IImportClause>();
                    }
                    else
                    {
                        var namespaceImport = firstDeclaration.Cast <INamespaceImport>();
                        importClause = namespaceImport.Parent.Cast <IImportClause>();
                    }

                    var importDeclaration = importClause.Parent.Cast <IImportDeclaration>();

                    return(CreateScriptHoverWithCodeSnippetAndDocumentation(
                               symbol,
                               node,
                               string.Format(BuildXL.Ide.LanguageServer.Strings.HoverImportFormat, symbolAsString, importDeclaration.ModuleSpecifier.ToDisplayString())));
                }

                // For interface declarations, just show a hover of "interface X"
                if (firstDeclaration.Kind == SyntaxKind.InterfaceDeclaration)
                {
                    return(CreateScriptHoverWithCodeSnippetAndDocumentation(symbol, node, firstDeclaration.GetFormattedText()));
                    // We have decided to show the formatted text of the declaration as it allows
                    // the user to browse the entire interface.
                    // If we decide we want a more conscise hover, we can uncomment the following
                    // code.
                    //var interfaceDeclaration = firstDeclaration.Cast<IInterfaceDeclaration>();
                    //return CreateScriptHoverWithCodeSnippetAndDocumentation(symbol, node, string.Format(Strings.HoverInterfaceFormat, interfaceDeclaration.Name.Text));
                }

                // For enum declarations, show a hover of "enum { x, y, z}"
                if (firstDeclaration.Kind == SyntaxKind.EnumDeclaration)
                {
                    return(CreateScriptHoverWithCodeSnippetAndDocumentation(symbol, node, firstDeclaration.GetFormattedText()));
                    // We have decided to show the formatted text of the declaration as it allows
                    // the user to browse the entire enumeration.
                    // If we decide we want a more conscise hover, we can uncomment the following
                    // code.

                    /*
                     * var enumDeclaration = firstDeclaration.Cast<IEnumDeclaration>();
                     *
                     * var memberStrings = new List<string>();
                     * foreach (var member in enumDeclaration.Members)
                     * {
                     *  memberStrings.Add(member.Cast<IEnumMember>().Name.Text);
                     * }
                     *
                     * var memberString = memberStrings.Aggregate((current, next) => string.Format(Strings.HoverEnumMemberFormat, current, next));
                     *
                     * return CreateScriptHoverWithCodeSnippetAndDocumentation(symbol, node, string.Format(Strings.HoverEnumFormat, enumDeclaration.Name.Text, memberString));
                     */
                }


                // Handle things that are function-like (such as interface methods, functions, etc).
                var functionLike = firstDeclaration.As <IFunctionLikeDeclaration>();
                if (functionLike != null)
                {
                    return(CreateScriptHoverWithCodeSnippetAndDocumentation(symbol, node, functionLike.ToDisplayString()));
                }
            }

            // So if we can't find a suitable declaration for the node to display for hover,
            // Then we will display the type associated the symbol, which is super useful
            // for things like variable declarations, etc. (You'll notice that variable declarations are not
            // handled above, for exactly this purpose).
            if (node != null && symbol != null)
            {
                return(CreateHoverBasedOnTypeInformation(symbol, node, symbolAsString));
            }

            return(Result <Hover, ResponseError> .Success(null));
        }