static ExitCode ProcessSolution(string solutionPath) { Stopwatch stopwatch = Stopwatch.StartNew(); CGFParserReporter reporter = new CGFParserReporter(); CGFParser solutionParser = CGFParser.ParseSolution(reporter, solutionPath); if (solutionParser == null) { return(ExitCode.GenerationError); } reporter.LogInfo("Generating code"); foreach (CGFDocument cgfDocument in solutionParser.Documents) { string sourcePath = cgfDocument.DocumentFilePath; const string sourceString = "source"; const string generatedString = "generated"; string generatedPath = ReplaceFolderInPath(sourcePath, sourceString, generatedString); bool hasResolvedGeneratedPath = !generatedPath.Equals(sourcePath); if (!hasResolvedGeneratedPath) { generatedPath = Path.Combine(generatedPath, "CGFGenerated"); reporter.LogWarning($"Failed to find {sourceString} in {sourcePath} to replace with {generatedString}. Writing generated files to Appending {generatedPath}."); } string headerPath = generatedPath.Replace(".cs", ".h"); string inlinePath = generatedPath.Replace(".cs", ".inl"); string relativeInlinePath; if (hasResolvedGeneratedPath) { relativeInlinePath = inlinePath.Substring(inlinePath.LastIndexOf(generatedString) + generatedString.Length + 1); //1 is for path separator } else { relativeInlinePath = Path.GetFileName(inlinePath); } string userPath = sourcePath.Replace(".cs", ".user.inl"); string relativeUserPath = GetRelativePath(userPath, sourceString); //Get System Includes HashSet <string> systemIncludes = new HashSet <string>(); systemIncludes.Add("iostream"); //Always need iostream for istream/ostream //Get User includes HashSet <string> userIncludes = new HashSet <string>(); foreach (CGFTypeSymbol type in cgfDocument.Types) { foreach (CGFFieldSymbol field in type.Fields) { CGFAttributeDataList fieldAttributes = field.Attributes; ArrayAttribute arrayAttribute = fieldAttributes.GetAttribute <ArrayAttribute>(); if (arrayAttribute != null) { foreach (ArrayDimension dimension in arrayAttribute.Dimensions) { systemIncludes.Add(dimension.LibraryName); } } if (field.IsSystemType && field.UnderlyingSpecialType == SpecialType.System_String) { systemIncludes.Add("string"); } string typePath = null; if (solutionParser.TypeNameToPathMap.TryGetValue(field.TypeName, out typePath)) { if (typePath != cgfDocument.DocumentFilePath) { string relativeTypePath = GetRelativePath(typePath, sourceString); userIncludes.Add(relativeTypePath.Replace(".cs", ".h").Replace("\\", "/")); } } } } CGFHeaderCodeGenerator headerCodeGenerator = new CGFHeaderCodeGenerator(cgfDocument, relativeInlinePath, relativeUserPath, systemIncludes, userIncludes); CGFInlineCodeGenerator inlineCodeGenerator = new CGFInlineCodeGenerator(cgfDocument); CGFUserCodeGenerator userCodeGenerator = new CGFUserCodeGenerator(cgfDocument); string headerCode = headerCodeGenerator.TransformText(); string inlineCode = inlineCodeGenerator.TransformText(); string userCode = userCodeGenerator.TransformText(); WriteFile(headerPath, headerCode); WriteFile(inlinePath, inlineCode); WriteUserFile(userPath, userCode, reporter); } long elapsedMS = stopwatch.ElapsedMilliseconds; reporter.LogInfo(String.Format("Code generation done in {0:0.0} sec", elapsedMS / 1000.0f)); if (reporter.HasError()) { reporter.LogError("Code generation failed with errors"); return(ExitCode.GenerationError); } else { reporter.LogInfo("Code generated"); return(ExitCode.Success); } }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { this.Write(@"#pragma once ///////////////////////////////////////////////////////////////////////////////////// // This file is auto generated. // *Any modifications to this file will be lost.* ///////////////////////////////////////////////////////////////////////////////////// "); #line 14 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" WriteSystemIncludes(SystemIncludes); WriteUserIncludes(UserIncludes); #line default #line hidden this.Write("\r\n///////////////////////////////////////////////////////////////////////////////" + "//////\r\n\r\n"); #line 21 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" CGFDocument cgfDocument = CGFDocument; foreach (CGFTypeSymbol cgfTypeSymbol in cgfDocument.Types) { if (cgfTypeSymbol.IsEnum) { #line default #line hidden this.Write("enum class "); #line 29 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cgfTypeSymbol.Name)); #line default #line hidden this.Write("\r\n{\r\n"); #line 31 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" foreach (CGFFieldSymbol cgfFieldSymbol in cgfTypeSymbol.Fields) { #line default #line hidden this.Write(" "); #line 35 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cgfFieldSymbol.Name)); #line default #line hidden this.Write(" = "); #line 35 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cgfFieldSymbol.ConstantValue)); #line default #line hidden this.Write(",\r\n"); #line 36 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" } #line default #line hidden this.Write("};\r\n\r\nstd::istream& operator>>(std::istream& inputStream, "); #line 41 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cgfTypeSymbol.Name)); #line default #line hidden this.Write("& "); #line 41 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cgfTypeSymbol.VariableName)); #line default #line hidden this.Write(");\r\nstd::ostream& operator<<(std::ostream& outputStream, const "); #line 42 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cgfTypeSymbol.Name)); #line default #line hidden this.Write("& "); #line 42 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cgfTypeSymbol.VariableName)); #line default #line hidden this.Write(");\r\n"); #line 43 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" } else { #line default #line hidden this.Write("class "); #line 48 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cgfTypeSymbol.GeneratedName)); #line default #line hidden this.Write("\r\n{\r\n"); #line 50 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" ExtendAttribute typeExtendAttribute = cgfTypeSymbol.Attributes.GetAttribute <ExtendAttribute>(); if (typeExtendAttribute == null || !typeExtendAttribute.HasCustomSerialization) { #line default #line hidden this.Write("public:\r\n friend std::istream& operator>>(std::istream& inputStream, "); #line 56 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cgfTypeSymbol.GeneratedName)); #line default #line hidden this.Write("& "); #line 56 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cgfTypeSymbol.VariableName)); #line default #line hidden this.Write(");\r\n friend std::ostream& operator<<(std::ostream& outputStream, const "); #line 57 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cgfTypeSymbol.GeneratedName)); #line default #line hidden this.Write("& "); #line 57 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cgfTypeSymbol.VariableName)); #line default #line hidden this.Write(");\r\n\r\n"); #line 59 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" } for (int accessibility = 0; accessibility < 3; ++accessibility) { string accessibilityString; List <CGFFieldSymbol> fields; switch (accessibility) { case 0: fields = cgfTypeSymbol.PublicFields; accessibilityString = "public"; break; case 1: fields = cgfTypeSymbol.ProtectedFields; accessibilityString = "protected"; break; case 2: fields = cgfTypeSymbol.PrivateFields; accessibilityString = "private"; break; default: fields = null; accessibilityString = "error"; break; } if (fields.Count > 0) { #line default #line hidden #line 89 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(accessibilityString)); #line default #line hidden this.Write(":\r\n"); #line 90 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" foreach (CGFFieldSymbol cgfFieldSymbol in fields) { CGFAttributeDataList fieldAttributes = cgfFieldSymbol.Attributes; string cppType = CGFParserUtils.GetCPPStringForType(cgfFieldSymbol.TypeName); ArrayAttribute arrayAttribute = fieldAttributes.GetAttribute <ArrayAttribute>(); if (arrayAttribute != null) { //Start by indenting the line #line default #line hidden this.Write(" "); #line 101 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" //Write the array type List <ArrayDimension> arrayDimensions = arrayAttribute.Dimensions; for (int i = (arrayDimensions.Count - 1); i >= 0; --i) { ArrayDimension dimension = arrayDimensions[i]; if (dimension.IsFixedSize) { #line default #line hidden this.Write("std::array<"); #line 110 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" } else { #line default #line hidden this.Write("std::vector<"); #line 114 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" } } #line default #line hidden #line 118 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cppType)); #line default #line hidden #line 118 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" for (int i = 0; i < arrayDimensions.Count; ++i) { ArrayDimension dimension = arrayDimensions[i]; if (dimension.IsFixedSize) { #line default #line hidden this.Write(", "); #line 124 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(dimension.SizeString)); #line default #line hidden this.Write(">"); #line 124 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" } else { #line default #line hidden this.Write(">"); #line 128 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" } } #line default #line hidden this.Write(" "); #line 131 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cgfFieldSymbol.Name)); #line default #line hidden this.Write(";\r\n"); #line 132 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" } else { #line default #line hidden this.Write(" "); #line 137 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cppType)); #line default #line hidden this.Write(" "); #line 137 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cgfFieldSymbol.Name)); #line default #line hidden this.Write(";\r\n"); #line 138 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" } } } } #line default #line hidden this.Write("};\r\n"); #line 145 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" } #line default #line hidden this.Write("\r\n///////////////////////////////////////////////////////////////////////////////" + "//////\r\n\r\n"); #line 151 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" } #line default #line hidden this.Write("#include <"); #line 154 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(RelativeInlinePath)); #line default #line hidden this.Write(">\r\n#include <"); #line 155 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFHeaderCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(RelativeUserPath)); #line default #line hidden this.Write(">\r\n"); return(this.GenerationEnvironment.ToString()); }
/// <summary> /// Create the template output /// </summary> public virtual string TransformText() { this.Write(@"///////////////////////////////////////////////////////////////////////////////////// // This file is auto generated. // *Any modifications to this file will be lost.* ///////////////////////////////////////////////////////////////////////////////////// "); #line 13 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" CGFDocument cgfDocument = CGFDocument; foreach(CGFTypeSymbol cgfTypeSymbol in cgfDocument.Types) { CGFAttributeDataList typeAttributes = cgfTypeSymbol.Attributes; ExtendAttribute typeExtendAttribute = typeAttributes.GetAttribute<ExtendAttribute>(); if (typeExtendAttribute != null && typeExtendAttribute.HasCustomSerialization) continue; if (cgfTypeSymbol.IsEnum) continue; bool isFrameData = typeAttributes.GetAttribute<FrameDataAttribute>() != null; bool isGlobalData = typeAttributes.GetAttribute<GlobalDataAttribute>() != null; bool isGlobalOrFrameData = isFrameData || isGlobalData; #line default #line hidden this.Write("std::istream& operator>>(std::istream& inputStream, "); #line 30 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cgfTypeSymbol.GeneratedName)); #line default #line hidden this.Write("& "); #line 30 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cgfTypeSymbol.VariableName)); #line default #line hidden this.Write(")\r\n{\r\n"); #line 32 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" foreach(CGFFieldSymbol cgfFieldSymbol in cgfTypeSymbol.Fields) { CGFAttributeDataList fieldAttributes = cgfFieldSymbol.Attributes; string cppType = CGFParserUtils.GetCPPStringForType(cgfFieldSymbol.TypeName); string variableName = cgfTypeSymbol.VariableName + "." + cgfFieldSymbol.Name; bool isFirstField = cgfTypeSymbol.Fields[0] == cgfFieldSymbol; bool isLastField = cgfTypeSymbol.Fields[cgfTypeSymbol.Fields.Count - 1] == cgfFieldSymbol; bool isStandaloneFieldType = IsStandaloneFieldType(cgfFieldSymbol); bool appendWithIgnore = !isStandaloneFieldType && (isLastField && isGlobalOrFrameData || !isLastField); ArrayAttribute arrayAttribute = fieldAttributes.GetAttribute<ArrayAttribute>(); if (arrayAttribute != null) { string indentationIncrement = " "; string indentation = indentationIncrement; string arrayVariableName = variableName; List<ArrayDimension> arrayDimensions = arrayAttribute.Dimensions; int arrayIndexCount = arrayDimensions.Count - 1; for (int i = arrayIndexCount; i >= 0; --i) { ArrayDimension dimension = arrayDimensions[i]; string variableNameSuffix = new string('i', (arrayDimensions.Count - i)); string loopVariableName = new string('i', (arrayDimensions.Count - i)); string arraySize; if (dimension.IsFixedSize) { arraySize = dimension.SizeString; } else { arraySize = cgfTypeSymbol.VariableName + "." + dimension.SizeString; } if (dimension.IsVariableSize) { #line default #line hidden #line 74 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden #line 74 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(arrayVariableName)); #line default #line hidden this.Write(".resize((unsigned int)"); #line 74 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(arraySize)); #line default #line hidden this.Write(");\r\n"); #line 75 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } #line default #line hidden #line 78 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write("for(int "); #line 78 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(loopVariableName)); #line default #line hidden this.Write(" = 0; "); #line 78 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(loopVariableName)); #line default #line hidden this.Write(" < "); #line 78 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(arraySize)); #line default #line hidden this.Write("; ++"); #line 78 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(loopVariableName)); #line default #line hidden this.Write(")\r\n"); #line 79 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write("{\r\n"); #line 80 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" indentation += indentationIncrement; if (i != 0) { ArrayDimension nextDimension = arrayDimensions[i - 1]; string nextArrayVariableName = cgfTypeSymbol.VariableName + "_" + variableNameSuffix; #line default #line hidden #line 88 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write("auto& "); #line 88 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(nextArrayVariableName)); #line default #line hidden this.Write(" = "); #line 88 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(arrayVariableName)); #line default #line hidden this.Write("["); #line 88 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(loopVariableName)); #line default #line hidden this.Write("];\r\n"); #line 89 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" arrayVariableName = nextArrayVariableName; } else { #line default #line hidden #line 95 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write("inputStream >> "); #line 95 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(arrayVariableName)); #line default #line hidden this.Write("["); #line 95 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(loopVariableName)); #line default #line hidden this.Write("];"); #line 95 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" if (appendWithIgnore) { #line default #line hidden this.Write(" inputStream.ignore();"); #line 95 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } #line default #line hidden this.Write(" \r\n"); #line 96 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } } for (int i = 0; i < arrayDimensions.Count; ++i) { indentation = indentation.Remove(indentation.Length - indentationIncrement.Length); #line default #line hidden #line 104 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write("}\r\n"); #line 105 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } } else //Not an array { #line default #line hidden this.Write(" inputStream >> "); #line 111 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(variableName)); #line default #line hidden this.Write(";"); #line 111 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" if (appendWithIgnore) { #line default #line hidden this.Write(" inputStream.ignore();"); #line 111 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } #line default #line hidden this.Write(" \r\n"); #line 112 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } } #line default #line hidden this.Write("\r\n return inputStream;\r\n}\r\n\r\nstd::ostream& operator<<(std::ostream& outputStre" + "am, const "); #line 120 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cgfTypeSymbol.GeneratedName)); #line default #line hidden this.Write("& "); #line 120 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(cgfTypeSymbol.VariableName)); #line default #line hidden this.Write(")\r\n{\r\n"); #line 122 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" if (isFrameData) { #line default #line hidden this.Write(" Logging::LogInputData(outputStream) << \"Frame Input:\" << Game::GetFrameCounte" + "r() << std::endl;\r\n\r\n"); #line 128 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } else if (isGlobalData) { #line default #line hidden this.Write(" Logging::LogInputData(outputStream) << \"Global Input:\" << std::endl;\r\n\r\n"); #line 135 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } CGFFieldSymbol previousSerializableFieldSymbol = null; foreach(CGFFieldSymbol cgfFieldSymbol in cgfTypeSymbol.Fields) { CGFAttributeDataList fieldAttributes = cgfFieldSymbol.Attributes; string cppType = CGFParserUtils.GetCPPStringForType(cgfFieldSymbol.TypeName); string variableName = cgfTypeSymbol.VariableName + "." + cgfFieldSymbol.Name; bool isFirstField = cgfTypeSymbol.Fields[0] == cgfFieldSymbol; bool isStandaloneFieldType = IsStandaloneFieldType(cgfFieldSymbol); bool prependWithLogging = !isStandaloneFieldType && ((isFirstField && isGlobalOrFrameData) || (!isFirstField && (previousSerializableFieldSymbol.Attributes.GetAttribute<GroupWithNextAttribute>() == null))); ArrayAttribute arrayAttribute = fieldAttributes.GetAttribute<ArrayAttribute>(); if (arrayAttribute != null) { string indentationIncrement = " "; string indentation = indentationIncrement; string arrayVariableName = variableName; List<ArrayDimension> arrayDimensions = arrayAttribute.Dimensions; int arrayIndexCount = arrayDimensions.Count - 1; for (int i = arrayIndexCount; i >= 0; --i) { ArrayDimension dimension = arrayDimensions[i]; string variableNameSuffix = new string('i', (arrayDimensions.Count - i)); string loopVariableName = new string('i', (arrayDimensions.Count - i)); string arraySize; if (dimension.IsFixedSize) { arraySize = dimension.SizeString; } else { arraySize = cgfTypeSymbol.VariableName + "." + dimension.SizeString; } #line default #line hidden #line 177 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write("for(int "); #line 177 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(loopVariableName)); #line default #line hidden this.Write(" = 0; "); #line 177 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(loopVariableName)); #line default #line hidden this.Write(" < "); #line 177 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(arraySize)); #line default #line hidden this.Write("; ++"); #line 177 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(loopVariableName)); #line default #line hidden this.Write(")\r\n"); #line 178 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write("{\r\n"); #line 179 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" indentation += indentationIncrement; if (i != 0) { ArrayDimension nextDimension = arrayDimensions[i - 1]; string nextArrayVariableName = cgfTypeSymbol.VariableName + "_" + variableNameSuffix; #line default #line hidden #line 187 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write("auto& "); #line 187 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(nextArrayVariableName)); #line default #line hidden this.Write(" = "); #line 187 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(arrayVariableName)); #line default #line hidden this.Write("["); #line 187 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(loopVariableName)); #line default #line hidden this.Write("];\r\n"); #line 188 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" arrayVariableName = nextArrayVariableName; } else { #line default #line hidden #line 194 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden #line 194 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" if (prependWithLogging) { #line default #line hidden this.Write("Logging::LogInputData(outputStream)"); #line 194 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } else { #line default #line hidden this.Write("outputStream"); #line 194 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } #line default #line hidden this.Write(" << "); #line 194 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(arrayVariableName)); #line default #line hidden this.Write("["); #line 194 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(loopVariableName)); #line default #line hidden this.Write("];\r\n"); #line 195 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" if (!isStandaloneFieldType) { if (fieldAttributes.GetAttribute<GroupWithNextAttribute>() != null) { #line default #line hidden #line 201 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write("bool isLastIndex = i == ("); #line 201 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(arraySize)); #line default #line hidden this.Write(" - 1);\r\n"); #line 202 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write("if (!isLastIndex)\r\n"); #line 203 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write("{\r\n"); #line 204 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write(" outputStream << \" \";\r\n"); #line 205 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write("}\r\n"); #line 206 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write("else\r\n"); #line 207 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write("{\r\n"); #line 208 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write(" outputStream << std::endl;\r\n"); #line 209 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write("}\r\n"); #line 210 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } else //!IsGroupWithNext { #line default #line hidden #line 215 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write("outputStream << std::endl;\r\n"); #line 216 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } //IsGroupWithNext } //IsSystemType } } for (int i = 0; i < arrayDimensions.Count; ++i) { indentation = indentation.Remove(indentation.Length - indentationIncrement.Length); #line default #line hidden #line 226 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(indentation)); #line default #line hidden this.Write("}\r\n"); #line 227 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } } else //Not an array { bool isLastField = cgfTypeSymbol.Fields[cgfTypeSymbol.Fields.Count - 1] == cgfFieldSymbol; bool appendWithEndl = !isStandaloneFieldType && (isLastField && isGlobalOrFrameData || ((!isLastField || isGlobalOrFrameData) && (fieldAttributes.GetAttribute<GroupWithNextAttribute>() == null))); bool appendWithSpace = !isStandaloneFieldType && (isLastField && isGlobalOrFrameData || !isLastField); #line default #line hidden this.Write(" "); #line 236 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" if (prependWithLogging) { #line default #line hidden this.Write("Logging::LogInputData(outputStream)"); #line 236 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } else { #line default #line hidden this.Write("outputStream"); #line 236 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } #line default #line hidden this.Write(" << "); #line 236 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(variableName)); #line default #line hidden #line 236 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" if (appendWithEndl) { #line default #line hidden this.Write(" << std::endl"); #line 236 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } else if (appendWithSpace) { #line default #line hidden this.Write(" << \" \""); #line 236 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } #line default #line hidden this.Write(";\r\n"); #line 237 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } previousSerializableFieldSymbol = cgfFieldSymbol; } #line default #line hidden this.Write("\r\n return outputStream;\r\n}\r\n\r\n////////////////////////////////////////////////" + "/////////////////////////////////////\r\n"); #line 248 "D:\Files\Projects\CodinGameCppFramework-Private\tools\CGFCodeGenerator\CGFCodeGenerator\CGFInlineCodeGenerator.tt" } #line default #line hidden return this.GenerationEnvironment.ToString(); }