예제 #1
0
        public IEnumerable <IFeature> AllFeatures(RegistryContext ctx)
        {
            foreach (Feature feature in Features)
            {
                if (ctx.IsSupportedApi(feature.Api))
                {
                    yield return(feature);
                }
            }

            List <Extension> extensions = new List <Extension>(Extensions);

            extensions.RemoveAll(delegate(Extension item) {
                return(item.Supported != null && !ctx.IsSupportedApi(item.Supported));
            });

            extensions.Sort(delegate(Extension x, Extension y) {
                int xIndex = ExtensionIndices.GetIndex(x.Name);
                int yIndex = ExtensionIndices.GetIndex(y.Name);

                if (xIndex != yIndex)
                {
                    return(xIndex.CompareTo(yIndex));
                }
                else
                {
                    return(x.Name.CompareTo(y.Name));
                }
            });

            foreach (Extension extension in extensions)
            {
                yield return(extension);
            }
        }
예제 #2
0
        /// <summary>
        /// Get a list of <see cref="IFeature"/> removing this enumerant.
        /// </summary>
        /// <param name="registry">
        ///  A <see cref="Registry"/> holding the registry information.
        /// </param>
        /// <returns>
        /// It returns a <see cref="T:IEnumerable{IFeature}"/> listing all features removing this enumerant.
        /// </returns>
        private IEnumerable <IFeature> GetFeaturesRemovingEnum(RegistryContext ctx)
        {
            List <IFeature> features = new List <IFeature>();

            // Features
            foreach (Feature feature in ctx.Registry.Features)
            {
                if (feature.Api != null && !ctx.IsSupportedApi(feature.Api))
                {
                    continue;
                }

                int requirementIndex = feature.Removals.FindIndex(delegate(FeatureCommand item) {
                    if (item.Api != null && !ctx.IsSupportedApi(item.Api))
                    {
                        return(false);
                    }

                    int enumIndex = item.Enums.FindIndex(delegate(FeatureCommand.Item subitem) {
                        return(subitem.Name == Name);
                    });

                    return(enumIndex != -1);
                });

                if (requirementIndex != -1)
                {
                    features.Add(feature);
                }
            }

            return(features);
        }
예제 #3
0
        /// <summary>
        /// Link other information against this enumerant.
        /// </summary>
        /// <param name="ctx">
        /// A <see cref="RegistryContext"/> holding the registry information to link.
        /// </param>
        internal void Link(RegistryContext ctx)
        {
            foreach (Enumerant enumerant in Enums)
            {
                // Link
                enumerant.ParentEnumerantBlock = this;
                if ((enumerant.Type == null) && (Type == "bitmask"))
                {
                    enumerant.Type = "u";
                }
                // Recurse
                enumerant.Link(ctx);
            }

            Enums.RemoveAll(delegate(Enumerant item) {
                if (item.RequiredBy.Count == 0)
                {
                    return(true);
                }
                if (item.Api != null && !ctx.IsSupportedApi(item.Api))
                {
                    return(true);
                }
                return(false);
            });
        }
예제 #4
0
파일: Command.cs 프로젝트: dzemz/OpenGL.Net
        /// <summary>
        /// Get a list of <see cref="IFeature"/> removing this enumerant.
        /// </summary>
        /// <param name="registry">
        ///  A <see cref="Registry"/> holding the registry information.
        /// </param>
        /// <returns>
        /// It returns a <see cref="T:IEnumerable{IFeature}"/> listing all features removing this enumerant.
        /// </returns>
        private IEnumerable <IFeature> GetFeaturesRemovingCommand(RegistryContext ctx)
        {
            List <IFeature> features = new List <IFeature>();

            // Features
            foreach (Feature feature in ctx.Registry.Features)
            {
                if (feature.Api != null && !ctx.IsSupportedApi(feature.Api))
                {
                    continue;
                }

                List <FeatureCommand> requirementIndexes = feature.Removals.FindAll(delegate(FeatureCommand item) {
                    if (item.Api != null && !ctx.IsSupportedApi(item.Api))
                    {
                        return(false);
                    }

                    int enumIndex = item.Commands.FindIndex(delegate(FeatureCommand.Item subitem) {
                        foreach (Command commandAlias in Aliases)
                        {
                            if (subitem.Name == commandAlias.Prototype.Name)
                            {
                                return(true);
                            }
                        }
                        return(subitem.Name == Prototype.Name);
                    });

                    return(enumIndex != -1);
                });

                foreach (FeatureCommand featureCommand in requirementIndexes)
                {
                    if (featureCommand.Api != null || featureCommand.Profile != null)
                    {
                        features.Add(new FeatureProfile(feature, featureCommand.Api, featureCommand.Profile));
                    }
                    else
                    {
                        features.Add(feature);
                    }
                }
            }

            return(features);
        }
