static object PerformMemberwiseClone(ref object o)
        {
            var ins = new UnityEngine.RuntimePlatform();

            ins = (UnityEngine.RuntimePlatform)o;
            return(ins);
        }
        public void PushUnityEngineRuntimePlatform(RealStatePtr L, UnityEngine.RuntimePlatform val)
        {
            if (UnityEngineRuntimePlatform_TypeID == -1)
            {
                bool is_first;
                UnityEngineRuntimePlatform_TypeID = getTypeId(L, typeof(UnityEngine.RuntimePlatform), out is_first);

                if (UnityEngineRuntimePlatform_EnumRef == -1)
                {
                    Utils.LoadCSTable(L, typeof(UnityEngine.RuntimePlatform));
                    UnityEngineRuntimePlatform_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX);
                }
            }

            if (LuaAPI.xlua_tryget_cachedud(L, (int)val, UnityEngineRuntimePlatform_EnumRef) == 1)
            {
                return;
            }

            IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, UnityEngineRuntimePlatform_TypeID);

            if (!CopyByValue.Pack(buff, 0, (int)val))
            {
                throw new Exception("pack fail fail for UnityEngine.RuntimePlatform ,value=" + val);
            }

            LuaAPI.lua_getref(L, UnityEngineRuntimePlatform_EnumRef);
            LuaAPI.lua_pushvalue(L, -2);
            LuaAPI.xlua_rawseti(L, -2, (int)val);
            LuaAPI.lua_pop(L, 1);
        }
    /// <summary>
    /// プラットフォーム名を取得する
    /// </summary>
    /// <returns>プラットフォーム名</returns>
    /// <param name="runtimePlatform">実行中のプラットフォーム</param>
    public static string GetPlatformName(UnityEngine.RuntimePlatform runtimePlatform)
    {
        switch (runtimePlatform)
        {
        case UnityEngine.RuntimePlatform.OSXPlayer:
        case UnityEngine.RuntimePlatform.OSXEditor:
            return(PlatformNameManager.OSXPlatformName);

        case UnityEngine.RuntimePlatform.WindowsEditor:
        case UnityEngine.RuntimePlatform.WindowsPlayer:
            return(PlatformNameManager.WindowsPlatformName);

        case UnityEngine.RuntimePlatform.IPhonePlayer:
            return(PlatformNameManager.IOSPlatformName);

        case UnityEngine.RuntimePlatform.Android:
            return(PlatformNameManager.AndroidPlatformName);

        case UnityEngine.RuntimePlatform.PS4:
            return(PlatformNameManager.PS4PlatformName);

        case UnityEngine.RuntimePlatform.XboxOne:
            return(PlatformNameManager.XboxOnePlatformName);

        case UnityEngine.RuntimePlatform.Switch:
            return(PlatformNameManager.SwitchPlatformName);

        default:
            return(string.Empty);
        }
    }
    static int IntToEnum(IntPtr L)
    {
        int arg0 = (int)LuaDLL.lua_tonumber(L, 1);

        UnityEngine.RuntimePlatform o = (UnityEngine.RuntimePlatform)arg0;
        ToLua.Push(L, o);
        return(1);
    }
Beispiel #5
0
        public static bool IsAvailableOn(UnityEngine.RuntimePlatform platform)
        {
            bool available = false;

            available = UnityEngine.Application.platform == platform;

            return(available);
        }
