<commit_before>using System;
using System.Collections.Generic;

namespace CppSharp.AST
{
    /// <summary>
    /// Represents a C/C++ enumeration declaration.
    /// </summary>
    public class Enumeration : Declaration
    {
        [Flags]
        public enum EnumModifiers
        {
            Anonymous,
            Scoped,
            Flags
        }

        /// <summary>
        /// Represents a C/C++ enumeration item.
        /// </summary>
        public class Item : Declaration
        {
            public ulong Value;
            public string Expression;
            public bool ExplicitValue = true;

            public bool IsHexadecimal
            {
                get
                {
                    if (Expression == null)
                    {
                        return false;
                    }
                    return Expression.Contains("0x") || Expression.Contains("0X");
                }
            }

            public override T Visit<T>(IDeclVisitor<T> visitor)
            {
                throw new NotImplementedException();
            }
        }

        public Enumeration()
        {
            Items = new List<Item>();
            ItemsByName = new Dictionary<string, Item>();
            BuiltinType = new BuiltinType(PrimitiveType.Int32);
        }

        public Enumeration AddItem(Item item)
        {
            Items.Add(item);
            ItemsByName[item.Name] = item;
            return this;
        }

        public string GetItemValueAsString(Item item)
        {
            var printAsHex = item.IsHexadecimal && BuiltinType.IsUnsigned;
            var format = printAsHex ? "x" : string.Empty;
            var value = BuiltinType.IsUnsigned ? item.Value.ToString(format) :
                ((long)item.Value).ToString(format);
            return printAsHex ? "0x" + value : value;
        }

        public Enumeration SetFlags()
        {
            Modifiers |= EnumModifiers.Flags;
            return this;
        }

        public bool IsFlags
        {
            get { return Modifiers.HasFlag(EnumModifiers.Flags); }
        }

        public Type Type { get; set; }
        public BuiltinType BuiltinType { get; set; }
        public EnumModifiers Modifiers { get; set; }

        public List<Item> Items;
        public Dictionary<string, Item> ItemsByName;

        public override T Visit<T>(IDeclVisitor<T> visitor)
        {
            return visitor.VisitEnumDecl(this);
        }
    }
}<commit_msg>Fixed EnumModifiers to define proper power of two values.<commit_after>using System;
using System.Collections.Generic;

namespace CppSharp.AST
{
    /// <summary>
    /// Represents a C/C++ enumeration declaration.
    /// </summary>
    public class Enumeration : Declaration
    {
        [Flags]
        public enum EnumModifiers
        {
            Anonymous = 1 << 0,
            Scoped = 1 << 1,
            Flags = 1 << 2,
        }

        /// <summary>
        /// Represents a C/C++ enumeration item.
        /// </summary>
        public class Item : Declaration
        {
            public ulong Value;
            public string Expression;
            public bool ExplicitValue = true;

            public bool IsHexadecimal
            {
                get
                {
                    if (Expression == null)
                    {
                        return false;
                    }
                    return Expression.Contains("0x") || Expression.Contains("0X");
                }
            }

            public override T Visit<T>(IDeclVisitor<T> visitor)
            {
                throw new NotImplementedException();
            }
        }

        public Enumeration()
        {
            Items = new List<Item>();
            ItemsByName = new Dictionary<string, Item>();
            BuiltinType = new BuiltinType(PrimitiveType.Int32);
        }

        public Enumeration AddItem(Item item)
        {
            Items.Add(item);
            ItemsByName[item.Name] = item;
            return this;
        }

        public string GetItemValueAsString(Item item)
        {
            var printAsHex = item.IsHexadecimal && BuiltinType.IsUnsigned;
            var format = printAsHex ? "x" : string.Empty;
            var value = BuiltinType.IsUnsigned ? item.Value.ToString(format) :
                ((long)item.Value).ToString(format);
            return printAsHex ? "0x" + value : value;
        }

        public Enumeration SetFlags()
        {
            Modifiers |= EnumModifiers.Flags;
            return this;
        }

        public bool IsFlags
        {
            get { return Modifiers.HasFlag(EnumModifiers.Flags); }
        }

        public Type Type { get; set; }
        public BuiltinType BuiltinType { get; set; }
        public EnumModifiers Modifiers { get; set; }

        public List<Item> Items;
        public Dictionary<string, Item> ItemsByName;

        public override T Visit<T>(IDeclVisitor<T> visitor)
        {
            return visitor.VisitEnumDecl(this);
        }
    }
}
{'fraction_non_alphanumeric': 0.08963750985027581, 'fraction_numerical': 0.0031520882584712374, 'mean_word_length': 1.3858082706766917, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5593719', 'n_tokens_mistral': 1336, 'n_tokens_neox': 1252, 'n_words': 316}