private static void GenerateVariableSummary(KLCodeWriter cw, KLVariableDefinition variable) { cw.WriteLine("/// <summary>"); cw.WriteLine("/// Variable: {0}", variable.name); cw.WriteLine("/// Range: [{0} - {1}]", variable.min, variable.max); cw.WriteLine("/// Type: {0}", variable.isGlobal ? "Global" : "Local"); cw.WriteLine("/// </summary>"); }
public static void GenerateCode() { KLCodeWriter cw = new KLCodeWriter(); KLStartup.Logger.Log("<b>[KLCodeGenerator]</b> Autogenerating code"); AutoGenerateHeader(cw); cw.WriteSpace(); GenerateBaseClass(cw); WriteCodeToFile(cw.ToString()); }
private static void GenerateTagClass(KLCodeWriter cw) { cw.WriteLine("public class Tags"); cw.BeginBracket(); foreach (var tag in KLEditorCore.AvailableTags) { GenerateTagConstant(cw, tag); cw.WriteSpace(); } cw.EndBracket(); }
private static void GenerateChannelClass(KLCodeWriter cw) { cw.WriteLine("public class Channels"); cw.BeginBracket(); foreach (var channel in KLEditorCore.AvailableChannels) { GenerateChannelConstant(cw, channel); cw.WriteSpace(); } cw.EndBracket(); }
private static void GenerateVariableConstant(KLCodeWriter cw, KLVariableDefinition variable) { string variableName = GetTagConstantName(variable.name); GenerateVariableSummary(cw, variable); if (variable.sourceContract == KLVariableDefinition.SourceContract.Placeholder) { cw.WriteLine("[System.Obsolete({0})]", "\"Placeholder\""); } cw.WriteLine(string.Format("public const string {0} = \"{1}\";", variableName, variable.name)); }
private static void GenerateVariablesClass(KLCodeWriter cw) { cw.WriteLine("public class Variables"); cw.BeginBracket(); foreach (var variable in KLEditorCore.AvailableVariables) { GenerateVariableConstant(cw, variable); cw.WriteSpace(); } cw.EndBracket(); }
private static void GenerateTagConstant(KLCodeWriter cw, KLTagDefinition tag) { string tagConstantName = GetTagConstantName(tag.name); GenerateTagSummary(cw, tag); if (tag.sourceContract != KLTagDefinition.SourceContract.Krilloud) { cw.WriteLine("[System.Obsolete(\"{0}\")]", tag.sourceContract); } cw.WriteLine(string.Format("public const string {0} = \"{1}\";", tagConstantName, tag.name)); }
private static void GenerateTagSummary(KLCodeWriter cw, KLTagDefinition tag) { cw.WriteLine("/// <summary>"); cw.WriteLine("/// Tag: {0}", tag.name); if (!string.IsNullOrEmpty(tag.description)) { string description = SecurityElement.Escape(tag.description); cw.WriteLine("/// " + description); } cw.WriteLine("/// {0}", tag.is3D ? "3D" : "2D"); cw.WriteLine("/// </summary>"); }
private static void GenerateBaseClass(KLCodeWriter cw) { cw.WriteLine("namespace KrillAudio.Krilloud"); cw.BeginBracket(); cw.WriteLine("public class " + BASE_CLASS_NAME); cw.BeginBracket(); GenerateTagClass(cw); cw.WriteSpace(); GenerateVariablesClass(cw); cw.WriteSpace(); GenerateChannelClass(cw); cw.EndBracket(); cw.EndBracket(); }
private static void AutoGenerateHeader(KLCodeWriter cw) { cw.WriteLine("// This is an Autogenerated code, don't touch!"); }
private static void GenerateChannelConstant(KLCodeWriter cw, KLChannelDefinition channel) { string variableName = GetTagConstantName(channel.name); cw.WriteLine(string.Format("public const string {0} = \"{1}\";", variableName, channel.name)); }