Beispiel #6
0
        public static string GetPlatformName(UnityEngine.RuntimePlatform platform)
        {
            switch (platform)
            {
            case UnityEngine.RuntimePlatform.WindowsPlayer:
                return(E_Platform.Windows64.ToString());

            case UnityEngine.RuntimePlatform.LinuxPlayer:
                return(E_Platform.Linux64.ToString());

            case UnityEngine.RuntimePlatform.OSXPlayer:
                return(E_Platform.OSX.ToString());

            case UnityEngine.RuntimePlatform.Android:
                return(E_Platform.Android.ToString());

            case UnityEngine.RuntimePlatform.IPhonePlayer:
                return(E_Platform.iOS.ToString());

            case UnityEngine.RuntimePlatform.XboxOne:
                return(E_Platform.XBox.ToString());

            case UnityEngine.RuntimePlatform.Switch:
                return(E_Platform.NSwitch.ToString());

            case UnityEngine.RuntimePlatform.WebGLPlayer:
                return(E_Platform.WebGL.ToString());

            case UnityEngine.RuntimePlatform.WSAPlayerARM:
                return(E_Platform.UWP.ToString());

            case UnityEngine.RuntimePlatform.WSAPlayerX64:
                return(E_Platform.UWP.ToString());

            case UnityEngine.RuntimePlatform.WSAPlayerX86:
                return(E_Platform.UWP.ToString());

            //EDITORS
            case UnityEngine.RuntimePlatform.WindowsEditor:
                return(E_Platform.Windows64.ToString());

            case UnityEngine.RuntimePlatform.LinuxEditor:
                return(E_Platform.Linux64.ToString());

            case UnityEngine.RuntimePlatform.OSXEditor:
                return(E_Platform.OSX.ToString());


            default:
                return(E_Platform.Windows64.ToString());
            }
        }
        static StackObject *GetPlatformPath_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.RuntimePlatform @platform = (UnityEngine.RuntimePlatform) typeof(UnityEngine.RuntimePlatform).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);


            var result_of_this_method = BDFramework.Helper.Utils.GetPlatformPath(@platform);

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
        static void WriteBackInstance(CSHotFix.Runtime.Enviorment.AppDomain __domain, StackObject *ptr_of_this_method, IList <object> __mStack, ref UnityEngine.RuntimePlatform instance_of_this_method)
        {
            ptr_of_this_method = ILIntepreter.GetObjectAndResolveReference(ptr_of_this_method);
            switch (ptr_of_this_method->ObjectType)
            {
            case ObjectTypes.Object:
            {
                __mStack[ptr_of_this_method->Value] = instance_of_this_method;
            }
            break;

            case ObjectTypes.FieldReference:
            {
                var ___obj = __mStack[ptr_of_this_method->Value];
                if (___obj is ILTypeInstance)
                {
                    ((ILTypeInstance)___obj)[ptr_of_this_method->ValueLow] = instance_of_this_method;
                }
                else
                {
                    var t = __domain.GetType(___obj.GetType()) as CLRType;
                    t.SetFieldValue(ptr_of_this_method->ValueLow, ref ___obj, instance_of_this_method);
                }
            }
            break;

            case ObjectTypes.StaticFieldReference:
            {
                var t = __domain.GetType(ptr_of_this_method->Value);
                if (t is ILType)
                {
                    ((ILType)t).StaticInstance[ptr_of_this_method->ValueLow] = instance_of_this_method;
                }
                else
                {
                    ((CLRType)t).SetStaticFieldValue(ptr_of_this_method->ValueLow, instance_of_this_method);
                }
            }
            break;

            case ObjectTypes.ArrayReference:
            {
                var instance_of_arrayReference = __mStack[ptr_of_this_method->Value] as UnityEngine.RuntimePlatform[];
                instance_of_arrayReference[ptr_of_this_method->ValueLow] = instance_of_this_method;
            }
            break;
            }
        }
Beispiel #9
0
        static void GetPlatform(Collection <CustomAttribute> CustomAttributes, System.Action <UnityEngine.RuntimePlatform> action)
        {
            CustomAttribute custom;

            for (int i = 0; i < CustomAttributes.Count; ++i)
            {
                custom = CustomAttributes[i];
                if (custom.AttributeType.FullName != "wxb.Platform")
                {
                    continue;
                }

                var param = custom.ConstructorArguments[0];
                UnityEngine.RuntimePlatform platform = (UnityEngine.RuntimePlatform)param.Value;
                action(platform);
            }
        }
