コード例 #1
0
        public int Set(IntPtr L)
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 4)
            {
                object arg0 = ToLua.CheckVarObject(L, 2, kclass);
                object arg1 = ToLua.ToVarObject(L, 3);
                if (arg1 != null)
                {
                    arg1 = TypeChecker.ChangeType(arg1, property.PropertyType);
                }
                object[] arg2 = ToLua.CheckObjectArray(L, 4);
                property.SetValue(arg0, arg1, arg2);
                return(0);
            }
            else if (count == 7)
            {
                object arg0 = ToLua.CheckVarObject(L, 2, kclass);
                object arg1 = ToLua.ToVarObject(L, 3);
                if (arg1 != null)
                {
                    arg1 = TypeChecker.ChangeType(arg1, property.PropertyType);
                }
                BindingFlags arg2 = (BindingFlags)LuaDLL.luaL_checknumber(L, 4);
                Binder       arg3 = (Binder)ToLua.CheckObject(L, 5, typeof(Binder));
                object[]     arg4 = ToLua.CheckObjectArray(L, 6);
                CultureInfo  arg5 = (CultureInfo)ToLua.CheckObject(L, 7, typeof(CultureInfo));
                property.SetValue(arg0, arg1, arg2, arg3, arg4, arg5);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: LuaInterface.LuaProperty.Set"));
            }
        }
コード例 #2
0
        static int GetProperty(IntPtr L)
        {
            try
            {
                int count = LuaDLL.lua_gettop(L);

                if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string)))
                {
                    Type         obj  = (Type)ToLua.ToObject(L, 1);
                    string       arg0 = ToLua.ToString(L, 2);
                    PropertyInfo o    = obj.GetProperty(arg0);
                    PushLuaProperty(L, o, obj);
                    return(1);
                }
                else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string), typeof(Type[])))
                {
                    Type         obj  = (Type)ToLua.ToObject(L, 1);
                    string       arg0 = ToLua.ToString(L, 2);
                    Type[]       arg1 = ToLua.CheckObjectArray <Type>(L, 3);
                    PropertyInfo o    = obj.GetProperty(arg0, arg1);
                    PushLuaProperty(L, o, obj);
                    return(1);
                }
                else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string), typeof(Type)))
                {
                    Type         obj  = (Type)ToLua.ToObject(L, 1);
                    string       arg0 = ToLua.ToString(L, 2);
                    Type         arg1 = (Type)ToLua.ToObject(L, 3);
                    PropertyInfo o    = obj.GetProperty(arg0, arg1);
                    PushLuaProperty(L, o, obj);
                    return(1);
                }
                else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string), typeof(uint)))
                {
                    Type         obj  = (Type)ToLua.ToObject(L, 1);
                    string       arg0 = ToLua.ToString(L, 2);
                    BindingFlags arg1 = (BindingFlags)LuaDLL.lua_tonumber(L, 3);
                    PropertyInfo o    = obj.GetProperty(arg0, arg1);
                    PushLuaProperty(L, o, obj);
                    return(1);
                }
                else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string), typeof(Type), typeof(Type[])))
                {
                    Type         obj  = (Type)ToLua.ToObject(L, 1);
                    string       arg0 = ToLua.ToString(L, 2);
                    Type         arg1 = (Type)ToLua.ToObject(L, 3);
                    Type[]       arg2 = ToLua.CheckObjectArray <Type>(L, 4);
                    PropertyInfo o    = obj.GetProperty(arg0, arg1, arg2);
                    PushLuaProperty(L, o, obj);
                    return(1);
                }
                else if (count == 5 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string), typeof(Type), typeof(Type[]), typeof(ParameterModifier[])))
                {
                    Type   obj  = (Type)ToLua.ToObject(L, 1);
                    string arg0 = ToLua.ToString(L, 2);
                    Type   arg1 = (Type)ToLua.ToObject(L, 3);
                    Type[] arg2 = ToLua.CheckObjectArray <Type>(L, 4);
                    ParameterModifier[] arg3 = ToLua.CheckObjectArray <ParameterModifier>(L, 5);
                    PropertyInfo        o    = obj.GetProperty(arg0, arg1, arg2, arg3);
                    PushLuaProperty(L, o, obj);
                    return(1);
                }
                else if (count == 7 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string), typeof(uint), typeof(Binder), typeof(Type), typeof(Type[]), typeof(ParameterModifier[])))
                {
                    Type                obj  = (Type)ToLua.ToObject(L, 1);
                    string              arg0 = ToLua.ToString(L, 2);
                    BindingFlags        arg1 = (BindingFlags)LuaDLL.lua_tonumber(L, 3);
                    Binder              arg2 = (Binder)ToLua.ToObject(L, 4);
                    Type                arg3 = (Type)ToLua.ToObject(L, 5);
                    Type[]              arg4 = ToLua.CheckObjectArray <Type>(L, 6);
                    ParameterModifier[] arg5 = ToLua.CheckObjectArray <ParameterModifier>(L, 7);
                    PropertyInfo        o    = obj.GetProperty(arg0, arg1, arg2, arg3, arg4, arg5);
                    PushLuaProperty(L, o, obj);
                    return(1);
                }
                else
                {
                    return(LuaDLL.luaL_throw(L, "invalid arguments to method: tolua.getproperty"));
                }
            }
            catch (Exception e)
            {
                return(LuaDLL.toluaL_exception(L, e));
            }
        }
