gfx/graphite2/src/inc/Error.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/graphite2/src/inc/Error.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,127 @@
     1.4 +/*  GRAPHITE2 LICENSING
     1.5 +
     1.6 +    Copyright 2013, SIL International
     1.7 +    All rights reserved.
     1.8 +
     1.9 +    This library is free software; you can redistribute it and/or modify
    1.10 +    it under the terms of the GNU Lesser General Public License as published
    1.11 +    by the Free Software Foundation; either version 2.1 of License, or
    1.12 +    (at your option) any later version.
    1.13 +
    1.14 +    This program is distributed in the hope that it will be useful,
    1.15 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.16 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.17 +    Lesser General Public License for more details.
    1.18 +
    1.19 +    You should also have received a copy of the GNU Lesser General Public
    1.20 +    License along with this library in the file named "LICENSE".
    1.21 +    If not, write to the Free Software Foundation, 51 Franklin Street, 
    1.22 +    Suite 500, Boston, MA 02110-1335, USA or visit their web page on the 
    1.23 +    internet at http://www.fsf.org/licenses/lgpl.html.
    1.24 +
    1.25 +Alternatively, the contents of this file may be used under the terms of the
    1.26 +Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public
    1.27 +License, as published by the Free Software Foundation, either version 2
    1.28 +of the License or (at your option) any later version.
    1.29 +*/
    1.30 +#pragma once
    1.31 +
    1.32 +// numbers are explicitly assigned for future proofing
    1.33 +
    1.34 +namespace graphite2
    1.35 +{
    1.36 +
    1.37 +class Error
    1.38 +{
    1.39 +public:
    1.40 +    Error() : _e(0) {};
    1.41 +    operator bool() { return (_e != 0); }
    1.42 +    int error() { return _e; }
    1.43 +    void error(int e) { _e = e; }
    1.44 +    bool test(bool pr, int err) { return (_e = int(pr) * err); }
    1.45 +
    1.46 +private:
    1.47 +    int _e;
    1.48 +};
    1.49 +
    1.50 +enum errcontext {
    1.51 +    EC_READGLYPHS = 1,      // while reading glyphs
    1.52 +    EC_READSILF = 2,        // in Silf table
    1.53 +    EC_ASILF = 3,           // in Silf %d
    1.54 +    EC_APASS = 4,           // in Silf %d, pass %d
    1.55 +    EC_PASSCCODE = 5,       // in pass constraint code for Silf %d, pass %d
    1.56 +    EC_ARULE = 6,           // in Silf %d, pass %d, rule %d
    1.57 +    EC_ASTARTS = 7,         // in Silf %d, pass %d, start state %d
    1.58 +    EC_ATRANS = 8,          // in Silf %d, pass %d, fsm state %d
    1.59 +    EC_ARULEMAP = 9         // in Silf %d, pass %d, state %d
    1.60 +};
    1.61 +
    1.62 +enum errors {
    1.63 +    E_OUTOFMEM = 1,         // Out of memory
    1.64 +    E_NOGLYPHS = 2,         // There are no glyphs in the font
    1.65 +    E_BADUPEM = 3,          // The units per em for the font is bad (0)
    1.66 +    E_BADCMAP = 4,          // The font does not contain any useful cmaps
    1.67 +    E_NOSILF = 5,           // Missing Silf table
    1.68 +    E_TOOOLD = 6,           // Silf table version is too old
    1.69 +    E_BADSIZE = 7,          // context object has the wrong structural size
    1.70 +// Silf Subtable Errors take a Silf subtable number * 256 in the context
    1.71 +    E_BADMAXGLYPH = 8,      // Silf max glyph id is too high
    1.72 +    E_BADNUMJUSTS = 9,      // Number of Silf justification blocks is too high
    1.73 +    E_BADENDJUSTS = 10,     // Silf justification blocks take too much of the Silf table space
    1.74 +    E_BADCRITFEATURES = 11, // Critical features section in a Silf table is too big
    1.75 +    E_BADSCRIPTTAGS = 12,   // Silf script tags area is too big
    1.76 +    E_BADAPSEUDO = 13,      // The pseudo glyph attribute number is too high
    1.77 +    E_BADABREAK = 14,       // The linebreak glyph attribute number is too high
    1.78 +    E_BADABIDI = 15,        // The bidi glyph attribute number is too high
    1.79 +    E_BADAMIRROR = 16,      // The mirrored glyph attribute number is too high
    1.80 +    E_BADNUMPASSES = 17,    // The number of passes is > 128
    1.81 +    E_BADPASSESSTART = 18,  // The Silf table is too small to hold any passes
    1.82 +    E_BADPASSBOUND = 19,    // The positioning pass number is too low or the substitution pass number is too high
    1.83 +    E_BADPPASS = 20,        // The positioning pass number is too high
    1.84 +    E_BADSPASS = 21,        // the substitution pass number is too high
    1.85 +    E_BADJPASSBOUND = 22,   // the justification pass must be higher than the positioning pass
    1.86 +    E_BADJPASS = 23,        // the justification pass is too high
    1.87 +    E_BADALIG = 24,         // the number of initial ligature component glyph attributes is too high
    1.88 +    E_BADBPASS = 25,        // the bidi pass number is specified and is either too high or too low
    1.89 +    E_BADNUMPSEUDO = 26,    // The number of pseudo glyphs is too high
    1.90 +    E_BADCLASSSIZE = 27,    // The size of the classes block is bad
    1.91 +    E_TOOMANYLINEAR = 28,   // The number of linear classes in the silf table is too high
    1.92 +    E_CLASSESTOOBIG = 29,   // There are too many classes for the space allocated in the Silf subtable
    1.93 +    E_MISALIGNEDCLASSES = 30,   // The class offsets in the class table don't line up with the number of classes
    1.94 +    E_HIGHCLASSOFFSET = 31, // The class offsets point out of the class table
    1.95 +    E_BADCLASSOFFSET = 32,  // A class offset is less than one following it
    1.96 +    E_BADCLASSLOOKUPINFO = 33,  // The search header info for a non-linear class has wrong values in it
    1.97 +// Pass subtable errors. Context has pass number * 65536
    1.98 +    E_BADPASSSTART = 34,    // The start offset for a particular pass is bad
    1.99 +    E_BADPASSEND = 35,      // The end offset for a particular pass is bad
   1.100 +    E_BADPASSLENGTH = 36,   // The length of the pass is too small
   1.101 +    E_BADNUMTRANS = 37,     // The number of transition states in the fsm is bad
   1.102 +    E_BADNUMSUCCESS = 38,   // The number of success states in the fsm is bad
   1.103 +    E_BADNUMSTATES = 39,    // The number of states in the fsm is bad
   1.104 +    E_NORANGES = 40,        // There are no columns in the fsm
   1.105 +    E_BADRULEMAPLEN = 41,   // The size of the success state to rule mapping is bad
   1.106 +    E_BADCTXTLENBOUNDS = 42,    // The precontext maximum is greater than its minimum
   1.107 +    E_BADCTXTLENS = 43,     // The lists of rule lengths or pre context lengths is bad
   1.108 +    E_BADPASSCCODEPTR = 44, // The pass constraint code position does not align with where the forward reference says it should be
   1.109 +    E_BADRULECCODEPTR = 45, // The rule constraint code position does not align with where the forward reference says it should be
   1.110 +    E_BADCCODELEN = 46,     // Bad rule/pass constraint code length
   1.111 +    E_BADACTIONCODEPTR = 47,    // The action code position does not align with where the forward reference says it should be
   1.112 +    E_MUTABLECCODE = 48,    // Constraint code edits slots. It shouldn't.
   1.113 +    E_BADSTATE = 49,        // Bad state transition referencing an illegal state
   1.114 +    E_BADRULEMAPPING = 50,  // The structure of the rule mapping is bad
   1.115 +    E_BADRANGE = 51,        // Bad column range structure including a glyph in more than one column
   1.116 +    E_BADRULENUM = 52,      // A reference to a rule is out of range (too high)
   1.117 +// Code errors
   1.118 +    E_CODEFAILURE = 60,     // Base code error. The following subcodes must align with Machine::Code::status_t in Code.h
   1.119 +        E_CODEALLOC = 61,       // Out of memory
   1.120 +        E_INVALIDOPCODE = 62,   // Invalid op code
   1.121 +        E_UNIMPOPCODE = 63,     // Unimplemented op code encountered
   1.122 +        E_OUTOFRANGECODE = 64,  // Code argument out of range
   1.123 +        E_BADJUMPCODE = 65,     // Code jumps past end of op codes
   1.124 +        E_CODEBADARGS = 66,     // Code arguments exhausted
   1.125 +        E_CODENORETURN = 67,    // Missing return type op code at end of code
   1.126 +        E_CODENESTEDCTXT = 68   // Nested context encountered in code
   1.127 +};
   1.128 +
   1.129 +}
   1.130 +

mercurial