Beispiel #10
0
        static StackObject *LoadOnEditor_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.RuntimePlatform @platform = (UnityEngine.RuntimePlatform) typeof(UnityEngine.RuntimePlatform).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            System.String @root = (System.String) typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);


            BDFramework.Sql.SqliteLoder.LoadOnEditor(@root, @platform);

            return(__ret);
        }
        public void UpdateUnityEngineRuntimePlatform(RealStatePtr L, int index, UnityEngine.RuntimePlatform val)
        {
            if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA)
            {
                if (LuaAPI.xlua_gettypeid(L, index) != UnityEngineRuntimePlatform_TypeID)
                {
                    throw new Exception("invalid userdata for UnityEngine.RuntimePlatform");
                }

                IntPtr buff = LuaAPI.lua_touserdata(L, index);
                if (!CopyByValue.Pack(buff, 0, (int)val))
                {
                    throw new Exception("pack fail for UnityEngine.RuntimePlatform ,value=" + val);
                }
            }

            else
            {
                throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index));
            }
        }
        public void Get(RealStatePtr L, int index, out UnityEngine.RuntimePlatform val)
        {
            LuaTypes type = LuaAPI.lua_type(L, index);

            if (type == LuaTypes.LUA_TUSERDATA)
            {
                if (LuaAPI.xlua_gettypeid(L, index) != UnityEngineRuntimePlatform_TypeID)
                {
                    throw new Exception("invalid userdata for UnityEngine.RuntimePlatform");
                }

                IntPtr buff = LuaAPI.lua_touserdata(L, index);
                int    e;
                if (!CopyByValue.UnPack(buff, 0, out e))
                {
                    throw new Exception("unpack fail for UnityEngine.RuntimePlatform");
                }
                val = (UnityEngine.RuntimePlatform)e;
            }
            else
            {
                val = (UnityEngine.RuntimePlatform)objectCasters.GetCaster(typeof(UnityEngine.RuntimePlatform))(L, index, null);
            }
        }
 static void Push(IntPtr L, UnityEngine.RuntimePlatform arg)
 {
     ToLua.Push(L, arg);
 }
Beispiel #14
0
        // 自动注册
        static void AutoReplace(List <IType> types)
        {
            Dictionary <string, List <MethodInfo> > NameToSorted = new Dictionary <string, List <MethodInfo> >();
            List <UnityEngine.RuntimePlatform>      platforms    = new List <UnityEngine.RuntimePlatform>();

            UnityEngine.RuntimePlatform rp = GetCurrentPlatform();
            foreach (var ator in types)
            {
                ILType type = ator as ILType;
                if (type == null)
                {
                    continue;
                }

                NameToSorted.Clear();
                var         typeDefinition = type.TypeDefinition;
                System.Type rt             = GetReplaceType(typeDefinition.CustomAttributes);
                platforms.Clear();
                GetPlatform(typeDefinition.CustomAttributes, (p) => { platforms.Add(p); });
                if (platforms.Count != 0 && !platforms.Contains(rp))
                {
                    wxb.L.LogWarningFormat("platorms:{0} type:{1} not hotfix!", rp, type.Name);
                    continue; // 不属于此平台的
                }
                // 相同函数名排序问题
                foreach (var il in type.GetMethods())
                {
                    var ilMethod = il as ILMethod;
                    if (ilMethod == null)
                    {
                        continue;
                    }

                    var         method = ilMethod.Definition;
                    System.Type methodType;
                    string      methodFieldName;
                    if (!GetReplaceFunction(method.CustomAttributes, out methodType, out methodFieldName))
                    {
                        continue;
                    }

                    if (!ilMethod.IsStatic)
                    {
                        wxb.L.LogErrorFormat("type:{0} method:{1} is not static fun!", type.Name, method.Name);
                        continue;
                    }

                    platforms.Clear();
                    GetPlatform(method.CustomAttributes, (p) => { platforms.Add(p); });
                    if (platforms.Count != 0 && !platforms.Contains(rp))
                    {
                        wxb.L.LogWarningFormat("platorms:{0} type:{1}.{2} not hotfix!", rp, type.Name, ilMethod.Name);
                        continue; // 不属于此平台的
                    }

                    System.Type srcType = methodType != null ? methodType : rt;
                    if (srcType == null)
                    {
                        wxb.L.LogErrorFormat("type:{0} method:{1} not set srcType!", type.Name, method.Name);
                        continue;
                    }

                    string fieldName = methodFieldName;
                    if (string.IsNullOrEmpty(fieldName))
                    {
                        fieldName = "__Hotfix_" + method.Name;
                    }

                    var field = srcType.GetField(fieldName, bindingFlags);
                    if (field == null)
                    {
                        wxb.L.LogErrorFormat("hotType:{0} method:{1} not find srcType:{2}.{3} hot field!", type.Name, method.Name, srcType.FullName, fieldName);
                        continue;
                    }

                    var bridge = new global::IL.DelegateBridge(ilMethod.ReflectionMethodInfo);
                    field.SetValue(null, bridge);
                    Fields.Add(field);
                    wxb.L.LogFormat("type:{0} method:{1} Replace {2}.{3}!", type.Name, method.Name, srcType.Name, fieldName);

                    AutoSetFieldMethodValue(srcType, field, type, fieldName, bridge, NameToSorted);
                }
            }
        }
Beispiel #15
0
 public Platform(UnityEngine.RuntimePlatform platform)
 {
 }