예제 #5
0
        /// <summary>
        /// Link registry information elements.
        /// </summary>
        internal void Link(RegistryContext ctx)
        {
            // Index enumeration groups
            foreach (EnumerantGroup enumerantGroup in Groups)
            {
                _EnumerantGroupRegistry.Add(enumerantGroup.Name, enumerantGroup);
            }
            // Index commands
            foreach (Command command in Commands)
            {
                _CommandRegistry.Add(command.Prototype.Name, command);
            }

            // Link command aliases
            foreach (Command command in Commands)
            {
                if (command.Alias == null)
                {
                    continue;
                }
                Command aliasCommand = GetCommand(command.Alias.Name);

                if (aliasCommand != null)
                {
                    aliasCommand.Aliases.Add(command);
                }
                else
                {
                    Console.WriteLine("Command {0} has an undefined alias {1}.", command.Prototype.Name, command.Alias.Name);
                }
            }

            foreach (EnumerantBlock enumerantBlock in Enums)
            {
                enumerantBlock.Link(ctx);
            }
            foreach (CommandBlock commandBlock in CommandBlocks)
            {
                commandBlock.Link(ctx);
            }

            // Index required enumerants
            foreach (Enumerant enumerant in Enumerants)
            {
                if ((enumerant.Api == null) || (ctx.IsSupportedApi(enumerant.Api)))
                {
                    _EnumerantRegistry[enumerant.Name] = enumerant;
                }
            }
            // Link enumerant aliases
            foreach (Enumerant enumerant in Enumerants)
            {
                if (enumerant.Alias != null)
                {
                    enumerant.EnumAlias = GetEnumerant(enumerant.Alias);
                }

                if (enumerant.EnumAlias == null)
                {
                    foreach (string extensionPostfix in ctx.ExtensionsDictionary.Words)
                    {
                        if (!enumerant.Name.EndsWith("_" + extensionPostfix))
                        {
                            continue;
                        }

                        Enumerant enumerantAlias = null;
                        string    aliasName = enumerant.Name.Substring(0, enumerant.Name.Length - (extensionPostfix.Length + 1));
                        bool      isArb = extensionPostfix == "ARB", isExt = extensionPostfix == "EXT";

                        if (!isArb && !isExt)
                        {
                            // Core enumerant
                            enumerantAlias = GetEnumerant(aliasName);
                            // ARB enumerant
                            if (enumerantAlias == null)
                            {
                                enumerantAlias = GetEnumerant(aliasName + "_ARB");
                            }
                            // EXT enumerant
                            if (enumerantAlias == null)
                            {
                                enumerantAlias = GetEnumerant(aliasName + "_EXT");
                            }
                        }
                        else if (isExt)
                        {
                            // Core enumerant
                            enumerantAlias = GetEnumerant(aliasName);
                            // ARB enumerant
                            if (enumerantAlias == null)
                            {
                                enumerantAlias = GetEnumerant(aliasName + "_ARB");
                            }
                        }
                        else if (isArb)
                        {
                            // Core enumerant
                            enumerantAlias = GetEnumerant(aliasName);
                        }

                        if (enumerantAlias != null)
                        {
                            if (enumerantAlias.Value == enumerant.Value)
                            {
                                enumerant.EnumAlias = enumerantAlias;
                                enumerantAlias.AliasOf.Add(enumerant);
                            }
                        }
                    }
                }
            }
        }
