protected virtual string PrintParameters(UnrealEventInfo info, CXXFileType fileType, out int parameterCount)
        {
            var sb = new StringBuilder();

            var pCount = 0;

            info.Parameters.ForEach(p =>
            {
                var deconstructed = new List <IMemberInfo>();
                if (DeconstructAttribute.TryDeconstruct(p, ref deconstructed))
                {
                    deconstructed.ForEach(o =>
                    {
                        sb.Append(ParameterPrinter.Print(o, fileType) + ", ");
                        pCount++;
                    });
                }
                else
                {
                    sb.Append(ParameterPrinter.Print(p, fileType) + ", ");
                    pCount++;
                }
            });

            sb.RemoveLastComma();

            parameterCount = pCount;

            return(sb.ToString());
        }
        public string Print(IMemberInfo info, CXXFileType fileType)
        {
            var sb = new StringBuilder();

            sb.Append($"{(info.Mutability == Mutability.Immutable ? "const " : string.Empty)}{TypeTransformer.TransformType(info.Type)}{(info.Type.TypeType == TypeType.Reference ? "*" : "&")} {NameTransformer.TransformName(info, info.Name, NameContext.Parameter)}");

            return(sb.ToString());
        }
Exemple #3
0
        public string Print(CXXPropertyInfo info, CXXFileType fileType)
        {
            var sb = new StringBuilder();

            sb.AppendLine($"{(info.IsStatic ? "static " : string.Empty)}{TypeTransformer.TransformType(info)} {NameTransformer.TransformName(info, info.Name, NameContext.Property)};", 1);

            return(sb.ToString());
        }
        public virtual string Print(CXXFileType fileType)
        {
            if (string.IsNullOrEmpty(ModuleName))
            {
                throw new Exception($"For an unreal generated file, the module name must be specified");
            }

            return(string.Empty);
        }
        protected string PrintIncludes(CXXFileType fileType)
        {
            var sb = new StringBuilder();

            Includes.ForEach(i => sb.AppendLine($"#incldue \"{i}\""));
            sb.AppendEmptyLine();

            return(sb.ToString());
        }
Exemple #6
0
        protected HashSet <string> GetIncludes(CXXFileType fileType)
        {
            var includes = new HashSet <string>();

            foreach (var o in TypeTemplates)
            {
                includes.UnionWith(o.Includes[fileType]);
            }

            return(includes);
        }
Exemple #7
0
        protected string PrintBody(CXXFileType fileType)
        {
            var sb = new StringBuilder();

            TypeTemplates.ForEach(o =>
            {
                sb.Append(o.Print(fileType));
                sb.AppendEmptyLine();
            });

            sb.RemoveLastLine();
            sb.RemoveLastLine();

            return(sb.ToString());
        }
        public string Print(CXXFunctionInfo info, CXXFileType fileType)
        {
            var sb = new StringBuilder();

            var returnTypeStr = TypeTransformer.TransformType(info.Type);
            var parameterStr  = PrintParameters(info, fileType);

            info.ForAttribute <AsyncAttribute>(attr =>
            {
                parameterStr += $", std::function<void({(info.Type.Native != typeof(void) ? returnTypeStr : string.Empty)})> Callback";
                returnTypeStr = "void";
            });

            sb.AppendLine($"{(info.IsStatic ? "static " : string.Empty)}{returnTypeStr} {NameTransformer.TransformName(info, info.Name, NameContext.Method)}({parameterStr})", 1);

            return(sb.ToString());
        }
        public string Print(UnrealEventInfo info, CXXFileType fileType)
        {
            var sb = new StringBuilder();

            int parameterCount = 0;

            var eventDeclarationName = info.HasAttribute <UnrealEventAttribute>()
                ? "DECLARE_DYNAMIC_EVENT_"
                : "DECLARE_EVENT_";

            //var returnTypeStr = TypeTransformer.TransformType(info.Type);
            var parameterStr = PrintParameters(info, fileType, out parameterCount);

            info.Parameters.ForEach(p =>
            {
            });

            return(sb.ToString());
        }
Exemple #10
0
        public string Print(UnrealPropertyInfo info, CXXFileType fileType)
        {
            var sb = new StringBuilder();

            info.ForAttribute <UnrealPropertyAttribute>(attr =>
            {
                var bpAccess = info.Permission.HasFlag(Permission.Write)
                    ? UnrealPropertyFlags.BlueprintReadWrite
                    : UnrealPropertyFlags.BlueprintReadOnly;

                var editorAccess = UnrealPropertyFlags.EditAnywhere;

                sb.AppendLine($"UPROPERTY({bpAccess},{editorAccess})");
            });

            //sb.AppendLine(base.Print(info, fileType));
            sb.RemoveLastLine();

            return(sb.ToString());
        }
        private string PrintParameters(CXXFunctionInfo info, CXXFileType fileType)
        {
            var sb = new StringBuilder();

            info.Parameters.ForEach(p =>
            {
                var deconstructed = new List <IMemberInfo>();
                if (DeconstructAttribute.TryDeconstruct(p, ref deconstructed))
                {
                    deconstructed.ForEach(o => { sb.Append(ParameterPrinter.Print(o, fileType) + ", "); });
                }
                else
                {
                    sb.Append(ParameterPrinter.Print(p, fileType) + ", ");
                }
            });

            sb.RemoveLastComma();

            return(sb.ToString());
        }
        public override string Print(CXXFileType fileType)
        {
            base.Print(fileType);

            var sb = new StringBuilder();

            if (fileType == CXXFileType.Declaration)
            {
                var isForBlueprint = true;

                if (isForBlueprint)
                {
                    sb.AppendLine($"UCLASS(BlueprintType)");
                }
                sb.AppendLine($"class {PrintAPI()} {NameTransformer.TransformName(Info, Info.Name, NameContext.Type)}");

                var baseClassName = "UObject";
                sb.AppendLine($": public {baseClassName}", 1);
                sb.OpenBracket();

                if (isForBlueprint)
                {
                    sb.AppendLine($"GENERATED_BODY()", 1);
                    sb.AppendEmptyLine();
                }

                sb.AppendLine($"public:");

                Info.Properties.ForEach(o =>
                {
                    sb.Append(PropertyPrinter.Print((UnrealPropertyInfo)o, CXXFileType.Declaration));
                    sb.AppendEmptyLine();
                });
                sb.RemoveLastLine();

                sb.CloseBracketWithSemicolon();
            }

            return(sb.ToString());
        }
Exemple #13
0
 public virtual string Print(CXXEventInfo info, CXXFileType fileType)
 {
     throw new NotImplementedException();
 }
 public string Print(IMemberInfo info, CXXFileType fileType)
 {
     throw new System.NotImplementedException();
 }
        public override string Print(CXXFileType fileType)
        {
            var sb = new StringBuilder();

            return(sb.ToString());
        }