public virtual void Process() { // Matches functions that cannot have their trailing 'v' trimmed for CLS-Compliance reasons. // Built through trial and error :) //Function.endingsAddV = // new Regex(@"(Coord1|Attrib(I?)1(u?)|Stream1|Uniform2(u?)|(Point|Convolution|Transform|Sprite|List|Combiner|Tex)Parameter|Fog(Coord)?.*|VertexWeight|(Fragment)?Light(Model)?|Material|ReplacementCodeu?b?|Tex(Gen|Env)|Indexu?|TextureParameter.v)", // RegexOptions.Compiled); Type.Initialize(glTypemap, csTypemap); Enum.Initialize(enumSpec, enumSpecExt); Enum.GLEnums.Translate(new XPathDocument(Path.Combine(Settings.InputPath, functionOverridesFile))); Function.Initialize(); Delegate.Initialize(glSpec, glSpecExt); WriteBindings( Delegate.Delegates, Function.Wrappers, Enum.GLEnums); }
void TranslateType(Bind.Structures.Type type, XPathNavigator function_override, XPathNavigator overrides, EnumProcessor enum_processor, EnumCollection enums, string category, string apiname) { Bind.Structures.Enum @enum; string s; category = enum_processor.TranslateEnumName(category); // Try to find out if it is an enum. If the type exists in the normal GLEnums list, use this. // Special case for Boolean - it is an enum, but it is dumb to use that instead of the 'bool' type. bool normal = enums.TryGetValue(type.CurrentType, out @enum); // Translate enum types type.IsEnum = false; if (normal && @enum.Name != "GLenum" && @enum.Name != "Boolean") { type.IsEnum = true; if ((Settings.Compatibility & Settings.Legacy.ConstIntEnums) != Settings.Legacy.None) { type.QualifiedType = "int"; } else { // Some functions and enums have the same names. // Make sure we reference the enums rather than the functions. if (normal) { type.QualifiedType = type.CurrentType.Insert(0, String.Format("{0}.", Settings.EnumsOutput)); } } } else if (Generator.GLTypes.TryGetValue(type.CurrentType, out s)) { // Check if the parameter is a generic GLenum. If it is, search for a better match, // otherwise fallback to Settings.CompleteEnumName (named 'All' by default). if (s.Contains("GLenum") /*&& !String.IsNullOrEmpty(category)*/) { type.IsEnum = true; if ((Settings.Compatibility & Settings.Legacy.ConstIntEnums) != Settings.Legacy.None) { type.QualifiedType = "int"; } else { // Better match: enum.Name == function.Category (e.g. GL_VERSION_1_1 etc) // Note: for backwards compatibility we use "category" only for the gl api. // glcore, gles1 and gles2 use the All enum instead. if (apiname == "gl" && enums.ContainsKey(category)) { type.QualifiedType = String.Format("{0}{1}{2}", Settings.EnumsOutput, Settings.NamespaceSeparator, enum_processor.TranslateEnumName(category)); } else { type.QualifiedType = String.Format("{0}{1}{2}", Settings.EnumsOutput, Settings.NamespaceSeparator, Settings.CompleteEnumName); } } } else { // Todo: what is the point of this here? It is overwritten below. // A few translations for consistency switch (type.CurrentType.ToLower()) { case "string": type.QualifiedType = "String"; break; } type.QualifiedType = s; } } type.CurrentType = Generator.CSTypes.ContainsKey(type.CurrentType) ? Generator.CSTypes[type.CurrentType] : type.CurrentType; // Make sure that enum parameters follow enum overrides, i.e. // if enum ErrorCodes is overriden to ErrorCode, then parameters // of type ErrorCodes should also be overriden to ErrorCode. XPathNavigator enum_override = overrides.SelectSingleNode( EnumProcessor.GetOverridesPath(apiname, type.CurrentType)); if (enum_override != null) { // For consistency - many overrides use string instead of String. if (enum_override.Value == "string") { type.QualifiedType = "String"; } else if (enum_override.Value == "StringBuilder") { type.QualifiedType = "StringBuilder"; } else { type.CurrentType = enum_override.Value; } } if (type.CurrentType == "IntPtr" && String.IsNullOrEmpty(type.PreviousType)) { type.Pointer = 0; } if (type.Pointer >= 3) { System.Diagnostics.Trace.WriteLine(String.Format( "[Error] Type '{0}' has a high pointer level. Bindings will be incorrect.", type)); } if (!type.IsEnum) { // Remove qualifier if type is not an enum // Resolves issues when replacing / overriding // an enum parameter with a non-enum type type.QualifiedType = type.CurrentType; } }