Exemple #1
0
        void MergeExtensionEnums(VkEnum[] specEnums, VkExtension[] extensions)
        {
            foreach (var specEnum in specEnums)
            {
                foreach (var ext in extensions.Where(x => x.Supported != "disabled"))
                {
                    var extNumber = ext.Number - 1;

                    var deltas = ext
                                 .Requirement.Enums
                                 .Where(x => !x.IsConstant && x.Extends == specEnum.Name);

                    if (deltas.Any())
                    {
                        var existing = specEnum.Values.ToList();
                        foreach (var newEnumValue in deltas)
                        {
                            if (newEnumValue.IsFlag)
                            {
                                // ... todo
                            }
                            else
                            {
                                if (!newEnumValue.Offset.HasValue)
                                {
                                    continue;
                                }

                                var enumValue = 1000000000;
                                enumValue += 1000 * extNumber;
                                enumValue += newEnumValue.Offset.Value;
                                if (newEnumValue.Dir == "-")
                                {
                                    enumValue *= -1;
                                }

                                VkEnumValue vkEnumValue = new VkEnumValue();
                                vkEnumValue.Name    = vkEnumValue.SpecName = newEnumValue.Name;
                                vkEnumValue.Comment = newEnumValue.Comment;
                                vkEnumValue.Value   = enumValue.ToString();

                                existing.Add(vkEnumValue);
                            }
                        }
                        specEnum.Values = existing.ToArray();
                    }
                }
            }
        }
Exemple #2
0
        static VkEnum GenerateEmptyBitmask(string name)
        {
            var vkEnum = new VkEnum
            {
                Name      = GetEnumName(name),
                IsBitmask = true,
            };

            var vkEnumValue = new VkEnumValue
            {
                Name  = "VK_NONE",
                Value = "0",
            };

            vkEnum.Values = new[] { vkEnumValue };

            return(vkEnum);
        }
Exemple #3
0
        VkEnumValue ReadEnumValue(XElement xenum)
        {
            if (xenum.Name != "enum")
            {
                throw new ArgumentException("Not an enum", nameof(xenum));
            }

            var vkEnum = new VkEnumValue();

            var xattributes = xenum.Attributes();

            if (xattributes.Any())
            {
                foreach (var xattrib in xattributes)
                {
                    switch (xattrib.Name.ToString())
                    {
                    case "name":
                        vkEnum.Name = vkEnum.SpecName = xattrib.Value;
                        break;

                    case "bitpos":
                    case "value":
                        vkEnum.Value = xattrib.Value;
                        break;

                    case "comment":
                        vkEnum.Comment = xattrib.Value;
                        break;

                    default: throw new NotImplementedException(xattrib.Name.ToString());
                    }
                }
            }

            if (string.IsNullOrEmpty(vkEnum.Name) || string.IsNullOrEmpty(vkEnum.Value))
            {
                throw new InvalidOperationException("Enum collection does not have proper `<name>` or `<value>` or `<bitpos>` element");
            }

            return(vkEnum);
        }