1 : /* GRAPHITE2 LICENSING
2 :
3 : Copyright 2010, SIL International
4 : All rights reserved.
5 :
6 : This library is free software; you can redistribute it and/or modify
7 : it under the terms of the GNU Lesser General Public License as published
8 : by the Free Software Foundation; either version 2.1 of License, or
9 : (at your option) any later version.
10 :
11 : This program is distributed in the hope that it will be useful,
12 : but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 : Lesser General Public License for more details.
15 :
16 : You should also have received a copy of the GNU Lesser General Public
17 : License along with this library in the file named "LICENSE".
18 : If not, write to the Free Software Foundation, 51 Franklin Street,
19 : Suite 500, Boston, MA 02110-1335, USA or visit their web page on the
20 : internet at http://www.fsf.org/licenses/lgpl.html.
21 :
22 : Alternatively, the contents of this file may be used under the terms of the
23 : Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public
24 : License, as published by the Free Software Foundation, either version 2
25 : of the License or (at your option) any later version.
26 : */
27 : #pragma once
28 :
29 : #include <cstdlib>
30 : #include "inc/Code.h"
31 :
32 : namespace graphite2 {
33 :
34 : class Segment;
35 : class Face;
36 : class Silf;
37 : struct Rule;
38 : struct RuleEntry;
39 : struct State;
40 : class FiniteStateMachine;
41 :
42 : class Pass
43 : {
44 : public:
45 : Pass();
46 : ~Pass();
47 :
48 : bool readPass(void* pPass, size_t pass_length, size_t subtable_base, const Face & face);
49 : void runGraphite(vm::Machine & m, FiniteStateMachine & fsm) const;
50 0 : void init(Silf *silf) { m_silf = silf; }
51 :
52 0 : CLASS_NEW_DELETE
53 : private:
54 : void findNDoRule(Slot* & iSlot, vm::Machine &, FiniteStateMachine& fsm) const;
55 : int doAction(const vm::Machine::Code* codeptr, Slot * & slot_out, vm::Machine &) const;
56 : bool testPassConstraint(vm::Machine & m) const;
57 : bool testConstraint(const Rule & r, vm::Machine &) const;
58 : bool readFSM(const byte* p, const byte*const pass_start, const size_t max_offset);
59 : bool readRules(const byte * rule_map, const size_t num_entries,
60 : const byte *precontext, const uint16 * sort_key,
61 : const uint16 * o_constraint, const byte *constraint_data,
62 : const uint16 * o_action, const byte * action_data,
63 : const Face &);
64 : bool readStates(const byte * starts, const byte * states, const byte * o_rule_map);
65 : bool readRanges(const byte * ranges, size_t num_ranges);
66 : uint16 glyphToCol(const uint16 gid) const;
67 : bool runFSM(FiniteStateMachine & fsm, Slot * slot) const;
68 : void dumpRuleEventConsidered(const FiniteStateMachine & fsm, const RuleEntry & re) const;
69 : void dumpRuleEventOutput(const FiniteStateMachine & fsm, const Rule & r, Slot * os) const;
70 : void adjustSlot(int delta, Slot * & slot_out, SlotMap &) const;
71 : const Silf* m_silf;
72 : uint16 * m_cols;
73 : Rule * m_rules; // rules
74 : RuleEntry * m_ruleMap;
75 : State * * m_startStates; // prectxt length
76 : State * * m_sTable;
77 : State * m_states;
78 :
79 : bool m_immutable;
80 : byte m_iMaxLoop;
81 : uint16 m_numGlyphs;
82 : uint16 m_numRules;
83 : uint16 m_sRows;
84 : uint16 m_sTransition;
85 : uint16 m_sSuccess;
86 : uint16 m_sColumns;
87 : byte m_minPreCtxt;
88 : byte m_maxPreCtxt;
89 : vm::Machine::Code m_cPConstraint;
90 :
91 : private: //defensive
92 : Pass(const Pass&);
93 : Pass& operator=(const Pass&);
94 : };
95 :
96 : } // namespace graphite2
|