# Copyright (C) MatrixEditor 2023-2025
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
from typing import Annotated as f

# use this module to import everything Python related
from .registry import TypeConverter, annotation_registry, to_struct
from .byteorder import (
    ByteOrder,
    SysNative,
    Dynamic,
    DynByteOrder,
    Arch,
    system_arch,
    Native,
    BigEndian,
    LittleEndian,
    NetEndian,
    AARCH64,
    ARM,
    ARM64,
    MIPS,
    MIPS64,
    PowerPC,
    PowerPC64,
    RISC_V,
    RISC_V64,
    SPARC,
    SPARC64,
    x86,
    x86_64,
    AMD,
    AMD64,
)
from .context import (
    Context,
    ContextPath,
    ContextLength,
    ConditionContext,
    UnaryExpression,
    BinaryExpression,
    this,
    ctx,
    parent,
    CTX_PARENT,
    CTX_OBJECT,
    CTX_OFFSETS,
    CTX_STREAM,
    CTX_FIELD,
    CTX_VALUE,
    CTX_POS,
    CTX_INDEX,
    CTX_PATH,
    CTX_SEQ,
    CTX_ARCH,
    CTX_ROOT,
    CTX_ORDER,
    ExprMixin,
    root,
    SetContextVar,
    O_CONTEXT_FACTORY,
    parentctx,
)
from .exception import (
    StructException,
    StreamError,
    DelegationError,
    InvalidValueError,
    Stop,
    OptionError,
    ValidationError,
    DynamicSizeError,
)
from .fields import *  # noqa
from .model import *  # noqa
from .options import (
    Flag,
    F_SEQUENTIAL,
    F_DYNAMIC,
    F_KEEP_POSITION,
    F_OFFSET_OVERRIDE,
    set_field_flags,
    set_struct_flags,
    set_union_flags,
    S_ADD_BYTES,
    S_DISCARD_CONST,
    S_SLOTS,
    S_DISCARD_UNNAMED,
    S_REPLACE_TYPES,
    S_UNION,
    S_EVAL_ANNOTATIONS,
    GLOBAL_BITFIELD_FLAGS,
    GLOBAL_STRUCT_OPTIONS,
    GLOBAL_UNION_OPTIONS,
    GLOBAL_FIELD_FLAGS,
    get_flag,
    get_flags,
    has_flag,
    O_ARRAY_FACTORY,
    B_GROUP_END,
    B_GROUP_KEEP,
    B_GROUP_NEW,
    B_NO_AUTO_BOOL,
    B_OVERWRITE_ALIGNMENT,
)
from ._common import WithoutContextVar, iseof, pack_seq, unpack_seq
from .shared import (
    ATTR_ACTION_PACK,
    ATTR_STRUCT,
    Action,
    ATTR_ACTION_UNPACK,
    ATTR_BITS,
    ATTR_BYTEORDER,
    ATTR_SIGNED,
    ATTR_TEMPLATE,
    ATTR_TYPE,
    getstruct,
    hasstruct,
    MODE_PACK,
    MODE_UNPACK,
    typeof,
    constval,
    ATTR_PACK,
    ATTR_UNPACK,
)

