Ejemplo n.º 1
0
 static FBox2D()
 {
     if (UnrealTypes.CanLazyLoadNativeType(typeof(FBox2D)))
     {
         LoadNativeType();
     }
     UnrealTypes.OnCCtorCalled(typeof(FBox2D));
 }
Ejemplo n.º 2
0
 static FFloatRange()
 {
     if (UnrealTypes.CanLazyLoadNativeType(typeof(FFloatRange)))
     {
         LoadNativeType();
     }
     UnrealTypes.OnCCtorCalled(typeof(FFloatRange));
 }
Ejemplo n.º 3
0
 static FColor()
 {
     if (UnrealTypes.CanLazyLoadNativeType(typeof(FColor)))
     {
         LoadNativeType();
     }
     UnrealTypes.OnCCtorCalled(typeof(FColor));
 }
Ejemplo n.º 4
0
 static FInterpCurvePointVector()
 {
     if (UnrealTypes.CanLazyLoadNativeType(typeof(FInterpCurvePointVector)))
     {
         LoadNativeType();
     }
     UnrealTypes.OnCCtorCalled(typeof(FInterpCurvePointVector));
 }
Ejemplo n.º 5
0
 static FFloatInterval()
 {
     if (UnrealTypes.CanLazyLoadNativeType(typeof(FFloatInterval)))
     {
         LoadNativeType();
     }
     UnrealTypes.OnCCtorCalled(typeof(FFloatInterval));
 }
Ejemplo n.º 6
0
 static FBoxSphereBounds()
 {
     if (UnrealTypes.CanLazyLoadNativeType(typeof(FBoxSphereBounds)))
     {
         LoadNativeType();
     }
     UnrealTypes.OnCCtorCalled(typeof(FBoxSphereBounds));
 }
Ejemplo n.º 7
0
 static FPlane()
 {
     if (UnrealTypes.CanLazyLoadNativeType(typeof(FPlane)))
     {
         LoadNativeType();
     }
     UnrealTypes.OnCCtorCalled(typeof(FPlane));
 }
Ejemplo n.º 8
0
 static FIntPoint()
 {
     if (UnrealTypes.CanLazyLoadNativeType(typeof(FIntPoint)))
     {
         LoadNativeType();
     }
     UnrealTypes.OnCCtorCalled(typeof(FIntPoint));
 }
