/// <summary> /// Get the API enumeration summary. /// </summary> /// <param name="ctx"> /// The <see cref="RegistryContext"/> holding information about the generated class. /// </param> /// <param name="enumerant"> /// The relative <see cref="Enumerant"/>. /// </param> /// <returns> /// It returns the summary relative to <paramref name="enumerant"/>. /// </returns> public override string QueryEnumSummary(RegistryContext ctx, Enumerant enumerant) { if (ctx == null) { throw new ArgumentNullException(nameof(ctx)); } if (enumerant == null) { throw new ArgumentNullException(nameof(enumerant)); } if (_Xml != null) { XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable()); nsmgr.AddNamespace("mml", "http://www.w3.org/2001/XMLSchema-instance"); nsmgr.AddNamespace("x", "http://docbook.org/ns/docbook"); XmlNodeList enumerants = _Xml.SelectNodes("/x:refentry/x:refsect1[@xml:id='description']/x:variablelist/x:varlistentry", nsmgr); foreach (XmlNode xmlNode in enumerants) { XmlNode enumerantId = xmlNode.SelectSingleNode("x:term/x:constant", nsmgr); if (enumerantId == null || enumerantId.InnerText != enumerant.Name) { continue; } XmlNode enumerantDoc = xmlNode.SelectSingleNode("x:listitem", nsmgr); if (enumerantDoc == null) { continue; } if (!Regex.IsMatch(enumerantId.InnerText, "^(GL_|WGL_|GLX_|EGL_).*")) { continue; } XmlNodeList xmlIdentifiers = _Xml.DocumentElement.SelectNodes("/x:refentry/x:refsynopsisdiv/x:funcsynopsis/x:funcprototype/x:funcdef/x:function", nsmgr); string functionName = string.Empty; if (xmlIdentifiers.Count > 0) { Command commandRef = ctx.Registry.GetCommand(xmlIdentifiers[0].InnerXml); functionName = $"{ctx.Class}.{commandRef.GetImplementationName(ctx)}: "; } return(functionName + GetDocumentationLine(enumerantDoc.InnerXml, _TranformEnumerantMan, ctx)); } return(base.QueryEnumSummary(ctx, enumerant)); } else { return(base.QueryEnumSummary(ctx, enumerant)); } }
/// <summary> /// Get the API enumeration summary. /// </summary> /// <param name="ctx"> /// The <see cref="RegistryContext"/> holding information about the generated class. /// </param> /// <param name="enumerant"> /// The relative <see cref="Enumerant"/>. /// </param> /// <returns> /// It returns the summary relative to <paramref name="enumerant"/>. /// </returns> public override string QueryEnumSummary(RegistryContext ctx, Enumerant enumerant) { if (ctx == null) { throw new ArgumentNullException(nameof(ctx)); } if (enumerant == null) { throw new ArgumentNullException(nameof(enumerant)); } return($"Value of {enumerant.Name} symbol{(enumerant.IsDeprecated ? " (DEPRECATED)" : string.Empty)}."); }
public static void GenerateDocumentation(this ICollection <IRegistryDocumentation> docs, SourceStreamWriter sw, RegistryContext ctx, Enumerant enumerant) { if (docs == null || docs.Count == 0) { return; } List <IRegistryDocumentation> validDocs = GetDocRegistries(docs, enumerant); if (validDocs.Count > 0) { if (validDocs.Count > 1) { List <RegistryDocumentationHandler> handlers = new List <RegistryDocumentationHandler>(); foreach (IRegistryDocumentation docRegistry in validDocs) { List <RegistryDocumentationHandler> registryHandlers = docRegistry.GetDocumentationHandlers(enumerant); if (registryHandlers != null) { handlers.AddRange(registryHandlers); } } RegistryDocumentation.GenerateDocumentation(sw, ctx, enumerant, handlers); } else { validDocs[0].GenerateDocumentation(sw, ctx, enumerant); } } else { RegistryDocumentation.GenerateDocumentation(sw, ctx, enumerant, new List <RegistryDocumentationHandler>(new RegistryDocumentationHandler[] { new RegistryDocumentationHandler_Default() })); } }
private static void GenerateLimitsSupportClass(RegistryProcessor glRegistryProcessor, RegistryContext ctx) { string path = String.Format("{0}/{1}.Limits.cs", _OutputBasePath, ctx.Class); List <Enumerant> limitEnums = new List <Enumerant>(); foreach (Enumerant enumerant in ctx.Registry.Enumerants) { // Skip enumeration with aliases if (enumerant.EnumAlias != null) { continue; } bool maxLimit = enumerant.Name.StartsWith("GL_MAX_"); bool minLimit = enumerant.Name.StartsWith("GL_MIN_"); if (!maxLimit && !minLimit) { continue; } if (CommandFlagsDatabase.IsExcludedLimit(enumerant.Name)) { continue; } limitEnums.Add(enumerant); } foreach (CommandFlagsDatabase.Limit limit in CommandFlagsDatabase.GetLimits()) { if (limitEnums.Exists(delegate(Enumerant item) { return(item.Name == limit.Name); })) { continue; } Enumerant addedEnum = ctx.Registry.GetEnumerant(limit.Name); Debug.Assert(addedEnum != null); if (addedEnum == null) { continue; } limitEnums.Add(addedEnum); } Console.WriteLine("Generate API limits to {0}.", path); using (SourceStreamWriter sw = new SourceStreamWriter(Path.Combine(BasePath, path), false)) { RegistryProcessor.GenerateLicensePreamble(sw); sw.WriteLine("using System;"); sw.WriteLine(); sw.WriteLine("namespace {0}", _Namespace); sw.WriteLine("{"); sw.Indent(); sw.WriteLine("public partial class {0}", ctx.Class); sw.WriteLine("{"); sw.Indent(); sw.WriteLine("/// <summary>"); sw.WriteLine("/// Limits support listing."); sw.WriteLine("/// </summary>"); sw.WriteLine("public sealed partial class Limits"); sw.WriteLine("{"); sw.Indent(); foreach (Enumerant enumerant in limitEnums) { // Filter enumerant CommandFlagsDatabase.Limit limit = CommandFlagsDatabase.GetLimit(enumerant.Name); string fieldName = SpecificationStyle.GetCamelCase(enumerant.ImplementationName); string fieldType = "int"; int fieldLength = 1; if (limit != null) { fieldType = limit.Type; fieldLength = limit.Length; } enumerant.GenerateDocumentation(sw, ctx); if (fieldLength > 1) { sw.WriteLine("[Limit({0}, ArrayLength = {1})]", enumerant.ImplementationName, fieldLength); enumerant.GenerateRequirements(sw, ctx); StringBuilder sb = new StringBuilder(); sb.AppendFormat("public {0}[] {1} = new {0}[] {{", fieldType, fieldName); for (int i = 0; i < fieldLength; i++) { switch (fieldType) { case "int": sb.Append("0"); break; case "float": sb.Append("0.0f"); break; } if (i < fieldLength - 1) { sb.Append(", "); } } sb.Append(" };"); sw.WriteLine(sb.ToString()); } else { sw.WriteLine("[Limit({0})]", enumerant.ImplementationName); enumerant.GenerateRequirements(sw, ctx); sw.WriteLine("public {0} {1};", fieldType, fieldName); } sw.WriteLine(); } sw.Unindent(); sw.WriteLine("}"); sw.Unindent(); sw.Unindent(); sw.WriteLine("}"); sw.Unindent(); sw.WriteLine(); sw.WriteLine("}"); } }
/// <summary> /// Generate all required files for OpenGL C# bindings. /// </summary> /// <param name="glRegistryProcessor"> /// The <see cref="RegistryProcessor"/> that actually process the OpenGL specification. /// </param> /// <param name="ctx"> /// The <see cref="RegistryContext"/> that actually parses the OpenGL specification. /// </param> private static void GenerateCommandsAndEnums(RegistryProcessor glRegistryProcessor, RegistryContext ctx) { Dictionary <string, bool> serializedCommands = new Dictionary <string, bool>(); Dictionary <string, bool> serializedEnums = new Dictionary <string, bool>(); glRegistryProcessor.GenerateStronglyTypedEnums(ctx, Path.Combine(BasePath, String.Format("{0}/{1}.Enums.cs", _OutputBasePath, ctx.Class)), null); #region By features and extensions foreach (IFeature feature in ctx.Registry.AllFeatures(ctx)) { List <Command> featureCommands = new List <Command>(); List <Enumerant> featureEnums = new List <Enumerant>(); #region Select enumerants and commands foreach (FeatureCommand featureCommand in feature.Requirements) { if (featureCommand.Api != null && !ctx.IsSupportedApi(featureCommand.Api)) { Console.WriteLine("Skip command: API {1} not supported", featureCommand.Api); continue; } foreach (FeatureCommand.Item featureCommandItem in featureCommand.Commands) { Command command = ctx.Registry.GetCommand(featureCommandItem.Name); Debug.Assert(command != null); if (serializedCommands.ContainsKey(command.Prototype.Name)) { continue; } serializedCommands.Add(command.Prototype.Name, true); // Do not generate manually disabled command if ((command.Flags & CommandFlags.Disable) != 0) { continue; } // Do not generate command with aliases if (command.Alias != null) { continue; } featureCommands.Add(command); } foreach (FeatureCommand.Item featureEnumItem in featureCommand.Enums) { Enumerant enumerant = ctx.Registry.GetEnumerant(featureEnumItem.Name); if (enumerant == null) { continue; } if (serializedEnums.ContainsKey(enumerant.Name)) { continue; } serializedEnums.Add(enumerant.Name, true); // Do not generate enumerant if it has an alias if (enumerant.EnumAlias != null) { continue; } featureEnums.Add(enumerant); } } #endregion if ((featureCommands.Count == 0) && (featureEnums.Count == 0)) { // No commands and no enumerations: remove file if existing string sourceFilePath = GetFeatureFilePath(feature, ctx); if (File.Exists(sourceFilePath)) { File.Delete(sourceFilePath); } // Next... continue; } glRegistryProcessor.GenerateCommands(ctx, GetFeatureFilePath(feature, ctx), delegate(RegistryContext cctx, SourceStreamWriter sw) { Console.WriteLine("\tGenerate {0} enumerants...", featureEnums.Count); foreach (Enumerant enumerant in featureEnums) { enumerant.GenerateSource(sw, ctx); sw.WriteLine(); } Console.WriteLine("\tGenerate {0} commands...", featureCommands.Count); foreach (Command command in featureCommands) { command.GenerateImplementations(sw, cctx); sw.WriteLine(); } if (featureCommands.Count > 0) { GenerateCommandsImports(cctx, sw, featureCommands); sw.WriteLine(); } if (featureCommands.Count > 0) { GenerateCommandsDelegates(cctx, sw, featureCommands); } }); } #endregion #region Orphans List <Command> orphanCommands = new List <Command>(); List <Enumerant> orphanEnums = new List <Enumerant>(); foreach (Command command in ctx.Registry.Commands) { if (serializedCommands.ContainsKey(command.Prototype.Name)) { continue; } // Do not generate manually disabled command if ((command.Flags & CommandFlags.Disable) != 0) { continue; } // Do not generate command with aliases if (command.Alias != null) { continue; } orphanCommands.Add(command); } foreach (Enumerant enumerant in ctx.Registry.Enumerants) { if (serializedEnums.ContainsKey(enumerant.Name)) { continue; } orphanEnums.Add(enumerant); } string orphanFile = Path.Combine(BasePath, String.Format("{0}/{1}.Orphans.cs", _OutputBasePath, ctx.Class)); if ((orphanCommands.Count != 0) || (orphanEnums.Count != 0)) { glRegistryProcessor.GenerateCommands(ctx, orphanFile, delegate(RegistryContext cctx, SourceStreamWriter sw) { Console.WriteLine("\tGenerate {0} enumerants...", orphanEnums.Count); foreach (Enumerant enumerant in orphanEnums) { enumerant.GenerateSource(sw, ctx); sw.WriteLine(); } Console.WriteLine("\tGenerate {0} commands...", orphanCommands.Count); foreach (Command command in orphanCommands) { command.GenerateImplementations(sw, cctx); sw.WriteLine(); } }); } else { if (File.Exists(orphanFile)) { File.Delete(orphanFile); } } #endregion }
public Dim(Enumerant value) { Value = value; }
public MemoryModel(Enumerant value) { Value = value; }
public MemorySemantics(Enumerant value) { Value = value; }
public RayFlags(Enumerant value) { Value = value; }
public SamplerAddressingMode(Enumerant value) { Value = value; }
public GroupOperation(Enumerant value) { Value = value; }
protected internal override Enumerant VisitEnumerant(Enumerant e) { _ValidateAnnotations(new[] { e.Annotation }, AnnotationTypes.enumerant); return base.VisitEnumerant(e); }
public BuiltIn(Enumerant value) { Value = value; }
protected internal virtual Enumerant VisitEnumerant(Enumerant e) { e.Annotation = VisitAnnotation(e.Annotation); return e; }
public KernelEnqueueFlags(Enumerant value) { Value = value; }
public LoopControl(Enumerant value) { Value = value; }
public AccessQualifier(Enumerant value) { Value = value; }
public ImageChannelDataType(Enumerant value) { Value = value; }
/// <summary> /// Get the API enumeration summary. /// </summary> /// <param name="ctx"> /// The <see cref="RegistryContext"/> holding information about the generated class. /// </param> /// <param name="enumerant"> /// The relative <see cref="Enumerant"/>. /// </param> /// <returns> /// It returns the summary relative to <paramref name="enumerant"/>. /// </returns> public abstract string QueryEnumSummary(RegistryContext ctx, Enumerant enumerant);
public FunctionParameterAttribute(Enumerant value) { Value = value; }
public ImageOperands(Enumerant value) { Value = value; }
public ExecutionModel(Enumerant value) { Value = value; }
public MemoryAccess(Enumerant value) { Value = value; }
public AddressingModel(Enumerant value) { Value = value; }
public FunctionControl(Enumerant value) { Value = value; }
public SelectionControl(Enumerant value) { Value = value; }
private static void GenerateVbCommands(RegistryProcessor glRegistryProcessor, RegistryContext ctx) { Dictionary <string, bool> serializedCommands = new Dictionary <string, bool>(); Dictionary <string, bool> serializedEnums = new Dictionary <string, bool>(); List <Command> featureVbCommands = new List <Command>(); List <Enumerant> featureVbEnums = new List <Enumerant>(); Console.WriteLine("Testing for VB.Net incompatibilities."); #region Select VB incompatible commands foreach (IFeature feature in ctx.Registry.AllFeatures(ctx)) { foreach (FeatureCommand featureCommand in feature.Requirements) { if (featureCommand.Api != null && !ctx.IsSupportedApi(featureCommand.Api)) { Console.WriteLine("Skip command: API {1} not supported", featureCommand.Api); continue; } foreach (FeatureCommand.Item featureCommandItem in featureCommand.Commands) { Command command = ctx.Registry.GetCommand(featureCommandItem.Name); Debug.Assert(command != null); if (serializedCommands.ContainsKey(command.Prototype.Name)) { continue; } serializedCommands.Add(command.Prototype.Name, true); // Do not generate manually disabled command if ((command.Flags & CommandFlags.Disable) != 0) { continue; } // Do not generate command with aliases if (command.Alias != null) { continue; } // Do not generate methods not conflicting with enumerations having the same name with different case Enumerant enumInConflict = ctx.Registry.GetEnumerantNoCase(command.GetImplementationName(ctx)); if (enumInConflict == null) { continue; } // VB.Net command featureVbCommands.Add(command); if (serializedEnums.ContainsKey(enumInConflict.Name)) { continue; } serializedEnums.Add(enumInConflict.Name, true); // VB.Net enum featureVbEnums.Add(enumInConflict); } } } #endregion string path = Path.Combine(BasePath, String.Format("{0}/{1}.Vb.cs", _OutputBasePath, ctx.Class)); if (featureVbCommands.Count > 0) { Console.WriteLine("Generate registry commands to {0}.", path); using (SourceStreamWriter sw = new SourceStreamWriter(path, false)) { RegistryProcessor.GenerateLicensePreamble(sw); // Warning CS1734 XML comment on 'method' has a paramref tag for 'param', but there is no parameter by that name // sw.WriteLine("#pragma warning disable 1734"); // sw.WriteLine(); sw.WriteLine("#pragma warning disable 649, 1572, 1573"); sw.WriteLine(); sw.WriteLine("using System;"); sw.WriteLine("using System.Diagnostics;"); sw.WriteLine("using System.Runtime.InteropServices;"); sw.WriteLine("using System.Security;"); sw.WriteLine("using System.Text;"); sw.WriteLine(); sw.WriteLine("namespace {0}", _Namespace); sw.WriteLine("{"); sw.Indent(); sw.WriteLine("/// <summary>"); sw.WriteLine("/// Class for scoping those methods conflicting with other fields/enums."); sw.WriteLine("/// </summary>"); sw.WriteLine("public partial class {0}", ctx.Class); sw.WriteLine("{"); sw.Indent(); // VB Commands class sw.WriteLine("public static class VB"); sw.WriteLine("{"); sw.Indent(); // VB Function implementations foreach (Command command in featureVbCommands) { command.GenerateImplementations(sw, ctx); sw.WriteLine(); } sw.Unindent(); sw.WriteLine("}"); // VB Commands class sw.WriteLine(); sw.WriteLine("public static class VBEnum"); sw.WriteLine("{"); sw.Indent(); // VB Function implementations foreach (Enumerant enumerant in featureVbEnums) { enumerant.GenerateSource(sw, ctx); sw.WriteLine(); } sw.Unindent(); sw.WriteLine("}"); sw.Unindent(); sw.Unindent(); sw.WriteLine("}"); sw.Unindent(); sw.WriteLine(); sw.WriteLine("}"); } } else { if (File.Exists(path)) { File.Delete(path); } } }
public KernelProfilingInfo(Enumerant value) { Value = value; }
private static List <IRegistryDocumentation> GetDocRegistries(ICollection <IRegistryDocumentation> docs, Enumerant enumerant) { List <IRegistryDocumentation> validDocs = new List <IRegistryDocumentation>(); foreach (IRegistryDocumentation doc in docs) { if (doc.HasDocumentation(enumerant) == false) { continue; } validDocs.Add(doc); } return(FilterDocRegistries(validDocs)); }
public ImageFormat(Enumerant value) { Value = value; }
internal static bool GenerateDocumentation(SourceStreamWriter sw, RegistryContext ctx, Enumerant enumerant, IList <RegistryDocumentationHandler> docHandlers) { // Loads documentation information foreach (RegistryDocumentationHandler docHandler in docHandlers) { docHandler.Load(); } string defaultApi = ctx.Class.ToUpperInvariant(); List <KeyValuePair <string, string> > docHandlersDoc = new List <KeyValuePair <string, string> >(); foreach (RegistryDocumentationHandler docHandler in docHandlers) { docHandlersDoc.Add(new KeyValuePair <string, string>(docHandler.Api ?? defaultApi, docHandler.QueryEnumSummary(ctx, enumerant))); } if (docHandlersDoc.Count == 2 && docHandlersDoc[0].Value == docHandlersDoc[1].Value) { string api = (docHandlers[0].Api ?? defaultApi) + "|" + (docHandlers[1].Api ?? defaultApi); string doc = docHandlersDoc[0].Value; docHandlersDoc.Clear(); docHandlersDoc.Add(new KeyValuePair <string, string>(api, doc)); } if (docHandlersDoc.Count == 4) { bool func1 = docHandlersDoc[0].Value == docHandlersDoc[2].Value; bool func2 = docHandlersDoc[1].Value == docHandlersDoc[3].Value; if (func1 && func2) { string api1 = (docHandlers[0].Api ?? defaultApi) + "|" + (docHandlers[2].Api ?? defaultApi); string doc1 = docHandlersDoc[0].Value; string api2 = (docHandlers[1].Api ?? defaultApi) + "|" + (docHandlers[3].Api ?? defaultApi); string doc2 = docHandlersDoc[1].Value; docHandlersDoc.Clear(); docHandlersDoc.Add(new KeyValuePair <string, string>(api1, doc1)); docHandlersDoc.Add(new KeyValuePair <string, string>(api2, doc2)); } } sw.WriteLine("/// <summary>"); if (docHandlersDoc.Count > 1) { foreach (KeyValuePair <string, string> doc in docHandlersDoc) { sw.WriteLine("/// <para>"); sw.WriteLine("/// {0}", SplitDocumentationLines(String.Format("[{0}] {1}", doc.Key, doc.Value))); sw.WriteLine("/// </para>"); } } else { sw.WriteLine("/// {0}", SplitDocumentationLines(String.Format("[{0}] {1}", docHandlersDoc[0].Key, docHandlersDoc[0].Value))); } sw.WriteLine("/// </summary>"); // Dispose documentation information foreach (RegistryDocumentationHandler docHandler in docHandlers) { docHandler.Dispose(); } return(true); }
public FPFastMathMode(Enumerant value) { Value = value; }