Made the escape character for reserved keywords customizable. (C# uses '@' 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.
This commit is contained in:
parent
6443b271dd
commit
154ce76303
3 changed files with 33 additions and 10 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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".
|
||||
|
|
|
@ -52,25 +52,44 @@ namespace Bind.Structures
|
|||
|
||||
#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 @@ 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(")");
|
||||
|
|
Loading…
Reference in a new issue