__all__ = [
    "ExprMixin",
    "WithoutContextVar",
    "AARCH64",
    "AMD",
    "AMD64",
    "ARM",
    "ARM64",
    "Arch",
    "BigEndian",
    "ByteOrder",
    "Dynamic",
    "DynByteOrder",
    "LittleEndian",
    "MIPS",
    "MIPS64",
    "Native",
    "NetEndian",
    "PowerPC",
    "PowerPC64",
    "RISC_V",
    "RISC_V64",
    "SPARC",
    "SPARC64",
    "SysNative",
    "system_arch",
    "x86",
    "x86_64",
    "BinaryExpression",
    "CTX_ARCH",
    "CTX_FIELD",
    "CTX_INDEX",
    "CTX_OBJECT",
    "CTX_OFFSETS",
    "CTX_PARENT",
    "CTX_PATH",
    "CTX_POS",
    "CTX_SEQ",
    "CTX_STREAM",
    "CTX_VALUE",
    "ConditionContext",
    "Context",
    "ContextLength",
    "ContextPath",
    "UnaryExpression",
    "ctx",
    "parent",
    "this",
    "DelegationError",
    "DynamicSizeError",
    "InvalidValueError",
    "OptionError",
    "Stop",
    "StreamError",
    "StructException",
    "ValidationError",
    "F_DYNAMIC",
    "F_KEEP_POSITION",
    "F_OFFSET_OVERRIDE",
    "F_SEQUENTIAL",
    "Flag",
    "GLOBAL_BITFIELD_FLAGS",
    "GLOBAL_FIELD_FLAGS",
    "GLOBAL_STRUCT_OPTIONS",
    "GLOBAL_UNION_OPTIONS",
    "O_ARRAY_FACTORY",
    "S_ADD_BYTES",
    "S_DISCARD_CONST",
    "S_DISCARD_UNNAMED",
    "S_EVAL_ANNOTATIONS",
    "S_REPLACE_TYPES",
    "S_SLOTS",
    "S_UNION",
    "get_flag",
    "get_flags",
    "has_flag",
    "set_field_flags",
    "set_struct_flags",
    "set_union_flags",
    "TypeConverter",
    "annotation_registry",
    "to_struct",
    "ATTR_ACTION_PACK",
    "ATTR_STRUCT",
    "Action",
    "iseof",
    "pack_seq",
    "unpack_seq",
    "ATTR_ACTION_UNPACK",
    "ATTR_BITS",
    "ATTR_BYTEORDER",
    "ATTR_SIGNED",
    "ATTR_TEMPLATE",
    "ATTR_TYPE",
    "getstruct",
    "hasstruct",
    "MODE_PACK",
    "MODE_UNPACK",
    "typeof",
    "Sequence",
    "Struct",
    "struct",
    "UnionHook",
    "union",
    "unpack",
    "unpack_file",
    "pack",
    "pack_into",
    "pack_file",
    "sizeof",
    "Bitfield",
    "bitfield",
    "BitfieldGroup",
    "issigned",
    "getbits",
    "istemplate",
    "template",
    "TemplateTypeVar",
    "derive",
    "NewGroup",
    "EndGroup",
    "SetAlignment",
    "BitfieldEntry",
    "BitfieldValueFactory",
    "EnumFactory",
    "CharFactory",
    "DEFAULT_ALIGNMENT",
    "Digest",
    "Algorithm",
    "Md5",
    "Sha1",
    "Sha2_256",
    "Sha2_224",
    "Sha2_384",
    "Sha2_512",
    "Sha3_224",
    "Sha3_256",
    "Sha3_384",
    "Sha3_512",
    "Crc32",
    "Adler",
    "HMAC",
    "DigestField",
    "DigestFieldAction",
    "Md5_Algo",
    "Md5_Field",
    "Sha1_Algo",
    "Sha1_Field",
    "Sha2_256_Algo",
    "Sha2_256_Field",
    "Sha2_224_Algo",
    "Sha2_224_Field",
    "Sha2_384_Algo",
    "Sha2_384_Field",
    "Sha2_512_Algo",
    "Sha2_512_Field",
    "Sha3_224_Algo",
    "Sha3_224_Field",
    "Sha3_256_Algo",
    "Sha3_256_Field",
    "Sha3_384_Algo",
    "Sha3_384_Field",
    "Sha3_512_Algo",
    "Sha3_512_Field",
    "Crc32_Algo",
    "Crc32_Field",
    "Adler_Algo",
    "Adler_Field",
    "CTX_DIGEST",
    "CTX_DIGEST_ALGO",
    "CTX_DIGEST_HOOK",
    "CTX_DIGEST_OBJ",
    "HMACAlgorithm",
    "uintptr",
    "intptr",
    "offintptr",
    "offuintptr",
    "Pointer",
    "pointer",
    "intptr_fn",
    "PTR_STRICT",
    "relative_pointer",
    "RelativePointer",
    "uintptr_fn",
    "Compressed",
    "ZLibCompressed",
    "Bz2Compressed",
    "LZMACompressed",
    "LZOCompressed",
    "PyStructFormattedField",
    "Transformer",
    "Const",
    "ConstBytes",
    "ConstString",
    "Enum",
    "String",
    "Bytes",
    "Memory",
    "Computed",
    "Pass",
    "CString",
    "Prefixed",
    "Int",
    "UInt",
    "padding",
    "char",
    "boolean",
    "int8",
    "uint8",
    "int16",
    "uint16",
    "int24",
    "uint24",
    "int32",
    "uint32",
    "int64",
    "uint64",
    "pssize",
    "psize",
    "float16",
    "float32",
    "float64",
    "double",
    "void_ptr",
    "Uuid",
    "Aligned",
    "align",
    "Lazy",
    "ENUM_STRICT",
    "Field",
    "INVALID_DEFAULT",
    "DEFAULT_OPTION",
    "singleton",
    "FieldMixin",
    "FieldStruct",
    "Chain",
    "Operator",
    "get_args",
    "get_kwargs",
    "VarInt",
    "VARINT_LSB",
    "vint",
    "Encrypted",
    "Xor",
    "Or",
    "And",
    "KeyCipher",
    "MAC",
    "MACAddress",
    "IPv4Address",
    "IPv6Address",
    "ConditionalChain",
    "If",
    "Else",
    "ElseIf",
    "IOHook",
    "CTX_ROOT",
    "CTX_ORDER",
    "root",
    "B_GROUP_END",
    "B_GROUP_KEEP",
    "B_GROUP_NEW",
    "B_NO_AUTO_BOOL",
    "B_OVERWRITE_ALIGNMENT",
    "constval",
    "f",
    "Padding",
    "Invisible",
    "O_CONTEXT_FACTORY",
    "SetContextVar",
    "ATTR_PACK",
    "ATTR_UNPACK",
    "StructDefMixin",
    "AsLengthRef",
    "struct_factory",
    "parentctx",
    "bitfield_factory",
]
