class DelphiCompiledUnitChunks:
    STOP = 0x63
    INTERFACE_USES = 0x64
    IMPL_USES = 0x65
    IMPORT_TYPE = 0x66
    IMPORT_VALUE = 0x67
    DLL = 0x68
    IMPORT_TYPE_DEF = 0x6E
    SRC = 0x70
    OBJ = 0x71
    RESOURCE = 0x72
    ASM = 0x73
    ASSEMBLY_SRC = 0x74
    INLINE_SRC = 0x76
    UNIT_FLAGS = 0x96
    CONST_ADD_INFO = 0x9C
    STOP2 = 0x9F


class DelphiCompiledUnitVersions:
    DCU_VERSION_D2 = 2
    DCU_VERSION_D4 = 4
    DCU_VERSION_D3 = 3
    DCU_VERSION_D5 = 5
    DCU_VERSION_D6 = 6
    DCU_VERSION_D7 = 7
    DCU_VERSION_D8 = 8
    DCU_VERSION_D2005 = 9
    DCU_VERSION_D2006 = 10
    DCU_VERSION_D2009 = 12
    DCU_VERSION_D2010 = 14
    DCU_VERSION_D_XE = 15
    DCU_VERSION_D_XE2 = 16
    DCU_VERSION_D_XE3 = 17
    DCU_VERSION_D_XE4 = 18
    DCU_VERSION_D_XE5 = 19
    DCU_VERSION_D_XE6 = 20
    DCU_VERSION_D_XE7 = 21
    DCU_VERSION_D_XE8 = 22
    DCU_VERSION_D_10 = 23
    DCU_VERSION_D_10_1 = 24

    MAGIC_TO_VERSION = {
        0x50505348: DCU_VERSION_D2,
        0x44518641: DCU_VERSION_D3,
        0x4768A6D8: DCU_VERSION_D4,
        0xF21F148B: DCU_VERSION_D5,

        0x0E0000DD: DCU_VERSION_D6,
        0x0E8000DD: DCU_VERSION_D6,

        0xFF0000DF: DCU_VERSION_D7,
        0x0F0000DF: DCU_VERSION_D7,
        0x0F8000DF: DCU_VERSION_D7,

        0x10000229: DCU_VERSION_D8,

        0x11000239: DCU_VERSION_D2005,
        0x1100000D: DCU_VERSION_D2005,
        0x11800009: DCU_VERSION_D2005,

        0x1200024D: DCU_VERSION_D2006,
        0x12000023: DCU_VERSION_D2006,

        0x14000039: DCU_VERSION_D2009,
        0x15000045: DCU_VERSION_D2010,
        0x1600034B: DCU_VERSION_D_XE
    }
