Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e81ac8ba authored by Jean Chalard's avatar Jean Chalard
Browse files

Add a method to get the flags from a binary dictionary.

This method is not used yet

Change-Id: Ic15d3d423aff2c83c712bc0aa56571d30755e663
parent 5b0761e6
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ class BinaryFormat {

    static int detectFormat(const uint8_t* const dict);
    static unsigned int getHeaderSize(const uint8_t* const dict);
    static unsigned int getFlags(const uint8_t* const dict);
    static int getGroupCountAndForwardPointer(const uint8_t* const dict, int* pos);
    static uint8_t getFlagsAndForwardPointer(const uint8_t* const dict, int* pos);
    static int32_t getCharCodeAndForwardPointer(const uint8_t* const dict, int* pos);
@@ -65,6 +66,15 @@ class BinaryFormat {
            const int length);
    static int getWordAtAddress(const uint8_t* const root, const int address, const int maxDepth,
            uint16_t* outWord);

    // Flags for special processing
    // Those *must* match the flags in makedict (BinaryDictInputOutput#*_PROCESSING_FLAG) or
    // something very bad (like, the apocalypse) will happen. Please update both at the same time.
    enum {
        REQUIRES_GERMAN_UMLAUT_PROCESSING = 0x1,
        REQUIRES_FRENCH_LIGATURES_PROCESSING = 0x4
    };
    const static unsigned int NO_FLAGS = 0;
};

inline int BinaryFormat::detectFormat(const uint8_t* const dict) {
@@ -89,6 +99,15 @@ inline int BinaryFormat::detectFormat(const uint8_t* const dict) {
    }
}

inline unsigned int BinaryFormat::getFlags(const uint8_t* const dict) {
    switch (detectFormat(dict)) {
    case 1:
        return NO_FLAGS;
    default:
        return (dict[6] << 8) + dict[7];
    }
}

inline unsigned int BinaryFormat::getHeaderSize(const uint8_t* const dict) {
    switch (detectFormat(dict)) {
    case 1:
+2 −2
Original line number Diff line number Diff line
@@ -171,7 +171,7 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo,

    queuePool->clearAll();
    Correction* masterCorrection = correction;
    if (REQUIRES_GERMAN_UMLAUT_PROCESSING & flags)
    if (BinaryFormat::REQUIRES_GERMAN_UMLAUT_PROCESSING & flags)
    { // Incrementally tune the word and try all possibilities
        int codesBuffer[getCodesBufferSize(codes, codesSize)];
        int xCoordinatesBuffer[codesSize];
@@ -181,7 +181,7 @@ int UnigramDictionary::getSuggestions(ProximityInfo *proximityInfo,
                codesSize, flags, codes, codesSize, 0, codesBuffer, masterCorrection, queuePool,
                GERMAN_UMLAUT_DIGRAPHS,
                sizeof(GERMAN_UMLAUT_DIGRAPHS) / sizeof(GERMAN_UMLAUT_DIGRAPHS[0]));
    } else if (REQUIRES_FRENCH_LIGATURES_PROCESSING & flags) {
    } else if (BinaryFormat::REQUIRES_FRENCH_LIGATURES_PROCESSING & flags) {
        int codesBuffer[getCodesBufferSize(codes, codesSize)];
        int xCoordinatesBuffer[codesSize];
        int yCoordinatesBuffer[codesSize];
+0 −2
Original line number Diff line number Diff line
@@ -149,9 +149,7 @@ class UnigramDictionary {
    // or something very bad (like, the apocalypse) will happen.
    // Please update both at the same time.
    enum {
        REQUIRES_GERMAN_UMLAUT_PROCESSING = 0x1,
        USE_FULL_EDIT_DISTANCE = 0x2,
        REQUIRES_FRENCH_LIGATURES_PROCESSING = 0x4
    };
    static const digraph_t GERMAN_UMLAUT_DIGRAPHS[];
    static const digraph_t FRENCH_LIGATURES_DIGRAPHS[];