Esempio n. 1
0
        static void ParseEnum(XPathNavigator node)
        {
            var result = new SpecEnum();

            result.Name    = result.MapName = node.GetAttribute("name");
            result.Comment = node.GetAttribute("comment");
            result.Bitmask = string.Equals("bitmask", node.GetAttribute("type"), StringComparison.InvariantCultureIgnoreCase);
            result.Members = new List <SpecEnumMember> ();
            GetSpecType(result.Name).TypeObject = result;
            enumMap.Add(result.Name, result);

            foreach (XPathNavigator member in node.Select("enum"))
            {
                var mem = GetSpecEnumMember(member.GetAttribute("name"));
                mem.Comment = member.GetAttribute("comment");
                mem.Value   = member.GetAttribute("value");
                mem.BitPos  = member.GetAttribute <int> ("bitpos");

                if (mem.Value != null)
                {
                    if (mem.Value.IndexOf("ull", StringComparison.InvariantCultureIgnoreCase) != -1)
                    {
                        mem.Value = Regex.Replace(mem.Value, "[uU][lL][lL]", "ul");
                    }
                    if (mem.Value.IndexOf("f", StringComparison.InvariantCultureIgnoreCase) != -1)
                    {
                        mem.Value = "(int)" + mem.Value;
                    }
                    if (mem.Value.IndexOf("~", StringComparison.InvariantCultureIgnoreCase) != -1)
                    {
                        mem.Value = "(int)" + mem.Value;
                    }
                }

                result.Members.Add(mem);
            }
        }
Esempio n. 2
0
        protected void WriteEnum(SpecEnum info)
        {
        #line default
        #line hidden

        #line 8 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"
            this.Write("// <summary>");


        #line default
        #line hidden

        #line 9 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(info.Name));


        #line default
        #line hidden

        #line 9 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"
            this.Write("</summary>\r\n");


        #line default
        #line hidden

        #line 10 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"

            if (info.Bitmask)
            {
        #line default
        #line hidden

        #line 12 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"
                this.Write("[Flags]\r\n");


        #line default
        #line hidden

        #line 14 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"
            }


        #line default
        #line hidden

        #line 16 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"
            this.Write("public enum ");


        #line default
        #line hidden

        #line 17 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(info.MapName));


        #line default
        #line hidden

        #line 17 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"
            this.Write("\r\n{\r\n");


        #line default
        #line hidden

        #line 19 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"

            foreach (var item in info.Members)
            {
        #line default
        #line hidden

        #line 22 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"
                this.Write("\t// <summary>");


        #line default
        #line hidden

        #line 23 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Name));


        #line default
        #line hidden

        #line 23 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"
                this.Write("</summary>\r\n\t");


        #line default
        #line hidden

        #line 24 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.MapName));


        #line default
        #line hidden

        #line 24 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"
                this.Write(" = unchecked(");


        #line default
        #line hidden

        #line 24 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"
                this.Write(this.ToStringHelper.ToStringWithCulture(item.Value == null ? "1 << " + item.BitPos : item.Value));


        #line default
        #line hidden

        #line 24 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"
                this.Write("),\r\n");


        #line default
        #line hidden

        #line 25 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"
            }


        #line default
        #line hidden

        #line 27 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"
            this.Write("}\r\n");


        #line default
        #line hidden

        #line 29 "F:\Projects\Crow.Graphics.OpenGl\Crow.Graphics.Vulkan.SpecGen\EnumTemplate.tt"
        }