* GL2/Generator.cs: Improved handling for 'u' and 'ull' suffixes in

OpenGL constants.
This commit is contained in:
the_fiddler 2009-08-03 23:06:05 +00:00
parent 920d737f1f
commit 5a0357ee06

View file

@ -244,6 +244,14 @@ namespace Bind.GL2
c.Name = words[0]; c.Name = words[0];
uint number; uint number;
// Trim the unsigned or long specifiers used in C constants ('u' or 'ull').
if (words[2].ToLower().StartsWith("0x"))
{
if (words[2].ToLower().EndsWith("ull"))
words[2] = words[2].Substring(0, words[2].Length - 3);
if (words[2].ToLower().EndsWith("u"))
words[2] = words[2].Substring(0, words[2].Length - 1);
}
if (UInt32.TryParse(words[2].Replace("0x", String.Empty), System.Globalization.NumberStyles.AllowHexSpecifier, null, out number)) if (UInt32.TryParse(words[2].Replace("0x", String.Empty), System.Globalization.NumberStyles.AllowHexSpecifier, null, out number))
{ {
// The value is a number, check if it should be unchecked. // The value is a number, check if it should be unchecked.
@ -630,18 +638,15 @@ namespace Bind.GL2
sw.WriteLine(); sw.WriteLine();
foreach (Bind.Structures.Delegate d in delegates.Values) foreach (Bind.Structures.Delegate d in delegates.Values)
{ {
if (String.IsNullOrEmpty(d.Extension) || d.Extension == "Core") sw.WriteLine("[System.Security.SuppressUnmanagedCodeSecurity()]");
{ sw.WriteLine(
sw.WriteLine("[System.Security.SuppressUnmanagedCodeSecurity()]"); "[System.Runtime.InteropServices.DllImport({0}.Library, EntryPoint = \"{1}{2}\"{3})]",
sw.WriteLine( Settings.OutputClass,
"[System.Runtime.InteropServices.DllImport({0}.Library, EntryPoint = \"{1}{2}\"{3})]", Settings.FunctionPrefix,
Settings.OutputClass, d.Name,
Settings.FunctionPrefix, d.Name.EndsWith("W") || d.Name.EndsWith("A") ? ", CharSet = CharSet.Auto" : ", ExactSpelling = true"
d.Name, );
d.Name.EndsWith("W") || d.Name.EndsWith("A") ? ", CharSet = CharSet.Auto" : ", ExactSpelling = true" sw.WriteLine("internal extern static {0};", d.DeclarationString());
);
sw.WriteLine("internal extern static {0};", d.DeclarationString());
}
} }
sw.Unindent(); sw.Unindent();
sw.WriteLine("}"); sw.WriteLine("}");