コード例 #3
0
 public Type[] CheckTypeArray(IntPtr L, int stackPos)
 {
     return(ToLua.CheckObjectArray <Type>(L, stackPos));
 }
コード例 #4
0
        private static int GetProperty(IntPtr L)
        {
            int result;

            try
            {
                int num = LuaDLL.lua_gettop(L);
                if (num == 2 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string)))
                {
                    Type         type     = (Type)ToLua.ToObject(L, 1);
                    string       name     = ToLua.ToString(L, 2);
                    PropertyInfo property = type.GetProperty(name);
                    LuaReflection.PushLuaProperty(L, property, type);
                    result = 1;
                }
                else if (num == 3 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string), typeof(Type[])))
                {
                    Type         type2     = (Type)ToLua.ToObject(L, 1);
                    string       name2     = ToLua.ToString(L, 2);
                    Type[]       types     = ToLua.CheckObjectArray <Type>(L, 3);
                    PropertyInfo property2 = type2.GetProperty(name2, types);
                    LuaReflection.PushLuaProperty(L, property2, type2);
                    result = 1;
                }
                else if (num == 3 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string), typeof(Type)))
                {
                    Type         type3      = (Type)ToLua.ToObject(L, 1);
                    string       name3      = ToLua.ToString(L, 2);
                    Type         returnType = (Type)ToLua.ToObject(L, 3);
                    PropertyInfo property3  = type3.GetProperty(name3, returnType);
                    LuaReflection.PushLuaProperty(L, property3, type3);
                    result = 1;
                }
                else if (num == 3 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string), typeof(uint)))
                {
                    Type         type4       = (Type)ToLua.ToObject(L, 1);
                    string       name4       = ToLua.ToString(L, 2);
                    BindingFlags bindingAttr = (BindingFlags)LuaDLL.lua_tonumber(L, 3);
                    PropertyInfo property4   = type4.GetProperty(name4, bindingAttr);
                    LuaReflection.PushLuaProperty(L, property4, type4);
                    result = 1;
                }
                else if (num == 4 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string), typeof(Type), typeof(Type[])))
                {
                    Type         type5       = (Type)ToLua.ToObject(L, 1);
                    string       name5       = ToLua.ToString(L, 2);
                    Type         returnType2 = (Type)ToLua.ToObject(L, 3);
                    Type[]       types2      = ToLua.CheckObjectArray <Type>(L, 4);
                    PropertyInfo property5   = type5.GetProperty(name5, returnType2, types2);
                    LuaReflection.PushLuaProperty(L, property5, type5);
                    result = 1;
                }
                else if (num == 5 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string), typeof(Type), typeof(Type[]), typeof(ParameterModifier[])))
                {
                    Type   type6                  = (Type)ToLua.ToObject(L, 1);
                    string name6                  = ToLua.ToString(L, 2);
                    Type   returnType3            = (Type)ToLua.ToObject(L, 3);
                    Type[] types3                 = ToLua.CheckObjectArray <Type>(L, 4);
                    ParameterModifier[] modifiers = ToLua.CheckObjectArray <ParameterModifier>(L, 5);
                    PropertyInfo        property6 = type6.GetProperty(name6, returnType3, types3, modifiers);
                    LuaReflection.PushLuaProperty(L, property6, type6);
                    result = 1;
                }
                else if (num == 7 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string), typeof(uint), typeof(Binder), typeof(Type), typeof(Type[]), typeof(ParameterModifier[])))
                {
                    Type                type7        = (Type)ToLua.ToObject(L, 1);
                    string              name7        = ToLua.ToString(L, 2);
                    BindingFlags        bindingAttr2 = (BindingFlags)LuaDLL.lua_tonumber(L, 3);
                    Binder              binder       = (Binder)ToLua.ToObject(L, 4);
                    Type                returnType4  = (Type)ToLua.ToObject(L, 5);
                    Type[]              types4       = ToLua.CheckObjectArray <Type>(L, 6);
                    ParameterModifier[] modifiers2   = ToLua.CheckObjectArray <ParameterModifier>(L, 7);
                    PropertyInfo        property7    = type7.GetProperty(name7, bindingAttr2, binder, returnType4, types4, modifiers2);
                    LuaReflection.PushLuaProperty(L, property7, type7);
                    result = 1;
                }
                else
                {
                    result = LuaDLL.luaL_throw(L, "invalid arguments to method: tolua.getproperty");
                }
            }
            catch (Exception e)
            {
                result = LuaDLL.toluaL_exception(L, e, null);
            }
            return(result);
        }
