private StructInfo GetStructInfo(UStruct unrealStruct, bool isBlueprintType)
        {
            StructInfo structInfo;

            if (structInfos.TryGetValue(unrealStruct, out structInfo))
            {
                return(structInfo);
            }

            structInfo = new StructInfo(this, unrealStruct, isBlueprintType);
            foreach (UFunction function in unrealStruct.GetFields <UFunction>(false, true, true))
            {
                // We need to include interface functions as otherwise some interface functions wont be implemented.
                // If the interface function already has an implementation skip that function (as otherwise there will be duplicates).
                if (!structInfo.IsClass || !function.GetOwnerClass().IsChildOf <UInterface>() ||
                    structInfo.Class.FindFunctionByName(function.GetFName(), true).GetOwnerClass().IsChildOf <UInterface>())
                {
                    structInfo.AddFunction(function, CanExportFunction(function, isBlueprintType));
                }
            }

            if (isBlueprintType)
            {
                UUserDefinedStruct userDefinedStruct = unrealStruct as UUserDefinedStruct;
                if (userDefinedStruct != null)
                {
                    Dictionary <UProperty, string> variableNames = GetStructBPVariableNames(userDefinedStruct);

                    foreach (UProperty property in unrealStruct.GetFields <UProperty>(false))
                    {
                        structInfo.AddProperty(property, variableNames[property], CanExportProperty(property, unrealStruct, isBlueprintType));
                    }
                }
                else
                {
                    foreach (UProperty property in unrealStruct.GetProperties <UProperty>(false))
                    {
                        structInfo.AddProperty(property, null, CanExportProperty(property, unrealStruct, isBlueprintType));
                    }
                }
            }
            else
            {
                foreach (UProperty property in unrealStruct.GetFields <UProperty>(false))
                {
                    structInfo.AddProperty(property, null, CanExportProperty(property, unrealStruct, isBlueprintType));
                }
            }

            structInfo.ResolveCollapsedMembers();
            structInfo.PostProcess();

            structInfos.Add(unrealStruct, structInfo);
            return(structInfo);
        }
示例#2
0
        private StructInfo GetStructInfo(UStruct unrealStruct, bool isBlueprintType)
        {
            StructInfo structInfo;

            if (structInfos.TryGetValue(unrealStruct, out structInfo))
            {
                return(structInfo);
            }

            structInfo = new StructInfo(this, unrealStruct, isBlueprintType);
            foreach (UFunction function in unrealStruct.GetFields <UFunction>(false, true, true))
            {
                structInfo.AddFunction(function, CanExportFunction(function, isBlueprintType));
            }

            if (isBlueprintType)
            {
                UUserDefinedStruct userDefinedStruct = unrealStruct as UUserDefinedStruct;
                if (userDefinedStruct != null)
                {
                    Dictionary <UProperty, string> variableNames = GetStructBPVariableNames(userDefinedStruct);

                    foreach (UProperty property in unrealStruct.GetFields <UProperty>(false))
                    {
                        structInfo.AddProperty(property, variableNames[property], CanExportProperty(property, unrealStruct, isBlueprintType));
                    }
                }
                else
                {
                    foreach (UProperty property in unrealStruct.GetProperties <UProperty>(false))
                    {
                        structInfo.AddProperty(property, null, CanExportProperty(property, unrealStruct, isBlueprintType));
                    }
                }
            }
            else
            {
                foreach (UProperty property in unrealStruct.GetFields <UProperty>(false))
                {
                    structInfo.AddProperty(property, null, CanExportProperty(property, unrealStruct, isBlueprintType));
                }
            }

            structInfo.ResolveCollapsedMembers();
            structInfo.PostProcess();

            structInfos.Add(unrealStruct, structInfo);
            return(structInfo);
        }
示例#3
0
        private void UpdateAvailableTypes(UField field)
        {
            if (field == null)
            {
                return;
            }

            System.Diagnostics.Debug.Assert(!field.IsA <UProperty>(), "Shouldn't have UProperty here");

            if (field.IsA <UStruct>() || field.IsA <UEnum>())
            {
                bool isNewElement = availableTypes.Add(field);
                if (!isNewElement)
                {
                    return;
                }
            }

            if (Settings.ExportMode != CodeGeneratorSettings.CodeExportMode.Referenced)
            {
                return;
            }

            // Get all of the references from this struct
            UStruct unrealStruct = field as UStruct;

            if (unrealStruct != null)
            {
                bool isBlueprintType = unrealStruct.IsA <UUserDefinedStruct>() || unrealStruct.IsA <UBlueprintGeneratedClass>();

                // Get struct references from parent class chain
                UStruct parentStruct = unrealStruct.GetSuperStruct();
                while (parentStruct != null)
                {
                    UpdateAvailableTypes(parentStruct);
                    parentStruct = parentStruct.GetSuperStruct();
                }

                // Get references from interfaces
                UClass unrealClass = field as UClass;
                if (unrealClass != null)
                {
                    foreach (FImplementedInterface implementedInterface in unrealClass.Interfaces)
                    {
                        UpdateAvailableTypes(implementedInterface.InterfaceClass);
                    }
                }

                // Get struct references from members
                foreach (UProperty property in unrealStruct.GetFields <UProperty>(false))
                {
                    if (CanExportProperty(property, unrealStruct, isBlueprintType))
                    {
                        UpdateAvailableTypesProp(property);
                    }
                }

                // Get struct references from function params (and return type)
                foreach (UFunction unrealFunction in unrealStruct.GetFields <UFunction>(false))
                {
                    if (CanExportFunction(unrealFunction, isBlueprintType))
                    {
                        foreach (UProperty parameter in unrealFunction.GetFields <UProperty>())
                        {
                            UpdateAvailableTypesProp(parameter);
                        }
                    }
                }
            }

            // This should be for global functions only (delegates)
            UFunction function = field as UFunction;

            if (function != null)
            {
                if (CanExportFunction(function, false))
                {
                    UStruct functionOwner = function.GetOuter() as UStruct;
                    if (functionOwner != null)
                    {
                        UpdateAvailableTypes(functionOwner);
                    }

                    foreach (UProperty parameter in function.GetFields <UProperty>())
                    {
                        UpdateAvailableTypesProp(parameter);
                    }
                }
            }
        }