예제 #6
0
        public IEnumerable <IFeature> AllFeatures(RegistryContext ctx)
        {
            List <Feature> features = Features.FindAll(delegate(Feature item) {
                return(ctx.IsSupportedApi(item.Api));
            });

            features.Sort(delegate(Feature x, Feature y) {
                OpenGL.KhronosVersion xVersion = OpenGL.KhronosVersion.ParseFeature(x.Name, false);
                OpenGL.KhronosVersion yVersion = OpenGL.KhronosVersion.ParseFeature(y.Name, false);

                if (xVersion.Api != yVersion.Api)
                {
                    int xPriority = GetVersionApiPriority(xVersion.Api);
                    int yPriority = GetVersionApiPriority(yVersion.Api);

                    if (xPriority != yPriority)
                    {
                        return(xPriority.CompareTo(yPriority));
                    }
                    else
                    {
                        return(x.Name.CompareTo(y.Name));
                    }
                }
                else
                {
                    return(xVersion.CompareTo(yVersion));
                }
            });

            foreach (Feature feature in features)
            {
                yield return(feature);
            }

            List <Extension> extensions = new List <Extension>(Extensions);

            extensions.RemoveAll(delegate(Extension item) {
                return(item.Supported != null && !ctx.IsSupportedApi(item.Supported));
            });

            extensions.Sort(delegate(Extension x, Extension y) {
                int xVendor = GetExtensionVendorPriority(x.Vendor), yVendor = GetExtensionVendorPriority(y.Vendor);

                if (xVendor != yVendor)
                {
                    return(GetExtensionVendorPriority(x.Vendor).CompareTo(GetExtensionVendorPriority(y.Vendor)));
                }

                int xIndex = ExtensionIndices.GetIndex(x.Name);
                int yIndex = ExtensionIndices.GetIndex(y.Name);

                if (xIndex != yIndex)
                {
                    return(xIndex.CompareTo(yIndex));
                }
                else
                {
                    return(x.Name.CompareTo(y.Name));
                }
            });

            foreach (Extension extension in extensions)
            {
                yield return(extension);
            }
        }
예제 #7
0
        /// <summary>
        /// Get a list of <see cref="IFeature"/> requiring this enumerant.
        /// </summary>
        /// <param name="ctx">
        ///  A <see cref="RegistryContext"/> holding the registry information.
        /// </param>
        /// <returns>
        /// It returns a <see cref="T:IEnumerable{IFeature}"/> listing all features requiring this enumerant.
        /// </returns>
        private IEnumerable <IFeature> GetFeaturesRequiringCommand(RegistryContext ctx)
        {
            List <IFeature> features = new List <IFeature>();

            // Features
            foreach (Feature feature in ctx.Registry.Features)
            {
                if (feature.Api != null && !ctx.IsSupportedApi(feature.Api))
                {
                    continue;
                }

                int requirementIndex = feature.Requirements.FindIndex(delegate(FeatureCommand item) {
                    if (item.Api != null && !ctx.IsSupportedApi(item.Api))
                    {
                        return(false);
                    }

                    int enumIndex = item.Commands.FindIndex(delegate(FeatureCommand.Item subitem) {
                        return(subitem.Name == Prototype.Name);
                    });

                    return(enumIndex != -1);
                });

                if (requirementIndex != -1)
                {
                    features.Add(feature);
                }
            }

            // Extensions
            foreach (Extension extension in ctx.Registry.Extensions)
            {
                if (extension.Supported != null && !ctx.IsSupportedApi(extension.Supported))
                {
                    continue;
                }

                int requirementIndex = extension.Requirements.FindIndex(delegate(FeatureCommand item) {
                    if (item.Api != null && !ctx.IsSupportedApi(item.Api))
                    {
                        return(false);
                    }

                    int enumIndex = item.Commands.FindIndex(delegate(FeatureCommand.Item subitem) {
                        foreach (Command commandAlias in Aliases)
                        {
                            if (subitem.Name == commandAlias.Prototype.Name)
                            {
                                return(true);
                            }
                        }

                        return(subitem.Name == Prototype.Name);
                    });

                    return(enumIndex != -1);
                });

                if (requirementIndex != -1)
                {
                    features.Add(extension);
                }
            }

            return(features);
        }