diff --git a/CSharpTranslator/antlr3/src/CS2JTranslator/CS2JMain/CS2JSettings.cs b/CSharpTranslator/antlr3/src/CS2JTranslator/CS2JMain/CS2JSettings.cs index 3a29fb8..6fe288d 100644 --- a/CSharpTranslator/antlr3/src/CS2JTranslator/CS2JMain/CS2JSettings.cs +++ b/CSharpTranslator/antlr3/src/CS2JTranslator/CS2JMain/CS2JSettings.cs @@ -9,142 +9,756 @@ using System.IO; namespace Twiglet.CS2J.Translator { + public class CS2JOption + { + private bool isDefault = true; + public bool IsDefault + { + get + { + return isDefault; + } + } + private T optValue = default(T); + public T Value + { + get + { + return optValue; + } + set + { + optValue = value; + isDefault = false; + } + } + public void setIfDefault(T newVal) + { + if (IsDefault) + { + Value = newVal; + } + } + + public void setDefault(T newVal) + { + optValue = newVal; + } + } + public class CS2JSettings { - - public bool DisplayTokens { get; set; } - - // dump parse trees to stdout - public bool DumpCSharp { get; set; } - public bool DumpJavaSyntax { get; set; } - public bool DumpJava { get; set; } - - public bool DumpXmls { get; set; } - public bool DumpEnums { get; set; } - public string OutDir { get; set; } - public string CheatDir { get; set; } - public IList NetRoot { get; set; } - public IList ExNetRoot { get; set; } - public IList NetSchemaDir { get; set; } - public IList AppRoot { get; set; } - public IList ExAppRoot { get; set; } - public IList Exclude { get; set; } - public IList MacroDefines { get; set; } - - public IList AltTranslations { get; set; } - - public string XmlDir { get; set; } - public string EnumDir { get; set; } - public int Verbosity { get; set; } - - public string KeyFile { get; set; } - - public bool DebugTemplateExtraction { get; set; } - public int DebugLevel { get; set; } - - public bool Warnings { get; set; } - public bool WarningsFailedResolves { get; set; } - - public bool TranslatorKeepParens - { - get; set; + + // DisplayTokens + private CS2JOption optDisplayTokens = new CS2JOption(); + public CS2JOption OptDisplayTokens { + get + { + return optDisplayTokens; + } + } + public bool DisplayTokens { + get + { + return optDisplayTokens.Value; + } + set + { + optDisplayTokens.Value = value; + } } - public bool TranslatorAddTimeStamp - { - get; set; + // DumpCSharp + private CS2JOption optDumpCSharp = new CS2JOption(); + public CS2JOption OptDumpCSharp { + get + { + return optDumpCSharp; + } + } + public bool DumpCSharp { + get + { + return optDumpCSharp.Value; + } + set + { + optDumpCSharp.Value = value; + } } - public bool TranslatorExceptionIsThrowable - { - get; set; + // DumpJavaSyntax + private CS2JOption optDumpJavaSyntax = new CS2JOption(); + public CS2JOption OptDumpJavaSyntax { + get + { + return optDumpJavaSyntax; + } + } + public bool DumpJavaSyntax { + get + { + return optDumpJavaSyntax.Value; + } + set + { + optDumpJavaSyntax.Value = value; + } } - public bool TranslatorBlanketThrow - { - get; set; + // DumpJava + private CS2JOption optDumpJava = new CS2JOption(); + public CS2JOption OptDumpJava { + get + { + return optDumpJava; + } + } + public bool DumpJava { + get + { + return optDumpJava.Value; + } + set + { + optDumpJava.Value = value; + } } - public bool TranslatorMakeJavadocComments - { - get; set; + // DumpXmls + private CS2JOption optDumpXmls = new CS2JOption(); + public CS2JOption OptDumpXmls { + get + { + return optDumpXmls; + } + } + public bool DumpXmls { + get + { + return optDumpXmls.Value; + } + set + { + optDumpXmls.Value = value; + } } - public bool TranslatorMakeJavaNamingConventions - { - get; set; + // DumpEnums + private CS2JOption optDumpEnums = new CS2JOption(); + public CS2JOption OptDumpEnums { + get + { + return optDumpEnums; + } + } + public bool DumpEnums { + get + { + return optDumpEnums.Value; + } + set + { + optDumpEnums.Value = value; + } } - public bool EnumsAsNumericConsts - { - get; set; + // OutDir + private CS2JOption optOutDir = new CS2JOption(); + public CS2JOption OptOutDir { + get + { + return optOutDir; + } + } + public string OutDir { + get + { + return optOutDir.Value; + } + set + { + optOutDir.Value = value; + } } - public bool UnsignedNumbersToSigned - { - get; set; + // CheatDir + private CS2JOption optCheatDir = new CS2JOption(); + public CS2JOption OptCheatDir { + get + { + return optCheatDir; + } + } + public string CheatDir { + get + { + return optCheatDir.Value; + } + set + { + optCheatDir.Value = value; + } } - public bool UnsignedNumbersToBiggerSignedNumbers - { - get; set; + // NetRoot + private CS2JOption> optNetRoot = new CS2JOption>(); + public CS2JOption> OptNetRoot { + get + { + return optNetRoot; + } + } + public IList NetRoot { + get + { + return optNetRoot.Value; + } + set + { + optNetRoot.Value = value; + } } - public bool ExperimentalTransforms - { - get; set; + // ExNetRoot + private CS2JOption> optExNetRoot = new CS2JOption>(); + public CS2JOption> OptExNetRoot { + get + { + return optExNetRoot; + } + } + public IList ExNetRoot { + get + { + return optExNetRoot.Value; + } + set + { + optExNetRoot.Value = value; + } } - public bool InternalIsJavaish - { - get; set; - } + // NetSchemaDir + private CS2JOption> optNetSchemaDir = new CS2JOption>(); + public CS2JOption> OptNetSchemaDir { + get + { + return optNetSchemaDir; + } + } + public IList NetSchemaDir { + get + { + return optNetSchemaDir.Value; + } + set + { + optNetSchemaDir.Value = value; + } + } + + // AppRoot + private CS2JOption> optAppRoot = new CS2JOption>(); + public CS2JOption> OptAppRoot { + get + { + return optAppRoot; + } + } + public IList AppRoot { + get + { + return optAppRoot.Value; + } + set + { + optAppRoot.Value = value; + } + } + + // ExAppRoot + private CS2JOption> optExAppRoot = new CS2JOption>(); + public CS2JOption> OptExAppRoot { + get + { + return optExAppRoot; + } + } + public IList ExAppRoot { + get + { + return optExAppRoot.Value; + } + set + { + optExAppRoot.Value = value; + } + } + + // Exclude + private CS2JOption> optExclude = new CS2JOption>(); + public CS2JOption> OptExclude { + get + { + return optExclude; + } + } + public IList Exclude { + get + { + return optExclude.Value; + } + set + { + optExclude.Value = value; + } + } + + // MacroDefines + private CS2JOption> optMacroDefines = new CS2JOption>(); + public CS2JOption> OptMacroDefines { + get + { + return optMacroDefines; + } + } + public IList MacroDefines { + get + { + return optMacroDefines.Value; + } + set + { + optMacroDefines.Value = value; + } + } + + // AltTranslations + private CS2JOption> optAltTranslations = new CS2JOption>(); + public CS2JOption> OptAltTranslations { + get + { + return optAltTranslations; + } + } + public IList AltTranslations { + get + { + return optAltTranslations.Value; + } + set + { + optAltTranslations.Value = value; + } + } + + // XmlDir + private CS2JOption optXmlDir = new CS2JOption(); + public CS2JOption OptXmlDir { + get + { + return optXmlDir; + } + } + public string XmlDir { + get + { + return optXmlDir.Value; + } + set + { + optXmlDir.Value = value; + } + } + + // EnumDir + private CS2JOption optEnumDir = new CS2JOption(); + public CS2JOption OptEnumDir { + get + { + return optEnumDir; + } + } + public string EnumDir { + get + { + return optEnumDir.Value; + } + set + { + optEnumDir.Value = value; + } + } + + // Verbosity + private CS2JOption optVerbosity = new CS2JOption(); + public CS2JOption OptVerbosity { + get + { + return optVerbosity; + } + } + public int Verbosity { + get + { + return optVerbosity.Value; + } + set + { + optVerbosity.Value = value; + } + } + + // KeyFile + private CS2JOption optKeyFile = new CS2JOption(); + public CS2JOption OptKeyFile { + get + { + return optKeyFile; + } + } + public string KeyFile { + get + { + return optKeyFile.Value; + } + set + { + optKeyFile.Value = value; + } + } + + // DebugTemplateExtraction + private CS2JOption optDebugTemplateExtraction = new CS2JOption(); + public CS2JOption OptDebugTemplateExtraction { + get + { + return optDebugTemplateExtraction; + } + } + public bool DebugTemplateExtraction { + get + { + return optDebugTemplateExtraction.Value; + } + set + { + optDebugTemplateExtraction.Value = value; + } + } + + // DebugLevel + private CS2JOption optDebugLevel = new CS2JOption(); + public CS2JOption OptDebugLevel { + get + { + return optDebugLevel; + } + } + public int DebugLevel { + get + { + return optDebugLevel.Value; + } + set + { + optDebugLevel.Value = value; + } + } + + // Warnings + private CS2JOption optWarnings = new CS2JOption(); + public CS2JOption OptWarnings { + get + { + return optWarnings; + } + } + public bool Warnings { + get + { + return optWarnings.Value; + } + set + { + optWarnings.Value = value; + } + } + + // WarningsFailedResolves + private CS2JOption optWarningsFailedResolves = new CS2JOption(); + public CS2JOption OptWarningsFailedResolves { + get + { + return optWarningsFailedResolves; + } + } + public bool WarningsFailedResolves { + get + { + return optWarningsFailedResolves.Value; + } + set + { + optWarningsFailedResolves.Value = value; + } + } + + // TranslatorKeepParens + private CS2JOption optTranslatorKeepParens = new CS2JOption(); + public CS2JOption OptTranslatorKeepParens { + get + { + return optTranslatorKeepParens; + } + } + public bool TranslatorKeepParens { + get + { + return optTranslatorKeepParens.Value; + } + set + { + optTranslatorKeepParens.Value = value; + } + } + + // TranslatorAddTimeStamp + private CS2JOption optTranslatorAddTimeStamp = new CS2JOption(); + public CS2JOption OptTranslatorAddTimeStamp { + get + { + return optTranslatorAddTimeStamp; + } + } + public bool TranslatorAddTimeStamp { + get + { + return optTranslatorAddTimeStamp.Value; + } + set + { + optTranslatorAddTimeStamp.Value = value; + } + } + + // TranslatorExceptionIsThrowable + private CS2JOption optTranslatorExceptionIsThrowable = new CS2JOption(); + public CS2JOption OptTranslatorExceptionIsThrowable { + get + { + return optTranslatorExceptionIsThrowable; + } + } + public bool TranslatorExceptionIsThrowable { + get + { + return optTranslatorExceptionIsThrowable.Value; + } + set + { + optTranslatorExceptionIsThrowable.Value = value; + } + } + + // TranslatorBlanketThrow + private CS2JOption optTranslatorBlanketThrow = new CS2JOption(); + public CS2JOption OptTranslatorBlanketThrow { + get + { + return optTranslatorBlanketThrow; + } + } + public bool TranslatorBlanketThrow { + get + { + return optTranslatorBlanketThrow.Value; + } + set + { + optTranslatorBlanketThrow.Value = value; + } + } + + // TranslatorMakeJavadocComments + private CS2JOption optTranslatorMakeJavadocComments = new CS2JOption(); + public CS2JOption OptTranslatorMakeJavadocComments { + get + { + return optTranslatorMakeJavadocComments; + } + } + public bool TranslatorMakeJavadocComments { + get + { + return optTranslatorMakeJavadocComments.Value; + } + set + { + optTranslatorMakeJavadocComments.Value = value; + } + } + + // TranslatorMakeJavaNamingConventions + private CS2JOption optTranslatorMakeJavaNamingConventions = new CS2JOption(); + public CS2JOption OptTranslatorMakeJavaNamingConventions { + get + { + return optTranslatorMakeJavaNamingConventions; + } + } + public bool TranslatorMakeJavaNamingConventions { + get + { + return optTranslatorMakeJavaNamingConventions.Value; + } + set + { + optTranslatorMakeJavaNamingConventions.Value = value; + } + } + + // EnumsAsNumericConsts + private CS2JOption optEnumsAsNumericConsts = new CS2JOption(); + public CS2JOption OptEnumsAsNumericConsts { + get + { + return optEnumsAsNumericConsts; + } + } + public bool EnumsAsNumericConsts { + get + { + return optEnumsAsNumericConsts.Value; + } + set + { + optEnumsAsNumericConsts.Value = value; + } + } + + // UnsignedNumbersToSigned + private CS2JOption optUnsignedNumbersToSigned = new CS2JOption(); + public CS2JOption OptUnsignedNumbersToSigned { + get + { + return optUnsignedNumbersToSigned; + } + } + public bool UnsignedNumbersToSigned { + get + { + return optUnsignedNumbersToSigned.Value; + } + set + { + optUnsignedNumbersToSigned.Value = value; + } + } + + // UnsignedNumbersToBiggerSignedNumbers + private CS2JOption optUnsignedNumbersToBiggerSignedNumbers = new CS2JOption(); + public CS2JOption OptUnsignedNumbersToBiggerSignedNumbers { + get + { + return optUnsignedNumbersToBiggerSignedNumbers; + } + } + public bool UnsignedNumbersToBiggerSignedNumbers { + get + { + return optUnsignedNumbersToBiggerSignedNumbers.Value; + } + set + { + optUnsignedNumbersToBiggerSignedNumbers.Value = value; + } + } + + // ExperimentalTransforms + private CS2JOption optExperimentalTransforms = new CS2JOption(); + public CS2JOption OptExperimentalTransforms { + get + { + return optExperimentalTransforms; + } + } + public bool ExperimentalTransforms { + get + { + return optExperimentalTransforms.Value; + } + set + { + optExperimentalTransforms.Value = value; + } + } + + // InternalIsJavaish + private CS2JOption optInternalIsJavaish = new CS2JOption(); + public CS2JOption OptInternalIsJavaish { + get + { + return optInternalIsJavaish; + } + } + public bool InternalIsJavaish { + get + { + return optInternalIsJavaish.Value; + } + set + { + optInternalIsJavaish.Value = value; + } + } public CS2JSettings () { - DisplayTokens = false; + OptDisplayTokens.setDefault(false); // dump parse trees to stdout - DumpCSharp = false; - DumpJavaSyntax = false; - DumpJava = false; + OptDumpCSharp.setDefault(false); + OptDumpJavaSyntax.setDefault(false); + OptDumpJava.setDefault(false); - DumpXmls = false; - DumpEnums = false; - OutDir = Directory.GetCurrentDirectory(); - CheatDir = ""; - NetRoot = new List(); - ExNetRoot = new List(); - NetSchemaDir = new List(); - AppRoot = new List(); - ExAppRoot = new List(); - Exclude = new List(); - MacroDefines = new List(); - AltTranslations = new List(); - XmlDir = Path.Combine(Directory.GetCurrentDirectory(), "tmpXMLs"); - EnumDir = Path.Combine(Directory.GetCurrentDirectory(), "enums"); - KeyFile = null; - Verbosity = 0; - DebugTemplateExtraction = true; - DebugLevel = 1; - Warnings = true; - WarningsFailedResolves = false; + OptDumpXmls.setDefault(false); + OptDumpEnums.setDefault(false); + OptOutDir.setDefault(Directory.GetCurrentDirectory()); + OptCheatDir.setDefault(""); + OptNetRoot.setDefault(new List()); + OptExNetRoot.setDefault(new List()); + OptNetSchemaDir.setDefault(new List()); + OptAppRoot.setDefault(new List()); + OptExAppRoot.setDefault(new List()); + OptExclude.setDefault(new List()); + OptMacroDefines.setDefault(new List()); + OptAltTranslations.setDefault(new List()); + OptXmlDir.setDefault(Path.Combine(Directory.GetCurrentDirectory(), "tmpXMLs")); + OptEnumDir.setDefault(Path.Combine(Directory.GetCurrentDirectory(), "enums")); + OptKeyFile.setDefault(null); + OptVerbosity.setDefault(0); + OptDebugTemplateExtraction.setDefault(true); + OptDebugLevel.setDefault(1); + OptWarnings.setDefault(true); + OptWarningsFailedResolves.setDefault(false); - TranslatorKeepParens = true; - TranslatorAddTimeStamp = true; - TranslatorExceptionIsThrowable = false; - TranslatorBlanketThrow = true; - TranslatorMakeJavadocComments = true; - TranslatorMakeJavaNamingConventions = true; + OptTranslatorKeepParens.setDefault(true); + OptTranslatorAddTimeStamp.setDefault(true); + OptTranslatorExceptionIsThrowable.setDefault(false); + OptTranslatorBlanketThrow.setDefault(true); + OptTranslatorMakeJavadocComments.setDefault(true); + OptTranslatorMakeJavaNamingConventions.setDefault(true); - EnumsAsNumericConsts = false; - UnsignedNumbersToSigned = false; - UnsignedNumbersToBiggerSignedNumbers = false; + OptEnumsAsNumericConsts.setDefault(false); + OptUnsignedNumbersToSigned.setDefault(false); + OptUnsignedNumbersToBiggerSignedNumbers.setDefault(false); - ExperimentalTransforms = false; + OptExperimentalTransforms.setDefault(false); - InternalIsJavaish = false; + OptInternalIsJavaish.setDefault(false); } } }