Example #1
0
        public IEnumerable <Struct> ReadStructs(object obj, ProfileConverterOptions opts)
        {
            var xd         = (XDocument)obj;
            var rawStructs = xd.Element("registry")?.Element("types")?.Elements("type")
                             .Where(typex => typex.HasCategoryAttribute("struct"))
                             .Select(typex => StructureDefinition.CreateFromXml(typex))
                             .ToArray();
            var structs = ConvertStructs(rawStructs, opts);

            foreach (var feature in xd.Element("registry").Elements("feature").Attributes("api").Select(x => x.Value).RemoveDuplicates())
            {
                foreach (var(_, s) in structs)
                {
                    yield return(new Struct
                    {
                        Attributes = s.Attributes,
                        ExtensionName = "Core",
                        Fields = s.Fields,
                        Functions = s.Functions,
                        Name = s.Name,
                        NativeName = s.NativeName,
                        ProfileName = feature,
                        ProfileVersion = null
                    });
                }
            }

            opts.TypeMaps.Add(structs.ToDictionary(x => x.Key, x => x.Value.Name));
        }