liblouis: Data structure of liblouis tables
1
1 6.3 Data structure of liblouis tables
1 =====================================
1
1 The data structure 'TranslationTableHeader' is defined by a 'typedef'
1 statement in 'louis.h'. To find the beginning, search for the word
1 'header'. As its name implies, this is actually the table header. Data
1 are placed in the 'ruleArea' array, which is the last item defined in
1 this structure. This array is declared with a length of 1 and is
1 expanded as needed. The table header consists mostly of arrays of
1 pointers of size 'HASHNUM'. These pointers are actually offsets into
1 'ruleArea' and point to chains of items which have been placed in the
1 same hash bucket by a simple hashing algorithm. 'HASHNUM' should be a
1 prime and is currently 1123. The structure of the table was chosen to
1 optimize speed rather than memory usage.
1
1 The first part of the table contains miscellaneous information, such
1 as the number of passes and whether various opcodes have been used. It
1 also contains the amount of memory allocated to the table and the amount
1 actually used.
1
1 The next section contains pointers to various braille indicators and
1 begins with 'capitalSign'. The rules pointed to contain the dot pattern
1 for the indicator and an opcode which is used by the back-translator but
1 does not appear in the list of opcodes. The braille indicators also
1 include various kinds of emphasis, such as italic and bold and
1 information about the length of emphasized phrases. The latter is
1 contained directly in the table item instead of in a rule.
1
1 After the braille indicators comes information about when a letter
1 sign should be used.
1
1 Next is an array of size 'HASHNUM' which points to character
1 definitions. These are created by the character-definition opcodes.
1
1 Following this is a similar array pointing to definitions of
1 single-cell dot patterns. This is also created from the
1 character-definition opcodes. If a character definition contains a
1 multi-cell dot pattern this is compiled into ordinary forward and
1 backward rules. If such a multi-cell dot pattern contains a single cell
1 which has not previously been defined that cell is placed in this array,
1 but is given the attribute 'space'.
1
1 Next come arrays that map characters to single-cell dot patterns and
1 dots to characters. These are created from both character-definition
1 opcodes and display opcodes.
1
1 Next is an array of size 256 which maps characters in this range to
1 dot patterns which may consist of multiple cells. It is used, for
1 example, to map '{' to dots 456-246. These mappings are created by the
1 'compdots' or the 'comp6' opcode (⇒comp6 comp6 opcode.).
1
1 Next are two small arrays that held pointers to chains of rules
1 produced by the 'swapcd' opcode (⇒swapcd swapcd opcode.) and the
1 'swapdd' opcode (⇒swapdd swapdd opcode.) and by some multipass,
1 'context' and 'correct' opcodes.
1
1 Now we get to an array of size 'HASHNUM' which points to chains of
1 rules for forward translation.
1
1 Following this is a similar array for back-translation.
1
1 Finally is the 'ruleArea', an array of variable size to which various
1 structures are mapped and to which almost everything else points.
1