Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Made the escape character for reserved keywords customizable. (C# use…

…s '@' and Java/C++ use '_' by default). Updated the Parameter class to return escaped names by default and added a RawName parameter to access the raw names.

git-svn-id: https://opentk.svn.sourceforge.net/svnroot/opentk/trunk@3093 ebc5dd9b-fb1d-0410-b6f8-d24c324e9604
  • Loading branch information...
commit a1c8bdf31db0b5c09e312e9625e359e6ea8bdb5f 1 parent ec7f8ba
the_fiddler authored
2  Source/Bind/Main.cs
View
@@ -94,6 +94,7 @@ static void Main(string[] arguments)
// Settings.DefaultLanguageTypeMapFile = "cpp.tm"; // Todo: create this file!
Settings.EnumsNamespace = "";
Settings.NamespaceSeparator = "::";
+ Settings.DefaultKeywordEscapeCharacter = "_";
}
else if (arg == "java")
{
@@ -103,6 +104,7 @@ static void Main(string[] arguments)
Settings.DefaultLanguageTypeMapFile = "java.tm";
Settings.EnumsNamespace = "";
Settings.NamespaceSeparator = ".";
+ Settings.DefaultKeywordEscapeCharacter = "_";
}
break;
}
4 Source/Bind/Settings.cs
View
@@ -21,9 +21,10 @@ static class Settings
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 @@ static class Settings
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".
37 Source/Bind/Structures/Parameter.cs
View
@@ -52,25 +52,44 @@ public Parameter(Parameter p)
#endregion
- #region public string Name
+ #region RawName
- string _name = String.Empty;
/// <summary>
- /// Gets or sets the name of the parameter.
+ /// Gets or sets the raw name of the parameter.
+ /// </summary>
+ public string RawName
+ {
+ get;
+ private set;
+ }
+
+ #endregion
+
+ #region Name
+
+ /// <summary>
+ /// Gets the name of the parameter. If the name matches a keyword of the current language,
+ /// then it is escaped with <see cref="Settings.KeywordEscapeCharacter"/>.
/// </summary>
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 @@ public string ToString(bool override_unsafe_setting)
if (!String.IsNullOrEmpty(Name))
{
sb.Append(" ");
- sb.Append(Utilities.Keywords.Contains(Name) ? "@" + Name : Name);
+ sb.Append(Name);
}
rebuild = false;
@@ -329,7 +348,7 @@ override public void Translate(XPathNavigator overrides, string category, EnumCo
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 @@ private void BuildCallStringCache()
}
}
- sb.Append(Utilities.Keywords.Contains(p.Name) ? "@" + p.Name : p.Name);
+ sb.Append(p.Name);
if (p.Unchecked)
sb.Append(")");
Please sign in to comment.
Something went wrong with that request. Please try again.