diff --git a/Source/Bind/Main.cs b/Source/Bind/Main.cs index a5685f0f..cde67d4a 100644 --- a/Source/Bind/Main.cs +++ b/Source/Bind/Main.cs @@ -94,6 +94,7 @@ namespace Bind // Settings.DefaultLanguageTypeMapFile = "cpp.tm"; // Todo: create this file! Settings.EnumsNamespace = ""; Settings.NamespaceSeparator = "::"; + Settings.DefaultKeywordEscapeCharacter = "_"; } else if (arg == "java") { @@ -103,6 +104,7 @@ namespace Bind Settings.DefaultLanguageTypeMapFile = "java.tm"; Settings.EnumsNamespace = ""; Settings.NamespaceSeparator = "."; + Settings.DefaultKeywordEscapeCharacter = "_"; } break; } diff --git a/Source/Bind/Settings.cs b/Source/Bind/Settings.cs index 9a37ddb8..1e020cbd 100644 --- a/Source/Bind/Settings.cs +++ b/Source/Bind/Settings.cs @@ -21,9 +21,10 @@ namespace Bind public static string DefaultLicenseFile = "License.txt"; public static string DefaultOverridesFile = "GL2/gloverrides.xml"; public static string DefaultLanguageTypeMapFile = "csharp.tm"; + public static string DefaultKeywordEscapeCharacter = "@"; static string inputPath, outputPath, outputNamespace, docPath, docFile, licenseFile, overridesFile, - languageTypeMapFile; + languageTypeMapFile, keywordEscapeCharacter; public static string InputPath { get { return inputPath ?? DefaultInputPath; } set { inputPath = value; } } public static string OutputPath { get { return outputPath ?? DefaultOutputPath; } set { outputPath = value; } } public static string OutputNamespace { get { return outputNamespace ?? DefaultOutputNamespace; } set { outputNamespace = value; } } @@ -32,6 +33,7 @@ namespace Bind public static string LicenseFile { get { return licenseFile ?? DefaultLicenseFile; } set { licenseFile = value; } } public static string OverridesFile { get { return overridesFile ?? DefaultOverridesFile; } set { overridesFile = value; } } public static string LanguageTypeMapFile { get { return languageTypeMapFile ?? DefaultLanguageTypeMapFile; } set { languageTypeMapFile = value; } } + public static string KeywordEscapeCharacter { get { return keywordEscapeCharacter ?? DefaultKeywordEscapeCharacter; } set { keywordEscapeCharacter = value; } } public static string GLClass = "GL"; // Needed by Glu for the AuxEnumsClass. Can be set through -gl:"xxx". public static string OutputClass = "GL"; // The real output class. Can be set through -class:"xxx". diff --git a/Source/Bind/Structures/Parameter.cs b/Source/Bind/Structures/Parameter.cs index 098ceb3a..aa6b3bc4 100644 --- a/Source/Bind/Structures/Parameter.cs +++ b/Source/Bind/Structures/Parameter.cs @@ -52,25 +52,44 @@ namespace Bind.Structures #endregion - #region public string Name + #region RawName - string _name = String.Empty; /// - /// Gets or sets the name of the parameter. + /// Gets or sets the raw name of the parameter. + /// + public string RawName + { + get; + private set; + } + + #endregion + + #region Name + + /// + /// Gets the name of the parameter. If the name matches a keyword of the current language, + /// then it is escaped with . /// public string Name { - get { return _name; } + get + { + if (Utilities.Keywords.Contains(RawName)) + return Settings.KeywordEscapeCharacter + RawName; + else + return RawName; + } set { - if (_name != value) + if (RawName != value) { while (value.StartsWith("*")) { Pointer++; value = value.Substring(1); } - _name = value; + RawName = value; rebuild = true; } } @@ -270,7 +289,7 @@ namespace Bind.Structures if (!String.IsNullOrEmpty(Name)) { sb.Append(" "); - sb.Append(Utilities.Keywords.Contains(Name) ? "@" + Name : Name); + sb.Append(Name); } rebuild = false; @@ -329,7 +348,7 @@ namespace Bind.Structures WrapperType |= WrapperTypes.ReferenceParameter; if (Utilities.Keywords.Contains(Name)) - Name = "@" + Name; + Name = Settings.KeywordEscapeCharacter + Name; // This causes problems with bool arrays //if (CurrentType.ToLower().Contains("bool")) @@ -626,7 +645,7 @@ namespace Bind.Structures } } - sb.Append(Utilities.Keywords.Contains(p.Name) ? "@" + p.Name : p.Name); + sb.Append(p.Name); if (p.Unchecked) sb.Append(")");