Ejemplo n.º 9
0
        static StructDefault()
        {
            Type type = typeof(T);

            IsStructAsClass = type.IsSubclassOf(typeof(StructAsClass));

            if (!type.IsValueType && !IsStructAsClass)
            {
                useDefaultT = true;
                return;
            }

            UUnrealTypePathAttribute pathAttribute = UnrealTypes.GetPathAttribute(type);

            if (UnrealTypes.All.TryGetValue(type, out pathAttribute) && !string.IsNullOrEmpty(pathAttribute.Path))
            {
                structPath = pathAttribute.Path;
            }

            IsStruct = !string.IsNullOrEmpty(structPath);

            if (IsStructAsClass)
            {
                // All structs as classes must be allocated on the heap and cannot use default(T)
                useDefaultT = false;
                fromNative  = MarshalingDelegateResolver <T> .FromNative;
                return;
            }

            if (!IsStruct)
            {
                useDefaultT = true;
                return;
            }

            foreach (MethodInfo method in type.GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly))
            {
                if (method.Name == "FromNative" && method.GetParameters().Length == 3)
                {
                    fromNative = (MarshalingDelegates <T> .FromNative)Delegate.CreateDelegate(typeof(MarshalingDelegates <T> .FromNative), method);
                    break;
                }
            }

            if (fromNative != null)
            {
                IsBlittableStruct = false;
            }
            else
            {
                IsBlittableStruct = true;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Gets the address of the UEnum for the given enum type
        /// </summary>
        /// <param name="type">The type of the enum</param>
        /// <returns>The address of the UEnum for the given type</returns>
        public static IntPtr GetEnumAddress(Type type)
        {
            UUnrealTypePathAttribute pathAttribute = UnrealTypes.GetPathAttribute(type);

            if (pathAttribute != null)
            {
                if (pathAttribute.IsManagedType)
                {
                    return(ManagedUnrealTypes.GetEnumAddress(type));
                }
                else
                {
                    return(GetEnumAddress(pathAttribute.Path));
                }
            }
            return(IntPtr.Zero);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Gets the address of the UFunction for the given delegate type
        /// </summary>
        /// <param name="type">The type of the delegate</param>
        /// <returns>The address of the UFunction for the given type</returns>
        public static IntPtr GetDelegateSignatureAddress(Type type)
        {
            UUnrealTypePathAttribute pathAttribute = UnrealTypes.GetPathAttribute(type);

            if (pathAttribute != null)
            {
                if (pathAttribute.IsManagedType)
                {
                    // TODO: Support dynamic loading of managed types
                    return(ManagedUnrealTypes.GetDelegateSignatureAddress(type));
                }
                else
                {
                    return(GetFunctionAddress(pathAttribute.Path));
                }
            }
            return(IntPtr.Zero);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Loads the address of the UScriptStruct for the given struct type
        /// </summary>
        /// <param name="type">The type of the struct</param>
        /// <returns>The address of the UScriptStruct for the given type</returns>
        public static IntPtr LoadStructAddress(Type type)
        {
            UUnrealTypePathAttribute pathAttribute = UnrealTypes.GetPathAttribute(type);

            if (pathAttribute != null)
            {
                if (pathAttribute.IsManagedType)
                {
                    // TODO: Support dynamic loading of managed types
                    return(ManagedUnrealTypes.GetStructAddress(type));
                }
                else
                {
                    return(LoadStructAddress(pathAttribute.Path));
                }
            }
            return(IntPtr.Zero);
        }
Ejemplo n.º 13
0
        public static void Main(string[] args)
        {
            if (!args.Any())
            {
                Console.Error.WriteLine("Error: No input files. Add file path to dll as argument.");
                Environment.Exit(2);
            }

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            UnrealTypes.Load();
            AssemblyRewriter rewriter = new AssemblyRewriter();

            if (Debugger.IsAttached)
            {
                ManagedUnrealReflectionBase.UpdateSerializerCode();
                //RunTests(rewriter);
            }

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            foreach (string filePath in args)
            {
                Console.WriteLine("Processing file: " + filePath);
                if (!ProcessAssembly(rewriter, filePath))
                {
                    Environment.ExitCode = 3;
                    break;
                }
                additionalAssemblySearchPath = null;
            }

            stopwatch.Stop();
            Console.WriteLine("AssemblyRewriter finished " + stopwatch.Elapsed);
            if (ManagedUnrealModuleInfo.NumWarnings > 0)
            {
                Console.WriteLine("!!!!!! " + ManagedUnrealModuleInfo.NumWarnings + " warning(s) whilst running AssemblyRewriter");
                ManagedUnrealModuleInfo.NumWarnings = 0;
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Gets the UClass address for the given UObject derived type
        /// </summary>
        /// <param name="type">The UObject derived type</param>
        /// <returns>The address of the UClass for the given type</returns>
        public static IntPtr GetClassAddress(Type type)
        {
            UUnrealTypePathAttribute pathAttribute = UnrealTypes.GetPathAttribute(type);

            if (pathAttribute != null)
            {
                if (pathAttribute.IsManagedType)
                {
                    return(ManagedUnrealTypes.GetClassAddress(type));
                }
                else
                {
                    UClass unrealClass = GetClass(type);
                    if (unrealClass != null)
                    {
                        return(unrealClass.Address);
                    }
                }
            }
            return(IntPtr.Zero);
        }
Ejemplo n.º 15
0
        public static void Main(string[] args)
        {
            if (!args.Any())
            {
                Console.Error.WriteLine($"Error: No input files. Add file path to dll as argument.");
                Environment.Exit(2);
            }

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            UnrealTypes.Load();
            AssemblyRewriter rewriter = new AssemblyRewriter();

            if (System.Diagnostics.Debugger.IsAttached)
            {
                ManagedUnrealReflectionBase.UpdateSerializerCode();
                //RunTests(rewriter);
            }


            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            foreach (string filePath in args)
            {
                Console.WriteLine($"Processing file: {filePath}");
                var success = ProcessAssembly(rewriter, filePath);
                if (!success)
                {
                    Environment.ExitCode = 3;
                }
                additionalAssemblySearchPath = null;
            }

            stopwatch.Stop();
            Console.WriteLine("AssemblyRewriter finished " + stopwatch.Elapsed);
            Console.ReadLine();
        }