Exemple #1
0
        private static void ParseEnum(
            XmlReader xmlReader,
            Dictionary <string, List <KeyValuePair <string, string> > > enums,
            Dictionary <string, List <KeyValuePair <string, string> > > flagEnums)
        {
            bool isFlags  = xmlReader.GetAttribute("type") == "bitmask";
            var  enumName = xmlReader.GetAttribute("name");
            var  values   = new List <KeyValuePair <string, string> >();

            while (xmlReader.Read() && (xmlReader.NodeType != XmlNodeType.EndElement || xmlReader.Name != "enums"))
            {
                if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "enum")
                {
                    var rawName = xmlReader.GetAttribute("name");
                    var value   =
                        xmlReader.GetAttribute("value") ??
                        VulkanCodeGenerator.ToPascalCase(xmlReader.GetAttribute("alias")) ??
                        "1 << " + xmlReader.GetAttribute("bitpos");
                    values.Add(KeyValuePair.Create(rawName, value));
                }
            }

            if (isFlags)
            {
                flagEnums.Add(enumName, values);
            }
            else
            {
                enums.Add(enumName, values);
            }
        }
Exemple #2
0
 private static void ParseConstants(
     XmlReader xmlReader,
     Dictionary <string, string> constants)
 {
     while (xmlReader.Read() && (xmlReader.NodeType != XmlNodeType.EndElement || xmlReader.Name != "enums"))
     {
         if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "enum")
         {
             var name  = xmlReader.GetAttribute("name");
             var value =
                 xmlReader.GetAttribute("value") ??
                 VulkanCodeGenerator.ToPascalCase(xmlReader.GetAttribute("alias")) ??
                 "1 << " + xmlReader.GetAttribute("bitpos");
             constants.Add(name, value);
         }
     }
 }