示例#1
0
 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>");
 }
示例#2
0
        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());
        }
示例#3
0
        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();
        }
示例#4
0
        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();
        }
示例#5
0
        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));
        }
示例#6
0
        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();
        }
示例#7
0
        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));
        }
示例#8
0
        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>");
        }
示例#9
0
        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();
        }
示例#10
0
 private static void AutoGenerateHeader(KLCodeWriter cw)
 {
     cw.WriteLine("// This is an Autogenerated code, don't touch!");
 }
示例#11
0
        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));
        }