# 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/>.

# use this module to import everything Python related
from .registry import TypeConverter, annotation_registry, to_struct
from .byteorder import (
    ByteOrder,
    SysNative,
    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,
    ExprMixin,
)
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,
)
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,
)

from .model import __all__ as model_all
from .fields import __all__ as fields_all

# pyright: reportUnsupportedDunderAll=false
__all__ = model_all + fields_all + [
    "ExprMixin",
    "WithoutContextVar",
    "AARCH64",
    "AMD",
    "AMD64",
    "ARM",
    "ARM64",
    "Arch",
    "BigEndian",
    "ByteOrder",
    "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",
]
