# Path: python/loaderlib/constants.py
# DATA_TYPE_BIT0          = DATA_TYPE_CODE - 1
# 
# DATA_TYPE_BITCOUNT      = _count_bits(DATA_TYPE_DATA32)
# 
# DATA_TYPE_BITMASK       = _make_bitmask(DATA_TYPE_BITCOUNT)
# 
# DATA_TYPE_DATA08        = 3
# 
# DATA_TYPE_DATA16        = 4
# 
# DATA_TYPE_DATA32        = 5
# 
# DATA_TYPE_SIZES = [
#     (DATA_TYPE_DATA32, 4),
#     (DATA_TYPE_DATA16, 2),
#     (DATA_TYPE_DATA08, 1),
# ]
# 
# class FileFormat(IntEnum):
#     UNKNOWN = 0
#     AMIGA_HUNK_EXECUTABLE = PLATFORM_AMIGA + 1
#     AMIGA_HUNK_LIBRARY = PLATFORM_AMIGA + 2
#     ATARIST_GEMDOS_EXECUTABLE = PLATFORM_ATARIST + 1
#     SNES_SMC = PLATFORM_SNES + 1
#     X68000_X_EXECUTABLE = PLATFORM_X68000 + 1
#     ZXSPECTRUM_Z80_1 = PLATFORM_ZXSPECTRUM + 1
#     ZXSPECTRUM_Z80_2 = PLATFORM_ZXSPECTRUM + 2
#     ZXSPECTRUM_Z80_3 = PLATFORM_ZXSPECTRUM + 3
# 
# class Processor(IntEnum):
#     UNKNOWN = 0
#     M680x0 = 100
#     M68000 = 101
#     M68010 = 102
#     M68020 = 103
#     M68030 = 104
#     M68040 = 105
#     M68060 = 106
#     MIPS = 200
#     P65c816 = 300       # This gets a P prefix to account for the numeric name.
#     Z80 = 400


import io
from typing import Any, Dict, List, Optional, Tuple
from .loaderlib.constants import DATA_TYPE_BIT0, DATA_TYPE_BITCOUNT, DATA_TYPE_BITMASK, \
    DATA_TYPE_DATA08, DATA_TYPE_DATA16, DATA_TYPE_DATA32, DATA_TYPE_SIZES, FileFormat, Processor
    def __init__(self, copy_block=None):
        if copy_block is not None:
            copy_block.copy_to(self)

        # Override the copied sequence_id so that copied references are distinct.
        self.sequence_id = SegmentBlock.last_sequence_id + 1
        SegmentBlock.last_sequence_id = self.sequence_id

    def __repr__(self):
        return "<SegmentBlock sid=%d address=%x>" % (self.sequence_id, self.address)

    def copy_to(self, new_block):
        new_block.sequence_id = self.sequence_id
        new_block.segment_id = self.segment_id
        new_block.segment_offset = self.segment_offset
        new_block.address = self.address
        new_block.length = self.length
        new_block.flags = self.flags
        new_block.line_data = self.line_data
        new_block.line_count = self.line_count
        new_block.references = self.references


class NewProjectOptions:
    # Binary file options.
    dis_name: Optional[str] = None
    loader_load_address: Optional[int] = None
    loader_entrypoint_offset: Optional[int] = None
    is_binary_file: Optional[bool] = None
    processor_id: Optional[int] = None

# Path: python/loaderlib/constants.py
# DATA_TYPE_BIT0          = DATA_TYPE_CODE - 1
# 
# DATA_TYPE_BITCOUNT      = _count_bits(DATA_TYPE_DATA32)
# 
# DATA_TYPE_BITMASK       = _make_bitmask(DATA_TYPE_BITCOUNT)
# 
# DATA_TYPE_DATA08        = 3
# 
# DATA_TYPE_DATA16        = 4
# 
# DATA_TYPE_DATA32        = 5
# 
# DATA_TYPE_SIZES = [
#     (DATA_TYPE_DATA32, 4),
#     (DATA_TYPE_DATA16, 2),
#     (DATA_TYPE_DATA08, 1),
# ]
# 
# class FileFormat(IntEnum):
#     UNKNOWN = 0
#     AMIGA_HUNK_EXECUTABLE = PLATFORM_AMIGA + 1
#     AMIGA_HUNK_LIBRARY = PLATFORM_AMIGA + 2
#     ATARIST_GEMDOS_EXECUTABLE = PLATFORM_ATARIST + 1
#     SNES_SMC = PLATFORM_SNES + 1
#     X68000_X_EXECUTABLE = PLATFORM_X68000 + 1
#     ZXSPECTRUM_Z80_1 = PLATFORM_ZXSPECTRUM + 1
#     ZXSPECTRUM_Z80_2 = PLATFORM_ZXSPECTRUM + 2
#     ZXSPECTRUM_Z80_3 = PLATFORM_ZXSPECTRUM + 3
# 
# class Processor(IntEnum):
#     UNKNOWN = 0
#     M680x0 = 100
#     M68000 = 101
#     M68010 = 102
#     M68020 = 103
#     M68030 = 104
#     M68040 = 105
#     M68060 = 106
#     MIPS = 200
#     P65c816 = 300       # This gets a P prefix to account for the numeric name.
#     Z80 = 400


# Path: python/disassembly_data.py
import io
from typing import Any, Dict, List, Optional, Tuple
from .loaderlib.constants import DATA_TYPE_BIT0, DATA_TYPE_BITCOUNT, DATA_TYPE_BITMASK, \
    DATA_TYPE_DATA08, DATA_TYPE_DATA16, DATA_TYPE_DATA32, DATA_TYPE_SIZES, FileFormat, Processor

    def __init__(self, copy_block=None):
        if copy_block is not None:
            copy_block.copy_to(self)

        # Override the copied sequence_id so that copied references are distinct.
        self.sequence_id = SegmentBlock.last_sequence_id + 1
        SegmentBlock.last_sequence_id = self.sequence_id

    def __repr__(self):
        return "<SegmentBlock sid=%d address=%x>" % (self.sequence_id, self.address)

    def copy_to(self, new_block):
        new_block.sequence_id = self.sequence_id
        new_block.segment_id = self.segment_id
        new_block.segment_offset = self.segment_offset
        new_block.address = self.address
        new_block.length = self.length
        new_block.flags = self.flags
        new_block.line_data = self.line_data
        new_block.line_count = self.line_count
        new_block.references = self.references


class NewProjectOptions:
    # Binary file options.
    dis_name: Optional[str] = None
    loader_load_address: Optional[int] = None
    loader_entrypoint_offset: Optional[int] = None
    is_binary_file: Optional[bool] = None
    processor_id: Optional[int] = None

    loader_filetype: FileFormat = FileFormat.UNKNOWN