コード例 #5
0
        private static int GetTypeMethod(IntPtr L)
        {
            int result;

            try
            {
                int num = LuaDLL.lua_gettop(L);
                if (num == 2 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string)))
                {
                    Type       type   = (Type)ToLua.ToObject(L, 1);
                    string     name   = ToLua.ToString(L, 2);
                    MethodInfo method = type.GetMethod(name);
                    LuaReflection.PushLuaMethod(L, method, type, null);
                    result = 1;
                }
                else if (num == 3 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string), typeof(Type[])))
                {
                    Type       type2   = (Type)ToLua.ToObject(L, 1);
                    string     name2   = ToLua.ToString(L, 2);
                    Type[]     types   = ToLua.CheckObjectArray <Type>(L, 3);
                    MethodInfo method2 = type2.GetMethod(name2, types);
                    LuaReflection.PushLuaMethod(L, method2, type2, types);
                    result = 1;
                }
                else if (num == 3 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string), typeof(uint)))
                {
                    Type         type3       = (Type)ToLua.ToObject(L, 1);
                    string       name3       = ToLua.ToString(L, 2);
                    BindingFlags bindingAttr = (BindingFlags)LuaDLL.lua_tonumber(L, 3);
                    MethodInfo   method3     = type3.GetMethod(name3, bindingAttr);
                    LuaReflection.PushLuaMethod(L, method3, type3, null);
                    result = 1;
                }
                else if (num == 4 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string), typeof(Type[]), typeof(ParameterModifier[])))
                {
                    Type   type4  = (Type)ToLua.ToObject(L, 1);
                    string name4  = ToLua.ToString(L, 2);
                    Type[] types2 = ToLua.CheckObjectArray <Type>(L, 3);
                    ParameterModifier[] modifiers = ToLua.CheckObjectArray <ParameterModifier>(L, 4);
                    MethodInfo          method4   = type4.GetMethod(name4, types2, modifiers);
                    LuaReflection.PushLuaMethod(L, method4, type4, types2);
                    result = 1;
                }
                else if (num == 6 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string), typeof(uint), typeof(Binder), typeof(Type[]), typeof(ParameterModifier[])))
                {
                    Type                type5        = (Type)ToLua.ToObject(L, 1);
                    string              name5        = ToLua.ToString(L, 2);
                    BindingFlags        bindingAttr2 = (BindingFlags)LuaDLL.lua_tonumber(L, 3);
                    Binder              binder       = (Binder)ToLua.ToObject(L, 4);
                    Type[]              types3       = ToLua.CheckObjectArray <Type>(L, 5);
                    ParameterModifier[] modifiers2   = ToLua.CheckObjectArray <ParameterModifier>(L, 6);
                    MethodInfo          method5      = type5.GetMethod(name5, bindingAttr2, binder, types3, modifiers2);
                    LuaReflection.PushLuaMethod(L, method5, type5, types3);
                    result = 1;
                }
                else if (num == 7 && TypeChecker.CheckTypes(L, 1, typeof(Type), typeof(string), typeof(uint), typeof(Binder), typeof(CallingConventions), typeof(Type[]), typeof(ParameterModifier[])))
                {
                    Type                type6          = (Type)ToLua.ToObject(L, 1);
                    string              name6          = ToLua.ToString(L, 2);
                    BindingFlags        bindingAttr3   = (BindingFlags)LuaDLL.lua_tonumber(L, 3);
                    Binder              binder2        = (Binder)ToLua.ToObject(L, 4);
                    CallingConventions  callConvention = (CallingConventions)((int)ToLua.ToObject(L, 5));
                    Type[]              types4         = ToLua.CheckObjectArray <Type>(L, 6);
                    ParameterModifier[] modifiers3     = ToLua.CheckObjectArray <ParameterModifier>(L, 7);
                    MethodInfo          method6        = type6.GetMethod(name6, bindingAttr3, binder2, callConvention, types4, modifiers3);
                    LuaReflection.PushLuaMethod(L, method6, type6, types4);
                    result = 1;
                }
                else
                {
                    result = LuaDLL.luaL_throw(L, "invalid arguments to method: tolua.gettypemethod");
                }
            }
            catch (Exception e)
            {
                result = LuaDLL.toluaL_exception(L, e, null);
            }
            return(result);
        }