Replace gr version of fixedwidth types with cstdint types instead
diff --git a/doc/building.txt b/doc/building.txt index 4fb146e..3950b40 100644 --- a/doc/building.txt +++ b/doc/building.txt
@@ -4,7 +4,7 @@ https://github.com/silnrsi/graphite/releases or + http://sf.net/projects/silgraphite/files/graphite2 -While Graphite 2 is written in C++11 it is written in a subset that ensures no +While Graphite 2 is written in C++11, it is written in a subset that ensures no runtime dependency on the language runtime. Graphite 2 uses cmake for its build system. The basic build procedure is to
diff --git a/gr2fonttest/UtfCodec.cpp b/gr2fonttest/UtfCodec.cpp index c7b71e8..75f3fef 100644 --- a/gr2fonttest/UtfCodec.cpp +++ b/gr2fonttest/UtfCodec.cpp
@@ -27,19 +27,15 @@ #include "UtfCodec.h" //using namespace graphite2; -namespace graphite2 { - -} - using namespace graphite2; -const int8 _utf_codec<8>::sz_lut[16] = +const int8_t _utf_codec<8>::sz_lut[16] = { - 1,1,1,1,1,1,1,1, // 1 byte - 0,0,0,0, // trailing byte - 2,2, // 2 bytes - 3, // 3 bytes - 4 // 4 bytes + 1,1,1,1,1,1,1,1, // 1 uint8_t + 0,0,0,0, // trailing uint8_t + 2,2, // 2 bytes + 3, // 3 bytes + 4 // 4 bytes }; -const byte _utf_codec<8>::mask_lut[5] = {0x7f, 0xff, 0x3f, 0x1f, 0x0f}; +const uint8_t _utf_codec<8>::mask_lut[5] = {0x7f, 0xff, 0x3f, 0x1f, 0x0f};
diff --git a/gr2fonttest/UtfCodec.h b/gr2fonttest/UtfCodec.h index c0207f8..a6655a7 100644 --- a/gr2fonttest/UtfCodec.h +++ b/gr2fonttest/UtfCodec.h
@@ -1,6 +1,6 @@ /* GRAPHITE2 LICENSING - Copyright 2010, SIL International + Copyright 2011, SIL International All rights reserved. This library is free software; you can redistribute it and/or modify @@ -26,28 +26,24 @@ */ #pragma once +#include <cstddef> +#include <cstdint> #include <cstdlib> -#include "graphite2/Types.h" -typedef gr_uint8 uint8; -typedef gr_uint8 byte; -typedef gr_uint16 uint16; -typedef gr_uint32 uint32; -typedef gr_int8 int8; -typedef gr_int16 int16; -typedef gr_int32 int32; +#define GR_FALLTHROUGH namespace graphite2 { -typedef uint32 uchar_t; +typedef uint32_t uchar_t; template <int N> struct _utf_codec { - typedef uchar_t codeunit_t; + typedef uchar_t codeunit_t; - static void put(codeunit_t * cp, const uchar_t , int8 & len) throw(); - static uchar_t get(const codeunit_t * cp, int8 & len) throw(); + static void put(codeunit_t * cp, const uchar_t , int8_t & len) throw(); + static uchar_t get(const codeunit_t * cp, int8_t & len) throw(); + static bool validate(const codeunit_t * s, const codeunit_t * e) throw(); }; @@ -55,22 +51,28 @@ struct _utf_codec<32> { private: - static const uchar_t limit = 0x110000; + static const uchar_t limit = 0x110000; public: - typedef uint32 codeunit_t; + typedef uint32_t codeunit_t; - inline - static void put(codeunit_t * cp, const uchar_t usv, int8 & l) throw() - { - *cp = usv; l = 1; - } + inline + static void put(codeunit_t * cp, const uchar_t usv, int8_t & l) throw() + { + *cp = usv; l = 1; + } - inline - static uchar_t get(const codeunit_t * cp, int8 & l) throw() - { - if (cp[0] < limit) { l = 1; return cp[0]; } - else { l = -1; return 0xFFFD; } - } + inline + static uchar_t get(const codeunit_t * cp, int8_t & l) throw() + { + if (cp[0] < limit) { l = 1; return cp[0]; } + else { l = -1; return 0xFFFD; } + } + + inline + static bool validate(codeunit_t * s, codeunit_t * e) throw() + { + return e > s; + } }; @@ -78,35 +80,44 @@ struct _utf_codec<16> { private: - static const int32 lead_offset = 0xD800 - (0x10000 >> 10); - static const int32 surrogate_offset = 0x10000 - (0xD800 << 10) - 0xDC00; + static const int32_t lead_offset = 0xD800 - (0x10000 >> 10); + static const int32_t surrogate_offset = 0x10000 - (0xD800 << 10) - 0xDC00; public: - typedef uint16 codeunit_t; + typedef uint16_t codeunit_t; - inline - static void put(codeunit_t * cp, const uchar_t usv, int8 & l) throw() - { - if (usv < 0x10000) { l = 1; cp[0] = codeunit_t(usv); } - else - { - cp[0] = codeunit_t(lead_offset + (usv >> 10)); - cp[1] = codeunit_t(0xDC00 + (usv & 0x3FF)); - l = 2; - } - } + inline + static void put(codeunit_t * cp, const uchar_t usv, int8_t & l) throw() + { + if (usv < 0x10000) { l = 1; cp[0] = codeunit_t(usv); } + else + { + cp[0] = codeunit_t(lead_offset + (usv >> 10)); + cp[1] = codeunit_t(0xDC00 + (usv & 0x3FF)); + l = 2; + } + } - inline - static uchar_t get(const codeunit_t * cp, int8 & l) throw() - { - const uint32 uh = cp[0]; - l = 1; + inline + static uchar_t get(const codeunit_t * cp, int8_t & l) throw() + { + const uint32_t uh = cp[0]; + l = 1; - if (0xD800 > uh || uh > 0xDFFF) { return uh; } - const uint32 ul = cp[1]; - if (uh > 0xDBFF || 0xDC00 > ul || ul > 0xDFFF) { l = -1; return 0xFFFD; } - ++l; - return (uh<<10) + ul + surrogate_offset; - } + if (uh < 0xD800|| uh > 0xDFFF) { return uh; } + const uint32_t ul = cp[1]; + if (uh > 0xDBFF || ul < 0xDC00 || ul > 0xDFFF) { l = -1; return 0xFFFD; } + ++l; + return (uh<<10) + ul + surrogate_offset; + } + + inline + static bool validate(codeunit_t * s, codeunit_t * e) throw() + { + const ptrdiff_t n = e-s; + if (n <= 0) return n == 0; + const uint32_t u = *(s+(n-1)); // Get the last codepoint + return (u < 0xD800 || u > 0xDBFF); + } }; @@ -114,105 +125,128 @@ struct _utf_codec<8> { private: - static const int8 sz_lut[16]; - static const byte mask_lut[5]; - + static const int8_t sz_lut[16]; + static const uint8_t mask_lut[5]; + static const uchar_t limit = 0x110000; public: - typedef uint8 codeunit_t; + typedef uint8_t codeunit_t; - inline - static void put(codeunit_t * cp, const uchar_t usv, int8 & l) throw() - { - if (usv < 0x80) {l = 1; cp[0] = usv; return; } - if (usv < 0x0800) {l = 2; cp[0] = 0xC0 + (usv >> 6); cp[1] = 0x80 + (usv & 0x3F); return; } - if (usv < 0x10000) {l = 3; cp[0] = 0xE0 + (usv >> 12); cp[1] = 0x80 + ((usv >> 6) & 0x3F); cp[2] = 0x80 + (usv & 0x3F); return; } - else {l = 4; cp[0] = 0xF0 + (usv >> 18); cp[1] = 0x80 + ((usv >> 12) & 0x3F); cp[2] = 0x80 + ((usv >> 6) & 0x3F); cp[3] = 0x80 + (usv & 0x3F); return; } - } + inline + static void put(codeunit_t * cp, const uchar_t usv, int8_t & l) throw() + { + if (usv < 0x80) {l = 1; cp[0] = usv; return; } + if (usv < 0x0800) {l = 2; cp[0] = 0xC0 + (usv >> 6); cp[1] = 0x80 + (usv & 0x3F); return; } + if (usv < 0x10000) {l = 3; cp[0] = 0xE0 + (usv >> 12); cp[1] = 0x80 + ((usv >> 6) & 0x3F); cp[2] = 0x80 + (usv & 0x3F); return; } + else {l = 4; cp[0] = 0xF0 + (usv >> 18); cp[1] = 0x80 + ((usv >> 12) & 0x3F); cp[2] = 0x80 + ((usv >> 6) & 0x3F); cp[3] = 0x80 + (usv & 0x3F); return; } + } - inline - static uchar_t get(const codeunit_t * cp, int8 & l) throw() - { - const int8 seq_sz = sz_lut[*cp >> 4]; - uchar_t u = *cp & mask_lut[seq_sz]; - l = 1; - bool toolong = false; + inline + static uchar_t get(const codeunit_t * cp, int8_t & l) throw() + { + const int8_t seq_sz = sz_lut[*cp >> 4]; + uchar_t u = *cp & mask_lut[seq_sz]; + l = 1; + bool toolong = false; - switch(seq_sz) { - case 4: u <<= 6; u |= *++cp & 0x3F; if (*cp >> 6 != 2) break; ++l; toolong = (u < 0x10); - // no break - case 3: u <<= 6; u |= *++cp & 0x3F; if (*cp >> 6 != 2) break; ++l; toolong |= (u < 0x20); - // no break - case 2: u <<= 6; u |= *++cp & 0x3F; if (*cp >> 6 != 2) break; ++l; toolong |= (u < 0x80); - // no break - case 1: break; - case 0: l = -1; return 0xFFFD; - } + switch(seq_sz) { + case 4: u <<= 6; u |= *++cp & 0x3F; if (*cp >> 6 != 2) break; ++l; toolong = (u < 0x10); GR_FALLTHROUGH; + // no break + case 3: u <<= 6; u |= *++cp & 0x3F; if (*cp >> 6 != 2) break; ++l; toolong |= (u < 0x20); GR_FALLTHROUGH; + // no break + case 2: u <<= 6; u |= *++cp & 0x3F; if (*cp >> 6 != 2) break; ++l; toolong |= (u < 0x80); GR_FALLTHROUGH; + // no break + case 1: break; + case 0: l = -1; return 0xFFFD; + } - if (l != seq_sz || toolong) - { - l = -l; - return 0xFFFD; - } - return u; - } + if (l != seq_sz || toolong || u >= limit) + { + l = -l; + return 0xFFFD; + } + return u; + } + + inline + static bool validate(codeunit_t * s, codeunit_t * e) throw() + { + const ptrdiff_t n = e-s; + if (n <= 0) return n == 0; + s += (n-1); + if (*s < 0x80) return true; + if (*s >= 0xC0) return false; + if (n == 1) return true; + if (*--s < 0x80) return true; + if (*s >= 0xe0) return false; + if (n == 2 || *s >= 0xC0) return true; + if (*--s < 0x80) return true; + if (*s >= 0xF0) return false; + return true; + } + }; template <typename C> class _utf_iterator { - typedef _utf_codec<sizeof(C)*8> codec; + typedef _utf_codec<sizeof(C)*8> codec; - C * cp; - mutable int8 sl; + C * cp; + mutable int8_t sl; public: - typedef C codeunit_type; - typedef uchar_t value_type; - typedef uchar_t * pointer; + typedef C codeunit_type; + typedef uchar_t value_type; + typedef uchar_t * pointer; - class reference - { - const _utf_iterator & _i; + class reference + { + const _utf_iterator & _i; - reference(const _utf_iterator & i): _i(i) {} - public: - operator value_type () const throw () { return codec::get(_i.cp, _i.sl); } - reference & operator = (const value_type usv) throw() { codec::put(_i.cp, usv, _i.sl); return *this; } + reference(const _utf_iterator & i): _i(i) {} + public: + operator value_type () const throw () { return codec::get(_i.cp, _i.sl); } + reference & operator = (const value_type usv) throw() { codec::put(_i.cp, usv, _i.sl); return *this; } - friend class _utf_iterator; - }; + friend class _utf_iterator; + }; - _utf_iterator(const void * us=0) : cp(reinterpret_cast<C *>(const_cast<void *>(us))), sl(1) { } + _utf_iterator(const void * us=0) : cp(reinterpret_cast<C *>(const_cast<void *>(us))), sl(1) { } - _utf_iterator & operator ++ () { cp += abs(sl); return *this; } - _utf_iterator operator ++ (int) { _utf_iterator tmp(*this); operator++(); return tmp; } + _utf_iterator & operator ++ () { cp += abs(sl); return *this; } + _utf_iterator operator ++ (int) { _utf_iterator tmp(*this); operator++(); return tmp; } - bool operator == (const _utf_iterator & rhs) const throw() { return cp >= rhs.cp; } - bool operator != (const _utf_iterator & rhs) const throw() { return !operator==(rhs); } + bool operator == (const _utf_iterator & rhs) const throw() { return cp >= rhs.cp; } + bool operator != (const _utf_iterator & rhs) const throw() { return !operator==(rhs); } - reference operator * () const throw() { return *this; } - pointer operator ->() const throw() { return &operator *(); } + reference operator * () const throw() { return *this; } + pointer operator ->() const throw() { return &operator *(); } - operator codeunit_type * () const throw() { return cp; } + operator codeunit_type * () const throw() { return cp; } - bool error() const throw() { return sl < 1; } + bool error() const throw() { return sl < 1; } }; template <typename C> struct utf { - typedef typename _utf_codec<sizeof(C)*8>::codeunit_t codeunit_t; + typedef typename _utf_codec<sizeof(C)*8>::codeunit_t codeunit_t; - typedef _utf_iterator<C> iterator; - typedef _utf_iterator<const C> const_iterator; + typedef _utf_iterator<C> iterator; + typedef _utf_iterator<const C> const_iterator; + + inline + static bool validate(codeunit_t * s, codeunit_t * e) throw() { + return _utf_codec<sizeof(C)*8>::validate(s,e); + } }; -typedef utf<uint32> utf32; -typedef utf<uint16> utf16; -typedef utf<uint8> utf8; +typedef utf<uint32_t> utf32; +typedef utf<uint16_t> utf16; +typedef utf<uint8_t> utf8; } // namespace graphite2
diff --git a/gr2fonttest/gr2FontTest.cpp b/gr2fonttest/gr2FontTest.cpp index a20ddcd..591857f 100644 --- a/gr2fonttest/gr2FontTest.cpp +++ b/gr2fonttest/gr2FontTest.cpp
@@ -202,7 +202,7 @@ codesize = 4; bool argError = false; char* pText = NULL; - typedef enum + enum TestOptions { NONE, POINT_SIZE, @@ -218,7 +218,7 @@ TRACE, ALLTRACE, SIZE - } TestOptions; + }; TestOptions option = NONE; char * pIntEnd = NULL; char * pFloatEnd = NULL; @@ -487,7 +487,7 @@ return (argError) ? false : true; } -typedef gr_uint32 tag_t; +typedef uint32_t tag_t; void Parameters::printFeatures(const gr_face * face) const {
diff --git a/include/graphite2/Types.h b/include/graphite2/Types.h index 916c911..a55caf1 100644 --- a/include/graphite2/Types.h +++ b/include/graphite2/Types.h
@@ -27,17 +27,18 @@ #pragma once #include <stddef.h> +#include <stdint.h> -typedef unsigned char gr_uint8; -typedef gr_uint8 gr_byte; -typedef signed char gr_int8; -typedef unsigned short gr_uint16; -typedef short gr_int16; -typedef unsigned int gr_uint32; -typedef int gr_int32; +typedef uint8_t gr_uint8; +typedef uint8_t gr_byte; +typedef int8_t gr_int8; +typedef uint16_t gr_uint16; +typedef int16_t gr_int16; +typedef uint32_t gr_uint32; +typedef int32_t gr_int32; enum gr_encform { - gr_utf8 = 1/*sizeof(uint8)*/, gr_utf16 = 2/*sizeof(uint16)*/, gr_utf32 = 4/*sizeof(uint32)*/ + gr_utf8 = 1/*sizeof(uint8_t)*/, gr_utf16 = 2/*sizeof(uint16_t)*/, gr_utf32 = 4/*sizeof(uint32_t)*/ };
diff --git a/src/CmapCache.cpp b/src/CmapCache.cpp index d070019..3d3555d 100644 --- a/src/CmapCache.cpp +++ b/src/CmapCache.cpp
@@ -58,18 +58,18 @@ } template <unsigned int (*NextCodePoint)(const void *, unsigned int, int *), - uint16 (*LookupCodePoint)(const void *, unsigned int, int)> -bool cache_subtable(uint16 * blocks[], const void * cst, const unsigned int limit) + uint16_t (*LookupCodePoint)(const void *, unsigned int, int)> +bool cache_subtable(uint16_t * blocks[], const void * cst, const unsigned int limit) { int rangeKey = 0; - uint32 codePoint = NextCodePoint(cst, 0, &rangeKey), + uint32_t codePoint = NextCodePoint(cst, 0, &rangeKey), prevCodePoint = 0; while (codePoint < limit) { unsigned int block = codePoint >> 8; if (!blocks[block]) { - blocks[block] = grzeroalloc<uint16>(0x100); + blocks[block] = grzeroalloc<uint16_t>(0x100); if (!blocks[block]) return false; } @@ -95,7 +95,7 @@ const void * smp_cmap = smp_subtable(cmap); m_isBmpOnly = !smp_cmap; - m_blocks = grzeroalloc<uint16 *>(m_isBmpOnly ? 0x100 : 0x1100); + m_blocks = grzeroalloc<uint16_t *>(m_isBmpOnly ? 0x100 : 0x1100); if (m_blocks && smp_cmap) { if (!cache_subtable<TtfUtil::CmapSubtable12NextCodepoint, TtfUtil::CmapSubtable12Lookup>(m_blocks, smp_cmap, 0x10FFFF)) @@ -118,11 +118,11 @@ free(m_blocks); } -uint16 CachedCmap::operator [] (const uint32 usv) const throw() +uint16_t CachedCmap::operator [] (const uint32_t usv) const throw() { if ((m_isBmpOnly && usv > 0xFFFF) || (usv > 0x10FFFF)) return 0; - const uint32 block = 0xFFFF & (usv >> 8); + const uint32_t block = 0xFFFF & (usv >> 8); if (m_blocks[block]) return m_blocks[block][usv & 0xFF]; return 0; @@ -141,7 +141,7 @@ { } -uint16 DirectCmap::operator [] (const uint32 usv) const throw() +uint16_t DirectCmap::operator [] (const uint32_t usv) const throw() { return usv > 0xFFFF ? (_smp ? TtfUtil::CmapSubtable12Lookup(_smp, usv, 0) : 0)
diff --git a/src/Code.cpp b/src/Code.cpp index 5cff6b5..d590786 100644 --- a/src/Code.cpp +++ b/src/Code.cpp
@@ -66,12 +66,12 @@ struct context { - context(uint8 ref=0) : codeRef(ref) {flags.changed=false; flags.referenced=false;} + context(uint8_t ref=0) : codeRef(ref) {flags.changed=false; flags.referenced=false;} struct { - uint8 changed:1, + uint8_t changed:1, referenced:1; } flags; - uint8 codeRef; + uint8_t codeRef; }; } // end namespace @@ -85,48 +85,48 @@ decoder(limits & lims, Code &code, enum passtype pt) throw(); - bool load(const byte * bc_begin, const byte * bc_end); + bool load(const uint8_t * bc_begin, const uint8_t * bc_end); void apply_analysis(instr * const code, instr * code_end); - byte max_ref() { return _max_ref; } + uint8_t max_ref() { return _max_ref; } int out_index() const { return _out_index; } private: void set_ref(int index) throw(); void set_noref(int index) throw(); void set_changed(int index) throw(); - opcode fetch_opcode(const byte * bc); - void analyse_opcode(const opcode, const int8 * const dp) throw(); - bool emit_opcode(opcode opc, const byte * & bc); - bool validate_opcode(const byte opc, const byte * const bc); - bool valid_upto(const uint16 limit, const uint16 x) const throw(); + opcode fetch_opcode(const uint8_t * bc); + void analyse_opcode(const opcode, const int8_t * const dp) throw(); + bool emit_opcode(opcode opc, const uint8_t * & bc); + bool validate_opcode(const uint8_t opc, const uint8_t * const bc); + bool valid_upto(const uint16_t limit, const uint16_t x) const throw(); bool test_context() const throw(); - bool test_ref(int8 index) const throw(); + bool test_ref(int8_t index) const throw(); void failure(const status_t s) const throw() { _code.failure(s); } Code & _code; int _out_index; - uint16 _out_length; + uint16_t _out_length; instr * _instr; - byte * _data; + uint8_t * _data; limits & _max; enum passtype _passtype; int _stack_depth; bool _in_ctxt_item; - int16 _slotref; + int16_t _slotref; context _contexts[NUMCONTEXTS]; - byte _max_ref; + uint8_t _max_ref; }; struct Machine::Code::decoder::limits { - const byte * bytecode; - const uint8 pre_context; - const uint16 rule_length, + const uint8_t * bytecode; + const uint8_t pre_context; + const uint16_t rule_length, classes, glyf_attrs, features; - const byte attrid[gr_slatMax]; + const uint8_t attrid[gr_slatMax]; }; inline Machine::Code::decoder::decoder(limits & lims, Code &code, enum passtype pt) throw() @@ -142,9 +142,9 @@ -Machine::Code::Code(bool is_constraint, const byte * bytecode_begin, const byte * const bytecode_end, - uint8 pre_context, uint16 rule_length, const Silf & silf, const Face & face, - enum passtype pt, byte * * const _out) +Machine::Code::Code(bool is_constraint, const uint8_t * bytecode_begin, const uint8_t * const bytecode_end, + uint8_t pre_context, uint16_t rule_length, const Silf & silf, const Face & face, + enum passtype pt, uint8_t * * const _out) : _code(0), _data(0), _data_size(0), _instr_count(0), _max_ref(0), _status(loaded), _constraint(is_constraint), _modify(false), _delete(false), _own(_out==0) { @@ -164,7 +164,7 @@ // estimate. Once we know their real sizes the we'll shrink them. if (_out) _code = reinterpret_cast<instr *>(*_out); else _code = static_cast<instr *>(malloc(estimateCodeDataOut(bytecode_end-bytecode_begin, 1, is_constraint ? 0 : rule_length))); - _data = reinterpret_cast<byte *>(_code + (bytecode_end - bytecode_begin)); + _data = reinterpret_cast<uint8_t *>(_code + (bytecode_end - bytecode_begin)); if (!_code || !_data) { failure(alloc_failed); @@ -214,7 +214,7 @@ // memory. assert((bytecode_end - bytecode_begin) >= ptrdiff_t(_instr_count)); assert((bytecode_end - bytecode_begin) >= ptrdiff_t(_data_size)); - memmove(_code + (_instr_count+1), _data, _data_size*sizeof(byte)); + memmove(_code + (_instr_count+1), _data, _data_size*sizeof(uint8_t)); size_t const total_sz = ((_instr_count+1) + (_data_size + sizeof(instr)-1)/sizeof(instr))*sizeof(instr); if (_out) *_out += total_sz; @@ -224,7 +224,7 @@ _code = static_cast<instr *>(realloc(_code, total_sz)); if (!_code) free(old_code); } - _data = reinterpret_cast<byte *>(_code + (_instr_count+1)); + _data = reinterpret_cast<uint8_t *>(_code + (_instr_count+1)); if (!_code) { @@ -247,7 +247,7 @@ } -bool Machine::Code::decoder::load(const byte * bc, const byte * bc_end) +bool Machine::Code::decoder::load(const uint8_t * bc, const uint8_t * bc_end) { _max.bytecode = bc_end; while (bc < bc_end) @@ -256,7 +256,7 @@ if (opc == vm::MAX_OPCODE) return false; - analyse_opcode(opc, reinterpret_cast<const int8 *>(bc)); + analyse_opcode(opc, reinterpret_cast<const int8_t *>(bc)); if (!emit_opcode(opc, bc)) return false; @@ -268,9 +268,9 @@ // Validation check and fixups. // -opcode Machine::Code::decoder::fetch_opcode(const byte * bc) +opcode Machine::Code::decoder::fetch_opcode(const uint8_t * bc) { - const byte opc = *bc++; + const uint8_t opc = *bc++; // Do some basic sanity checks based on what we know about the opcode if (!validate_opcode(opc, bc)) return MAX_OPCODE; @@ -333,13 +333,13 @@ test_context(); break; case PUT_SUBS_8BIT_OBS : - test_ref(int8(bc[0])); + test_ref(int8_t(bc[0])); valid_upto(_max.classes, bc[1]); valid_upto(_max.classes, bc[2]); test_context(); break; case PUT_COPY : - test_ref(int8(bc[0])); + test_ref(int8_t(bc[0])); test_context(); break; case INSERT : @@ -363,12 +363,12 @@ case ASSOC : if (bc[0] == 0) failure(out_of_range_data); - for (uint8 num = bc[0]; num; --num) - test_ref(int8(bc[num])); + for (uint8_t num = bc[0]; num; --num) + test_ref(int8_t(bc[num])); test_context(); break; case CNTXT_ITEM : - valid_upto(_max.rule_length, _max.pre_context + int8(bc[0])); + valid_upto(_max.rule_length, _max.pre_context + int8_t(bc[0])); if (bc + 2 + bc[1] >= _max.bytecode) failure(jump_past_end); if (_in_ctxt_item) failure(nested_context_item); break; @@ -393,7 +393,7 @@ case PUSH_SLOT_ATTR : ++_stack_depth; valid_upto(gr_slatMax, bc[0]); - test_ref(int8(bc[1])); + test_ref(int8_t(bc[1])); if (attrCode(bc[0]) == gr_slatUserDefn) // use IATTR for user attributes failure(out_of_range_data); break; @@ -401,25 +401,25 @@ case PUSH_ATT_TO_GATTR_OBS : ++_stack_depth; valid_upto(_max.glyf_attrs, bc[0]); - test_ref(int8(bc[1])); + test_ref(int8_t(bc[1])); break; case PUSH_ATT_TO_GLYPH_METRIC : case PUSH_GLYPH_METRIC : ++_stack_depth; valid_upto(kgmetDescent, bc[0]); - test_ref(int8(bc[1])); + test_ref(int8_t(bc[1])); // level: dp[2] no check necessary break; case PUSH_FEAT : ++_stack_depth; valid_upto(_max.features, bc[0]); - test_ref(int8(bc[1])); + test_ref(int8_t(bc[1])); break; case PUSH_ISLOT_ATTR : ++_stack_depth; if (valid_upto(gr_slatMax, bc[0])) { - test_ref(int8(bc[1])); + test_ref(int8_t(bc[1])); valid_upto(_max.attrid[bc[0]], bc[2]); } break; @@ -448,27 +448,27 @@ ++_stack_depth; break; case PUT_SUBS : - test_ref(int8(bc[0])); - valid_upto(_max.classes, uint16(bc[1]<< 8) | bc[2]); - valid_upto(_max.classes, uint16(bc[3]<< 8) | bc[4]); + test_ref(int8_t(bc[0])); + valid_upto(_max.classes, uint16_t(bc[1]<< 8) | bc[2]); + valid_upto(_max.classes, uint16_t(bc[3]<< 8) | bc[4]); test_context(); break; case PUT_SUBS2 : // not implemented case PUT_SUBS3 : // not implemented break; case PUT_GLYPH : - valid_upto(_max.classes, uint16(bc[0]<< 8) | bc[1]); + valid_upto(_max.classes, uint16_t(bc[0]<< 8) | bc[1]); test_context(); break; case PUSH_GLYPH_ATTR : case PUSH_ATT_TO_GLYPH_ATTR : ++_stack_depth; - valid_upto(_max.glyf_attrs, uint16(bc[0]<< 8) | bc[1]); - test_ref(int8(bc[2])); + valid_upto(_max.glyf_attrs, uint16_t(bc[0]<< 8) | bc[1]); + test_ref(int8_t(bc[2])); break; case SET_FEAT : valid_upto(_max.features, bc[0]); - test_ref(int8(bc[1])); + test_ref(int8_t(bc[1])); break; default: failure(invalid_opcode); @@ -479,7 +479,7 @@ } -void Machine::Code::decoder::analyse_opcode(const opcode opc, const int8 * arg) throw() +void Machine::Code::decoder::analyse_opcode(const opcode opc, const int8_t * arg) throw() { switch (opc) { @@ -488,7 +488,7 @@ break; case ASSOC : set_changed(0); -// for (uint8 num = arg[0]; num; --num) +// for (uint8_t num = arg[0]; num; --num) // _analysis.set_noref(num); break; case PUT_GLYPH_8BIT_OBS : @@ -509,7 +509,7 @@ case NEXT : case COPY_NEXT : ++_slotref; - _contexts[_slotref] = context(uint8(_code._instr_count+1)); + _contexts[_slotref] = context(uint8_t(_code._instr_count+1)); // if (_analysis.slotref > _analysis.max_ref) _analysis.max_ref = _analysis.slotref; break; case INSERT : @@ -546,7 +546,7 @@ } -bool Machine::Code::decoder::emit_opcode(opcode opc, const byte * & bc) +bool Machine::Code::decoder::emit_opcode(opcode opc, const uint8_t * & bc) { const opcode_t * op_to_fn = Machine::getOpcodeTable(); const opcode_t & op = op_to_fn[opc]; @@ -564,7 +564,7 @@ // Grab the parameters if (param_sz) { - memcpy(_data, bc, param_sz * sizeof(byte)); + memcpy(_data, bc, param_sz * sizeof(uint8_t)); bc += param_sz; _data += param_sz; _code._data_size += param_sz; @@ -576,21 +576,21 @@ { assert(_out_index == 0); _in_ctxt_item = true; - _out_index = _max.pre_context + int8(_data[-2]); - _slotref = int8(_data[-2]); + _out_index = _max.pre_context + int8_t(_data[-2]); + _slotref = int8_t(_data[-2]); _out_length = _max.rule_length; const size_t ctxt_start = _code._instr_count; - byte & instr_skip = _data[-1]; - byte & data_skip = *_data++; + uint8_t & instr_skip = _data[-1]; + uint8_t & data_skip = *_data++; ++_code._data_size; - const byte *curr_end = _max.bytecode; + const uint8_t *curr_end = _max.bytecode; if (load(bc, bc + instr_skip)) { bc += instr_skip; - data_skip = instr_skip - byte(_code._instr_count - ctxt_start); - instr_skip = byte(_code._instr_count - ctxt_start); + data_skip = instr_skip - uint8_t(_code._instr_count - ctxt_start); + instr_skip = uint8_t(_code._instr_count - ctxt_start); _max.bytecode = curr_end; _out_length = 1; @@ -634,7 +634,7 @@ inline -bool Machine::Code::decoder::validate_opcode(const byte opc, const byte * const bc) +bool Machine::Code::decoder::validate_opcode(const uint8_t opc, const uint8_t * const bc) { if (opc >= MAX_OPCODE) { @@ -662,7 +662,7 @@ } -bool Machine::Code::decoder::valid_upto(const uint16 limit, const uint16 x) const throw() +bool Machine::Code::decoder::valid_upto(const uint16_t limit, const uint16_t x) const throw() { const bool t = (limit != 0) && (x < limit); if (!t) failure(out_of_range_data); @@ -670,7 +670,7 @@ } inline -bool Machine::Code::decoder::test_ref(int8 index) const throw() +bool Machine::Code::decoder::test_ref(int8_t index) const throw() { if (_code._constraint && !_in_ctxt_item) { @@ -735,7 +735,7 @@ } -int32 Machine::Code::run(Machine & m, slotref * & map) const +int32_t Machine::Code::run(Machine & m, slotref * & map) const { // assert(_own); assert(*this); // Check we are actually runnable
diff --git a/src/Collider.cpp b/src/Collider.cpp index 53d498c..626f9bb 100644 --- a/src/Collider.cpp +++ b/src/Collider.cpp
@@ -480,7 +480,7 @@ // Process sub-boxes that are defined for this glyph. // We only need to do this if there was in fact a collision with the main octabox. - uint8 numsub = gc.numSubBounds(gid); + uint8_t numsub = gc.numSubBounds(gid); if (numsub > 0) { bool anyhits = false; @@ -766,7 +766,7 @@ unsigned short gid = s->gid(); float sx = s->origin().x + shift.x; float sy = s->origin().y + shift.y; - uint8 numsub = gc.numSubBounds(gid); + uint8_t numsub = gc.numSubBounds(gid); float res = isRight ? (float)-1e38 : (float)1e38; if (numsub > 0) @@ -1074,8 +1074,8 @@ // Initialize slot attributes from glyph attributes. // The order here must match the order in the grcompiler code, // GrcSymbolTable::AssignInternalGlyphAttrIDs. - uint16 gid = slot->gid(); - uint16 aCol = seg->silf()->aCollision(); // flags attr ID + uint16_t gid = slot->gid(); + uint16_t aCol = seg->silf()->aCollision(); // flags attr ID const GlyphFace * glyphFace = seg->getFace()->glyphs().glyphSafe(gid); if (!glyphFace) return;
diff --git a/src/Face.cpp b/src/Face.cpp index 9ed0903..8ec2f71 100644 --- a/src/Face.cpp +++ b/src/Face.cpp
@@ -87,7 +87,7 @@ return font.face().glyphs().glyph(glyphid)->theAdvance().x * font.scale(); } -bool Face::readGlyphs(uint32 faceOptions) +bool Face::readGlyphs(uint32_t faceOptions) { Error e; #ifdef GRAPHITE2_TELEMETRY @@ -123,16 +123,16 @@ #endif Error e; error_context(EC_READSILF); - const byte * p = silf; + const uint8_t * p = silf; if (e.test(!p, E_NOSILF) || e.test(silf.size() < 20, E_BADSIZE)) return error(e); - const uint32 version = be::read<uint32>(p); + const uint32_t version = be::read<uint32_t>(p); if (e.test(version < 0x00020000, E_TOOOLD)) return error(e); if (version >= 0x00030000) - be::skip<uint32>(p); // compilerVersion - m_numSilf = be::read<uint16>(p); + be::skip<uint32_t>(p); // compilerVersion + m_numSilf = be::read<uint16_t>(p); - be::skip<uint16>(p); // reserved + be::skip<uint16_t>(p); // reserved bool havePasses = false; m_silfs = new Silf[m_numSilf]; @@ -140,8 +140,8 @@ for (int i = 0; i < m_numSilf; i++) { error_context(EC_ASILF + (i << 8)); - const uint32 offset = be::read<uint32>(p), - next = i == m_numSilf - 1 ? uint32(silf.size()) : be::peek<uint32>(p); + const uint32_t offset = be::read<uint32_t>(p), + next = i == m_numSilf - 1 ? uint32_t(silf.size()) : be::peek<uint32_t>(p); if (e.test(next > silf.size() || offset >= next, E_BADSIZE)) return error(e); @@ -217,7 +217,7 @@ #endif } -const Silf *Face::chooseSilf(uint32 script) const +const Silf *Face::chooseSilf(uint32_t script) const { if (m_numSilf == 0) return NULL; @@ -227,12 +227,12 @@ return m_silfs; } -uint16 Face::findPseudo(uint32 uid) const +uint16_t Face::findPseudo(uint32_t uid) const { return (m_numSilf) ? m_silfs[0].findPseudo(uid) : 0; } -int32 Face::getGlyphMetric(uint16 gid, uint8 metric) const +int32_t Face::getGlyphMetric(uint16_t gid, uint8_t metric) const { switch (metrics(metric)) { @@ -264,7 +264,7 @@ return m_pNames; } -uint16 Face::languageForLocale(const char * locale) const +uint16_t Face::languageForLocale(const char * locale) const { nameTable(); if (m_pNames) @@ -274,12 +274,12 @@ -Face::Table::Table(const Face & face, const Tag n, uint32 version) throw() +Face::Table::Table(const Face & face, const Tag n, uint32_t version) throw() : _f(&face), _compressed(false) { size_t sz = 0; - _p = static_cast<const byte *>((*_f->m_ops.get_table)(_f->m_appFaceHandle, n, &sz)); - _sz = uint32(sz); + _p = static_cast<const uint8_t *>((*_f->m_ops.get_table)(_f->m_appFaceHandle, n, &sz)); + _sz = uint32_t(sz); if (!TtfUtil::CheckTable(n, _p, _sz)) { @@ -287,14 +287,14 @@ return; } - if (be::peek<uint32>(_p) >= version) + if (be::peek<uint32_t>(_p) >= version) decompress(); } void Face::Table::releaseBuffers() { if (_compressed) - free(const_cast<byte *>(_p)); + free(const_cast<uint8_t *>(_p)); else if (_p && _f->m_ops.release_table) (*_f->m_ops.release_table)(_f->m_appFaceHandle, _p); _p = 0; _sz = 0; @@ -312,16 +312,16 @@ Error Face::Table::decompress() { Error e; - if (e.test(_sz < 5 * sizeof(uint32), E_BADSIZE)) + if (e.test(_sz < 5 * sizeof(uint32_t), E_BADSIZE)) return e; - byte * uncompressed_table = 0; + uint8_t * uncompressed_table = 0; size_t uncompressed_size = 0; - const byte * p = _p; - const uint32 version = be::read<uint32>(p); // Table version number. + const uint8_t * p = _p; + const uint32_t version = be::read<uint32_t>(p); // Table version number. - // The scheme is in the top 5 bits of the 1st uint32. - const uint32 hdr = be::read<uint32>(p); + // The scheme is in the top 5 bits of the 1st uint32_t. + const uint32_t hdr = be::read<uint32_t>(p); switch(compression(hdr >> 27)) { case NONE: return e; @@ -329,13 +329,13 @@ case LZ4: { uncompressed_size = hdr & 0x07ffffff; - uncompressed_table = gralloc<byte>(uncompressed_size); + uncompressed_table = gralloc<uint8_t>(uncompressed_size); if (!e.test(!uncompressed_table || uncompressed_size < 4, E_OUTOFMEM)) { memset(uncompressed_table, 0, 4); // make sure version number is initialised // coverity[forward_null : FALSE] - uncompressed_table has been checked so can't be null // coverity[checked_return : FALSE] - we test e later - e.test(lz4::decompress(p, _sz - 2*sizeof(uint32), uncompressed_table, uncompressed_size) != signed(uncompressed_size), E_SHRINKERFAILED); + e.test(lz4::decompress(p, _sz - 2*sizeof(uint32_t), uncompressed_table, uncompressed_size) != signed(uncompressed_size), E_SHRINKERFAILED); } break; } @@ -348,7 +348,7 @@ if (!e) // coverity[forward_null : FALSE] - uncompressed_table has already been tested so can't be null // coverity[checked_return : FALSE] - we test e later - e.test(be::peek<uint32>(uncompressed_table) != version, E_SHRINKERFAILED); + e.test(be::peek<uint32_t>(uncompressed_table) != version, E_SHRINKERFAILED); // Tell the provider to release the compressed form since were replacing // it anyway.
diff --git a/src/FeatureMap.cpp b/src/FeatureMap.cpp index e63415d..07bcc8c 100644 --- a/src/FeatureMap.cpp +++ b/src/FeatureMap.cpp
@@ -48,21 +48,21 @@ return (a < b ? -1 : (b < a ? 1 : 0)); } - const size_t FEAT_HEADER = sizeof(uint32) + 2*sizeof(uint16) + sizeof(uint32), - FEATURE_SIZE = sizeof(uint32) - + 2*sizeof(uint16) - + sizeof(uint32) - + 2*sizeof(uint16), - FEATURE_SETTING_SIZE = sizeof(int16) + sizeof(uint16); + const size_t FEAT_HEADER = sizeof(uint32_t) + 2*sizeof(uint16_t) + sizeof(uint32_t), + FEATURE_SIZE = sizeof(uint32_t) + + 2*sizeof(uint16_t) + + sizeof(uint32_t) + + 2*sizeof(uint16_t), + FEATURE_SETTING_SIZE = sizeof(int16_t) + sizeof(uint16_t); - uint16 readFeatureSettings(const byte * p, FeatureSetting * s, size_t num_settings) + uint16_t readFeatureSettings(const uint8_t * p, FeatureSetting * s, size_t num_settings) { - uint16 max_val = 0; + uint16_t max_val = 0; for (FeatureSetting * const end = s + num_settings; s != end; ++s) { - const int16 value = be::read<int16>(p); - ::new (s) FeatureSetting(value, be::read<uint16>(p)); - if (uint16(value) > max_val) max_val = value; + const int16_t value = be::read<int16_t>(p); + ::new (s) FeatureSetting(value, be::read<uint16_t>(p)); + if (uint16_t(value) > max_val) max_val = value; } return max_val; @@ -70,9 +70,9 @@ } FeatureRef::FeatureRef(const Face & face, - unsigned short & bits_offset, uint32 max_val, - uint32 name, uint16 uiName, uint16 flags, - FeatureSetting *settings, uint16 num_set) throw() + unsigned short & bits_offset, uint32_t max_val, + uint32_t name, uint16_t uiName, uint16_t flags, + FeatureSetting *settings, uint16_t num_set) throw() : m_face(&face), m_nameValues(settings), m_mask(mask_over_val(max_val)), @@ -82,7 +82,7 @@ m_flags(flags), m_numSet(num_set) { - const uint8 need_bits = bit_set_count(m_mask); + const uint8_t need_bits = bit_set_count(m_mask); m_index = (bits_offset + need_bits) / SIZEOF_CHUNK; if (m_index > bits_offset / SIZEOF_CHUNK) bits_offset = m_index*SIZEOF_CHUNK; @@ -99,17 +99,17 @@ bool FeatureMap::readFeats(const Face & face) { const Face::Table feat(face, TtfUtil::Tag::Feat); - const byte * p = feat; + const uint8_t * p = feat; if (!p) return true; if (feat.size() < FEAT_HEADER) return false; - const byte *const feat_start = p, + const uint8_t *const feat_start = p, *const feat_end = p + feat.size(); - const uint32 version = be::read<uint32>(p); - m_numFeats = be::read<uint16>(p); - be::skip<uint16>(p); - be::skip<uint32>(p); + const uint32_t version = be::read<uint32_t>(p); + m_numFeats = be::read<uint16_t>(p); + be::skip<uint16_t>(p); + be::skip<uint32_t>(p); // Sanity checks if (m_numFeats == 0) return true; @@ -121,19 +121,19 @@ } m_feats = new FeatureRef [m_numFeats]; - uint16 * const defVals = gralloc<uint16>(m_numFeats); + uint16_t * const defVals = gralloc<uint16_t>(m_numFeats); if (!defVals || !m_feats) return false; unsigned short bits = 0; //to cause overflow on first Feature for (int i = 0, ie = m_numFeats; i != ie; i++) { - const uint32 label = version < 0x00020000 ? be::read<uint16>(p) : be::read<uint32>(p); - const uint16 num_settings = be::read<uint16>(p); + const uint32_t label = version < 0x00020000 ? be::read<uint16_t>(p) : be::read<uint32_t>(p); + const uint16_t num_settings = be::read<uint16_t>(p); if (version >= 0x00020000) - be::skip<uint16>(p); - const uint32 settings_offset = be::read<uint32>(p); - const uint16 flags = be::read<uint16>(p), - uiName = be::read<uint16>(p); + be::skip<uint16_t>(p); + const uint32_t settings_offset = be::read<uint32_t>(p); + const uint16_t flags = be::read<uint16_t>(p), + uiName = be::read<uint16_t>(p); if (settings_offset > size_t(feat_end - feat_start) || settings_offset + num_settings * FEATURE_SETTING_SIZE > size_t(feat_end - feat_start)) @@ -143,7 +143,7 @@ } FeatureSetting *uiSet; - uint32 maxVal; + uint32_t maxVal; if (num_settings != 0) { uiSet = gralloc<FeatureSetting>(num_settings); @@ -166,7 +166,7 @@ label, uiName, flags, uiSet, num_settings); } - new (&m_defaultFeatures) Features(bits/(sizeof(uint32)*8) + 1, *this); + new (&m_defaultFeatures) Features(bits/(sizeof(uint32_t)*8) + 1, *this); m_pNamedFeats = new NameAndFeatureRef[m_numFeats]; if (!m_pNamedFeats) { @@ -197,12 +197,12 @@ bool SillMap::readSill(const Face & face) { const Face::Table sill(face, TtfUtil::Tag::Sill); - const byte *p = sill; + const uint8_t *p = sill; if (!p) return true; if (sill.size() < 12) return false; - if (be::read<uint32>(p) != 0x00010000UL) return false; - m_numLanguages = be::read<uint16>(p); + if (be::read<uint32_t>(p) != 0x00010000UL) return false; + m_numLanguages = be::read<uint16_t>(p); m_langFeats = new LangFeaturePair[m_numLanguages]; if (!m_langFeats || !m_FeatureMap.m_numFeats) { m_numLanguages = 0; return true; } //defensive @@ -211,19 +211,19 @@ for (int i = 0; i < m_numLanguages; i++) { - uint32 langid = be::read<uint32>(p); - uint16 numSettings = be::read<uint16>(p); - uint16 offset = be::read<uint16>(p); + uint32_t langid = be::read<uint32_t>(p); + uint16_t numSettings = be::read<uint16_t>(p); + uint16_t offset = be::read<uint16_t>(p); if (offset + 8U * numSettings > sill.size() && numSettings > 0) return false; Features* feats = new Features(m_FeatureMap.m_defaultFeatures); if (!feats) return false; - const byte *pLSet = sill + offset; + const uint8_t *pLSet = sill + offset; // Apply langauge specific settings for (int j = 0; j < numSettings; j++) { - uint32 name = be::read<uint32>(pLSet); - uint16 val = be::read<uint16>(pLSet); + uint32_t name = be::read<uint32_t>(pLSet); + uint16_t val = be::read<uint16_t>(pLSet); pLSet += 2; const FeatureRef* pRef = m_FeatureMap.findFeatureRef(name); if (pRef) pRef->applyValToFeature(val, *feats); @@ -239,13 +239,13 @@ } -Features* SillMap::cloneFeatures(uint32 langname/*0 means default*/) const +Features* SillMap::cloneFeatures(uint32_t langname/*0 means default*/) const { if (langname) { // the number of languages in a font is usually small e.g. 8 in Doulos // so this loop is not very expensive - for (uint16 i = 0; i < m_numLanguages; i++) + for (uint16_t i = 0; i < m_numLanguages; i++) { if (m_langFeats[i].m_lang == langname) return new Features(*m_langFeats[i].m_pFeatures); @@ -256,7 +256,7 @@ -const FeatureRef *FeatureMap::findFeatureRef(uint32 name) const +const FeatureRef *FeatureMap::findFeatureRef(uint32_t name) const { NameAndFeatureRef *it; @@ -266,7 +266,7 @@ return NULL; } -bool FeatureRef::applyValToFeature(uint32 val, Features & pDest) const +bool FeatureRef::applyValToFeature(uint32_t val, Features & pDest) const { if (val>maxVal() || !m_face) return false; @@ -278,11 +278,11 @@ if (m_index >= pDest.size()) pDest.resize(m_index+1); pDest[m_index] &= ~m_mask; - pDest[m_index] |= (uint32(val) << m_bits); + pDest[m_index] |= (uint32_t(val) << m_bits); return true; } -uint32 FeatureRef::getFeatureVal(const Features& feats) const +uint32_t FeatureRef::getFeatureVal(const Features& feats) const { if (m_index < feats.size() && m_face && &m_face->theSill().theFeatureMap()==feats.m_pMap)
diff --git a/src/GlyphCache.cpp b/src/GlyphCache.cpp index 6d050ce..66f9029 100644 --- a/src/GlyphCache.cpp +++ b/src/GlyphCache.cpp
@@ -46,14 +46,14 @@ template<typename W> class _glat_iterator : public std::iterator<std::input_iterator_tag, std::pair<sparse::key_type, sparse::mapped_type> > { - unsigned short key() const { return uint16(be::peek<W>(_e) + _n); } + unsigned short key() const { return uint16_t(be::peek<W>(_e) + _n); } unsigned int run() const { return be::peek<W>(_e+sizeof(W)); } void advance_entry() { _n = 0; _e = _v; be::skip<W>(_v,2); } public: - _glat_iterator(const void * glat=0) : _e(reinterpret_cast<const byte *>(glat)), _v(_e+2*sizeof(W)), _n(0) {} + _glat_iterator(const void * glat=0) : _e(reinterpret_cast<const uint8_t *>(glat)), _v(_e+2*sizeof(W)), _n(0) {} _glat_iterator<W> & operator ++ () { - ++_n; be::skip<uint16>(_v); + ++_n; be::skip<uint16_t>(_v); if (_n == run()) advance_entry(); return *this; } @@ -66,16 +66,16 @@ bool operator != (const _glat_iterator<W> & rhs) { return !operator==(rhs); } value_type operator * () const { - return value_type(key(), be::peek<uint16>(_v)); + return value_type(key(), be::peek<uint16_t>(_v)); } protected: - const byte * _e, * _v; + const uint8_t * _e, * _v; size_t _n; }; - typedef _glat_iterator<uint8> glat_iterator; - typedef _glat_iterator<uint16> glat2_iterator; + typedef _glat_iterator<uint8_t> glat_iterator; + typedef _glat_iterator<uint16_t> glat2_iterator; } const SlantBox SlantBox::empty = {0,0,0,0}; @@ -93,7 +93,7 @@ bool has_boxes() const throw(); const GlyphFace * read_glyph(unsigned short gid, GlyphFace &, int *numsubs) const throw(); - GlyphBox * read_box(uint16 gid, GlyphBox *curr, const GlyphFace & face) const throw(); + GlyphBox * read_box(uint16_t gid, GlyphBox *curr, const GlyphFace & face) const throw(); CLASS_NEW_DELETE; private: @@ -114,7 +114,7 @@ -GlyphCache::GlyphCache(const Face & face, const uint32 face_options) +GlyphCache::GlyphCache(const Face & face, const uint32_t face_options) : _glyph_loader(new Loader(face)), _glyphs(_glyph_loader && *_glyph_loader && _glyph_loader->num_glyphs() ? grzeroalloc<const GlyphFace *>(_glyph_loader->num_glyphs()) : 0), @@ -138,7 +138,7 @@ // thus assigning the &glyphs[0] to _glyphs[0] means _glyphs[0] points // to the entire array. const GlyphFace * loaded = _glyphs[0]; - for (uint16 gid = 1; loaded && gid != _num_glyphs; ++gid) + for (uint16_t gid = 1; loaded && gid != _num_glyphs; ++gid) _glyphs[gid] = loaded = _glyph_loader->read_glyph(gid, glyphs[gid], &numsubs); if (!loaded) @@ -151,7 +151,7 @@ GlyphBox * boxes = (GlyphBox *)gralloc<char>(_num_glyphs * sizeof(GlyphBox) + numsubs * 8 * sizeof(float)); GlyphBox * currbox = boxes; - for (uint16 gid = 0; currbox && gid != _num_glyphs; ++gid) + for (uint16_t gid = 0; currbox && gid != _num_glyphs; ++gid) { _boxes[gid] = currbox; currbox = _glyph_loader->read_box(gid, currbox, *_glyphs[gid]); @@ -199,7 +199,7 @@ if (_glyph_loader) { GlyphBox * * g = _boxes; - for (uint16 n = _num_glyphs; n; --n, ++g) + for (uint16_t n = _num_glyphs; n; --n, ++g) free(*g); } else @@ -272,18 +272,18 @@ _head = Face::Table(); return; } - const byte * p = m_pGloc; - int version = be::read<uint32>(p); - const uint16 flags = be::read<uint16>(p); - _num_attrs = be::read<uint16>(p); + const uint8_t * p = m_pGloc; + int version = be::read<uint32_t>(p); + const uint16_t flags = be::read<uint16_t>(p); + _num_attrs = be::read<uint16_t>(p); // We can accurately calculate the number of attributed glyphs by // subtracting the length of the attribids array (numAttribs long if present) // and dividing by either 2 or 4 depending on shor or lonf format _long_fmt = flags & 1; ptrdiff_t tmpnumgattrs = (m_pGloc.size() - (p - m_pGloc) - - sizeof(uint16)*(flags & 0x2 ? _num_attrs : 0)) - / (_long_fmt ? sizeof(uint32) : sizeof(uint16)) - 1; + - sizeof(uint16_t)*(flags & 0x2 ? _num_attrs : 0)) + / (_long_fmt ? sizeof(uint32_t) : sizeof(uint16_t)) - 1; if (version >= 0x00020000 || tmpnumgattrs < 0 || tmpnumgattrs > 65535 || _num_attrs == 0 || _num_attrs > 0x3000 // is this hard limit appropriate? @@ -296,7 +296,7 @@ _num_glyphs_attributes = static_cast<unsigned short>(tmpnumgattrs); p = m_pGlat; - version = be::read<uint32>(p); + version = be::read<uint32_t>(p); if (version >= 0x00040000 || (version >= 0x00030000 && m_pGlat.size() < 8)) // reject Glat tables that are too new { _head = Face::Table(); @@ -304,7 +304,7 @@ } else if (version >= 0x00030000) { - unsigned int glatflags = be::read<uint32>(p); + unsigned int glatflags = be::read<uint32_t>(p); _has_boxes = glatflags & 1; // delete this once the compiler is fixed _has_boxes = true; @@ -370,39 +370,39 @@ if (glyphid < _num_glyphs_attributes) { - const byte * gloc = m_pGloc; + const uint8_t * gloc = m_pGloc; size_t glocs = 0, gloce = 0; - be::skip<uint32>(gloc); - be::skip<uint16>(gloc,2); + be::skip<uint32_t>(gloc); + be::skip<uint16_t>(gloc,2); if (_long_fmt) { - if (8 + glyphid * sizeof(uint32) > m_pGloc.size()) + if (8 + glyphid * sizeof(uint32_t) > m_pGloc.size()) return 0; - be::skip<uint32>(gloc, glyphid); - glocs = be::read<uint32>(gloc); - gloce = be::peek<uint32>(gloc); + be::skip<uint32_t>(gloc, glyphid); + glocs = be::read<uint32_t>(gloc); + gloce = be::peek<uint32_t>(gloc); } else { - if (8 + glyphid * sizeof(uint16) > m_pGloc.size()) + if (8 + glyphid * sizeof(uint16_t) > m_pGloc.size()) return 0; - be::skip<uint16>(gloc, glyphid); - glocs = be::read<uint16>(gloc); - gloce = be::peek<uint16>(gloc); + be::skip<uint16_t>(gloc, glyphid); + glocs = be::read<uint16_t>(gloc); + gloce = be::peek<uint16_t>(gloc); } if (glocs >= m_pGlat.size() - 1 || gloce > m_pGlat.size()) return 0; - const uint32 glat_version = be::peek<uint32>(m_pGlat); + const uint32_t glat_version = be::peek<uint32_t>(m_pGlat); if (glat_version >= 0x00030000) { if (glocs >= gloce) return 0; - const byte * p = m_pGlat + glocs; - uint16 bmap = be::read<uint16>(p); - int num = bit_set_count((uint32)bmap); + const uint8_t * p = m_pGlat + glocs; + uint16_t bmap = be::read<uint16_t>(p); + int num = bit_set_count((uint32_t)bmap); if (numsubs) *numsubs += num; glocs += 6 + 8 * num; if (glocs > gloce) @@ -410,16 +410,16 @@ } if (glat_version < 0x00020000) { - if (gloce - glocs < 2*sizeof(byte)+sizeof(uint16) - || gloce - glocs > _num_attrs*(2*sizeof(byte)+sizeof(uint16))) + if (gloce - glocs < 2*sizeof(uint8_t)+sizeof(uint16_t) + || gloce - glocs > _num_attrs*(2*sizeof(uint8_t)+sizeof(uint16_t))) return 0; new (&glyph) GlyphFace(bbox, advance, glat_iterator(m_pGlat + glocs), glat_iterator(m_pGlat + gloce)); } else { - if (gloce - glocs < 3*sizeof(uint16) // can a glyph have no attributes? why not? - || gloce - glocs > _num_attrs*3*sizeof(uint16) - || glocs > m_pGlat.size() - 2*sizeof(uint16)) + if (gloce - glocs < 3*sizeof(uint16_t) // can a glyph have no attributes? why not? + || gloce - glocs > _num_attrs*3*sizeof(uint16_t) + || glocs > m_pGlat.size() - 2*sizeof(uint16_t)) return 0; new (&glyph) GlyphFace(bbox, advance, glat2_iterator(m_pGlat + glocs), glat2_iterator(m_pGlat + gloce)); } @@ -429,52 +429,52 @@ return &glyph; } -inline float scale_to(uint8 t, float zmin, float zmax) +inline float scale_to(uint8_t t, float zmin, float zmax) { return (zmin + t * (zmax - zmin) / 255); } -Rect readbox(Rect &b, uint8 zxmin, uint8 zymin, uint8 zxmax, uint8 zymax) +Rect readbox(Rect &b, uint8_t zxmin, uint8_t zymin, uint8_t zxmax, uint8_t zymax) { return Rect(Position(scale_to(zxmin, b.bl.x, b.tr.x), scale_to(zymin, b.bl.y, b.tr.y)), Position(scale_to(zxmax, b.bl.x, b.tr.x), scale_to(zymax, b.bl.y, b.tr.y))); } -GlyphBox * GlyphCache::Loader::read_box(uint16 gid, GlyphBox *curr, const GlyphFace & glyph) const throw() +GlyphBox * GlyphCache::Loader::read_box(uint16_t gid, GlyphBox *curr, const GlyphFace & glyph) const throw() { if (gid >= _num_glyphs_attributes) return 0; - const byte * gloc = m_pGloc; + const uint8_t * gloc = m_pGloc; size_t glocs = 0, gloce = 0; - be::skip<uint32>(gloc); - be::skip<uint16>(gloc,2); + be::skip<uint32_t>(gloc); + be::skip<uint16_t>(gloc,2); if (_long_fmt) { - be::skip<uint32>(gloc, gid); - glocs = be::read<uint32>(gloc); - gloce = be::peek<uint32>(gloc); + be::skip<uint32_t>(gloc, gid); + glocs = be::read<uint32_t>(gloc); + gloce = be::peek<uint32_t>(gloc); } else { - be::skip<uint16>(gloc, gid); - glocs = be::read<uint16>(gloc); - gloce = be::peek<uint16>(gloc); + be::skip<uint16_t>(gloc, gid); + glocs = be::read<uint16_t>(gloc); + gloce = be::peek<uint16_t>(gloc); } if (gloce > m_pGlat.size() || glocs + 6 >= gloce) return 0; - const byte * p = m_pGlat + glocs; - uint16 bmap = be::read<uint16>(p); - int num = bit_set_count((uint32)bmap); + const uint8_t * p = m_pGlat + glocs; + uint16_t bmap = be::read<uint16_t>(p); + int num = bit_set_count((uint32_t)bmap); Rect bbox = glyph.theBBox(); Rect diamax(Position(bbox.bl.x + bbox.bl.y, bbox.bl.x - bbox.tr.y), Position(bbox.tr.x + bbox.tr.y, bbox.tr.x - bbox.bl.y)); Rect diabound = readbox(diamax, p[0], p[2], p[1], p[3]); ::new (curr) GlyphBox(num, bmap, &diabound); - be::skip<uint8>(p, 4); + be::skip<uint8_t>(p, 4); if (glocs + 6 + num * 8 >= gloce) return 0; @@ -482,7 +482,7 @@ { Rect box = readbox((i & 1) ? diamax : bbox, p[0], p[2], p[1], p[3]); curr->addSubBox(i >> 1, i & 1, &box); - be::skip<uint8>(p, 4); + be::skip<uint8_t>(p, 4); } return (GlyphBox *)((char *)(curr) + sizeof(GlyphBox) + 2 * num * sizeof(Rect)); }
diff --git a/src/GlyphFace.cpp b/src/GlyphFace.cpp index bc5e63a..dac1112 100644 --- a/src/GlyphFace.cpp +++ b/src/GlyphFace.cpp
@@ -29,20 +29,20 @@ using namespace graphite2; -int32 GlyphFace::getMetric(uint8 metric) const +int32_t GlyphFace::getMetric(uint8_t metric) const { switch (metrics(metric)) { - case kgmetLsb : return int32(m_bbox.bl.x); - case kgmetRsb : return int32(m_advance.x - m_bbox.tr.x); - case kgmetBbTop : return int32(m_bbox.tr.y); - case kgmetBbBottom : return int32(m_bbox.bl.y); - case kgmetBbLeft : return int32(m_bbox.bl.x); - case kgmetBbRight : return int32(m_bbox.tr.x); - case kgmetBbHeight : return int32(m_bbox.tr.y - m_bbox.bl.y); - case kgmetBbWidth : return int32(m_bbox.tr.x - m_bbox.bl.x); - case kgmetAdvWidth : return int32(m_advance.x); - case kgmetAdvHeight : return int32(m_advance.y); + case kgmetLsb : return int32_t(m_bbox.bl.x); + case kgmetRsb : return int32_t(m_advance.x - m_bbox.tr.x); + case kgmetBbTop : return int32_t(m_bbox.tr.y); + case kgmetBbBottom : return int32_t(m_bbox.bl.y); + case kgmetBbLeft : return int32_t(m_bbox.bl.x); + case kgmetBbRight : return int32_t(m_bbox.tr.x); + case kgmetBbHeight : return int32_t(m_bbox.tr.y - m_bbox.bl.y); + case kgmetBbWidth : return int32_t(m_bbox.tr.x - m_bbox.bl.x); + case kgmetAdvWidth : return int32_t(m_advance.x); + case kgmetAdvHeight : return int32_t(m_advance.y); default : return 0; } }
diff --git a/src/Intervals.cpp b/src/Intervals.cpp index 0fe99a1..b247321 100644 --- a/src/Intervals.cpp +++ b/src/Intervals.cpp
@@ -57,7 +57,7 @@ } inline -uint8 Zones::Exclusion::outcode(float val) const { +uint8_t Zones::Exclusion::outcode(float val) const { float p = val; //float d = std::numeric_limits<float>::epsilon(); float d = 0.; @@ -96,7 +96,7 @@ for (iterator i = _exclusions.begin(), ie = _exclusions.end(); i != ie && e.x < e.xm; ++i) { - const uint8 oca = e.outcode(i->x), + const uint8_t oca = e.outcode(i->x), ocb = e.outcode(i->xm); if ((oca & ocb) != 0) continue; @@ -152,7 +152,7 @@ for (iterator i = _exclusions.begin(), ie = _exclusions.end(); i != ie; ++i) { - const uint8 oca = i->outcode(x), + const uint8_t oca = i->outcode(x), ocb = i->outcode(xm); if ((oca & ocb) != 0) continue;
diff --git a/src/Justifier.cpp b/src/Justifier.cpp index caf4e64..ef028ca 100644 --- a/src/Justifier.cpp +++ b/src/Justifier.cpp
@@ -154,14 +154,14 @@ if (!step) step = 1; // handle lazy font developers if (pref > 0) { - float max = uint16(s->getJustify(this, i, 0)); + float max = uint16_t(s->getJustify(this, i, 0)); if (i == 0) max -= s->just(); if (pref > max) pref = max; else tWeight += w; } else { - float max = uint16(s->getJustify(this, i, 1)); + float max = uint16_t(s->getJustify(this, i, 1)); if (i == 0) max += s->just(); if (-pref > max) pref = -max; else tWeight += w; @@ -239,7 +239,7 @@ { Slot *eSlot = newSlot(); if (!eSlot) return NULL; - const uint16 gid = silf()->endLineGlyphid(); + const uint16_t gid = silf()->endLineGlyphid(); const GlyphFace * theGlyph = m_face->glyphs().glyphSafe(gid); eSlot->setGlyph(this, gid, theGlyph); if (nSlot)
diff --git a/src/NameTable.cpp b/src/NameTable.cpp index d42b7f9..c5968e7 100644 --- a/src/NameTable.cpp +++ b/src/NameTable.cpp
@@ -32,26 +32,26 @@ using namespace graphite2; -NameTable::NameTable(const void* data, size_t length, uint16 platformId, uint16 encodingID) +NameTable::NameTable(const void* data, size_t length, uint16_t platformId, uint16_t encodingID) : m_platformId(0), m_encodingId(0), m_languageCount(0), m_platformOffset(0), m_platformLastRecord(0), m_nameDataLength(0), m_table(0), m_nameData(NULL) { - void *pdata = gralloc<byte>(length); + void *pdata = gralloc<uint8_t>(length); if (!pdata) return; memcpy(pdata, data, length); m_table = reinterpret_cast<const TtfUtil::Sfnt::FontNames*>(pdata); if ((length > sizeof(TtfUtil::Sfnt::FontNames)) && (length > sizeof(TtfUtil::Sfnt::FontNames) + - sizeof(TtfUtil::Sfnt::NameRecord) * ( be::swap<uint16>(m_table->count) - 1))) + sizeof(TtfUtil::Sfnt::NameRecord) * ( be::swap<uint16_t>(m_table->count) - 1))) { - uint16 offset = be::swap<uint16>(m_table->string_offset); + uint16_t offset = be::swap<uint16_t>(m_table->string_offset); if (offset < length) { - m_nameData = reinterpret_cast<const uint8*>(pdata) + offset; + m_nameData = reinterpret_cast<const uint8_t*>(pdata) + offset; setPlatformEncoding(platformId, encodingID); - m_nameDataLength = uint16(length - offset); + m_nameDataLength = uint16_t(length - offset); return; } } @@ -59,23 +59,23 @@ m_table = NULL; } -uint16 NameTable::setPlatformEncoding(uint16 platformId, uint16 encodingID) +uint16_t NameTable::setPlatformEncoding(uint16_t platformId, uint16_t encodingID) { if (!m_nameData) return 0; - uint16 i = 0; - uint16 count = be::swap<uint16>(m_table->count); + uint16_t i = 0; + uint16_t count = be::swap<uint16_t>(m_table->count); for (; i < count; i++) { - if (be::swap<uint16>(m_table->name_record[i].platform_id) == platformId && - be::swap<uint16>(m_table->name_record[i].platform_specific_id) == encodingID) + if (be::swap<uint16_t>(m_table->name_record[i].platform_id) == platformId && + be::swap<uint16_t>(m_table->name_record[i].platform_specific_id) == encodingID) { m_platformOffset = i; break; } } while ((++i < count) && - (be::swap<uint16>(m_table->name_record[i].platform_id) == platformId) && - (be::swap<uint16>(m_table->name_record[i].platform_specific_id) == encodingID)) + (be::swap<uint16_t>(m_table->name_record[i].platform_id) == platformId) && + (be::swap<uint16_t>(m_table->name_record[i].platform_specific_id) == encodingID)) { m_platformLastRecord = i; } @@ -84,28 +84,28 @@ return 0; } -void* NameTable::getName(uint16& languageId, uint16 nameId, gr_encform enc, uint32& length) +void* NameTable::getName(uint16_t& languageId, uint16_t nameId, gr_encform enc, uint32_t& length) { - uint16 anyLang = 0; - uint16 enUSLang = 0; - uint16 bestLang = 0; + uint16_t anyLang = 0; + uint16_t enUSLang = 0; + uint16_t bestLang = 0; if (!m_table) { languageId = 0; length = 0; return NULL; } - for (uint16 i = m_platformOffset; i <= m_platformLastRecord; i++) + for (uint16_t i = m_platformOffset; i <= m_platformLastRecord; i++) { - if (be::swap<uint16>(m_table->name_record[i].name_id) == nameId) + if (be::swap<uint16_t>(m_table->name_record[i].name_id) == nameId) { - uint16 langId = be::swap<uint16>(m_table->name_record[i].language_id); + uint16_t langId = be::swap<uint16_t>(m_table->name_record[i].language_id); if (langId == languageId) { bestLang = i; break; } - // MS language tags have the language in the lower byte, region in the higher + // MS language tags have the language in the lower uint8_t, region in the higher else if ((langId & 0xFF) == (languageId & 0xFF)) { bestLang = i; @@ -135,9 +135,9 @@ } } const TtfUtil::Sfnt::NameRecord & nameRecord = m_table->name_record[bestLang]; - languageId = be::swap<uint16>(nameRecord.language_id); - uint16 utf16Length = be::swap<uint16>(nameRecord.length); - uint16 offset = be::swap<uint16>(nameRecord.offset); + languageId = be::swap<uint16_t>(nameRecord.language_id); + uint16_t utf16Length = be::swap<uint16_t>(nameRecord.length); + uint16_t offset = be::swap<uint16_t>(nameRecord.offset); if(offset + utf16Length > m_nameDataLength) { languageId = 0; @@ -152,10 +152,10 @@ length = 0; return NULL; } - const uint8* pName = m_nameData + offset; + const uint8_t* pName = m_nameData + offset; for (size_t i = 0; i < utf16Length; i++) { - utf16Name[i] = be::read<uint16>(pName); + utf16Name[i] = be::read<uint16_t>(pName); } utf16Name[utf16Length] = 0; if (!utf16::validate(utf16Name, utf16Name + utf16Length)) @@ -180,7 +180,7 @@ utf8::iterator d = uniBuffer; for (utf16::const_iterator s = utf16Name, e = utf16Name + utf16Length; s != e; ++s, ++d) *d = *s; - length = uint32(d - uniBuffer); + length = uint32_t(d - uniBuffer); uniBuffer[length] = 0; free(utf16Name); return uniBuffer; @@ -201,7 +201,7 @@ utf32::iterator d = uniBuffer; for (utf16::const_iterator s = utf16Name, e = utf16Name + utf16Length; s != e; ++s, ++d) *d = *s; - length = uint32(d - uniBuffer); + length = uint32_t(d - uniBuffer); uniBuffer[length] = 0; free(utf16Name); return uniBuffer; @@ -213,31 +213,31 @@ return NULL; } -uint16 NameTable::getLanguageId(const char * bcp47Locale) +uint16_t NameTable::getLanguageId(const char * bcp47Locale) { size_t localeLength = strlen(bcp47Locale); - uint16 localeId = m_locale2Lang.getMsId(bcp47Locale); - if (m_table && (be::swap<uint16>(m_table->format) == 1)) + uint16_t localeId = m_locale2Lang.getMsId(bcp47Locale); + if (m_table && (be::swap<uint16_t>(m_table->format) == 1)) { - const uint8 * pLangEntries = reinterpret_cast<const uint8*>(m_table) + + const uint8_t * pLangEntries = reinterpret_cast<const uint8_t*>(m_table) + sizeof(TtfUtil::Sfnt::FontNames) - + sizeof(TtfUtil::Sfnt::NameRecord) * ( be::swap<uint16>(m_table->count) - 1); - uint16 numLangEntries = be::read<uint16>(pLangEntries); + + sizeof(TtfUtil::Sfnt::NameRecord) * ( be::swap<uint16_t>(m_table->count) - 1); + uint16_t numLangEntries = be::read<uint16_t>(pLangEntries); const TtfUtil::Sfnt::LangTagRecord * langTag = reinterpret_cast<const TtfUtil::Sfnt::LangTagRecord*>(pLangEntries); if (pLangEntries + numLangEntries * sizeof(TtfUtil::Sfnt::LangTagRecord) <= m_nameData) { - for (uint16 i = 0; i < numLangEntries; i++) + for (uint16_t i = 0; i < numLangEntries; i++) { - uint16 offset = be::swap<uint16>(langTag[i].offset); - uint16 length = be::swap<uint16>(langTag[i].length); + uint16_t offset = be::swap<uint16_t>(langTag[i].offset); + uint16_t length = be::swap<uint16_t>(langTag[i].length); if ((offset + length <= m_nameDataLength) && (length == 2 * localeLength)) { - const uint8* pName = m_nameData + offset; + const uint8_t* pName = m_nameData + offset; bool match = true; for (size_t j = 0; j < localeLength; j++) { - uint16 code = be::read<uint16>(pName); + uint16_t code = be::read<uint16_t>(pName); if ((code > 0x7F) || (code != bcp47Locale[j])) { match = false;
diff --git a/src/Pass.cpp b/src/Pass.cpp index 76d4983..3bef533 100644 --- a/src/Pass.cpp +++ b/src/Pass.cpp
@@ -90,16 +90,16 @@ free(m_progs); } -bool Pass::readPass(const byte * const pass_start, size_t pass_length, size_t subtable_base, - GR_MAYBE_UNUSED Face & face, passtype pt, GR_MAYBE_UNUSED uint32 version, Error &e) +bool Pass::readPass(const uint8_t * const pass_start, size_t pass_length, size_t subtable_base, + GR_MAYBE_UNUSED Face & face, passtype pt, GR_MAYBE_UNUSED uint32_t version, Error &e) { - const byte * p = pass_start, + const uint8_t * p = pass_start, * const pass_end = p + pass_length; size_t numRanges; if (e.test(pass_length < 40, E_BADPASSLENGTH)) return face.error(e); // Read in basic values - const byte flags = be::read<byte>(p); + const uint8_t flags = be::read<uint8_t>(p); if (e.test((flags & 0x1f) && (pt < PASS_TYPE_POSITIONING || !m_silf->aCollision() || !face.glyphs().hasBoxes() || !(m_silf->flags() & 0x20)), E_BADCOLLISIONPASS)) @@ -107,22 +107,22 @@ m_numCollRuns = flags & 0x7; m_kernColls = (flags >> 3) & 0x3; m_isReverseDir = (flags >> 5) & 0x1; - m_iMaxLoop = be::read<byte>(p); + m_iMaxLoop = be::read<uint8_t>(p); if (m_iMaxLoop < 1) m_iMaxLoop = 1; - be::skip<byte>(p,2); // skip maxContext & maxBackup - m_numRules = be::read<uint16>(p); + be::skip<uint8_t>(p,2); // skip maxContext & maxBackup + m_numRules = be::read<uint16_t>(p); if (e.test(!m_numRules && m_numCollRuns == 0, E_BADEMPTYPASS)) return face.error(e); - be::skip<uint16>(p); // fsmOffset - not sure why we would want this - const byte * const pcCode = pass_start + be::read<uint32>(p) - subtable_base, - * const rcCode = pass_start + be::read<uint32>(p) - subtable_base, - * const aCode = pass_start + be::read<uint32>(p) - subtable_base; - be::skip<uint32>(p); - m_numStates = be::read<uint16>(p); - m_numTransition = be::read<uint16>(p); - m_numSuccess = be::read<uint16>(p); - m_numColumns = be::read<uint16>(p); - numRanges = be::read<uint16>(p); - be::skip<uint16>(p, 3); // skip searchRange, entrySelector & rangeShift. + be::skip<uint16_t>(p); // fsmOffset - not sure why we would want this + const uint8_t * const pcCode = pass_start + be::read<uint32_t>(p) - subtable_base, + * const rcCode = pass_start + be::read<uint32_t>(p) - subtable_base, + * const aCode = pass_start + be::read<uint32_t>(p) - subtable_base; + be::skip<uint32_t>(p); + m_numStates = be::read<uint16_t>(p); + m_numTransition = be::read<uint16_t>(p); + m_numSuccess = be::read<uint16_t>(p); + m_numColumns = be::read<uint16_t>(p); + numRanges = be::read<uint16_t>(p); + be::skip<uint16_t>(p, 3); // skip searchRange, entrySelector & rangeShift. assert(p - pass_start == 40); // Perform some sanity checks. if ( e.test(m_numTransition > m_numStates, E_BADNUMTRANS) @@ -133,56 +133,56 @@ return face.error(e); m_successStart = m_numStates - m_numSuccess; - // test for beyond end - 1 to account for reading uint16 + // test for beyond end - 1 to account for reading uint16_t if (e.test(p + numRanges * 6 - 2 > pass_end, E_BADPASSLENGTH)) return face.error(e); - m_numGlyphs = be::peek<uint16>(p + numRanges * 6 - 4) + 1; + m_numGlyphs = be::peek<uint16_t>(p + numRanges * 6 - 4) + 1; // Calculate the start of various arrays. - const byte * const ranges = p; - be::skip<uint16>(p, numRanges*3); - const byte * const o_rule_map = p; - be::skip<uint16>(p, m_numSuccess + 1); + const uint8_t * const ranges = p; + be::skip<uint16_t>(p, numRanges*3); + const uint8_t * const o_rule_map = p; + be::skip<uint16_t>(p, m_numSuccess + 1); // More sanity checks - if (e.test(reinterpret_cast<const byte *>(o_rule_map + m_numSuccess*sizeof(uint16)) > pass_end + if (e.test(reinterpret_cast<const uint8_t *>(o_rule_map + m_numSuccess*sizeof(uint16_t)) > pass_end || p > pass_end, E_BADRULEMAPLEN)) return face.error(e); - const size_t numEntries = be::peek<uint16>(o_rule_map + m_numSuccess*sizeof(uint16)); - const byte * const rule_map = p; - be::skip<uint16>(p, numEntries); + const size_t numEntries = be::peek<uint16_t>(o_rule_map + m_numSuccess*sizeof(uint16_t)); + const uint8_t * const rule_map = p; + be::skip<uint16_t>(p, numEntries); - if (e.test(p + 2*sizeof(uint8) > pass_end, E_BADPASSLENGTH)) return face.error(e); - m_minPreCtxt = be::read<uint8>(p); - m_maxPreCtxt = be::read<uint8>(p); + if (e.test(p + 2*sizeof(uint8_t) > pass_end, E_BADPASSLENGTH)) return face.error(e); + m_minPreCtxt = be::read<uint8_t>(p); + m_maxPreCtxt = be::read<uint8_t>(p); if (e.test(m_minPreCtxt > m_maxPreCtxt, E_BADCTXTLENBOUNDS)) return face.error(e); - const byte * const start_states = p; - be::skip<int16>(p, m_maxPreCtxt - m_minPreCtxt + 1); - const uint16 * const sort_keys = reinterpret_cast<const uint16 *>(p); - be::skip<uint16>(p, m_numRules); - const byte * const precontext = p; - be::skip<byte>(p, m_numRules); + const uint8_t * const start_states = p; + be::skip<int16_t>(p, m_maxPreCtxt - m_minPreCtxt + 1); + const uint16_t * const sort_keys = reinterpret_cast<const uint16_t *>(p); + be::skip<uint16_t>(p, m_numRules); + const uint8_t * const precontext = p; + be::skip<uint8_t>(p, m_numRules); - if (e.test(p + sizeof(uint16) + sizeof(uint8) > pass_end, E_BADCTXTLENS)) return face.error(e); - m_colThreshold = be::read<uint8>(p); + if (e.test(p + sizeof(uint16_t) + sizeof(uint8_t) > pass_end, E_BADCTXTLENS)) return face.error(e); + m_colThreshold = be::read<uint8_t>(p); if (m_colThreshold == 0) m_colThreshold = 10; // A default - const size_t pass_constraint_len = be::read<uint16>(p); + const size_t pass_constraint_len = be::read<uint16_t>(p); - const uint16 * const o_constraint = reinterpret_cast<const uint16 *>(p); - be::skip<uint16>(p, m_numRules + 1); - const uint16 * const o_actions = reinterpret_cast<const uint16 *>(p); - be::skip<uint16>(p, m_numRules + 1); - const byte * const states = p; + const uint16_t * const o_constraint = reinterpret_cast<const uint16_t *>(p); + be::skip<uint16_t>(p, m_numRules + 1); + const uint16_t * const o_actions = reinterpret_cast<const uint16_t *>(p); + be::skip<uint16_t>(p, m_numRules + 1); + const uint8_t * const states = p; if (e.test(2u*m_numTransition*m_numColumns >= (unsigned)(pass_end - p), E_BADPASSLENGTH) || e.test(p >= pass_end, E_BADPASSLENGTH)) return face.error(e); - be::skip<int16>(p, m_numTransition*m_numColumns); - be::skip<uint8>(p); + be::skip<int16_t>(p, m_numTransition*m_numColumns); + be::skip<uint8_t>(p); if (e.test(p != pcCode, E_BADPASSCCODEPTR)) return face.error(e); - be::skip<byte>(p, pass_constraint_len); + be::skip<uint8_t>(p, pass_constraint_len); if (e.test(p != rcCode, E_BADRULECCODEPTR) || e.test(size_t(rcCode - pcCode) != pass_constraint_len, E_BADCCODELEN)) return face.error(e); - be::skip<byte>(p, be::peek<uint16>(o_constraint + m_numRules)); + be::skip<uint8_t>(p, be::peek<uint16_t>(o_constraint + m_numRules)); if (e.test(p != aCode, E_BADACTIONCODEPTR)) return face.error(e); - be::skip<byte>(p, be::peek<uint16>(o_actions + m_numRules)); + be::skip<uint8_t>(p, be::peek<uint16_t>(o_actions + m_numRules)); // We should be at the end or within the pass if (e.test(p > pass_end, E_BADPASSLENGTH)) return face.error(e); @@ -192,7 +192,7 @@ { face.error_context(face.error_context() + 1); m_cPConstraint = vm::Machine::Code(true, pcCode, pcCode + pass_constraint_len, - precontext[0], be::peek<uint16>(sort_keys), *m_silf, face, PASS_TYPE_UNKNOWN); + precontext[0], be::peek<uint16_t>(sort_keys), *m_silf, face, PASS_TYPE_UNKNOWN); if (e.test(!m_cPConstraint, E_OUTOFMEM) || e.test(m_cPConstraint.status() != Code::loaded, m_cPConstraint.status() + E_CODEFAILURE)) return face.error(e); @@ -211,14 +211,14 @@ } -bool Pass::readRules(const byte * rule_map, const size_t num_entries, - const byte *precontext, const uint16 * sort_key, - const uint16 * o_constraint, const byte *rc_data, - const uint16 * o_action, const byte * ac_data, +bool Pass::readRules(const uint8_t * rule_map, const size_t num_entries, + const uint8_t *precontext, const uint16_t * sort_key, + const uint16_t * o_constraint, const uint8_t *rc_data, + const uint16_t * o_action, const uint8_t * ac_data, Face & face, passtype pt, Error &e) { - const byte * const ac_data_end = ac_data + be::peek<uint16>(o_action + m_numRules); - const byte * const rc_data_end = rc_data + be::peek<uint16>(o_constraint + m_numRules); + const uint8_t * const ac_data_end = ac_data + be::peek<uint16_t>(o_action + m_numRules); + const uint8_t * const rc_data_end = rc_data + be::peek<uint16_t>(o_constraint + m_numRules); precontext += m_numRules; sort_key += m_numRules; @@ -226,20 +226,20 @@ o_action += m_numRules; // Load rules. - const byte * ac_begin = 0, * rc_begin = 0, - * ac_end = ac_data + be::peek<uint16>(o_action), - * rc_end = rc_data + be::peek<uint16>(o_constraint); + const uint8_t * ac_begin = 0, * rc_begin = 0, + * ac_end = ac_data + be::peek<uint16_t>(o_action), + * rc_end = rc_data + be::peek<uint16_t>(o_constraint); // Allocate pools m_rules = new Rule [m_numRules]; m_codes = new Code [m_numRules*2]; int totalSlots = 0; - const uint16 *tsort = sort_key; + const uint16_t *tsort = sort_key; for (int i = 0; i < m_numRules; ++i) - totalSlots += be::peek<uint16>(--tsort); + totalSlots += be::peek<uint16_t>(--tsort); const size_t prog_pool_sz = vm::Machine::Code::estimateCodeDataOut(ac_end - ac_data + rc_end - rc_data, 2 * m_numRules, totalSlots); - m_progs = gralloc<byte>(prog_pool_sz); - byte * prog_pool_free = m_progs, + m_progs = gralloc<uint8_t>(prog_pool_sz); + uint8_t * prog_pool_free = m_progs, * prog_pool_end = m_progs + prog_pool_sz; if (e.test(!(m_rules && m_codes && m_progs), E_OUTOFMEM)) return face.error(e); @@ -248,15 +248,15 @@ { face.error_context((face.error_context() & 0xFFFF00) + EC_ARULE + int((n - 1) << 24)); r->preContext = *--precontext; - r->sort = be::peek<uint16>(--sort_key); + r->sort = be::peek<uint16_t>(--sort_key); #ifndef NDEBUG - r->rule_idx = uint16(n - 1); + r->rule_idx = uint16_t(n - 1); #endif if (r->sort > 63 || r->preContext >= r->sort || r->preContext > m_maxPreCtxt || r->preContext < m_minPreCtxt) return false; - ac_begin = ac_data + be::peek<uint16>(--o_action); + ac_begin = ac_data + be::peek<uint16_t>(--o_action); --o_constraint; - rc_begin = be::peek<uint16>(o_constraint) ? rc_data + be::peek<uint16>(o_constraint) : rc_end; + rc_begin = be::peek<uint16_t>(o_constraint) ? rc_data + be::peek<uint16_t>(o_constraint) : rc_end; if (ac_begin > ac_end || ac_begin > ac_data_end || ac_end > ac_data_end || rc_begin > rc_end || rc_begin > rc_data_end || rc_end > rc_data_end @@ -272,7 +272,7 @@ return face.error(e); } - byte * const moved_progs = prog_pool_free > m_progs ? static_cast<byte *>(realloc(m_progs, prog_pool_free - m_progs)) : 0; + uint8_t * const moved_progs = prog_pool_free > m_progs ? static_cast<uint8_t *>(realloc(m_progs, prog_pool_free - m_progs)) : 0; if (e.test(!moved_progs, E_OUTOFMEM)) { free(m_progs); @@ -296,7 +296,7 @@ if (e.test(!re, E_OUTOFMEM)) return face.error(e); for (size_t n = num_entries; n; --n, ++re) { - const ptrdiff_t rn = be::read<uint16>(rule_map); + const ptrdiff_t rn = be::read<uint16_t>(rule_map); if (e.test(rn >= m_numRules, E_BADRULENUM)) return face.error(e); re->rule = m_rules + rn; } @@ -307,12 +307,12 @@ static int cmpRuleEntry(const void *a, const void *b) { return (*(RuleEntry *)a < *(RuleEntry *)b ? -1 : (*(RuleEntry *)b < *(RuleEntry *)a ? 1 : 0)); } -bool Pass::readStates(const byte * starts, const byte *states, const byte * o_rule_map, GR_MAYBE_UNUSED Face & face, Error &e) +bool Pass::readStates(const uint8_t * starts, const uint8_t *states, const uint8_t * o_rule_map, GR_MAYBE_UNUSED Face & face, Error &e) { #ifdef GRAPHITE2_TELEMETRY telemetry::category _states_cat(face.tele.starts); #endif - m_startStates = gralloc<uint16>(m_maxPreCtxt - m_minPreCtxt + 1); + m_startStates = gralloc<uint16_t>(m_maxPreCtxt - m_minPreCtxt + 1); #ifdef GRAPHITE2_TELEMETRY telemetry::set_category(face.tele.states); #endif @@ -320,14 +320,14 @@ #ifdef GRAPHITE2_TELEMETRY telemetry::set_category(face.tele.transitions); #endif - m_transitions = gralloc<uint16>(m_numTransition * m_numColumns); + m_transitions = gralloc<uint16_t>(m_numTransition * m_numColumns); if (e.test(!m_startStates || !m_states || !m_transitions, E_OUTOFMEM)) return face.error(e); // load start states - for (uint16 * s = m_startStates, + for (uint16_t * s = m_startStates, * const s_end = s + m_maxPreCtxt - m_minPreCtxt + 1; s != s_end; ++s) { - *s = be::read<uint16>(starts); + *s = be::read<uint16_t>(starts); if (e.test(*s >= m_numStates, E_BADSTATE)) { face.error_context((face.error_context() & 0xFFFF00) + EC_ASTARTS + int((s - m_startStates) << 24)); @@ -336,10 +336,10 @@ } // load state transition table. - for (uint16 * t = m_transitions, + for (uint16_t * t = m_transitions, * const t_end = t + m_numTransition*m_numColumns; t != t_end; ++t) { - *t = be::read<uint16>(states); + *t = be::read<uint16_t>(states); if (e.test(*t >= m_numStates, E_BADSTATE)) { face.error_context((face.error_context() & 0xFFFF00) + EC_ATRANS + int(((t - m_transitions) / m_numColumns) << 8)); @@ -349,11 +349,11 @@ State * s = m_states, * const success_begin = m_states + m_numStates - m_numSuccess; - const RuleEntry * rule_map_end = m_ruleMap + be::peek<uint16>(o_rule_map + m_numSuccess*sizeof(uint16)); + const RuleEntry * rule_map_end = m_ruleMap + be::peek<uint16_t>(o_rule_map + m_numSuccess*sizeof(uint16_t)); for (size_t n = m_numStates; n; --n, ++s) { - RuleEntry * const begin = s < success_begin ? 0 : m_ruleMap + be::read<uint16>(o_rule_map), - * const end = s < success_begin ? 0 : m_ruleMap + be::peek<uint16>(o_rule_map); + RuleEntry * const begin = s < success_begin ? 0 : m_ruleMap + be::read<uint16_t>(o_rule_map), + * const end = s < success_begin ? 0 : m_ruleMap + be::peek<uint16_t>(o_rule_map); if (e.test(begin >= rule_map_end || end > rule_map_end || begin > end, E_BADRULEMAPPING)) { @@ -370,16 +370,16 @@ return true; } -bool Pass::readRanges(const byte * ranges, size_t num_ranges, Error &e) +bool Pass::readRanges(const uint8_t * ranges, size_t num_ranges, Error &e) { - m_cols = gralloc<uint16>(m_numGlyphs); + m_cols = gralloc<uint16_t>(m_numGlyphs); if (e.test(!m_cols, E_OUTOFMEM)) return false; - memset(m_cols, 0xFF, m_numGlyphs * sizeof(uint16)); + memset(m_cols, 0xFF, m_numGlyphs * sizeof(uint16_t)); for (size_t n = num_ranges; n; --n) { - uint16 * ci = m_cols + be::read<uint16>(ranges), - * ci_end = m_cols + be::read<uint16>(ranges) + 1, - col = be::read<uint16>(ranges); + uint16_t * ci = m_cols + be::read<uint16_t>(ranges), + * ci_end = m_cols + be::read<uint16_t>(ranges) + 1, + col = be::read<uint16_t>(ranges); if (e.test(ci >= ci_end || ci_end > m_cols+m_numGlyphs || col >= m_numColumns, E_BADRANGE)) return false; @@ -457,8 +457,8 @@ if (fsm.slots.context() < m_minPreCtxt) return false; - uint16 state = m_startStates[m_maxPreCtxt - fsm.slots.context()]; - uint8 free_slots = SlotMap::MAX_SLOTS; + uint16_t state = m_startStates[m_maxPreCtxt - fsm.slots.context()]; + uint8_t free_slots = SlotMap::MAX_SLOTS; do { fsm.slots.pushSlot(slot); @@ -468,7 +468,7 @@ || state >= m_numTransition) return free_slots != 0; - const uint16 * transitions = m_transitions + state*m_numColumns; + const uint16_t * transitions = m_transitions + state*m_numColumns; state = transitions[m_cols[slot->gid()]]; if (state >= m_successStart) fsm.rules.accumulate_rules(m_states[state]); @@ -623,7 +623,7 @@ m.slotMap().reset(*m.slotMap().segment.first(), 0); m.slotMap().pushSlot(m.slotMap().segment.first()); vm::slotref * map = m.slotMap().begin(); - const uint32 ret = m_cPConstraint.run(m, map); + const uint32_t ret = m_cPConstraint.run(m, map); #if !defined GRAPHITE2_NTRACING json * const dbgout = m.slotMap().segment.getFace()->logger(); @@ -637,7 +637,7 @@ bool Pass::testConstraint(const Rule & r, Machine & m) const { - const uint16 curr_context = m.slotMap().context(); + const uint16_t curr_context = m.slotMap().context(); if (unsigned(r.sort + curr_context - r.preContext) > m.slotMap().size() || curr_context - r.preContext < 0) return false; @@ -650,7 +650,7 @@ for (int n = r.sort; n && map; --n, ++map) { if (!*map) continue; - const int32 ret = r.constraint->run(m, map); + const int32_t ret = r.constraint->run(m, map); if (!ret || m.status() != Machine::finished) return false; } @@ -682,7 +682,7 @@ vm::slotref * map = &smap[smap.context()]; smap.highpassed(false); - int32 ret = codeptr->run(m, map); + int32_t ret = codeptr->run(m, map); if (m.status() != Machine::finished) {
diff --git a/src/Segment.cpp b/src/Segment.cpp index 0bb72e1..fc9fbe7 100644 --- a/src/Segment.cpp +++ b/src/Segment.cpp
@@ -42,7 +42,7 @@ using namespace graphite2; -Segment::Segment(size_t numchars, const Face* face, uint32 script, int textDir) +Segment::Segment(size_t numchars, const Face* face, uint32_t script, int textDir) : m_freeSlots(NULL), m_freeJustifies(NULL), m_charinfo(new CharInfo[numchars]), @@ -114,7 +114,7 @@ if (m_face->logger()) ++numUser; #endif Slot *newSlots = grzeroalloc<Slot>(m_bufSize); - int16 *newAttrs = grzeroalloc<int16>(m_bufSize * numUser); + int16_t *newAttrs = grzeroalloc<int16_t>(m_bufSize * numUser); if (!newSlots || !newAttrs) { free(newSlots); @@ -157,7 +157,7 @@ } // reset the slot incase it is reused ::new (aSlot) Slot(aSlot->userAttrs()); - memset(aSlot->userAttrs(), 0, m_silf->numUser() * sizeof(int16)); + memset(aSlot->userAttrs(), 0, m_silf->numUser() * sizeof(int16_t)); // Update generation counter for debug #if !defined GRAPHITE2_NTRACING if (m_face->logger()) @@ -176,7 +176,7 @@ if (!m_freeJustifies) { const size_t justSize = SlotJustify::size_of(m_silf->numJustLevels()); - byte *justs = grzeroalloc<byte>(justSize * m_bufSize); + uint8_t *justs = grzeroalloc<uint8_t>(justSize * m_bufSize); if (!justs) return NULL; for (ptrdiff_t i = m_bufSize - 2; i >= 0; --i) { @@ -198,7 +198,7 @@ int numJust = m_silf->numJustLevels(); if (m_silf->numJustLevels() <= 0) numJust = 1; aJustify->next = m_freeJustifies; - memset(aJustify->values, 0, numJust*SlotJustify::NUMJUSTPARAMS*sizeof(int16)); + memset(aJustify->values, 0, numJust*SlotJustify::NUMJUSTPARAMS*sizeof(int16_t)); m_freeJustifies = aJustify; } @@ -375,8 +375,8 @@ const typename utf_iter::codeunit_type * const base = c; for (; n_chars; --n_chars, ++c, ++slotid) { - const uint32 usv = *c; - uint16 gid = cmap[usv]; + const uint32_t usv = *c; + uint16_t gid = cmap[usv]; if (!gid) gid = face.findPseudo(usv); seg.appendSlot(slotid, usv, gid, fid, c - base); } @@ -399,7 +399,7 @@ return true; } -void Segment::doMirror(uint16 aMirror) +void Segment::doMirror(uint16_t aMirror) { Slot * s; for (s = m_first; s; s = s->next())
diff --git a/src/Silf.cpp b/src/Silf.cpp index 44d3c96..1181e85 100644 --- a/src/Silf.cpp +++ b/src/Silf.cpp
@@ -36,7 +36,7 @@ using namespace graphite2; -namespace { static const uint32 ERROROFFSET = 0xFFFFFFFF; } +namespace { static const uint32_t ERROROFFSET = 0xFFFFFFFF; } Silf::Silf() throw() : m_passes(0), @@ -89,9 +89,9 @@ } -bool Silf::readGraphite(const byte * const silf_start, size_t lSilf, Face& face, uint32 version) +bool Silf::readGraphite(const uint8_t * const silf_start, size_t lSilf, Face& face, uint32_t version) { - const byte * p = silf_start, + const uint8_t * p = silf_start, * const silf_end = p + lSilf; Error e; @@ -102,28 +102,28 @@ if (version >= 0x00030000) { if (e.test(lSilf < 28, E_BADSIZE)) { releaseBuffers(); return face.error(e); } - be::skip<int32>(p); // ruleVersion - be::skip<uint16>(p,2); // passOffset & pseudosOffset + be::skip<int32_t>(p); // ruleVersion + be::skip<uint16_t>(p,2); // passOffset & pseudosOffset } else if (e.test(lSilf < 20, E_BADSIZE)) { releaseBuffers(); return face.error(e); } - const uint16 maxGlyph = be::read<uint16>(p); - m_silfinfo.extra_ascent = be::read<uint16>(p); - m_silfinfo.extra_descent = be::read<uint16>(p); - m_numPasses = be::read<uint8>(p); - m_sPass = be::read<uint8>(p); - m_pPass = be::read<uint8>(p); - m_jPass = be::read<uint8>(p); - m_bPass = be::read<uint8>(p); - m_flags = be::read<uint8>(p); - be::skip<uint8>(p,2); // max{Pre,Post}Context. - m_aPseudo = be::read<uint8>(p); - m_aBreak = be::read<uint8>(p); - m_aBidi = be::read<uint8>(p); - m_aMirror = be::read<uint8>(p); - m_aPassBits = be::read<uint8>(p); + const uint16_t maxGlyph = be::read<uint16_t>(p); + m_silfinfo.extra_ascent = be::read<uint16_t>(p); + m_silfinfo.extra_descent = be::read<uint16_t>(p); + m_numPasses = be::read<uint8_t>(p); + m_sPass = be::read<uint8_t>(p); + m_pPass = be::read<uint8_t>(p); + m_jPass = be::read<uint8_t>(p); + m_bPass = be::read<uint8_t>(p); + m_flags = be::read<uint8_t>(p); + be::skip<uint8_t>(p,2); // max{Pre,Post}Context. + m_aPseudo = be::read<uint8_t>(p); + m_aBreak = be::read<uint8_t>(p); + m_aBidi = be::read<uint8_t>(p); + m_aMirror = be::read<uint8_t>(p); + m_aPassBits = be::read<uint8_t>(p); // Read Justification levels. - m_numJusts = be::read<uint8>(p); + m_numJusts = be::read<uint8_t>(p); if (e.test(maxGlyph >= face.glyphs().numGlyphs(), E_BADMAXGLYPH) || e.test(p + m_numJusts * 8 >= silf_end, E_BADNUMJUSTS)) { @@ -135,28 +135,28 @@ m_justs = gralloc<Justinfo>(m_numJusts); if (e.test(!m_justs, E_OUTOFMEM)) return face.error(e); - for (uint8 i = 0; i < m_numJusts; i++) + for (uint8_t i = 0; i < m_numJusts; i++) { ::new(m_justs + i) Justinfo(p[0], p[1], p[2], p[3]); - be::skip<byte>(p,8); + be::skip<uint8_t>(p,8); } } - if (e.test(p + sizeof(uint16) + sizeof(uint8)*8 >= silf_end, E_BADENDJUSTS)) { releaseBuffers(); return face.error(e); } - m_aLig = be::read<uint16>(p); - m_aUser = be::read<uint8>(p); - m_iMaxComp = be::read<uint8>(p); - m_dir = be::read<uint8>(p) - 1; - m_aCollision = be::read<uint8>(p); - be::skip<byte>(p,3); - be::skip<uint16>(p, be::read<uint8>(p)); // don't need critical features yet - be::skip<byte>(p); // reserved + if (e.test(p + sizeof(uint16_t) + sizeof(uint8_t)*8 >= silf_end, E_BADENDJUSTS)) { releaseBuffers(); return face.error(e); } + m_aLig = be::read<uint16_t>(p); + m_aUser = be::read<uint8_t>(p); + m_iMaxComp = be::read<uint8_t>(p); + m_dir = be::read<uint8_t>(p) - 1; + m_aCollision = be::read<uint8_t>(p); + be::skip<uint8_t>(p,3); + be::skip<uint16_t>(p, be::read<uint8_t>(p)); // don't need critical features yet + be::skip<uint8_t>(p); // reserved if (e.test(p >= silf_end, E_BADCRITFEATURES)) { releaseBuffers(); return face.error(e); } - be::skip<uint32>(p, be::read<uint8>(p)); // don't use scriptTag array. - if (e.test(p + sizeof(uint16) + sizeof(uint32) >= silf_end, E_BADSCRIPTTAGS)) { releaseBuffers(); return face.error(e); } - m_gEndLine = be::read<uint16>(p); // lbGID - const byte * o_passes = p; - uint32 passes_start = be::read<uint32>(p); + be::skip<uint32_t>(p, be::read<uint8_t>(p)); // don't use scriptTag array. + if (e.test(p + sizeof(uint16_t) + sizeof(uint32_t) >= silf_end, E_BADSCRIPTTAGS)) { releaseBuffers(); return face.error(e); } + m_gEndLine = be::read<uint16_t>(p); // lbGID + const uint8_t * o_passes = p; + uint32_t passes_start = be::read<uint32_t>(p); const size_t num_attrs = face.glyphs().numAttrs(); if (e.test(m_aPseudo >= num_attrs, E_BADAPSEUDO) @@ -173,20 +173,20 @@ releaseBuffers(); return face.error(e); } - be::skip<uint32>(p, m_numPasses); - if (e.test(unsigned(p - silf_start) + sizeof(uint16) >= passes_start, E_BADPASSESSTART)) { releaseBuffers(); return face.error(e); } - m_numPseudo = be::read<uint16>(p); - be::skip<uint16>(p, 3); // searchPseudo, pseudoSelector, pseudoShift + be::skip<uint32_t>(p, m_numPasses); + if (e.test(unsigned(p - silf_start) + sizeof(uint16_t) >= passes_start, E_BADPASSESSTART)) { releaseBuffers(); return face.error(e); } + m_numPseudo = be::read<uint16_t>(p); + be::skip<uint16_t>(p, 3); // searchPseudo, pseudoSelector, pseudoShift m_pseudos = new Pseudo[m_numPseudo]; - if (e.test(unsigned(p - silf_start) + m_numPseudo*(sizeof(uint32) + sizeof(uint16)) >= passes_start, E_BADNUMPSEUDO) + if (e.test(unsigned(p - silf_start) + m_numPseudo*(sizeof(uint32_t) + sizeof(uint16_t)) >= passes_start, E_BADNUMPSEUDO) || e.test(!m_pseudos, E_OUTOFMEM)) { releaseBuffers(); return face.error(e); } for (int i = 0; i < m_numPseudo; i++) { - m_pseudos[i].uid = be::read<uint32>(p); - m_pseudos[i].gid = be::read<uint16>(p); + m_pseudos[i].uid = be::read<uint32_t>(p); + m_pseudos[i].gid = be::read<uint16_t>(p); } const size_t clen = readClassMap(p, passes_start + silf_start - p, version, e); @@ -197,8 +197,8 @@ for (size_t i = 0; i < m_numPasses; ++i) { - uint32 pass_start = be::read<uint32>(o_passes); - uint32 pass_end = be::peek<uint32>(o_passes); + uint32_t pass_start = be::read<uint32_t>(o_passes); + uint32_t pass_end = be::peek<uint32_t>(o_passes); face.error_context((face.error_context() & 0xFF00) + EC_ASILF + unsigned(i << 16)); if (e.test(pass_start > pass_end, E_BADPASSSTART) || e.test(pass_start < passes_start, E_BADPASSSTART) @@ -230,45 +230,45 @@ return true; } -template<typename T> inline uint32 Silf::readClassOffsets(const byte *&p, size_t data_len, Error &e) +template<typename T> inline uint32_t Silf::readClassOffsets(const uint8_t *&p, size_t data_len, Error &e) { - const T cls_off = 2*sizeof(uint16) + sizeof(T)*(m_nClass+1); - const uint32 max_off = (be::peek<T>(p + sizeof(T)*m_nClass) - cls_off)/sizeof(uint16); + const T cls_off = 2*sizeof(uint16_t) + sizeof(T)*(m_nClass+1); + const uint32_t max_off = (be::peek<T>(p + sizeof(T)*m_nClass) - cls_off)/sizeof(uint16_t); // Check that the last+1 offset is less than or equal to the class map length. if (e.test(be::peek<T>(p) != cls_off, E_MISALIGNEDCLASSES) - || e.test(max_off > (data_len - cls_off)/sizeof(uint16), E_HIGHCLASSOFFSET)) + || e.test(max_off > (data_len - cls_off)/sizeof(uint16_t), E_HIGHCLASSOFFSET)) return ERROROFFSET; // Read in all the offsets. - m_classOffsets = gralloc<uint32>(m_nClass+1); + m_classOffsets = gralloc<uint32_t>(m_nClass+1); if (e.test(!m_classOffsets, E_OUTOFMEM)) return ERROROFFSET; - for (uint32 * o = m_classOffsets, * const o_end = o + m_nClass + 1; o != o_end; ++o) + for (uint32_t * o = m_classOffsets, * const o_end = o + m_nClass + 1; o != o_end; ++o) { - *o = (be::read<T>(p) - cls_off)/sizeof(uint16); + *o = (be::read<T>(p) - cls_off)/sizeof(uint16_t); if (e.test(*o > max_off, E_HIGHCLASSOFFSET)) return ERROROFFSET; } return max_off; } -size_t Silf::readClassMap(const byte *p, size_t data_len, uint32 version, Error &e) +size_t Silf::readClassMap(const uint8_t *p, size_t data_len, uint32_t version, Error &e) { - if (e.test(data_len < sizeof(uint16)*2, E_BADCLASSSIZE)) return ERROROFFSET; + if (e.test(data_len < sizeof(uint16_t)*2, E_BADCLASSSIZE)) return ERROROFFSET; - m_nClass = be::read<uint16>(p); - m_nLinear = be::read<uint16>(p); + m_nClass = be::read<uint16_t>(p); + m_nLinear = be::read<uint16_t>(p); // Check that numLinear < numClass, // that there is at least enough data for numClasses offsets. if (e.test(m_nLinear > m_nClass, E_TOOMANYLINEAR) - || e.test((m_nClass + 1) * (version >= 0x00040000 ? sizeof(uint32) : sizeof(uint16)) > (data_len - 4), E_CLASSESTOOBIG)) + || e.test((m_nClass + 1) * (version >= 0x00040000 ? sizeof(uint32_t) : sizeof(uint16_t)) > (data_len - 4), E_CLASSESTOOBIG)) return ERROROFFSET; - uint32 max_off; + uint32_t max_off; if (version >= 0x00040000) - max_off = readClassOffsets<uint32>(p, data_len, e); + max_off = readClassOffsets<uint32_t>(p, data_len, e); else - max_off = readClassOffsets<uint16>(p, data_len, e); + max_off = readClassOffsets<uint16_t>(p, data_len, e); if (max_off == ERROROFFSET) return ERROROFFSET; @@ -277,20 +277,20 @@ // Check the linear offsets are sane, these must be monotonically increasing. assert(m_nClass >= m_nLinear); - for (const uint32 *o = m_classOffsets, * const o_end = o + m_nLinear; o != o_end; ++o) + for (const uint32_t *o = m_classOffsets, * const o_end = o + m_nLinear; o != o_end; ++o) if (e.test(o[0] > o[1], E_BADCLASSOFFSET)) return ERROROFFSET; // Fortunately the class data is all uint16s so we can decode these now - m_classData = gralloc<uint16>(max_off); + m_classData = gralloc<uint16_t>(max_off); if (e.test(!m_classData, E_OUTOFMEM)) return ERROROFFSET; - for (uint16 *d = m_classData, * const d_end = d + max_off; d != d_end; ++d) - *d = be::read<uint16>(p); + for (uint16_t *d = m_classData, * const d_end = d + max_off; d != d_end; ++d) + *d = be::read<uint16_t>(p); // Check the lookup class invariants for each non-linear class - for (const uint32 *o = m_classOffsets + m_nLinear, * const o_end = m_classOffsets + m_nClass; o != o_end; ++o) + for (const uint32_t *o = m_classOffsets + m_nLinear, * const o_end = m_classOffsets + m_nClass; o != o_end; ++o) { - const uint16 * lookup = m_classData + *o; + const uint16_t * lookup = m_classData + *o; if (e.test(*o + 4 > max_off, E_HIGHCLASSOFFSET) // LookupClass doesn't stretch over max_off || e.test(lookup[0] == 0 // A LookupClass with no looks is a suspicious thing ... || lookup[0] * 2 + *o + 4 > max_off // numIDs lookup pairs fits within (start of LookupClass' lookups array, max_off] @@ -302,18 +302,18 @@ return max_off; } -uint16 Silf::findPseudo(uint32 uid) const +uint16_t Silf::findPseudo(uint32_t uid) const { for (int i = 0; i < m_numPseudo; i++) if (m_pseudos[i].uid == uid) return m_pseudos[i].gid; return 0; } -uint16 Silf::findClassIndex(uint16 cid, uint16 gid) const +uint16_t Silf::findClassIndex(uint16_t cid, uint16_t gid) const { if (cid > m_nClass) return -1; - const uint16 * cls = m_classData + m_classOffsets[cid]; + const uint16_t * cls = m_classData + m_classOffsets[cid]; if (cid < m_nLinear) // output class being used for input, shouldn't happen { for (unsigned int i = 0, n = m_classOffsets[cid + 1] - m_classOffsets[cid]; i < n; ++i, ++cls) @@ -322,11 +322,11 @@ } else { - const uint16 * min = cls + 4, // lookups array - * max = min + cls[0]*2; // lookups aray is numIDs (cls[0]) uint16 pairs long + const uint16_t * min = cls + 4, // lookups array + * max = min + cls[0]*2; // lookups aray is numIDs (cls[0]) uint16_t pairs long do { - const uint16 * p = min + (-2 & ((max-min)/2)); + const uint16_t * p = min + (-2 & ((max-min)/2)); if (p[0] > gid) max = p; else min = p; } @@ -335,11 +335,11 @@ } } -uint16 Silf::getClassGlyph(uint16 cid, unsigned int index) const +uint16_t Silf::getClassGlyph(uint16_t cid, unsigned int index) const { if (cid > m_nClass) return 0; - uint32 loc = m_classOffsets[cid]; + uint32_t loc = m_classOffsets[cid]; if (cid < m_nLinear) { if (index < m_classOffsets[cid + 1] - loc) @@ -354,14 +354,14 @@ } -bool Silf::runGraphite(Segment *seg, uint8 firstPass, uint8 lastPass, int dobidi) const +bool Silf::runGraphite(Segment *seg, uint8_t firstPass, uint8_t lastPass, int dobidi) const { assert(seg != 0); size_t maxSize = seg->slotCount() * MAX_SEG_GROWTH_FACTOR; SlotMap map(*seg, m_dir, maxSize); FiniteStateMachine fsm(map, seg->getFace()->logger()); vm::Machine m(map); - uint8 lbidi = m_bPass; + uint8_t lbidi = m_bPass; #if !defined GRAPHITE2_NTRACING json * const dbgout = seg->getFace()->logger(); #endif
diff --git a/src/Slot.cpp b/src/Slot.cpp index 2cb8559..4685767 100644 --- a/src/Slot.cpp +++ b/src/Slot.cpp
@@ -34,7 +34,7 @@ using namespace graphite2; -Slot::Slot(int16 *user_attrs) : +Slot::Slot(int16_t *user_attrs) : m_next(NULL), m_prev(NULL), m_glyphid(0), m_realglyphid(0), m_original(0), m_before(0), m_after(0), m_index(0), m_parent(NULL), m_child(NULL), m_sibling(NULL), @@ -85,7 +85,7 @@ m_position = m_position + relpos; } -Position Slot::finalise(const Segment *seg, const Font *font, Position & base, Rect & bbox, uint8 attrLevel, float & clusterMin, bool rtl, bool isFinal, int depth) +Position Slot::finalise(const Segment *seg, const Font *font, Position & base, Rect & bbox, uint8_t attrLevel, float & clusterMin, bool rtl, bool isFinal, int depth) { SlotCollision *coll = NULL; if (depth > 100 || (attrLevel && m_attLevel > attrLevel)) return Position(0, 0); @@ -153,7 +153,7 @@ return res; } -int32 Slot::clusterMetric(const Segment *seg, uint8 metric, uint8 attrLevel, bool rtl) +int32_t Slot::clusterMetric(const Segment *seg, uint8_t metric, uint8_t attrLevel, bool rtl) { Position base; if (glyph() >= seg->getFace()->glyphs().numGlyphs()) @@ -165,25 +165,25 @@ switch (metrics(metric)) { case kgmetLsb : - return int32(bbox.bl.x); + return int32_t(bbox.bl.x); case kgmetRsb : - return int32(res.x - bbox.tr.x); + return int32_t(res.x - bbox.tr.x); case kgmetBbTop : - return int32(bbox.tr.y); + return int32_t(bbox.tr.y); case kgmetBbBottom : - return int32(bbox.bl.y); + return int32_t(bbox.bl.y); case kgmetBbLeft : - return int32(bbox.bl.x); + return int32_t(bbox.bl.x); case kgmetBbRight : - return int32(bbox.tr.x); + return int32_t(bbox.tr.x); case kgmetBbWidth : - return int32(bbox.tr.x - bbox.bl.x); + return int32_t(bbox.tr.x - bbox.bl.x); case kgmetBbHeight : - return int32(bbox.tr.y - bbox.bl.y); + return int32_t(bbox.tr.y - bbox.bl.y); case kgmetAdvWidth : - return int32(res.x); + return int32_t(res.x); case kgmetAdvHeight : - return int32(res.y); + return int32_t(res.y); default : return 0; } @@ -191,7 +191,7 @@ #define SLOTGETCOLATTR(x) { SlotCollision *c = seg->collisionInfo(this); return c ? int(c-> x) : 0; } -int Slot::getAttr(const Segment *seg, attrCode ind, uint8 subindex) const +int Slot::getAttr(const Segment *seg, attrCode ind, uint8_t subindex) const { if (ind == gr_slatUserDefnV1) { @@ -270,7 +270,7 @@ c-> x ; c->setFlags(c->flags() & ~SlotCollision::COLL_KNOWN); } \ break; } -void Slot::setAttr(Segment *seg, attrCode ind, uint8 subindex, int16 value, const SlotMap & map) +void Slot::setAttr(Segment *seg, attrCode ind, uint8_t subindex, int16_t value, const SlotMap & map) { if (ind == gr_slatUserDefnV1) { @@ -291,7 +291,7 @@ case gr_slatAdvY : m_advance.y = value; break; case gr_slatAttTo : { - const uint16 idx = uint16(value); + const uint16_t idx = uint16_t(value); if (idx < map.size() && map[idx]) { Slot *other = map[idx]; @@ -330,7 +330,7 @@ case gr_slatAttWithXOff : case gr_slatAttWithYOff : break; case gr_slatAttLevel : - m_attLevel = byte(value); + m_attLevel = uint8_t(value); break; case gr_slatBreak : seg->charinfo(m_original)->breakWeight(value); @@ -377,7 +377,7 @@ } } -int Slot::getJustify(const Segment *seg, uint8 level, uint8 subindex) const +int Slot::getJustify(const Segment *seg, uint8_t level, uint8_t subindex) const { if (level && level >= seg->silf()->numJustLevels()) return 0; @@ -397,7 +397,7 @@ } } -void Slot::setJustify(Segment *seg, uint8 level, uint8 subindex, int16 value) +void Slot::setJustify(Segment *seg, uint8_t level, uint8_t subindex, int16_t value) { if (level && level >= seg->silf()->numJustLevels()) return; if (!m_justs) @@ -454,7 +454,7 @@ return false; } -void Slot::setGlyph(Segment *seg, uint16 glyphid, const GlyphFace * theGlyph) +void Slot::setGlyph(Segment *seg, uint16_t glyphid, const GlyphFace * theGlyph) { m_glyphid = glyphid; m_bidiCls = -1; @@ -480,7 +480,7 @@ m_advance = Position(aGlyph->theAdvance().x, 0.); if (seg->silf()->aPassBits()) { - seg->mergePassBits(uint8(theGlyph->attrs()[seg->silf()->aPassBits()])); + seg->mergePassBits(uint8_t(theGlyph->attrs()[seg->silf()->aPassBits()])); if (seg->silf()->numPasses() > 16) seg->mergePassBits(theGlyph->attrs()[seg->silf()->aPassBits()+1] << 16); } @@ -500,7 +500,7 @@ for (int i = seg->silf()->numJustLevels() - 1; i >= 0; --i) { Justinfo *justs = seg->silf()->justAttrs() + i; - int16 *v = values + i * NUMJUSTPARAMS; + int16_t *v = values + i * NUMJUSTPARAMS; v[0] = seg->glyphAttr(s->gid(), justs->attrStretch()); v[1] = seg->glyphAttr(s->gid(), justs->attrShrink()); v[2] = seg->glyphAttr(s->gid(), justs->attrStep());
diff --git a/src/TtfUtil.cpp b/src/TtfUtil.cpp index c942eea..3c5dc31 100644 --- a/src/TtfUtil.cpp +++ b/src/TtfUtil.cpp
@@ -157,7 +157,7 @@ { lOffset = 0; lSize = offsetof(Sfnt::OffsetSubTable, table_directory); - assert(sizeof(uint32) + 4*sizeof (uint16) == lSize); + assert(sizeof(uint32_t) + 4*sizeof (uint16_t) == lSize); return true; } @@ -304,16 +304,16 @@ if (be::swap(pOs2->version) == 0) { // OS/2 table version 1 size // if (sizeof(Sfnt::Compatibility) -// - sizeof(uint32)*2 - sizeof(int16)*2 -// - sizeof(uint16)*3 <= lTableSize) +// - sizeof(uint32_t)*2 - sizeof(int16_t)*2 +// - sizeof(uint16_t)*3 <= lTableSize) if (sizeof(Sfnt::Compatibility0) <= lTableSize) return true; } else if (be::swap(pOs2->version) == 1) { // OS/2 table version 2 size // if (sizeof(Sfnt::Compatibility) -// - sizeof(int16) *2 -// - sizeof(uint16)*3 <= lTableSize) +// - sizeof(int16_t) *2 +// - sizeof(uint16_t)*3 <= lTableSize) if (sizeof(Sfnt::Compatibility1) <= lTableSize) return true; } @@ -533,8 +533,8 @@ lSize = 0; const Sfnt::FontNames * pTable = reinterpret_cast<const Sfnt::FontNames *>(pName); - uint16 cRecord = be::swap(pTable->count); - uint16 nRecordOffset = be::swap(pTable->string_offset); + uint16_t cRecord = be::swap(pTable->count); + uint16_t nRecordOffset = be::swap(pTable->string_offset); const Sfnt::NameRecord * pRecord = reinterpret_cast<const Sfnt::NameRecord *>(pTable + 1); for (int i = 0; i < cRecord; ++i) @@ -565,9 +565,9 @@ { const Sfnt::FontNames * pTable = reinterpret_cast<const Sfnt::FontNames *>(pName); int cLangIds = 0; - uint16 cRecord = be::swap(pTable->count); + uint16_t cRecord = be::swap(pTable->count); if (cRecord > 127) return cLangIds; - //uint16 nRecordOffset = swapw(pTable->stringOffset); + //uint16_t nRecordOffset = swapw(pTable->stringOffset); const Sfnt::NameRecord * pRecord = reinterpret_cast<const Sfnt::NameRecord *>(pTable + 1); for (int i = 0; i < cRecord; ++i) @@ -610,7 +610,7 @@ /*---------------------------------------------------------------------------------------------- Get the offset and size of the font family name in English for the MS Platform with Unicode - writing system. The offset is within the pName data. The string is double byte with MSB + writing system. The offset is within the pName data. The string is double uint8_t with MSB first. ----------------------------------------------------------------------------------------------*/ bool Get31EngFamilyInfo(const void * pName, size_t & lOffset, size_t & lSize) @@ -621,7 +621,7 @@ /*---------------------------------------------------------------------------------------------- Get the offset and size of the full font name in English for the MS Platform with Unicode - writing system. The offset is within the pName data. The string is double byte with MSB + writing system. The offset is within the pName data. The string is double uint8_t with MSB first. Note: this method is not currently used by the Graphite engine. @@ -634,7 +634,7 @@ /*---------------------------------------------------------------------------------------------- Get the offset and size of the font family name in English for the MS Platform with Symbol - writing system. The offset is within the pName data. The string is double byte with MSB + writing system. The offset is within the pName data. The string is double uint8_t with MSB first. ----------------------------------------------------------------------------------------------*/ bool Get30EngFamilyInfo(const void * pName, size_t & lOffset, size_t & lSize) @@ -645,7 +645,7 @@ /*---------------------------------------------------------------------------------------------- Get the offset and size of the full font name in English for the MS Platform with Symbol - writing system. The offset is within the pName data. The string is double byte with MSB + writing system. The offset is within the pName data. The string is double uint8_t with MSB first. Note: this method is not currently used by the Graphite engine. @@ -707,7 +707,7 @@ int cnGlyphs = GlyphCount(pMaxp); for (gid16 nGlyphId = 0; nGlyphId < cnGlyphs && nGlyphId < kcPostNames; nGlyphId++) - { // glyph_name_index25 contains bytes so no byte swapping needed + { // glyph_name_index25 contains bytes so no uint8_t swapping needed // search for first glyph id that uses the standard name if (nGlyphId + pTable25->offset[nGlyphId] == iPostName) return nGlyphId; @@ -785,16 +785,16 @@ return; } - uint16 * pStr = reinterpret_cast<uint16 *>(pWStr); - uint16 * const pStrEnd = pStr + (nSize == 0 ? wcslen((const wchar_t*)pStr) : nSize); + uint16_t * pStr = reinterpret_cast<uint16_t *>(pWStr); + uint16_t * const pStrEnd = pStr + (nSize == 0 ? wcslen((const wchar_t*)pStr) : nSize); for (; pStr != pStrEnd; ++pStr) *pStr = be::swap(*pStr); -// std::transform(pStr, pStrEnd, pStr, read<uint16>); +// std::transform(pStr, pStrEnd, pStr, read<uint16_t>); // for (int i = 0; i < nSize; i++) // { // swap the wide characters in the string -// pStr[i] = utf16(be::swap(uint16(pStr[i]))); +// pStr[i] = utf16(be::swap(uint16_t(pStr[i]))); // } } #endif @@ -823,15 +823,15 @@ { // guard against bad glyph id size_t lLsbOffset = sizeof(Sfnt::HorizontalMetric) * cLongHorMetrics + - sizeof(int16) * (nGlyphId - cLongHorMetrics); // offset in bytes + sizeof(int16_t) * (nGlyphId - cLongHorMetrics); // offset in bytes // We test like this as LsbOffset is an offset not a length. - if (lLsbOffset >= lHmtxSize - sizeof(int16) || cLongHorMetrics == 0) + if (lLsbOffset >= lHmtxSize - sizeof(int16_t) || cLongHorMetrics == 0) { nLsb = 0; return false; } nAdvWid = be::swap(phmtx[cLongHorMetrics - 1].advance_width); - nLsb = be::peek<int16>(reinterpret_cast<const byte *>(phmtx) + lLsbOffset); + nLsb = be::peek<int16_t>(reinterpret_cast<const uint8_t *>(phmtx) + lLsbOffset); } return true; @@ -845,7 +845,7 @@ const void * FindCmapSubtable(const void * pCmap, int nPlatformId, /* =3 */ int nEncodingId, /* = 1 */ size_t length) { const Sfnt::CharacterCodeMap * pTable = reinterpret_cast<const Sfnt::CharacterCodeMap *>(pCmap); - uint16 csuPlatforms = be::swap(pTable->num_subtables); + uint16_t csuPlatforms = be::swap(pTable->num_subtables); if (length && (sizeof(Sfnt::CharacterCodeMap) + 8 * (csuPlatforms - 1) > length)) return NULL; for (int i = 0; i < csuPlatforms; i++) @@ -853,16 +853,16 @@ if (be::swap(pTable->encoding[i].platform_id) == nPlatformId && (nEncodingId == -1 || be::swap(pTable->encoding[i].platform_specific_id) == nEncodingId)) { - uint32 offset = be::swap(pTable->encoding[i].offset); - const uint8 * pRtn = reinterpret_cast<const uint8 *>(pCmap) + offset; + uint32_t offset = be::swap(pTable->encoding[i].offset); + const uint8_t * pRtn = reinterpret_cast<const uint8_t *>(pCmap) + offset; if (length) { if (offset > length - 2) return NULL; - uint16 format = be::read<uint16>(pRtn); + uint16_t format = be::read<uint16_t>(pRtn); if (format == 4) { if (offset > length - 4) return NULL; - uint16 subTableLength = be::peek<uint16>(pRtn); + uint16_t subTableLength = be::peek<uint16_t>(pRtn); if (i + 1 == csuPlatforms) { if (subTableLength > length - offset) @@ -874,7 +874,7 @@ if (format == 12) { if (offset > length - 6) return NULL; - uint32 subTableLength = be::peek<uint32>(pRtn); + uint32_t subTableLength = be::peek<uint32_t>(pRtn); if (i + 1 == csuPlatforms) { if (subTableLength > length - offset) @@ -884,7 +884,7 @@ return NULL; } } - return reinterpret_cast<const uint8 *>(pCmap) + offset; + return reinterpret_cast<const uint8_t *>(pCmap) + offset; } } @@ -896,7 +896,7 @@ ----------------------------------------------------------------------------------------------*/ bool CheckCmapSubtable4(const void * pCmapSubtable4, const void * pCmapEnd /*, unsigned int maxgid*/) { - size_t table_len = (const byte *)pCmapEnd - (const byte *)pCmapSubtable4; + size_t table_len = (const uint8_t *)pCmapEnd - (const uint8_t *)pCmapSubtable4; if (!pCmapSubtable4) return false; const Sfnt::CmapSubTable * pTable = reinterpret_cast<const Sfnt::CmapSubTable *>(pCmapSubtable4); // Bob H say some freeware TT fonts have version 1 (eg, CALIGULA.TTF) @@ -905,37 +905,37 @@ const Sfnt::CmapSubTableFormat4 * pTable4 = reinterpret_cast<const Sfnt::CmapSubTableFormat4 *>(pCmapSubtable4); if (table_len < sizeof(*pTable4)) return false; - uint16 length = be::swap(pTable4->length); + uint16_t length = be::swap(pTable4->length); if (length > table_len) return false; if (length < sizeof(Sfnt::CmapSubTableFormat4)) return false; - uint16 nRanges = be::swap(pTable4->seg_count_x2) >> 1; - if (!nRanges || length < sizeof(Sfnt::CmapSubTableFormat4) + 4 * nRanges * sizeof(uint16)) + uint16_t nRanges = be::swap(pTable4->seg_count_x2) >> 1; + if (!nRanges || length < sizeof(Sfnt::CmapSubTableFormat4) + 4 * nRanges * sizeof(uint16_t)) return false; // check last range is properly terminated - uint16 chEnd = be::peek<uint16>(pTable4->end_code + nRanges - 1); + uint16_t chEnd = be::peek<uint16_t>(pTable4->end_code + nRanges - 1); if (chEnd != 0xFFFF) return false; #if 0 int lastend = -1; for (int i = 0; i < nRanges; ++i) { - uint16 end = be::peek<uint16>(pTable4->end_code + i); - uint16 start = be::peek<uint16>(pTable4->end_code + nRanges + 1 + i); - int16 delta = be::peek<int16>(pTable4->end_code + 2*nRanges + 1 + i); - uint16 offset = be::peek<uint16>(pTable4->end_code + 3*nRanges + 1 + i); + uint16_t end = be::peek<uint16_t>(pTable4->end_code + i); + uint16_t start = be::peek<uint16_t>(pTable4->end_code + nRanges + 1 + i); + int16_t delta = be::peek<int16_t>(pTable4->end_code + 2*nRanges + 1 + i); + uint16_t offset = be::peek<uint16_t>(pTable4->end_code + 3*nRanges + 1 + i); if (lastend >= end || lastend >= start) return false; if (offset) { - const uint16 *gstart = pTable4->end_code + 3*nRanges + 1 + i + (offset >> 1); - const uint16 *gend = gstart + end - start; + const uint16_t *gstart = pTable4->end_code + 3*nRanges + 1 + i + (offset >> 1); + const uint16_t *gend = gstart + end - start; if ((char *)gend >= (char *)pCmapSubtable4 + length) return false; while (gstart <= gend) { - uint16 g = be::peek<uint16>(gstart++); + uint16_t g = be::peek<uint16_t>(gstart++); if (g && ((g + delta) & 0xFFFF) > maxgid) return false; } @@ -957,16 +957,16 @@ { const Sfnt::CmapSubTableFormat4 * pTable = reinterpret_cast<const Sfnt::CmapSubTableFormat4 *>(pCmapSubtabel4); - uint16 nSeg = be::swap(pTable->seg_count_x2) >> 1; + uint16_t nSeg = be::swap(pTable->seg_count_x2) >> 1; - uint16 n; - const uint16 * pLeft, * pMid; - uint16 cMid, chStart, chEnd; + uint16_t n; + const uint16_t * pLeft, * pMid; + uint16_t cMid, chStart, chEnd; if (rangeKey) { pMid = &(pTable->end_code[rangeKey]); - chEnd = be::peek<uint16>(pMid); + chEnd = be::peek<uint16_t>(pMid); } else { @@ -977,10 +977,10 @@ { cMid = n >> 1; // Pick an element in the middle pMid = pLeft + cMid; - chEnd = be::peek<uint16>(pMid); + chEnd = be::peek<uint16_t>(pMid); if (nUnicodeId <= chEnd) { - if (cMid == 0 || nUnicodeId > be::peek<uint16>(pMid -1)) + if (cMid == 0 || nUnicodeId > be::peek<uint16_t>(pMid -1)) break; // Must be this seg or none! n = cMid; // Continue on left side, omitting mid point } @@ -998,22 +998,22 @@ // Ok, we're down to one segment and pMid points to the endCode element // Either this is it or none is. - chStart = be::peek<uint16>(pMid += nSeg + 1); + chStart = be::peek<uint16_t>(pMid += nSeg + 1); if (chEnd >= nUnicodeId && nUnicodeId >= chStart) { // Found correct segment. Find Glyph Id - int16 idDelta = be::peek<uint16>(pMid += nSeg); - uint16 idRangeOffset = be::peek<uint16>(pMid += nSeg); + int16_t idDelta = be::peek<uint16_t>(pMid += nSeg); + uint16_t idRangeOffset = be::peek<uint16_t>(pMid += nSeg); if (idRangeOffset == 0) - return (uint16)(idDelta + nUnicodeId); // must use modulus 2^16 + return (uint16_t)(idDelta + nUnicodeId); // must use modulus 2^16 // Look up value in glyphIdArray const ptrdiff_t offset = (nUnicodeId - chStart) + (idRangeOffset >> 1) + - (pMid - reinterpret_cast<const uint16 *>(pTable)); - if (offset * 2 + 1 >= be::swap<uint16>(pTable->length)) + (pMid - reinterpret_cast<const uint16_t *>(pTable)); + if (offset * 2 + 1 >= be::swap<uint16_t>(pTable->length)) return 0; - gid16 nGlyphId = be::peek<uint16>(reinterpret_cast<const uint16 *>(pTable)+offset); + gid16 nGlyphId = be::peek<uint16_t>(reinterpret_cast<const uint16_t *>(pTable)+offset); // If this value is 0, return 0. Else add the idDelta return nGlyphId ? nGlyphId + idDelta : 0; } @@ -1031,11 +1031,11 @@ { const Sfnt::CmapSubTableFormat4 * pTable = reinterpret_cast<const Sfnt::CmapSubTableFormat4 *>(pCmap31); - uint16 nRange = be::swap(pTable->seg_count_x2) >> 1; + uint16_t nRange = be::swap(pTable->seg_count_x2) >> 1; - uint32 nUnicodePrev = (uint32)nUnicodeId; + uint32_t nUnicodePrev = (uint32_t)nUnicodeId; - const uint16 * pStartCode = &(pTable->end_code[0]) + const uint16_t * pStartCode = &(pTable->end_code[0]) + nRange // length of end code array + 1; // reserved word @@ -1044,7 +1044,7 @@ // return the first codepoint. if (pRangeKey) *pRangeKey = 0; - return be::peek<uint16>(pStartCode); + return be::peek<uint16_t>(pStartCode); } else if (nUnicodePrev >= 0xFFFF) { @@ -1055,14 +1055,14 @@ int iRange = (pRangeKey) ? *pRangeKey : 0; // Just in case we have a bad key: - while (iRange > 0 && be::peek<uint16>(pStartCode + iRange) > nUnicodePrev) + while (iRange > 0 && be::peek<uint16_t>(pStartCode + iRange) > nUnicodePrev) iRange--; - while (iRange < nRange - 1 && be::peek<uint16>(pTable->end_code + iRange) < nUnicodePrev) + while (iRange < nRange - 1 && be::peek<uint16_t>(pTable->end_code + iRange) < nUnicodePrev) iRange++; // Now iRange is the range containing nUnicodePrev. - unsigned int nStartCode = be::peek<uint16>(pStartCode + iRange); - unsigned int nEndCode = be::peek<uint16>(pTable->end_code + iRange); + unsigned int nStartCode = be::peek<uint16_t>(pStartCode + iRange); + unsigned int nEndCode = be::peek<uint16_t>(pTable->end_code + iRange); if (nStartCode > nUnicodePrev) // Oops, nUnicodePrev is not in the cmap! Adjust so we get a reasonable @@ -1082,7 +1082,7 @@ // ends with 0xFFFF. if (pRangeKey) *pRangeKey = iRange + 1; - return (iRange + 1 >= nRange) ? 0xFFFF : be::peek<uint16>(pStartCode + iRange + 1); + return (iRange + 1 >= nRange) ? 0xFFFF : be::peek<uint16_t>(pStartCode + iRange + 1); } /*---------------------------------------------------------------------------------------------- @@ -1090,7 +1090,7 @@ ----------------------------------------------------------------------------------------------*/ bool CheckCmapSubtable12(const void *pCmapSubtable12, const void *pCmapEnd /*, unsigned int maxgid*/) { - size_t table_len = (const byte *)pCmapEnd - (const byte *)pCmapSubtable12; + size_t table_len = (const uint8_t *)pCmapEnd - (const uint8_t *)pCmapSubtable12; if (!pCmapSubtable12) return false; const Sfnt::CmapSubTable * pTable = reinterpret_cast<const Sfnt::CmapSubTable *>(pCmapSubtable12); if (table_len < sizeof(*pTable) || be::swap(pTable->format) != 12) @@ -1098,13 +1098,13 @@ const Sfnt::CmapSubTableFormat12 * pTable12 = reinterpret_cast<const Sfnt::CmapSubTableFormat12 *>(pCmapSubtable12); if (table_len < sizeof(*pTable12)) return false; - uint32 length = be::swap(pTable12->length); + uint32_t length = be::swap(pTable12->length); if (length > table_len) return false; if (length < sizeof(Sfnt::CmapSubTableFormat12)) return false; - uint32 num_groups = be::swap(pTable12->num_groups); - if (num_groups > 0x10000000 || length != (sizeof(Sfnt::CmapSubTableFormat12) + (num_groups - 1) * sizeof(uint32) * 3)) + uint32_t num_groups = be::swap(pTable12->num_groups); + if (num_groups > 0x10000000 || length != (sizeof(Sfnt::CmapSubTableFormat12) + (num_groups - 1) * sizeof(uint32_t) * 3)) return false; #if 0 for (unsigned int i = 0; i < num_groups; ++i) @@ -1127,17 +1127,17 @@ { const Sfnt::CmapSubTableFormat12 * pTable = reinterpret_cast<const Sfnt::CmapSubTableFormat12 *>(pCmap310); - //uint32 uLength = be::swap(pTable->length); //could use to test for premature end of table - uint32 ucGroups = be::swap(pTable->num_groups); + //uint32_t uLength = be::swap(pTable->length); //could use to test for premature end of table + uint32_t ucGroups = be::swap(pTable->num_groups); for (unsigned int i = rangeKey; i < ucGroups; i++) { - uint32 uStartCode = be::swap(pTable->group[i].start_char_code); - uint32 uEndCode = be::swap(pTable->group[i].end_char_code); + uint32_t uStartCode = be::swap(pTable->group[i].start_char_code); + uint32_t uEndCode = be::swap(pTable->group[i].end_char_code); if (uUnicodeId >= uStartCode && uUnicodeId <= uEndCode) { - uint32 uDiff = uUnicodeId - uStartCode; - uint32 uStartGid = be::swap(pTable->group[i].start_glyph_id); + uint32_t uDiff = uUnicodeId - uStartCode; + uint32_t uStartGid = be::swap(pTable->group[i].start_glyph_id); return static_cast<gid16>(uStartGid + uDiff); } } @@ -1157,7 +1157,7 @@ int nRange = be::swap(pTable->num_groups); - uint32 nUnicodePrev = (uint32)nUnicodeId; + uint32_t nUnicodePrev = (uint32_t)nUnicodeId; if (nUnicodePrev == 0) { @@ -1223,9 +1223,9 @@ { // loca entries are two bytes and have been divided by two if (lLocaSize > 1 && nGlyphId + 1u < lLocaSize >> 1) // allow sentinel value to be accessed { - const uint16 * pShortTable = reinterpret_cast<const uint16 *>(pLoca); - res = be::peek<uint16>(pShortTable + nGlyphId) << 1; - if (res == static_cast<size_t>(be::peek<uint16>(pShortTable + nGlyphId + 1) << 1)) + const uint16_t * pShortTable = reinterpret_cast<const uint16_t *>(pLoca); + res = be::peek<uint16_t>(pShortTable + nGlyphId) << 1; + if (res == static_cast<size_t>(be::peek<uint16_t>(pShortTable + nGlyphId + 1) << 1)) return -1; } } @@ -1233,9 +1233,9 @@ { // loca entries are four bytes if (lLocaSize > 3 && nGlyphId + 1u < lLocaSize >> 2) { - const uint32 * pLongTable = reinterpret_cast<const uint32 *>(pLoca); - res = be::peek<uint32>(pLongTable + nGlyphId); - if (res == static_cast<size_t>(be::peek<uint32>(pLongTable + nGlyphId + 1))) + const uint32_t * pLongTable = reinterpret_cast<const uint32_t *>(pLoca); + res = be::peek<uint32_t>(pLongTable + nGlyphId); + if (res == static_cast<size_t>(be::peek<uint32_t>(pLongTable + nGlyphId + 1))) return -1; } } @@ -1251,10 +1251,10 @@ ----------------------------------------------------------------------------------------------*/ void * GlyfLookup(const void * pGlyf, size_t nGlyfOffset, size_t nTableLen) { - const uint8 * pByte = reinterpret_cast<const uint8 *>(pGlyf); + const uint8_t * pByte = reinterpret_cast<const uint8_t *>(pGlyf); if (nGlyfOffset + pByte < pByte || nGlyfOffset >= nTableLen - sizeof(Sfnt::Glyph)) return NULL; - return const_cast<uint8 *>(pByte + nGlyfOffset); + return const_cast<uint8_t *>(pByte + nGlyfOffset); } /*---------------------------------------------------------------------------------------------- @@ -1338,13 +1338,13 @@ if (cPts > cnPointsTotal) return false; - // skip over bounding box data & point to byte count of instructions (hints) - const uint8 * pbGlyph = reinterpret_cast<const uint8 *> + // skip over bounding box data & point to uint8_t count of instructions (hints) + const uint8_t * pbGlyph = reinterpret_cast<const uint8_t *> (&pGlyph->end_pts_of_contours[cContours]); // skip over hints & point to first flag - int cbHints = be::swap(*(uint16 *)pbGlyph); - pbGlyph += sizeof(uint16); + int cbHints = be::swap(*(uint16_t *)pbGlyph); + pbGlyph += sizeof(uint16_t); pbGlyph += cbHints; // load flags & point to first x coordinate @@ -1358,7 +1358,7 @@ iFlag++; } else - { // flag is repeated; count specified by next byte + { // flag is repeated; count specified by next uint8_t char chFlag = (char)*pbGlyph; pbGlyph++; int cFlags = (int)*pbGlyph; @@ -1397,8 +1397,8 @@ } else { - prgnX[iFlag] = be::swap(*(int16 *)pbGlyph); - pbGlyph += sizeof(int16); + prgnX[iFlag] = be::swap(*(int16_t *)pbGlyph); + pbGlyph += sizeof(int16_t); } } iFlag++; @@ -1426,8 +1426,8 @@ } else { - prgnY[iFlag] = be::swap(*(int16 *)pbGlyph); - pbGlyph += sizeof(int16); + prgnY[iFlag] = be::swap(*(int16_t *)pbGlyph); + pbGlyph += sizeof(int16_t); } } iFlag++; @@ -1456,16 +1456,16 @@ const Sfnt::SimpleGlyph * pGlyph = reinterpret_cast<const Sfnt::SimpleGlyph *>(pSimpleGlyf); // for a composite glyph, the special data begins here - const uint8 * pbGlyph = reinterpret_cast<const uint8 *>(&pGlyph->end_pts_of_contours[0]); + const uint8_t * pbGlyph = reinterpret_cast<const uint8_t *>(&pGlyph->end_pts_of_contours[0]); - uint16 GlyphFlags; + uint16_t GlyphFlags; size_t iCurrentComp = 0; do { - GlyphFlags = be::swap(*((uint16 *)pbGlyph)); - pbGlyph += sizeof(uint16); - prgnCompId[iCurrentComp++] = be::swap(*((uint16 *)pbGlyph)); - pbGlyph += sizeof(uint16); + GlyphFlags = be::swap(*((uint16_t *)pbGlyph)); + pbGlyph += sizeof(uint16_t); + prgnCompId[iCurrentComp++] = be::swap(*((uint16_t *)pbGlyph)); + pbGlyph += sizeof(uint16_t); if (iCurrentComp >= cnCompIdTotal) return false; int nOffset = 0; @@ -1501,24 +1501,24 @@ const Sfnt::SimpleGlyph * pGlyph = reinterpret_cast<const Sfnt::SimpleGlyph *>(pSimpleGlyf); // for a composite glyph, the special data begins here - const uint8 * pbGlyph = reinterpret_cast<const uint8 *>(&pGlyph->end_pts_of_contours[0]); + const uint8_t * pbGlyph = reinterpret_cast<const uint8_t *>(&pGlyph->end_pts_of_contours[0]); - uint16 GlyphFlags; + uint16_t GlyphFlags; do { - GlyphFlags = be::swap(*((uint16 *)pbGlyph)); - pbGlyph += sizeof(uint16); - if (be::swap(*((uint16 *)pbGlyph)) == nCompId) + GlyphFlags = be::swap(*((uint16_t *)pbGlyph)); + pbGlyph += sizeof(uint16_t); + if (be::swap(*((uint16_t *)pbGlyph)) == nCompId) { - pbGlyph += sizeof(uint16); // skip over glyph id of component + pbGlyph += sizeof(uint16_t); // skip over glyph id of component fOffset = (GlyphFlags & CompoundGlyph::ArgsAreXYValues) == CompoundGlyph::ArgsAreXYValues; if (GlyphFlags & CompoundGlyph::Arg1Arg2Words ) { - a = be::swap(*(int16 *)pbGlyph); - pbGlyph += sizeof(int16); - b = be::swap(*(int16 *)pbGlyph); - pbGlyph += sizeof(int16); + a = be::swap(*(int16_t *)pbGlyph); + pbGlyph += sizeof(int16_t); + b = be::swap(*(int16_t *)pbGlyph); + pbGlyph += sizeof(int16_t); } else { // args are signed bytes @@ -1527,7 +1527,7 @@ } return true; } - pbGlyph += sizeof(uint16); // skip over glyph id of component + pbGlyph += sizeof(uint16_t); // skip over glyph id of component int nOffset = 0; nOffset += GlyphFlags & CompoundGlyph::Arg1Arg2Words ? 4 : 2; nOffset += GlyphFlags & CompoundGlyph::HaveScale ? 2 : 0; @@ -1566,16 +1566,16 @@ const Sfnt::SimpleGlyph * pGlyph = reinterpret_cast<const Sfnt::SimpleGlyph *>(pSimpleGlyf); // for a composite glyph, the special data begins here - const uint8 * pbGlyph = reinterpret_cast<const uint8 *>(&pGlyph->end_pts_of_contours[0]); + const uint8_t * pbGlyph = reinterpret_cast<const uint8_t *>(&pGlyph->end_pts_of_contours[0]); - uint16 GlyphFlags; + uint16_t GlyphFlags; do { - GlyphFlags = be::swap(*((uint16 *)pbGlyph)); - pbGlyph += sizeof(uint16); - if (be::swap(*((uint16 *)pbGlyph)) == nCompId) + GlyphFlags = be::swap(*((uint16_t *)pbGlyph)); + pbGlyph += sizeof(uint16_t); + if (be::swap(*((uint16_t *)pbGlyph)) == nCompId) { - pbGlyph += sizeof(uint16); // skip over glyph id of component + pbGlyph += sizeof(uint16_t); // skip over glyph id of component pbGlyph += GlyphFlags & CompoundGlyph::Arg1Arg2Words ? 4 : 2; // skip over placement data if (fTransOffset) // MS rasterizer @@ -1585,31 +1585,31 @@ if (GlyphFlags & CompoundGlyph::HaveScale) { - flt11 = fixed_to_float<14>(be::swap(*(uint16 *)pbGlyph)); - pbGlyph += sizeof(uint16); + flt11 = fixed_to_float<14>(be::swap(*(uint16_t *)pbGlyph)); + pbGlyph += sizeof(uint16_t); flt12 = 0; flt21 = 0; flt22 = flt11; } else if (GlyphFlags & CompoundGlyph::HaveXAndYScale) { - flt11 = fixed_to_float<14>(be::swap(*(uint16 *)pbGlyph)); - pbGlyph += sizeof(uint16); + flt11 = fixed_to_float<14>(be::swap(*(uint16_t *)pbGlyph)); + pbGlyph += sizeof(uint16_t); flt12 = 0; flt21 = 0; - flt22 = fixed_to_float<14>(be::swap(*(uint16 *)pbGlyph)); - pbGlyph += sizeof(uint16); + flt22 = fixed_to_float<14>(be::swap(*(uint16_t *)pbGlyph)); + pbGlyph += sizeof(uint16_t); } else if (GlyphFlags & CompoundGlyph::HaveTwoByTwo) { - flt11 = fixed_to_float<14>(be::swap(*(uint16 *)pbGlyph)); - pbGlyph += sizeof(uint16); - flt12 = fixed_to_float<14>(be::swap(*(uint16 *)pbGlyph)); - pbGlyph += sizeof(uint16); - flt21 = fixed_to_float<14>(be::swap(*(uint16 *)pbGlyph)); - pbGlyph += sizeof(uint16); - flt22 = fixed_to_float<14>(be::swap(*(uint16 *)pbGlyph)); - pbGlyph += sizeof(uint16); + flt11 = fixed_to_float<14>(be::swap(*(uint16_t *)pbGlyph)); + pbGlyph += sizeof(uint16_t); + flt12 = fixed_to_float<14>(be::swap(*(uint16_t *)pbGlyph)); + pbGlyph += sizeof(uint16_t); + flt21 = fixed_to_float<14>(be::swap(*(uint16_t *)pbGlyph)); + pbGlyph += sizeof(uint16_t); + flt22 = fixed_to_float<14>(be::swap(*(uint16_t *)pbGlyph)); + pbGlyph += sizeof(uint16_t); } else { // identity transform @@ -1620,7 +1620,7 @@ } return true; } - pbGlyph += sizeof(uint16); // skip over glyph id of component + pbGlyph += sizeof(uint16_t); // skip over glyph id of component int nOffset = 0; nOffset += GlyphFlags & CompoundGlyph::Arg1Arg2Words ? 4 : 2; nOffset += GlyphFlags & CompoundGlyph::HaveScale ? 2 : 0; @@ -2028,9 +2028,9 @@ Currently used. ---------------------------------------------------------------------------------------------*/ #if 0 -size_t NameTableLength(const byte * pTable) +size_t NameTableLength(const uint8_t * pTable) { - byte * pb = (const_cast<byte *>(pTable)) + 2; // skip format + uint8_t * pb = (const_cast<uint8_t *>(pTable)) + 2; // skip format size_t cRecords = *pb++ << 8; cRecords += *pb++; int dbStringOffset0 = (*pb++) << 8; dbStringOffset0 += *pb++; int dbMaxStringOffset = 0;
diff --git a/src/UtfCodec.cpp b/src/UtfCodec.cpp index a944bbf..6904e66 100644 --- a/src/UtfCodec.cpp +++ b/src/UtfCodec.cpp
@@ -27,19 +27,15 @@ #include "inc/UtfCodec.h" //using namespace graphite2; -namespace graphite2 { - -} - using namespace graphite2; -const int8 _utf_codec<8>::sz_lut[16] = +const int8_t _utf_codec<8>::sz_lut[16] = { - 1,1,1,1,1,1,1,1, // 1 byte - 0,0,0,0, // trailing byte + 1,1,1,1,1,1,1,1, // 1 uint8_t + 0,0,0,0, // trailing uint8_t 2,2, // 2 bytes 3, // 3 bytes 4 // 4 bytes }; -const byte _utf_codec<8>::mask_lut[5] = {0x7f, 0xff, 0x3f, 0x1f, 0x0f}; +const uint8_t _utf_codec<8>::mask_lut[5] = {0x7f, 0xff, 0x3f, 0x1f, 0x0f};
diff --git a/src/call_machine.cpp b/src/call_machine.cpp index fcd8a0c..d1b6a6a 100644 --- a/src/call_machine.cpp +++ b/src/call_machine.cpp
@@ -46,7 +46,7 @@ #pragma GCC diagnostic ignored "-Wunused-parameter" #endif -#define registers const byte * & dp, vm::Machine::stack_t * & sp, \ +#define registers const uint8_t * & dp, vm::Machine::stack_t * & sp, \ vm::Machine::stack_t * const sb, regbank & reg // These are required by opcodes.h and should not be changed @@ -70,8 +70,8 @@ SlotMap & smap; slotref * const map_base; const instr * & ip; - uint8 direction; - int8 flags; + uint8_t direction; + int8_t flags; Machine::status_t & status; }; @@ -104,7 +104,7 @@ } Machine::stack_t Machine::run(const instr * program, - const byte * data, + const uint8_t * data, slotref * & map) { @@ -112,7 +112,7 @@ // Declare virtual machine registers const instr * ip = program-1; - const byte * dp = data; + const uint8_t * dp = data; stack_t * sp = _stack + Machine::STACK_GUARD, * const sb = sp; regbank reg = {*map, map, _map, _map.begin()+_map.context(), ip, _map.dir(), 0, _status};
diff --git a/src/direct_machine.cpp b/src/direct_machine.cpp index e654522..53b3c28 100644 --- a/src/direct_machine.cpp +++ b/src/direct_machine.cpp
@@ -58,10 +58,10 @@ const void * direct_run(const bool get_table_mode, const instr * program, - const byte * data, + const uint8_t * data, Machine::stack_t * stack, slotref * & __map, - uint8 _dir, + uint8_t _dir, Machine::status_t & status, SlotMap * __smap=0) { @@ -73,7 +73,7 @@ // Declare virtual machine registers const instr * ip = program; - const byte * dp = data; + const uint8_t * dp = data; Machine::stack_t * sp = stack + Machine::STACK_GUARD, * const sb = sp; SlotMap & smap = *__smap; @@ -81,8 +81,8 @@ slotref is = *__map, * map = __map, * const mapb = smap.begin()+smap.context(); - uint8 dir = _dir; - int8 flags = 0; + uint8_t dir = _dir; + int8_t flags = 0; // start the program goto **ip; @@ -107,7 +107,7 @@ Machine::stack_t Machine::run(const instr * program, - const byte * data, + const uint8_t * data, slotref * & is) { assert(program != 0);
diff --git a/src/gr_face.cpp b/src/gr_face.cpp index d2cba03..a472875 100644 --- a/src/gr_face.cpp +++ b/src/gr_face.cpp
@@ -111,7 +111,7 @@ gr_uint32 gr_str_to_tag(const char *str) { - uint32 res = 0; + uint32_t res = 0; switch(max(strlen(str),size_t(4))) { case 4: res |= str[3]; GR_FALLTHROUGH; @@ -135,7 +135,7 @@ } inline -uint32 zeropad(const uint32 x) +uint32_t zeropad(const uint32_t x) { if (x == 0x20202020) return 0; if ((x & 0x00FFFFFF) == 0x00202020) return x & 0xFF000000;
diff --git a/src/gr_features.cpp b/src/gr_features.cpp index a560e05..51b862d 100644 --- a/src/gr_features.cpp +++ b/src/gr_features.cpp
@@ -86,7 +86,7 @@ length = 0; return NULL; } - uint16 label = pfeatureref->getNameId(); + uint16_t label = pfeatureref->getNameId(); NameTable * names = pfeatureref->getFace().nameTable(); if (!names) { @@ -107,7 +107,7 @@ length = 0; return NULL; } - uint16 label = pfeatureref->getSettingName(setting); + uint16_t label = pfeatureref->getSettingName(setting); NameTable * names = pfeatureref->getFace().nameTable(); if (!names) {
diff --git a/src/gr_logging.cpp b/src/gr_logging.cpp index 8f1e675..8deb725 100644 --- a/src/gr_logging.cpp +++ b/src/gr_logging.cpp
@@ -252,15 +252,15 @@ graphite2::objectid::objectid(const dslot & ds) throw() { const Slot * const p = ds.second; - uint32 s = uint32(reinterpret_cast<size_t>(p)); - sprintf(name, "%.4x-%.2x-%.4hx", uint16(s >> 16), uint16(p ? p->userAttrs()[ds.first->silf()->numUser()] : 0), uint16(s)); + uint32_t s = uint32_t(reinterpret_cast<size_t>(p)); + sprintf(name, "%.4x-%.2x-%.4hx", uint16_t(s >> 16), uint16_t(p ? p->userAttrs()[ds.first->silf()->numUser()] : 0), uint16_t(s)); name[sizeof name-1] = 0; } graphite2::objectid::objectid(const Segment * const p) throw() { - uint32 s = uint32(reinterpret_cast<size_t>(p)); - sprintf(name, "%.4x-%.2x-%.4hx", uint16(s >> 16), 0, uint16(s)); + uint32_t s = uint32_t(reinterpret_cast<size_t>(p)); + sprintf(name, "%.4x-%.2x-%.4hx", uint16_t(s >> 16), 0, uint16_t(s)); name[sizeof name-1] = 0; }
diff --git a/src/gr_segment.cpp b/src/gr_segment.cpp index 7280889d..d651797 100644 --- a/src/gr_segment.cpp +++ b/src/gr_segment.cpp
@@ -33,7 +33,7 @@ namespace { - gr_segment* makeAndInitialize(const Font *font, const Face *face, uint32 script, const Features* pFeats/*must not be NULL*/, gr_encform enc, const void* pStart, size_t nChars, int dir) + gr_segment* makeAndInitialize(const Font *font, const Face *face, uint32_t script, const Features* pFeats/*must not be NULL*/, gr_encform enc, const void* pStart, size_t nChars, int dir) { if (script == 0x20202020) script = 0; else if ((script & 0x00FFFFFF) == 0x00202020) script = script & 0xFF000000; @@ -61,7 +61,7 @@ inline size_t count_unicode_chars(utf_iter first, const utf_iter last, const void **error) { size_t n_chars = 0; - uint32 usv = 0; + uint32_t usv = 0; if (last) {
diff --git a/src/inc/CharInfo.h b/src/inc/CharInfo.h index 01e7e31..bf8bee1 100644 --- a/src/inc/CharInfo.h +++ b/src/inc/CharInfo.h
@@ -47,8 +47,8 @@ void before(int val) { m_before = val; } size_t base() const { return m_base; } void base(size_t offset) { m_base = offset; } - void addflags(uint8 val) { m_flags |= val; } - uint8 flags() const { return m_flags; } + void addflags(uint8_t val) { m_flags |= val; } + uint8_t flags() const { return m_flags; } CLASS_NEW_DELETE private: @@ -56,9 +56,9 @@ int m_before; // slot index before us, comes before int m_after; // slot index after us, comes after size_t m_base; // offset into input string corresponding to this charinfo - uint8 m_featureid; // index into features list in the segment - int8 m_break; // breakweight coming from lb table - uint8 m_flags; // 0,1 segment split. + uint8_t m_featureid; // index into features list in the segment + int8_t m_break; // breakweight coming from lb table + uint8_t m_flags; // 0,1 segment split. }; } // namespace graphite2
diff --git a/src/inc/CmapCache.h b/src/inc/CmapCache.h index 7820c95..a18f3fe 100644 --- a/src/inc/CmapCache.h +++ b/src/inc/CmapCache.h
@@ -39,7 +39,7 @@ virtual ~Cmap() throw() {} - virtual uint16 operator [] (const uint32) const throw() { return 0; } + virtual uint16_t operator [] (const uint32_t) const throw() { return 0; } virtual operator bool () const throw() { return false; } @@ -53,7 +53,7 @@ public: DirectCmap(const Face &); - virtual uint16 operator [] (const uint32 usv) const throw(); + virtual uint16_t operator [] (const uint32_t usv) const throw(); virtual operator bool () const throw(); CLASS_NEW_DELETE; @@ -71,12 +71,12 @@ public: CachedCmap(const Face &); virtual ~CachedCmap() throw(); - virtual uint16 operator [] (const uint32 usv) const throw(); + virtual uint16_t operator [] (const uint32_t usv) const throw(); virtual operator bool () const throw(); CLASS_NEW_DELETE; private: bool m_isBmpOnly; - uint16 ** m_blocks; + uint16_t ** m_blocks; }; } // namespace graphite2
diff --git a/src/inc/Code.h b/src/inc/Code.h index 3cee67c..6afc93f 100644 --- a/src/inc/Code.h +++ b/src/inc/Code.h
@@ -72,10 +72,10 @@ class decoder; instr * _code; - byte * _data; + uint8_t * _data; size_t _data_size, _instr_count; - byte _max_ref; + uint8_t _max_ref; mutable status_t _status; bool _constraint, _modify, @@ -89,9 +89,9 @@ static size_t estimateCodeDataOut(size_t num_bytecodes, int nRules, int nSlots); Code() throw(); - Code(bool is_constraint, const byte * bytecode_begin, const byte * const bytecode_end, - uint8 pre_context, uint16 rule_length, const Silf &, const Face &, - enum passtype pt, byte * * const _out = 0); + Code(bool is_constraint, const uint8_t * bytecode_begin, const uint8_t * const bytecode_end, + uint8_t pre_context, uint16_t rule_length, const Silf &, const Face &, + enum passtype pt, uint8_t * * const _out = 0); Code(const Machine::Code &) throw(); ~Code() throw(); @@ -106,7 +106,7 @@ size_t maxRef() const throw() { return _max_ref; } void externalProgramMoved(ptrdiff_t) throw(); - int32 run(Machine &m, slotref * & map) const; + int32_t run(Machine &m, slotref * & map) const; CLASS_NEW_DELETE; }; @@ -116,7 +116,7 @@ { // max is: all codes are instructions + 1 for each rule + max tempcopies // allocate space for separate maximal code and data then merge them later - return (n_bc + nRules + nSlots) * sizeof(instr) + n_bc * sizeof(byte); + return (n_bc + nRules + nSlots) * sizeof(instr) + n_bc * sizeof(uint8_t); }
diff --git a/src/inc/Collider.h b/src/inc/Collider.h index 71e8400..6b1c4d2 100644 --- a/src/inc/Collider.h +++ b/src/inc/Collider.h
@@ -37,8 +37,8 @@ class Slot; class Segment; -#define SLOTCOLSETUINTPROP(x, y) uint16 x() const { return _ ##x; } void y (uint16 v) { _ ##x = v; } -#define SLOTCOLSETINTPROP(x, y) int16 x() const { return _ ##x; } void y (int16 v) { _ ##x = v; } +#define SLOTCOLSETUINTPROP(x, y) uint16_t x() const { return _ ##x; } void y (uint16_t v) { _ ##x = v; } +#define SLOTCOLSETINTPROP(x, y) int16_t x() const { return _ ##x; } void y (int16_t v) { _ ##x = v; } #define SLOTCOLSETPOSITIONPROP(x, y) const Position &x() const { return _ ##x; } void y (const Position &v) { _ ##x = v; } // Slot attributes related to collision-fixing @@ -101,19 +101,19 @@ Position _shift; // adjustment within the given pass Position _offset; // total adjustment for collisions Position _exclOffset; - uint16 _margin; - uint16 _marginWt; - uint16 _flags; - uint16 _exclGlyph; - uint16 _seqClass; - uint16 _seqProxClass; - uint16 _seqOrder; - int16 _seqAboveXoff; - uint16 _seqAboveWt; - int16 _seqBelowXlim; - uint16 _seqBelowWt; - uint16 _seqValignHt; - uint16 _seqValignWt; + uint16_t _margin; + uint16_t _marginWt; + uint16_t _flags; + uint16_t _exclGlyph; + uint16_t _seqClass; + uint16_t _seqProxClass; + uint16_t _seqOrder; + int16_t _seqAboveXoff; + uint16_t _seqAboveWt; + int16_t _seqBelowXlim; + uint16_t _seqBelowWt; + uint16_t _seqValignHt; + uint16_t _seqValignWt; }; // end of class SlotColllision @@ -161,9 +161,9 @@ float _margin; float _marginWt; float _len[4]; - uint16 _seqClass; - uint16 _seqProxClass; - uint16 _seqOrder; + uint16_t _seqClass; + uint16_t _seqProxClass; + uint16_t _seqOrder; //bool _scraping[4];
diff --git a/src/inc/Compression.h b/src/inc/Compression.h index 9fe10e0..e47bfeb 100644 --- a/src/inc/Compression.h +++ b/src/inc/Compression.h
@@ -34,18 +34,10 @@ namespace { -#if defined(_MSC_VER) -typedef unsigned __int8 u8; -typedef unsigned __int16 u16; -typedef unsigned __int32 u32; -typedef unsigned __int64 u64; -#else -#include <stdint.h> -typedef uint8_t u8; +#include <cstdint> +typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; -typedef uint64_t u64; -#endif ptrdiff_t const MINMATCH = 4, LASTLITERALS = 5,
diff --git a/src/inc/Endian.h b/src/inc/Endian.h index 56ecfd8..545f9f3 100644 --- a/src/inc/Endian.h +++ b/src/inc/Endian.h
@@ -28,10 +28,10 @@ /* Description: A set of fast template based decoders for decoding values of any C integer - type up to long int size laid out with most significant byte first or least - significant byte first (aka big endian or little endian). These are CPU - byte order agnostic and will function the same regardless of the CPUs native - byte order. + type up to long int size laid out with most significant uint8_t first or least + significant uint8_t first (aka big endian or little endian). These are CPU + uint8_t order agnostic and will function the same regardless of the CPUs native + uint8_t order. Being template based means if the either le or be class is not used then template code of unused functions will not be instantiated by the compiler
diff --git a/src/inc/Face.h b/src/inc/Face.h index 4d705e9..9ee1570 100644 --- a/src/inc/Face.h +++ b/src/inc/Face.h
@@ -66,7 +66,7 @@ virtual bool runGraphite(Segment *seg, const Silf *silf) const; public: - bool readGlyphs(uint32 faceOptions); + bool readGlyphs(uint32_t faceOptions); bool readGraphite(const Table & silf); bool readFeatures(); void takeFileFace(FileFace* pFileFace/*takes ownership*/); @@ -78,17 +78,17 @@ void setLogger(FILE *log_file); json * logger() const throw(); - const Silf * chooseSilf(uint32 script) const; - uint16 languageForLocale(const char * locale) const; + const Silf * chooseSilf(uint32_t script) const; + uint16_t languageForLocale(const char * locale) const; // Features - uint16 numFeatures() const; - const FeatureRef * featureById(uint32 id) const; - const FeatureRef * feature(uint16 index) const; + uint16_t numFeatures() const; + const FeatureRef * featureById(uint32_t id) const; + const FeatureRef * feature(uint16_t index) const; // Glyph related - int32 getGlyphMetric(uint16 gid, uint8 metric) const; - uint16 findPseudo(uint32 uid) const; + int32_t getGlyphMetric(uint16_t gid, uint8_t metric) const; + uint16_t findPseudo(uint32_t uid) const; // Errors unsigned int error() const { return m_error; } @@ -110,9 +110,9 @@ unsigned int m_errcntxt; protected: Silf * m_silfs; // silf subtables. - uint16 m_numSilf; // num silf subtables in the silf table + uint16_t m_numSilf; // num silf subtables in the silf table private: - uint16 m_ascent, + uint16_t m_ascent, m_descent; #ifdef GRAPHITE2_TELEMETRY public: @@ -129,19 +129,19 @@ } inline -uint16 Face::numFeatures() const +uint16_t Face::numFeatures() const { return m_Sill.theFeatureMap().numFeats(); } inline -const FeatureRef * Face::featureById(uint32 id) const +const FeatureRef * Face::featureById(uint32_t id) const { return m_Sill.theFeatureMap().findFeatureRef(id); } inline -const FeatureRef *Face::feature(uint16 index) const +const FeatureRef *Face::feature(uint16_t index) const { return m_Sill.theFeatureMap().feature(index); } @@ -169,7 +169,7 @@ class Face::Table { const Face * _f; - mutable const byte * _p; + mutable const uint8_t * _p; size_t _sz; bool _compressed; @@ -179,11 +179,11 @@ public: Table() throw(); - Table(const Face & face, const Tag n, uint32 version=0xffffffff) throw(); + Table(const Face & face, const Tag n, uint32_t version=0xffffffff) throw(); Table(const Table & rhs) throw(); ~Table() throw(); - operator const byte * () const throw(); + operator const uint8_t * () const throw(); Table & operator = (const Table & rhs) throw(); size_t size() const throw(); @@ -209,7 +209,7 @@ } inline -Face::Table::operator const byte * () const throw() +Face::Table::operator const uint8_t * () const throw() { return _p; }
diff --git a/src/inc/FeatureMap.h b/src/inc/FeatureMap.h index 142a00e7..b40a18d 100644 --- a/src/inc/FeatureMap.h +++ b/src/inc/FeatureMap.h
@@ -38,44 +38,44 @@ class FeatureSetting { public: - FeatureSetting(int16 theValue, uint16 labelId) : m_label(labelId), m_value(theValue) {}; - uint16 label() const { return m_label; } - int16 value() const { return m_value; } + FeatureSetting(int16_t theValue, uint16_t labelId) : m_label(labelId), m_value(theValue) {}; + uint16_t label() const { return m_label; } + int16_t value() const { return m_value; } CLASS_NEW_DELETE; private: FeatureSetting(const FeatureSetting & fs) : m_label(fs.m_label), m_value(fs.m_value) {}; - uint16 m_label; - int16 m_value; + uint16_t m_label; + int16_t m_value; }; class FeatureRef { - typedef uint32 chunk_t; - static const uint8 SIZEOF_CHUNK = sizeof(chunk_t)*8; + typedef uint32_t chunk_t; + static const uint8_t SIZEOF_CHUNK = sizeof(chunk_t)*8; public: FeatureRef() throw(); - FeatureRef(const Face & face, unsigned short & bits_offset, uint32 max_val, - uint32 name, uint16 uiName, uint16 flags, - FeatureSetting *settings, uint16 num_set) throw(); + FeatureRef(const Face & face, unsigned short & bits_offset, uint32_t max_val, + uint32_t name, uint16_t uiName, uint16_t flags, + FeatureSetting *settings, uint16_t num_set) throw(); ~FeatureRef() throw(); - bool applyValToFeature(uint32 val, Features& pDest) const; //defined in GrFaceImp.h + bool applyValToFeature(uint32_t val, Features& pDest) const; //defined in GrFaceImp.h void maskFeature(Features & pDest) const { if (m_index < pDest.size()) //defensive pDest[m_index] |= m_mask; } - uint32 getFeatureVal(const Features& feats) const; //defined in GrFaceImp.h + uint32_t getFeatureVal(const Features& feats) const; //defined in GrFaceImp.h - uint32 getId() const { return m_id; } - uint16 getNameId() const { return m_nameid; } - uint16 getNumSettings() const { return m_numSet; } - uint16 getSettingName(uint16 index) const { return m_nameValues[index].label(); } - int16 getSettingValue(uint16 index) const { return m_nameValues[index].value(); } - uint32 maxVal() const { return m_max; } + uint32_t getId() const { return m_id; } + uint16_t getNameId() const { return m_nameid; } + uint16_t getNumSettings() const { return m_numSet; } + uint16_t getSettingName(uint16_t index) const { return m_nameValues[index].label(); } + int16_t getSettingValue(uint16_t index) const { return m_nameValues[index].value(); } + uint32_t maxVal() const { return m_max; } const Face & getFace() const { assert(m_face); return *m_face;} const FeatureMap* getFeatureMap() const;// { return m_pFace;} @@ -87,11 +87,11 @@ FeatureSetting * m_nameValues; // array of name table ids for feature values chunk_t m_mask, // bit mask to get the value from the vector m_max; // max value the value can take - uint32 m_id; // feature identifier/name - uint16 m_nameid, // Name table id for feature name + uint32_t m_id; // feature identifier/name + uint16_t m_nameid, // Name table id for feature name m_flags, // feature flags (unused at the moment but read from the font) m_numSet; // number of values (number of entries in m_nameValues) - byte m_bits, // how many bits to shift the value into place + uint8_t m_bits, // how many bits to shift the value into place m_index; // index into the array to find the ulong to mask private: //unimplemented @@ -113,7 +113,7 @@ class NameAndFeatureRef { public: - NameAndFeatureRef(uint32 name = 0) : m_name(name) , m_pFRef(NULL){} + NameAndFeatureRef(uint32_t name = 0) : m_name(name) , m_pFRef(NULL){} NameAndFeatureRef(FeatureRef const & p) : m_name(p.getId()), m_pFRef(&p) {} bool operator<(const NameAndFeatureRef& rhs) const //orders by m_name @@ -121,7 +121,7 @@ CLASS_NEW_DELETE - uint32 m_name; + uint32_t m_name; const FeatureRef* m_pFRef; }; @@ -132,16 +132,16 @@ ~FeatureMap() { delete[] m_feats; delete[] m_pNamedFeats; } bool readFeats(const Face & face); - const FeatureRef *findFeatureRef(uint32 name) const; - FeatureRef *feature(uint16 index) const { return m_feats + index; } - //GrFeatureRef *featureRef(byte index) { return index < m_numFeats ? m_feats + index : NULL; } - const FeatureRef *featureRef(byte index) const { return index < m_numFeats ? m_feats + index : NULL; } - FeatureVal* cloneFeatures(uint32 langname/*0 means default*/) const; //call destroy_Features when done. - uint16 numFeats() const { return m_numFeats; }; + const FeatureRef *findFeatureRef(uint32_t name) const; + FeatureRef *feature(uint16_t index) const { return m_feats + index; } + //GrFeatureRef *featureRef(uint8_t index) { return index < m_numFeats ? m_feats + index : NULL; } + const FeatureRef *featureRef(uint8_t index) const { return index < m_numFeats ? m_feats + index : NULL; } + FeatureVal* cloneFeatures(uint32_t langname/*0 means default*/) const; //call destroy_Features when done. + uint16_t numFeats() const { return m_numFeats; }; CLASS_NEW_DELETE private: friend class SillMap; - uint16 m_numFeats; + uint16_t m_numFeats; FeatureRef *m_feats; NameAndFeatureRef* m_pNamedFeats; //owned @@ -165,7 +165,7 @@ LangFeaturePair() : m_lang(0), m_pFeatures(0) {} ~LangFeaturePair() { delete m_pFeatures; } - uint32 m_lang; + uint32_t m_lang; Features* m_pFeatures; //owns CLASS_NEW_DELETE }; @@ -174,15 +174,15 @@ ~SillMap() { delete[] m_langFeats; } bool readFace(const Face & face); bool readSill(const Face & face); - FeatureVal* cloneFeatures(uint32 langname/*0 means default*/) const; //call destroy_Features when done. - uint16 numLanguages() const { return m_numLanguages; }; - uint32 getLangName(uint16 index) const { return (index < m_numLanguages)? m_langFeats[index].m_lang : 0; }; + FeatureVal* cloneFeatures(uint32_t langname/*0 means default*/) const; //call destroy_Features when done. + uint16_t numLanguages() const { return m_numLanguages; }; + uint32_t getLangName(uint16_t index) const { return (index < m_numLanguages)? m_langFeats[index].m_lang : 0; }; const FeatureMap & theFeatureMap() const { return m_FeatureMap; }; private: FeatureMap m_FeatureMap; //of face LangFeaturePair * m_langFeats; - uint16 m_numLanguages; + uint16_t m_numLanguages; private: //defensive on m_langFeats SillMap(const SillMap&);
diff --git a/src/inc/FeatureVal.h b/src/inc/FeatureVal.h index cd3f93b..322482c 100644 --- a/src/inc/FeatureVal.h +++ b/src/inc/FeatureVal.h
@@ -35,14 +35,14 @@ class FeatureRef; class FeatureMap; -class FeatureVal : public Vector<uint32> +class FeatureVal : public Vector<uint32_t> { public: FeatureVal() : m_pMap(0) { } - FeatureVal(int num, const FeatureMap & pMap) : Vector<uint32>(num), m_pMap(&pMap) {} - FeatureVal(const FeatureVal & rhs) : Vector<uint32>(rhs), m_pMap(rhs.m_pMap) {} + FeatureVal(int num, const FeatureMap & pMap) : Vector<uint32_t>(num), m_pMap(&pMap) {} + FeatureVal(const FeatureVal & rhs) : Vector<uint32_t>(rhs), m_pMap(rhs.m_pMap) {} - FeatureVal & operator = (const FeatureVal & rhs) { Vector<uint32>::operator = (rhs); m_pMap = rhs.m_pMap; return *this; } + FeatureVal & operator = (const FeatureVal & rhs) { Vector<uint32_t>::operator = (rhs); m_pMap = rhs.m_pMap; return *this; } bool operator ==(const FeatureVal & b) const {
diff --git a/src/inc/GlyphCache.h b/src/inc/GlyphCache.h index 7d5324e..421b943 100644 --- a/src/inc/GlyphCache.h +++ b/src/inc/GlyphCache.h
@@ -71,16 +71,16 @@ GlyphBox & operator = (const GlyphBox &); public: - GlyphBox(uint8 numsubs, unsigned short bitmap, Rect *slanted) : _num(numsubs), _bitmap(bitmap), _slant(*slanted) {}; + GlyphBox(uint8_t numsubs, unsigned short bitmap, Rect *slanted) : _num(numsubs), _bitmap(bitmap), _slant(*slanted) {}; void addSubBox(int subindex, int boundary, Rect *val) { _subs[subindex * 2 + boundary] = *val; } Rect &subVal(int subindex, int boundary) { return _subs[subindex * 2 + boundary]; } const Rect &slant() const { return _slant; } - uint8 num() const { return _num; } + uint8_t num() const { return _num; } const Rect *subs() const { return _subs; } private: - uint8 _num; + uint8_t _num; unsigned short _bitmap; Rect _slant; Rect _subs[1]; @@ -94,7 +94,7 @@ GlyphCache& operator=(const GlyphCache&); public: - GlyphCache(const Face & face, const uint32 face_options); + GlyphCache(const Face & face, const uint32_t face_options); ~GlyphCache(); unsigned short numGlyphs() const throw(); @@ -103,14 +103,14 @@ const GlyphFace *glyph(unsigned short glyphid) const; //result may be changed by subsequent call with a different glyphid const GlyphFace *glyphSafe(unsigned short glyphid) const; - float getBoundingMetric(unsigned short glyphid, uint8 metric) const; - uint8 numSubBounds(unsigned short glyphid) const; - float getSubBoundingMetric(unsigned short glyphid, uint8 subindex, uint8 metric) const; + float getBoundingMetric(unsigned short glyphid, uint8_t metric) const; + uint8_t numSubBounds(unsigned short glyphid) const; + float getSubBoundingMetric(unsigned short glyphid, uint8_t subindex, uint8_t metric) const; const Rect & slant(unsigned short glyphid) const { return _boxes[glyphid] ? _boxes[glyphid]->slant() : _empty_slant_box; } const SlantBox & getBoundingSlantBox(unsigned short glyphid) const; const BBox & getBoundingBBox(unsigned short glyphid) const; - const SlantBox & getSubBoundingSlantBox(unsigned short glyphid, uint8 subindex) const; - const BBox & getSubBoundingBBox(unsigned short glyphid, uint8 subindex) const; + const SlantBox & getSubBoundingSlantBox(unsigned short glyphid, uint8_t subindex) const; + const BBox & getSubBoundingBBox(unsigned short glyphid, uint8_t subindex) const; bool check(unsigned short glyphid) const; bool hasBoxes() const { return _boxes != 0; } @@ -157,7 +157,7 @@ } inline -float GlyphCache::getBoundingMetric(unsigned short glyphid, uint8 metric) const +float GlyphCache::getBoundingMetric(unsigned short glyphid, uint8_t metric) const { if (glyphid >= _num_glyphs) return 0.; switch (metric) { @@ -184,7 +184,7 @@ } inline -float GlyphCache::getSubBoundingMetric(unsigned short glyphid, uint8 subindex, uint8 metric) const +float GlyphCache::getSubBoundingMetric(unsigned short glyphid, uint8_t subindex, uint8_t metric) const { GlyphBox *b = _boxes[glyphid]; if (b == NULL || subindex >= b->num()) return 0; @@ -202,20 +202,20 @@ } } -inline const SlantBox &GlyphCache::getSubBoundingSlantBox(unsigned short glyphid, uint8 subindex) const +inline const SlantBox &GlyphCache::getSubBoundingSlantBox(unsigned short glyphid, uint8_t subindex) const { GlyphBox *b = _boxes[glyphid]; return *(SlantBox *)(b->subs() + 2 * subindex + 1); } -inline const BBox &GlyphCache::getSubBoundingBBox(unsigned short glyphid, uint8 subindex) const +inline const BBox &GlyphCache::getSubBoundingBBox(unsigned short glyphid, uint8_t subindex) const { GlyphBox *b = _boxes[glyphid]; return *(BBox *)(b->subs() + 2 * subindex); } inline -uint8 GlyphCache::numSubBounds(unsigned short glyphid) const +uint8_t GlyphCache::numSubBounds(unsigned short glyphid) const { return _boxes[glyphid] ? _boxes[glyphid]->num() : 0; }
diff --git a/src/inc/GlyphFace.h b/src/inc/GlyphFace.h index fc29056..e8dc9e12 100644 --- a/src/inc/GlyphFace.h +++ b/src/inc/GlyphFace.h
@@ -51,7 +51,7 @@ const Position & theAdvance() const; const Rect & theBBox() const { return m_bbox; } const sparse & attrs() const { return m_attrs; } - int32 getMetric(uint8 metric) const; + int32_t getMetric(uint8_t metric) const; CLASS_NEW_DELETE; private:
diff --git a/src/inc/Intervals.h b/src/inc/Intervals.h index 81d2318..66c4e82 100644 --- a/src/inc/Intervals.h +++ b/src/inc/Intervals.h
@@ -61,7 +61,7 @@ Exclusion(float x, float w, float smi, float smxi, float c); Exclusion & operator += (Exclusion const & rhs); - uint8 outcode(float p) const; + uint8_t outcode(float p) const; Exclusion split_at(float p); void left_trim(float p);
diff --git a/src/inc/Machine.h b/src/inc/Machine.h index b23819fb..cb13a52 100644 --- a/src/inc/Machine.h +++ b/src/inc/Machine.h
@@ -128,7 +128,7 @@ struct opcode_t { instr impl[2]; - uint8 param_sz; + uint8_t param_sz; char name[MAX_NAME_LEN]; }; @@ -136,7 +136,7 @@ class Machine { public: - typedef int32 stack_t; + typedef int32_t stack_t; static size_t const STACK_ORDER = 10, STACK_MAX = 1 << STACK_ORDER, STACK_GUARD = 2; @@ -163,7 +163,7 @@ private: void check_final_stack(const stack_t * const sp); - stack_t run(const instr * program, const byte * data, + stack_t run(const instr * program, const uint8_t * data, slotref * & map) HOT; SlotMap & _map;
diff --git a/src/inc/Main.h b/src/inc/Main.h index ebf02dd..eb6619a 100644 --- a/src/inc/Main.h +++ b/src/inc/Main.h
@@ -35,15 +35,6 @@ namespace graphite2 { -typedef gr_uint8 uint8; -typedef gr_uint8 byte; -typedef gr_uint16 uint16; -typedef gr_uint32 uint32; -typedef gr_int8 int8; -typedef gr_int16 int16; -typedef gr_int32 int32; -typedef size_t uintptr; - #ifdef GRAPHITE2_TELEMETRY struct telemetry { @@ -157,9 +148,9 @@ } // namespace graphite2 #define CLASS_NEW_DELETE \ - void * operator new (size_t size){ return gralloc<byte>(size);} \ + void * operator new (size_t size){ return gralloc<uint8_t>(size);} \ void * operator new (size_t, void * p) throw() { return p; } \ - void * operator new[] (size_t size) {return gralloc<byte>(size);} \ + void * operator new[] (size_t size) {return gralloc<uint8_t>(size);} \ void * operator new[] (size_t, void * p) throw() { return p; } \ void operator delete (void * p) throw() { free(p);} \ void operator delete (void *, void *) throw() {} \
diff --git a/src/inc/NameTable.h b/src/inc/NameTable.h index 0fdbeb4..0c9d1ea 100644 --- a/src/inc/NameTable.h +++ b/src/inc/NameTable.h
@@ -38,27 +38,27 @@ NameTable & operator = (const NameTable &); public: - NameTable(const void * data, size_t length, uint16 platfromId=3, uint16 encodingID = 1); + NameTable(const void * data, size_t length, uint16_t platfromId=3, uint16_t encodingID = 1); ~NameTable() { free(const_cast<TtfUtil::Sfnt::FontNames *>(m_table)); } enum eNameFallback { eNoFallback = 0, eEnUSFallbackOnly = 1, eEnOrAnyFallback = 2 }; - uint16 setPlatformEncoding(uint16 platfromId=3, uint16 encodingID = 1); - void * getName(uint16 & languageId, uint16 nameId, gr_encform enc, uint32 & length); - uint16 getLanguageId(const char * bcp47Locale); + uint16_t setPlatformEncoding(uint16_t platfromId=3, uint16_t encodingID = 1); + void * getName(uint16_t & languageId, uint16_t nameId, gr_encform enc, uint32_t & length); + uint16_t getLanguageId(const char * bcp47Locale); CLASS_NEW_DELETE private: - uint16 m_platformId; - uint16 m_encodingId; - uint16 m_languageCount; - uint16 m_platformOffset; // offset of first NameRecord with for platform 3, encoding 1 - uint16 m_platformLastRecord; - uint16 m_nameDataLength; + uint16_t m_platformId; + uint16_t m_encodingId; + uint16_t m_languageCount; + uint16_t m_platformOffset; // offset of first NameRecord with for platform 3, encoding 1 + uint16_t m_platformLastRecord; + uint16_t m_nameDataLength; const TtfUtil::Sfnt::FontNames * m_table; - const uint8 * m_nameData; + const uint8_t * m_nameData; Locale2Lang m_locale2Lang; };
diff --git a/src/inc/Pass.h b/src/inc/Pass.h index e687a87..31c9303 100644 --- a/src/inc/Pass.h +++ b/src/inc/Pass.h
@@ -51,11 +51,11 @@ Pass(); ~Pass(); - bool readPass(const byte * pPass, size_t pass_length, size_t subtable_base, Face & face, - enum passtype pt, uint32 version, Error &e); + bool readPass(const uint8_t * pPass, size_t pass_length, size_t subtable_base, Face & face, + enum passtype pt, uint32_t version, Error &e); bool runGraphite(vm::Machine & m, FiniteStateMachine & fsm, bool reverse) const; void init(Silf *silf) { m_silf = silf; } - byte collisionLoops() const { return m_numCollRuns; } + uint8_t collisionLoops() const { return m_numCollRuns; } bool reverseDir() const { return m_isReverseDir; } CLASS_NEW_DELETE @@ -64,14 +64,14 @@ int doAction(const vm::Machine::Code* codeptr, Slot * & slot_out, vm::Machine &) const; bool testPassConstraint(vm::Machine & m) const; bool testConstraint(const Rule & r, vm::Machine &) const; - bool readRules(const byte * rule_map, const size_t num_entries, - const byte *precontext, const uint16 * sort_key, - const uint16 * o_constraint, const byte *constraint_data, - const uint16 * o_action, const byte * action_data, + bool readRules(const uint8_t * rule_map, const size_t num_entries, + const uint8_t *precontext, const uint16_t * sort_key, + const uint16_t * o_constraint, const uint8_t *constraint_data, + const uint16_t * o_action, const uint8_t * action_data, Face &, enum passtype pt, Error &e); - bool readStates(const byte * starts, const byte * states, const byte * o_rule_map, Face &, Error &e); - bool readRanges(const byte * ranges, size_t num_ranges, Error &e); - uint16 glyphToCol(const uint16 gid) const; + bool readStates(const uint8_t * starts, const uint8_t * states, const uint8_t * o_rule_map, Face &, Error &e); + bool readRanges(const uint8_t * ranges, size_t num_ranges, Error &e); + uint16_t glyphToCol(const uint16_t gid) const; bool runFSM(FiniteStateMachine & fsm, Slot * slot) const; void dumpRuleEventConsidered(const FiniteStateMachine & fsm, const RuleEntry & re) const; void dumpRuleEventOutput(const FiniteStateMachine & fsm, const Rule & r, Slot * os) const; @@ -85,28 +85,28 @@ float &ymin, float &ymax, json *const dbgout) const; const Silf * m_silf; - uint16 * m_cols; + uint16_t * m_cols; Rule * m_rules; // rules RuleEntry * m_ruleMap; - uint16 * m_startStates; // prectxt length - uint16 * m_transitions; + uint16_t * m_startStates; // prectxt length + uint16_t * m_transitions; State * m_states; vm::Machine::Code * m_codes; - byte * m_progs; + uint8_t * m_progs; - byte m_numCollRuns; - byte m_kernColls; - byte m_iMaxLoop; - uint16 m_numGlyphs; - uint16 m_numRules; - uint16 m_numStates; - uint16 m_numTransition; - uint16 m_numSuccess; - uint16 m_successStart; - uint16 m_numColumns; - byte m_minPreCtxt; - byte m_maxPreCtxt; - byte m_colThreshold; + uint8_t m_numCollRuns; + uint8_t m_kernColls; + uint8_t m_iMaxLoop; + uint16_t m_numGlyphs; + uint16_t m_numRules; + uint16_t m_numStates; + uint16_t m_numTransition; + uint16_t m_numSuccess; + uint16_t m_successStart; + uint16_t m_numColumns; + uint8_t m_minPreCtxt; + uint8_t m_maxPreCtxt; + uint8_t m_colThreshold; bool m_isReverseDir; vm::Machine::Code m_cPConstraint;
diff --git a/src/inc/Rule.h b/src/inc/Rule.h index 5964e00..3701535 100644 --- a/src/inc/Rule.h +++ b/src/inc/Rule.h
@@ -36,9 +36,9 @@ const vm::Machine::Code * constraint, * action; unsigned short sort; - byte preContext; + uint8_t preContext; #ifndef NDEBUG - uint16 rule_idx; + uint16_t rule_idx; #endif Rule(); @@ -102,7 +102,7 @@ { public: enum {MAX_SLOTS=64}; - SlotMap(Segment & seg, uint8 direction, size_t maxSize); + SlotMap(Segment & seg, uint8_t direction, size_t maxSize); Slot * * begin(); Slot * * end(); @@ -120,7 +120,7 @@ bool highpassed() const { return m_highpassed; } void highpassed(bool v) { m_highpassed = v; } - uint8 dir() const { return m_dir; } + uint8_t dir() const { return m_dir; } int decMax() { return --m_maxSize; } Segment & segment; @@ -130,7 +130,7 @@ unsigned short m_precontext; Slot * m_highwater; int m_maxSize; - uint8 m_dir; + uint8_t m_dir; bool m_highpassed; }; @@ -244,7 +244,7 @@ } inline -SlotMap::SlotMap(Segment & seg, uint8 direction, size_t maxSize) +SlotMap::SlotMap(Segment & seg, uint8_t direction, size_t maxSize) : segment(seg), m_size(0), m_precontext(0), m_highwater(0), m_maxSize(int(maxSize)), m_dir(direction), m_highpassed(false) {
diff --git a/src/inc/Segment.h b/src/inc/Segment.h index 6cf8340..a750c1a 100644 --- a/src/inc/Segment.h +++ b/src/inc/Segment.h
@@ -46,7 +46,7 @@ typedef Vector<Features> FeatureList; typedef Vector<Slot *> SlotRope; -typedef Vector<int16 *> AttributeRope; +typedef Vector<int16_t *> AttributeRope; typedef Vector<SlotJustify *> JustifyRope; class Font; @@ -92,16 +92,16 @@ void extendLength(ptrdiff_t num) { m_numGlyphs += num; } Position advance() const { return m_advance; } bool runGraphite() { if (m_silf) return m_face->runGraphite(this, m_silf); else return true;}; - void chooseSilf(uint32 script) { m_silf = m_face->chooseSilf(script); } + void chooseSilf(uint32_t script) { m_silf = m_face->chooseSilf(script); } const Silf *silf() const { return m_silf; } size_t charInfoCount() const { return m_numCharinfo; } const CharInfo *charinfo(unsigned int index) const { return index < m_numCharinfo ? m_charinfo + index : NULL; } CharInfo *charinfo(unsigned int index) { return index < m_numCharinfo ? m_charinfo + index : NULL; } - Segment(size_t numchars, const Face* face, uint32 script, int dir); + Segment(size_t numchars, const Face* face, uint32_t script, int dir); ~Segment(); - uint8 flags() const { return m_flags; } - void flags(uint8 f) { m_flags = f; } + uint8_t flags() const { return m_flags; } + void flags(uint8_t f) { m_flags = f; } Slot *first() { return m_first; } void first(Slot *p) { m_first = p; } Slot *last() { return m_last; } @@ -114,34 +114,34 @@ Position positionSlots(const Font *font=0, Slot *first=0, Slot *last=0, bool isRtl = false, bool isFinal = true); void associateChars(int offset, size_t num); void linkClusters(Slot *first, Slot *last); - uint16 getClassGlyph(uint16 cid, uint16 offset) const { return m_silf->getClassGlyph(cid, offset); } - uint16 findClassIndex(uint16 cid, uint16 gid) const { return m_silf->findClassIndex(cid, gid); } + uint16_t getClassGlyph(uint16_t cid, uint16_t offset) const { return m_silf->getClassGlyph(cid, offset); } + uint16_t findClassIndex(uint16_t cid, uint16_t gid) const { return m_silf->findClassIndex(cid, gid); } int addFeatures(const Features& feats) { m_feats.push_back(feats); return int(m_feats.size()) - 1; } - uint32 getFeature(int index, uint8 findex) const { const FeatureRef* pFR=m_face->theSill().theFeatureMap().featureRef(findex); if (!pFR) return 0; else return pFR->getFeatureVal(m_feats[index]); } - void setFeature(int index, uint8 findex, uint32 val) { + uint32_t getFeature(int index, uint8_t findex) const { const FeatureRef* pFR=m_face->theSill().theFeatureMap().featureRef(findex); if (!pFR) return 0; else return pFR->getFeatureVal(m_feats[index]); } + void setFeature(int index, uint8_t findex, uint32_t val) { const FeatureRef* pFR=m_face->theSill().theFeatureMap().featureRef(findex); if (pFR) { if (val > pFR->maxVal()) val = pFR->maxVal(); pFR->applyValToFeature(val, m_feats[index]); } } - int8 dir() const { return m_dir; } - void dir(int8 val) { m_dir = val; } + int8_t dir() const { return m_dir; } + void dir(int8_t val) { m_dir = val; } bool currdir() const { return ((m_dir >> 6) ^ m_dir) & 1; } - uint8 passBits() const { return m_passBits; } - void mergePassBits(const uint8 val) { m_passBits &= val; } - int16 glyphAttr(uint16 gid, uint16 gattr) const { const GlyphFace * p = m_face->glyphs().glyphSafe(gid); return p ? p->attrs()[gattr] : 0; } - int32 getGlyphMetric(Slot *iSlot, uint8 metric, uint8 attrLevel, bool rtl) const; - float glyphAdvance(uint16 gid) const { return m_face->glyphs().glyph(gid)->theAdvance().x; } - const Rect &theGlyphBBoxTemporary(uint16 gid) const { return m_face->glyphs().glyph(gid)->theBBox(); } //warning value may become invalid when another glyph is accessed + uint8_t passBits() const { return m_passBits; } + void mergePassBits(const uint8_t val) { m_passBits &= val; } + int16_t glyphAttr(uint16_t gid, uint16_t gattr) const { const GlyphFace * p = m_face->glyphs().glyphSafe(gid); return p ? p->attrs()[gattr] : 0; } + int32_t getGlyphMetric(Slot *iSlot, uint8_t metric, uint8_t attrLevel, bool rtl) const; + float glyphAdvance(uint16_t gid) const { return m_face->glyphs().glyph(gid)->theAdvance().x; } + const Rect &theGlyphBBoxTemporary(uint16_t gid) const { return m_face->glyphs().glyph(gid)->theBBox(); } //warning value may become invalid when another glyph is accessed Slot *findRoot(Slot *is) const { return is->attachedTo() ? findRoot(is->attachedTo()) : is; } int numAttrs() const { return m_silf->numUser(); } int defaultOriginal() const { return m_defaultOriginal; } const Face * getFace() const { return m_face; } const Features & getFeatures(unsigned int /*charIndex*/) { assert(m_feats.size() == 1); return m_feats[0]; } - void bidiPass(int paradir, uint8 aMirror); - int8 getSlotBidiClass(Slot *s) const; - void doMirror(uint16 aMirror); + void bidiPass(int paradir, uint8_t aMirror); + int8_t getSlotBidiClass(Slot *s) const; + void doMirror(uint16_t aMirror); Slot *addLineEnd(Slot *nSlot); void delLineEnd(Slot *s); bool hasJustification() const { return m_justifies.size() != 0; } @@ -152,7 +152,7 @@ SlotCollision *collisionInfo(const Slot *s) const { return m_collisions ? m_collisions + s->index() : 0; } CLASS_NEW_DELETE -public: //only used by: GrSegment* makeAndInitialize(const GrFont *font, const GrFace *face, uint32 script, const FeaturesHandle& pFeats/*must not be IsNull*/, encform enc, const void* pStart, size_t nChars, int dir); +public: //only used by: GrSegment* makeAndInitialize(const GrFont *font, const GrFace *face, uint32_t script, const FeaturesHandle& pFeats/*must not be IsNull*/, encform enc, const void* pStart, size_t nChars, int dir); bool read_text(const Face *face, const Features* pFeats/*must not be NULL*/, gr_encform enc, const void*pStart, size_t nChars); void finalise(const Font *font, bool reverse=false); float justify(Slot *pSlot, const Font *font, float width, enum justFlags flags, Slot *pFirst, Slot *pLast); @@ -176,17 +176,17 @@ m_numGlyphs, m_numCharinfo; // size of the array and number of input characters int m_defaultOriginal; // number of whitespace chars in the string - int8 m_dir; - uint8 m_flags, // General purpose flags + int8_t m_dir; + uint8_t m_flags, // General purpose flags m_passBits; // if bit set then skip pass }; inline -int8 Segment::getSlotBidiClass(Slot *s) const +int8_t Segment::getSlotBidiClass(Slot *s) const { - int8 res = s->getBidiClass(); + int8_t res = s->getBidiClass(); if (res != -1) return res; - res = int8(glyphAttr(s->gid(), m_silf->aBidi())); + res = int8_t(glyphAttr(s->gid(), m_silf->aBidi())); s->setBidiClass(res); return res; } @@ -204,7 +204,7 @@ } inline -int32 Segment::getGlyphMetric(Slot *iSlot, uint8 metric, uint8 attrLevel, bool rtl) const { +int32_t Segment::getGlyphMetric(Slot *iSlot, uint8_t metric, uint8_t attrLevel, bool rtl) const { if (attrLevel > 0) { Slot *is = findRoot(iSlot);
diff --git a/src/inc/Silf.h b/src/inc/Silf.h index edc0c3a..307f998 100644 --- a/src/inc/Silf.h +++ b/src/inc/Silf.h
@@ -41,27 +41,27 @@ class Pseudo { public: - uint32 uid; - uint32 gid; + uint32_t uid; + uint32_t gid; CLASS_NEW_DELETE; }; class Justinfo { public: - Justinfo(uint8 stretch, uint8 shrink, uint8 step, uint8 weight) : + Justinfo(uint8_t stretch, uint8_t shrink, uint8_t step, uint8_t weight) : m_astretch(stretch), m_ashrink(shrink), m_astep(step), m_aweight(weight) {}; - uint8 attrStretch() const { return m_astretch; } - uint8 attrShrink() const { return m_ashrink; } - uint8 attrStep() const { return m_astep; } - uint8 attrWeight() const { return m_aweight; } + uint8_t attrStretch() const { return m_astretch; } + uint8_t attrShrink() const { return m_ashrink; } + uint8_t attrStep() const { return m_astep; } + uint8_t attrWeight() const { return m_aweight; } private: - uint8 m_astretch; - uint8 m_ashrink; - uint8 m_astep; - uint8 m_aweight; + uint8_t m_astretch; + uint8_t m_ashrink; + uint8_t m_astep; + uint8_t m_aweight; }; class Silf @@ -74,51 +74,51 @@ Silf() throw(); ~Silf() throw(); - bool readGraphite(const byte * const pSilf, size_t lSilf, Face &face, uint32 version); - bool runGraphite(Segment *seg, uint8 firstPass=0, uint8 lastPass=0, int dobidi = 0) const; - uint16 findClassIndex(uint16 cid, uint16 gid) const; - uint16 getClassGlyph(uint16 cid, unsigned int index) const; - uint16 findPseudo(uint32 uid) const; - uint8 numUser() const { return m_aUser; } - uint8 aPseudo() const { return m_aPseudo; } - uint8 aBreak() const { return m_aBreak; } - uint8 aMirror() const {return m_aMirror; } - uint8 aPassBits() const { return m_aPassBits; } - uint8 aBidi() const { return m_aBidi; } - uint8 aCollision() const { return m_aCollision; } - uint8 substitutionPass() const { return m_sPass; } - uint8 positionPass() const { return m_pPass; } - uint8 justificationPass() const { return m_jPass; } - uint8 bidiPass() const { return m_bPass; } - uint8 numPasses() const { return m_numPasses; } - uint8 maxCompPerLig() const { return m_iMaxComp; } - uint16 numClasses() const { return m_nClass; } - byte flags() const { return m_flags; } - byte dir() const { return m_dir; } - uint8 numJustLevels() const { return m_numJusts; } + bool readGraphite(const uint8_t * const pSilf, size_t lSilf, Face &face, uint32_t version); + bool runGraphite(Segment *seg, uint8_t firstPass=0, uint8_t lastPass=0, int dobidi = 0) const; + uint16_t findClassIndex(uint16_t cid, uint16_t gid) const; + uint16_t getClassGlyph(uint16_t cid, unsigned int index) const; + uint16_t findPseudo(uint32_t uid) const; + uint8_t numUser() const { return m_aUser; } + uint8_t aPseudo() const { return m_aPseudo; } + uint8_t aBreak() const { return m_aBreak; } + uint8_t aMirror() const {return m_aMirror; } + uint8_t aPassBits() const { return m_aPassBits; } + uint8_t aBidi() const { return m_aBidi; } + uint8_t aCollision() const { return m_aCollision; } + uint8_t substitutionPass() const { return m_sPass; } + uint8_t positionPass() const { return m_pPass; } + uint8_t justificationPass() const { return m_jPass; } + uint8_t bidiPass() const { return m_bPass; } + uint8_t numPasses() const { return m_numPasses; } + uint8_t maxCompPerLig() const { return m_iMaxComp; } + uint16_t numClasses() const { return m_nClass; } + uint8_t flags() const { return m_flags; } + uint8_t dir() const { return m_dir; } + uint8_t numJustLevels() const { return m_numJusts; } Justinfo *justAttrs() const { return m_justs; } - uint16 endLineGlyphid() const { return m_gEndLine; } + uint16_t endLineGlyphid() const { return m_gEndLine; } const gr_faceinfo *silfInfo() const { return &m_silfinfo; } CLASS_NEW_DELETE; private: - size_t readClassMap(const byte *p, size_t data_len, uint32 version, Error &e); - template<typename T> inline uint32 readClassOffsets(const byte *&p, size_t data_len, Error &e); + size_t readClassMap(const uint8_t *p, size_t data_len, uint32_t version, Error &e); + template<typename T> inline uint32_t readClassOffsets(const uint8_t *&p, size_t data_len, Error &e); Pass * m_passes; Pseudo * m_pseudos; - uint32 * m_classOffsets; - uint16 * m_classData; + uint32_t * m_classOffsets; + uint16_t * m_classData; Justinfo * m_justs; - uint8 m_numPasses; - uint8 m_numJusts; - uint8 m_sPass, m_pPass, m_jPass, m_bPass, + uint8_t m_numPasses; + uint8_t m_numJusts; + uint8_t m_sPass, m_pPass, m_jPass, m_bPass, m_flags, m_dir; - uint8 m_aPseudo, m_aBreak, m_aUser, m_aBidi, m_aMirror, m_aPassBits, + uint8_t m_aPseudo, m_aBreak, m_aUser, m_aBidi, m_aMirror, m_aPassBits, m_iMaxComp, m_aCollision; - uint16 m_aLig, m_numPseudo, m_nClass, m_nLinear, + uint16_t m_aLig, m_numPseudo, m_nClass, m_nLinear, m_gEndLine; gr_faceinfo m_silfinfo;
diff --git a/src/inc/Slot.h b/src/inc/Slot.h index df39d9a..570207e 100644 --- a/src/inc/Slot.h +++ b/src/inc/Slot.h
@@ -47,12 +47,12 @@ SlotJustify & operator = (const SlotJustify &); public: - static size_t size_of(size_t levels) { return sizeof(SlotJustify) + ((levels > 1 ? levels : 1)*NUMJUSTPARAMS - 1)*sizeof(int16); } + static size_t size_of(size_t levels) { return sizeof(SlotJustify) + ((levels > 1 ? levels : 1)*NUMJUSTPARAMS - 1)*sizeof(int16_t); } void LoadSlot(const Slot *s, const Segment *seg); SlotJustify *next; - int16 values[1]; + int16_t values[1]; }; class Slot @@ -76,18 +76,18 @@ Position advancePos() const { return m_advance; } int before() const { return m_before; } int after() const { return m_after; } - uint32 index() const { return m_index; } - void index(uint32 val) { m_index = val; } + uint32_t index() const { return m_index; } + void index(uint32_t val) { m_index = val; } - Slot(int16 *m_userAttr = NULL); + Slot(int16_t *m_userAttr = NULL); void set(const Slot & slot, int charOffset, size_t numUserAttr, size_t justLevels, size_t numChars); Slot *next() const { return m_next; } void next(Slot *s) { m_next = s; } Slot *prev() const { return m_prev; } void prev(Slot *s) { m_prev = s; } - uint16 glyph() const { return m_realglyphid ? m_realglyphid : m_glyphid; } - void setGlyph(Segment *seg, uint16 glyphid, const GlyphFace * theGlyph = NULL); - void setRealGid(uint16 realGid) { m_realglyphid = realGid; } + uint16_t glyph() const { return m_realglyphid ? m_realglyphid : m_glyphid; } + void setGlyph(Segment *seg, uint16_t glyphid, const GlyphFace * theGlyph = NULL); + void setRealGid(uint16_t realGid) { m_realglyphid = realGid; } void adjKern(const Position &pos) { m_shift = m_shift + pos; m_advance = m_advance + pos; } void origin(const Position &pos) { m_position = pos + m_shift; } void originate(int ind) { m_original = ind; } @@ -96,7 +96,7 @@ void after(int ind) { m_after = ind; } bool isBase() const { return (!m_parent); } void update(int numSlots, int numCharInfo, Position &relpos); - Position finalise(const Segment* seg, const Font* font, Position & base, Rect & bbox, uint8 attrLevel, float & clusterMin, bool rtl, bool isFinal, int depth = 0); + Position finalise(const Segment* seg, const Font* font, Position & base, Rect & bbox, uint8_t attrLevel, float & clusterMin, bool rtl, bool isFinal, int depth = 0); bool isDeleted() const { return (m_flags & DELETED) ? true : false; } void markDeleted(bool state) { if (state) m_flags |= DELETED; else m_flags &= ~DELETED; } bool isCopied() const { return (m_flags & COPIED) ? true : false; } @@ -104,18 +104,18 @@ bool isPositioned() const { return (m_flags & POSITIONED) ? true : false; } void markPositioned(bool state) { if (state) m_flags |= POSITIONED; else m_flags &= ~POSITIONED; } bool isInsertBefore() const { return !(m_flags & INSERTED); } - uint8 getBidiLevel() const { return m_bidiLevel; } - void setBidiLevel(uint8 level) { m_bidiLevel = level; } - int8 getBidiClass(const Segment *seg); - int8 getBidiClass() const { return m_bidiCls; } - void setBidiClass(int8 cls) { m_bidiCls = cls; } - int16 *userAttrs() const { return m_userAttr; } - void userAttrs(int16 *p) { m_userAttr = p; } + uint8_t getBidiLevel() const { return m_bidiLevel; } + void setBidiLevel(uint8_t level) { m_bidiLevel = level; } + int8_t getBidiClass(const Segment *seg); + int8_t getBidiClass() const { return m_bidiCls; } + void setBidiClass(int8_t cls) { m_bidiCls = cls; } + int16_t *userAttrs() const { return m_userAttr; } + void userAttrs(int16_t *p) { m_userAttr = p; } void markInsertBefore(bool state) { if (!state) m_flags |= INSERTED; else m_flags &= ~INSERTED; } - void setAttr(Segment* seg, attrCode ind, uint8 subindex, int16 val, const SlotMap & map); - int getAttr(const Segment *seg, attrCode ind, uint8 subindex) const; - int getJustify(const Segment *seg, uint8 level, uint8 subindex) const; - void setJustify(Segment *seg, uint8 level, uint8 subindex, int16 value); + void setAttr(Segment* seg, attrCode ind, uint8_t subindex, int16_t val, const SlotMap & map); + int getAttr(const Segment *seg, attrCode ind, uint8_t subindex) const; + int getJustify(const Segment *seg, uint8_t level, uint8_t subindex) const; + void setJustify(Segment *seg, uint8_t level, uint8_t subindex, int16_t value); bool isLocalJustify() const { return m_justs != NULL; }; void attachTo(Slot *ap) { m_parent = ap; } Slot *attachedTo() const { return m_parent; } @@ -127,7 +127,7 @@ void nextSibling(Slot *ap) { m_sibling = ap; } bool sibling(Slot *ap); bool removeChild(Slot *ap); - int32 clusterMetric(const Segment* seg, uint8 metric, uint8 attrLevel, bool rtl); + int32_t clusterMetric(const Segment* seg, uint8_t metric, uint8_t attrLevel, bool rtl); void positionShift(Position a) { m_position += a; } void floodShift(Position adj, int depth = 0); float just() const { return m_just; } @@ -141,11 +141,11 @@ Slot *m_next; // linked list of slots Slot *m_prev; unsigned short m_glyphid; // glyph id - uint16 m_realglyphid; - uint32 m_original; // charinfo that originated this slot (e.g. for feature values) - uint32 m_before; // charinfo index of before association - uint32 m_after; // charinfo index of after association - uint32 m_index; // slot index given to this slot during finalising + uint16_t m_realglyphid; + uint32_t m_original; // charinfo that originated this slot (e.g. for feature values) + uint32_t m_before; // charinfo index of before association + uint32_t m_after; // charinfo index of after association + uint32_t m_index; // slot index given to this slot during finalising Slot *m_parent; // index to parent we are attached to Slot *m_child; // index to first child slot that attaches to us Slot *m_sibling; // index to next child that attaches to our parent @@ -155,11 +155,11 @@ Position m_attach; // attachment point on us Position m_with; // attachment point position on parent float m_just; // Justification inserted space - uint8 m_flags; // holds bit flags - byte m_attLevel; // attachment level - int8 m_bidiCls; // bidirectional class - byte m_bidiLevel; // bidirectional level - int16 *m_userAttr; // pointer to user attributes + uint8_t m_flags; // holds bit flags + uint8_t m_attLevel; // attachment level + int8_t m_bidiCls; // bidirectional class + uint8_t m_bidiLevel; // bidirectional level + int16_t *m_userAttr; // pointer to user attributes SlotJustify *m_justs; // pointer to justification parameters friend class Segment;
diff --git a/src/inc/Sparse.h b/src/inc/Sparse.h index fcda890..876c6fd 100644 --- a/src/inc/Sparse.h +++ b/src/inc/Sparse.h
@@ -33,7 +33,7 @@ namespace graphite2 { -// A read-only packed fast sparse array of uint16 with uint16 keys. +// A read-only packed fast sparse array of uint16_t with uint16_t keys. // Like most container classes this has capacity and size properties and these // refer to the number of stored entries and the number of addressable entries // as normal. However due the sparse nature the capacity is always <= than the @@ -41,8 +41,8 @@ class sparse { public: - typedef uint16 key_type; - typedef uint16 mapped_type; + typedef uint16_t key_type; + typedef uint16_t mapped_type; typedef std::pair<const key_type, mapped_type> value_type; private:
diff --git a/src/inc/TtfTypes.h b/src/inc/TtfTypes.h index b91c9f3b..14a6d74 100644 --- a/src/inc/TtfTypes.h +++ b/src/inc/TtfTypes.h
@@ -39,6 +39,8 @@ //********************************************************************************************** // Include files //********************************************************************************************** +#include <cstdint> + namespace graphite2 { namespace TtfUtil @@ -51,20 +53,12 @@ //********************************************************************************************** // Type declarations //********************************************************************************************** -typedef unsigned char uint8; -typedef uint8 byte; -typedef signed char int8; -typedef unsigned short uint16; -typedef short int16; -typedef unsigned int uint32; -typedef int int32; - -typedef int16 short_frac; -typedef int32 fixed; -typedef int16 fword; -typedef uint16 ufword; -typedef int16 f2dot14; -typedef uint32 long_date_time[2]; +typedef int16_t short_frac; +typedef int32_t fixed; +typedef int16_t fword; +typedef uint16_t ufword; +typedef int16_t f2dot14; +typedef uint32_t long_date_time[2]; //********************************************************************************************** // Constants and enum types @@ -86,14 +80,14 @@ struct OffsetSubTable { - uint32 scaler_type; - uint16 num_tables, + uint32_t scaler_type; + uint16_t num_tables, search_range, entry_selector, range_shift; struct Entry { - uint32 tag, + uint32_t tag, checksum, offset, length; @@ -112,26 +106,26 @@ struct CharacterCodeMap { - uint16 version, + uint16_t version, num_subtables; struct { - uint16 platform_id, + uint16_t platform_id, platform_specific_id; - uint32 offset; + uint32_t offset; } encoding[1]; }; struct CmapSubTable { - uint16 format, + uint16_t format, length, language; }; struct CmapSubTableFormat4 : CmapSubTable { - uint16 seg_count_x2, + uint16_t seg_count_x2, search_range, entry_selector, range_shift, @@ -144,12 +138,12 @@ struct CmapSubTableFormat12 { fixed format; - uint32 length, + uint32_t length, language, num_groups; struct { - uint32 start_char_code, + uint32_t start_char_code, end_char_code, start_glyph_id; } group[1]; @@ -161,9 +155,9 @@ { fixed version, font_revision; - uint32 check_sum_adjustment, + uint32_t check_sum_adjustment, magic_number; - uint16 flags, + uint16_t flags, units_per_em; long_date_time created, modified; @@ -171,9 +165,9 @@ y_min, x_max, y_max; - uint16 mac_style, + uint16_t mac_style, lowest_rec_ppem; - int16 font_direction_hint, + int16_t font_direction_hint, index_to_loc_format, glyph_data_format; enum @@ -193,7 +187,7 @@ italic_angle; fword underline_position, underline_thickness; - uint32 is_fixed_pitch, + uint32_t is_fixed_pitch, min_mem_type42, max_mem_type42, min_mem_type1, @@ -210,21 +204,21 @@ struct PostScriptGlyphName2 : PostScriptGlyphName { - uint16 number_of_glyphs, + uint16_t number_of_glyphs, glyph_name_index[1]; }; struct PostScriptGlyphName25 : PostScriptGlyphName { - uint16 number_of_glyphs; - int8 offset[1]; + uint16_t number_of_glyphs; + int8_t offset[1]; }; struct PostScriptGlyphName3 : PostScriptGlyphName {}; struct PostScriptGlyphName4 : PostScriptGlyphName { - uint16 glyph_to_char_map[1]; + uint16_t glyph_to_char_map[1]; }; @@ -238,18 +232,18 @@ fword min_left_side_bearing, max_left_side_bearing, x_max_element; - int16 caret_slope_rise, + int16_t caret_slope_rise, caret_slope_run; fword caret_offset; - int16 reserved[4], + int16_t reserved[4], metric_data_format; - uint16 num_long_hor_metrics; + uint16_t num_long_hor_metrics; }; struct MaximumProfile { fixed version; - uint16 num_glyphs, + uint16_t num_glyphs, max_points, max_contours, max_component_points, @@ -266,15 +260,15 @@ }; - typedef byte Panose[10]; + typedef uint8_t Panose[10]; struct Compatibility0 { - uint16 version; - int16 x_avg_char_width; - uint16 weight_class, + uint16_t version; + int16_t x_avg_char_width; + uint16_t weight_class, width_class; - int16 fs_type, + int16_t fs_type, y_subscript_x_size, y_subscript_y_size, y_subscript_x_offset, @@ -287,9 +281,9 @@ y_strikeout_position, family_class; Panose panose; - uint32 unicode_range[4]; - int8 ach_vend_id[4]; - uint16 fs_selection, + uint32_t unicode_range[4]; + int8_t ach_vend_id[4]; + uint16_t fs_selection, fs_first_char_index, fs_last_char_index, // Acording to Apple's spec this is where v0 should end typo_ascender, @@ -311,14 +305,14 @@ struct Compatibility1 : Compatibility0 { - uint32 codepage_range[2]; + uint32_t codepage_range[2]; }; struct Compatibility2 : Compatibility1 { - int16 x_height, + int16_t x_height, cap_height; - uint16 default_char, + uint16_t default_char, break_char, max_context; }; @@ -330,7 +324,7 @@ struct NameRecord { - uint16 platform_id, + uint16_t platform_id, platform_specific_id, language_id, name_id, @@ -346,13 +340,13 @@ struct LangTagRecord { - uint16 length, + uint16_t length, offset; }; struct FontNames { - uint16 format, + uint16_t format, count, string_offset; NameRecord name_record[1]; @@ -361,14 +355,14 @@ struct HorizontalMetric { - uint16 advance_width; - int16 left_side_bearing; + uint16_t advance_width; + int16_t left_side_bearing; }; struct Glyph { - int16 number_of_contours; + int16_t number_of_contours; fword x_min, y_min, x_max, @@ -377,7 +371,7 @@ struct SimpleGlyph : Glyph { - uint16 end_pts_of_contours[1]; + uint16_t end_pts_of_contours[1]; enum { OnCurve = 0x01, @@ -393,7 +387,7 @@ struct CompoundGlyph : Glyph { - uint16 flags, + uint16_t flags, glyph_index; enum {
diff --git a/src/inc/TtfUtil.h b/src/inc/TtfUtil.h index dcbc071..f24b347 100644 --- a/src/inc/TtfUtil.h +++ b/src/inc/TtfUtil.h
@@ -37,14 +37,13 @@ #include <cstddef> +#include <cstdint> namespace graphite2 { namespace TtfUtil { - -typedef long fontTableId32; -typedef unsigned short gid16; +typedef uint16_t gid16; #define TTF_TAG(a,b,c,d) ((a << 24UL) + (b << 16UL) + (c << 8UL) + (d)) @@ -127,7 +126,7 @@ ////////////////////////////////// utility methods helpful for name table bool GetNameInfo(const void * pName, int nPlatformId, int nEncodingId, int nLangId, int nNameId, size_t & lOffset, size_t & lSize); - //size_t NameTableLength(const byte * pTable); + //size_t NameTableLength(const uint8_t * pTable); #ifdef ALL_TTFUTILS int GetLangsForNames(const void * pName, int nPlatformId, int nEncodingId, int *nameIdList, int cNameIds, short *langIdList);
diff --git a/src/inc/UtfCodec.h b/src/inc/UtfCodec.h index 9dc760f..c283abd 100644 --- a/src/inc/UtfCodec.h +++ b/src/inc/UtfCodec.h
@@ -31,15 +31,15 @@ namespace graphite2 { -typedef uint32 uchar_t; +typedef uint32_t uchar_t; template <int N> struct _utf_codec { typedef uchar_t codeunit_t; - static void put(codeunit_t * cp, const uchar_t , int8 & len) throw(); - static uchar_t get(const codeunit_t * cp, int8 & len) throw(); + static void put(codeunit_t * cp, const uchar_t , int8_t & len) throw(); + static uchar_t get(const codeunit_t * cp, int8_t & len) throw(); static bool validate(const codeunit_t * s, const codeunit_t * e) throw(); }; @@ -50,16 +50,16 @@ private: static const uchar_t limit = 0x110000; public: - typedef uint32 codeunit_t; + typedef uint32_t codeunit_t; inline - static void put(codeunit_t * cp, const uchar_t usv, int8 & l) throw() + static void put(codeunit_t * cp, const uchar_t usv, int8_t & l) throw() { *cp = usv; l = 1; } inline - static uchar_t get(const codeunit_t * cp, int8 & l) throw() + static uchar_t get(const codeunit_t * cp, int8_t & l) throw() { if (cp[0] < limit) { l = 1; return cp[0]; } else { l = -1; return 0xFFFD; } @@ -77,13 +77,13 @@ struct _utf_codec<16> { private: - static const int32 lead_offset = 0xD800 - (0x10000 >> 10); - static const int32 surrogate_offset = 0x10000 - (0xD800 << 10) - 0xDC00; + static const int32_t lead_offset = 0xD800 - (0x10000 >> 10); + static const int32_t surrogate_offset = 0x10000 - (0xD800 << 10) - 0xDC00; public: - typedef uint16 codeunit_t; + typedef uint16_t codeunit_t; inline - static void put(codeunit_t * cp, const uchar_t usv, int8 & l) throw() + static void put(codeunit_t * cp, const uchar_t usv, int8_t & l) throw() { if (usv < 0x10000) { l = 1; cp[0] = codeunit_t(usv); } else @@ -95,13 +95,13 @@ } inline - static uchar_t get(const codeunit_t * cp, int8 & l) throw() + static uchar_t get(const codeunit_t * cp, int8_t & l) throw() { - const uint32 uh = cp[0]; + const uint32_t uh = cp[0]; l = 1; if (uh < 0xD800|| uh > 0xDFFF) { return uh; } - const uint32 ul = cp[1]; + const uint32_t ul = cp[1]; if (uh > 0xDBFF || ul < 0xDC00 || ul > 0xDFFF) { l = -1; return 0xFFFD; } ++l; return (uh<<10) + ul + surrogate_offset; @@ -112,7 +112,7 @@ { const ptrdiff_t n = e-s; if (n <= 0) return n == 0; - const uint32 u = *(s+(n-1)); // Get the last codepoint + const uint32_t u = *(s+(n-1)); // Get the last codepoint return (u < 0xD800 || u > 0xDBFF); } }; @@ -122,15 +122,15 @@ struct _utf_codec<8> { private: - static const int8 sz_lut[16]; - static const byte mask_lut[5]; + static const int8_t sz_lut[16]; + static const uint8_t mask_lut[5]; static const uchar_t limit = 0x110000; public: - typedef uint8 codeunit_t; + typedef uint8_t codeunit_t; inline - static void put(codeunit_t * cp, const uchar_t usv, int8 & l) throw() + static void put(codeunit_t * cp, const uchar_t usv, int8_t & l) throw() { if (usv < 0x80) {l = 1; cp[0] = usv; return; } if (usv < 0x0800) {l = 2; cp[0] = 0xC0 + (usv >> 6); cp[1] = 0x80 + (usv & 0x3F); return; } @@ -139,9 +139,9 @@ } inline - static uchar_t get(const codeunit_t * cp, int8 & l) throw() + static uchar_t get(const codeunit_t * cp, int8_t & l) throw() { - const int8 seq_sz = sz_lut[*cp >> 4]; + const int8_t seq_sz = sz_lut[*cp >> 4]; uchar_t u = *cp & mask_lut[seq_sz]; l = 1; bool toolong = false; @@ -191,7 +191,7 @@ typedef _utf_codec<sizeof(C)*8> codec; C * cp; - mutable int8 sl; + mutable int8_t sl; public: typedef C codeunit_type; @@ -242,8 +242,8 @@ }; -typedef utf<uint32> utf32; -typedef utf<uint16> utf16; -typedef utf<uint8> utf8; +typedef utf<uint32_t> utf32; +typedef utf<uint16_t> utf16; +typedef utf<uint8_t> utf8; } // namespace graphite2
diff --git a/src/inc/bits.h b/src/inc/bits.h index 9365986..cac3e364 100644 --- a/src/inc/bits.h +++ b/src/inc/bits.h
@@ -39,15 +39,15 @@ } template<> -inline unsigned int bit_set_count(int16 v) +inline unsigned int bit_set_count(int16_t v) { - return __builtin_popcount(static_cast<uint16>(v)); + return __builtin_popcount(static_cast<uint16_t>(v)); } template<> -inline unsigned int bit_set_count(int8 v) +inline unsigned int bit_set_count(int8_t v) { - return __builtin_popcount(static_cast<uint8>(v)); + return __builtin_popcount(static_cast<uint8_t>(v)); } template<> @@ -140,7 +140,7 @@ } #if 0 -inline float float_round(float x, uint32 m) +inline float float_round(float x, uint32_t m) { *reinterpret_cast<unsigned int *>(&x) &= m; return *reinterpret_cast<float *>(&x);
diff --git a/src/inc/json.h b/src/inc/json.h index 554cd9a..c303f2c 100644 --- a/src/inc/json.h +++ b/src/inc/json.h
@@ -66,7 +66,7 @@ enum class integer : std::intmax_t {}; enum class integer_u : std::uintmax_t {}; using boolean = bool; - static const std::nullptr_t null; + static std::nullptr_t constexpr null = nullptr; void setenv(unsigned int index, void *val) { _env.reserve(index + 1); if (index >= _env.size()) _env.insert(_env.end(), _env.size() - index + 1, 0); _env[index] = val; } void *getenv(unsigned int index) const { return _env[index]; }
diff --git a/src/inc/opcode_table.h b/src/inc/opcode_table.h index cb5acde..a4599ab 100644 --- a/src/inc/opcode_table.h +++ b/src/inc/opcode_table.h
@@ -32,7 +32,7 @@ #define NILOP 0U // types or parameters are: (.. is inclusive) -// number - any byte +// number - any uint8_t // output_class - 0 .. silf.m_nClass // input_class - 0 .. silf.m_nClass // sattrnum - 0 .. 29 (gr_slatJWidth) , 55 (gr_slatUserDefn) @@ -40,7 +40,7 @@ // gattrnum - 0 .. face->getGlyphFaceCache->numAttrs() // gmetric - 0 .. 11 (kgmetDescent) // featidx - 0 .. face.numFeatures() -// level - any byte +// level - any uint8_t static const opcode_t opcode_table[] = { {{do2(nop)}, 0, "NOP"},
diff --git a/src/inc/opcodes.h b/src/inc/opcodes.h index 20a1fb9..649b8be 100644 --- a/src/inc/opcodes.h +++ b/src/inc/opcodes.h
@@ -38,7 +38,7 @@ // first use of param. // use_params(n) Claim n extra bytes of param space beyond what was // claimed using delcare_param. -// param A const byte pointer for the parameter space claimed by +// param A const uint8_t pointer for the parameter space claimed by // this instruction. // binop(op) Implement a binary operation on the stack using the // specified C++ operator. @@ -67,11 +67,11 @@ // #define NOT_IMPLEMENTED assert(false) // #define NOT_IMPLEMENTED -#define binop(op) const uint32 a = pop(); *sp = uint32(*sp) op a -#define sbinop(op) const int32 a = pop(); *sp = int32(*sp) op a +#define binop(op) const uint32_t a = pop(); *sp = uint32_t(*sp) op a +#define sbinop(op) const int32_t a = pop(); *sp = int32_t(*sp) op a #define use_params(n) dp += n -#define declare_params(n) const byte * param = dp; \ +#define declare_params(n) const uint8_t * param = dp; \ use_params(n); #define push(n) { *++sp = n; } @@ -86,34 +86,34 @@ STARTOP(push_byte) declare_params(1); - push(int8(*param)); + push(int8_t(*param)); ENDOP STARTOP(push_byte_u) declare_params(1); - push(uint8(*param)); + push(uint8_t(*param)); ENDOP STARTOP(push_short) declare_params(2); - const int16 r = int16(param[0]) << 8 - | uint8(param[1]); + const int16_t r = int16_t(param[0]) << 8 + | uint8_t(param[1]); push(r); ENDOP STARTOP(push_short_u) declare_params(2); - const uint16 r = uint16(param[0]) << 8 - | uint8(param[1]); + const uint16_t r = uint16_t(param[0]) << 8 + | uint8_t(param[1]); push(r); ENDOP STARTOP(push_long) declare_params(4); - const int32 r = int32(param[0]) << 24 - | uint32(param[1]) << 16 - | uint32(param[2]) << 8 - | uint8(param[3]); + const int32_t r = int32_t(param[0]) << 24 + | uint32_t(param[1]) << 16 + | uint32_t(param[2]) << 8 + | uint8_t(param[3]); push(r); ENDOP @@ -130,36 +130,36 @@ ENDOP STARTOP(div_) - const int32 b = pop(); - const int32 a = int32(*sp); - if (b == 0 || (a == std::numeric_limits<int32>::min() && b == -1)) DIE; - *sp = int32(*sp) / b; + const int32_t b = pop(); + const int32_t a = int32_t(*sp); + if (b == 0 || (a == std::numeric_limits<int32_t>::min() && b == -1)) DIE; + *sp = int32_t(*sp) / b; ENDOP STARTOP(min_) - const int32 a = pop(), b = *sp; + const int32_t a = pop(), b = *sp; if (a < b) *sp = a; ENDOP STARTOP(max_) - const int32 a = pop(), b = *sp; + const int32_t a = pop(), b = *sp; if (a > b) *sp = a; ENDOP STARTOP(neg) - *sp = uint32(-int32(*sp)); + *sp = uint32_t(-int32_t(*sp)); ENDOP STARTOP(trunc8) - *sp = uint8(*sp); + *sp = uint8_t(*sp); ENDOP STARTOP(trunc16) - *sp = uint16(*sp); + *sp = uint16_t(*sp); ENDOP STARTOP(cond) - const uint32 f = pop(), t = pop(), c = pop(); + const uint32_t f = pop(), t = pop(), c = pop(); push(c ? t : f); ENDOP @@ -214,7 +214,7 @@ // use_params(1); // NOT_IMPLEMENTED; //declare_params(1); - //const size_t num = uint8(*param); + //const size_t num = uint8_t(*param); //ENDOP //STARTOP(copy_next) @@ -224,16 +224,16 @@ STARTOP(put_glyph_8bit_obs) declare_params(1); - const unsigned int output_class = uint8(*param); + const unsigned int output_class = uint8_t(*param); is->setGlyph(&seg, seg.getClassGlyph(output_class, 0)); ENDOP STARTOP(put_subs_8bit_obs) declare_params(3); - const int slot_ref = int8(param[0]); - const unsigned int input_class = uint8(param[1]), - output_class = uint8(param[2]); - uint16 index; + const int slot_ref = int8_t(param[0]); + const unsigned int input_class = uint8_t(param[1]), + output_class = uint8_t(param[2]); + uint16_t index; slotref slot = slotat(slot_ref); if (slot) { @@ -244,17 +244,17 @@ STARTOP(put_copy) declare_params(1); - const int slot_ref = int8(*param); + const int slot_ref = int8_t(*param); if (is && !is->isDeleted()) { slotref ref = slotat(slot_ref); if (ref && ref != is) { - int16 *tempUserAttrs = is->userAttrs(); + int16_t *tempUserAttrs = is->userAttrs(); if (is->attachedTo() || is->firstChild()) DIE Slot *prev = is->prev(); Slot *next = is->next(); - memcpy(tempUserAttrs, ref->userAttrs(), seg.numAttrs() * sizeof(uint16)); + memcpy(tempUserAttrs, ref->userAttrs(), seg.numAttrs() * sizeof(uint16_t)); memcpy(is, ref, sizeof(Slot)); is->firstChild(NULL); is->nextSibling(NULL); @@ -349,8 +349,8 @@ STARTOP(assoc) declare_params(1); - unsigned int num = uint8(*param); - const int8 * assocs = reinterpret_cast<const int8 *>(param+1); + unsigned int num = uint8_t(*param); + const int8_t * assocs = reinterpret_cast<const int8_t *>(param+1); use_params(num); int max = -1; int min = -1; @@ -372,9 +372,9 @@ STARTOP(cntxt_item) // It turns out this is a cunningly disguised condition forward jump. declare_params(3); - const int is_arg = int8(param[0]); - const size_t iskip = uint8(param[1]), - dskip = uint8(param[2]); + const int is_arg = int8_t(param[0]); + const size_t iskip = uint8_t(param[1]), + dskip = uint8_t(param[2]); if (mapb + is_arg != map) { @@ -386,14 +386,14 @@ STARTOP(attr_set) declare_params(1); - const attrCode slat = attrCode(uint8(*param)); + const attrCode slat = attrCode(uint8_t(*param)); const int val = pop(); is->setAttr(&seg, slat, 0, val, smap); ENDOP STARTOP(attr_add) declare_params(1); - const attrCode slat = attrCode(uint8(*param)); + const attrCode slat = attrCode(uint8_t(*param)); const int val = pop(); if ((slat == gr_slatPosX || slat == gr_slatPosY) && (flags & POSITIONED) == 0) { @@ -406,7 +406,7 @@ STARTOP(attr_sub) declare_params(1); - const attrCode slat = attrCode(uint8(*param)); + const attrCode slat = attrCode(uint8_t(*param)); const int val = pop(); if ((slat == gr_slatPosX || slat == gr_slatPosY) && (flags & POSITIONED) == 0) { @@ -419,7 +419,7 @@ STARTOP(attr_set_slot) declare_params(1); - const attrCode slat = attrCode(uint8(*param)); + const attrCode slat = attrCode(uint8_t(*param)); const int offset = int(map - smap.begin())*int(slat == gr_slatAttTo); const int val = pop() + offset; is->setAttr(&seg, slat, offset, val, smap); @@ -427,16 +427,16 @@ STARTOP(iattr_set_slot) declare_params(2); - const attrCode slat = attrCode(uint8(param[0])); - const uint8 idx = uint8(param[1]); + const attrCode slat = attrCode(uint8_t(param[0])); + const uint8_t idx = uint8_t(param[1]); const int val = int(pop() + (map - smap.begin())*int(slat == gr_slatAttTo)); is->setAttr(&seg, slat, idx, val, smap); ENDOP STARTOP(push_slot_attr) declare_params(2); - const attrCode slat = attrCode(uint8(param[0])); - const int slot_ref = int8(param[1]); + const attrCode slat = attrCode(uint8_t(param[0])); + const int slot_ref = int8_t(param[1]); if ((slat == gr_slatPosX || slat == gr_slatPosY) && (flags & POSITIONED) == 0) { seg.positionSlots(0, *smap.begin(), *(smap.end()-1), seg.currdir()); @@ -452,18 +452,18 @@ STARTOP(push_glyph_attr_obs) declare_params(2); - const unsigned int glyph_attr = uint8(param[0]); - const int slot_ref = int8(param[1]); + const unsigned int glyph_attr = uint8_t(param[0]); + const int slot_ref = int8_t(param[1]); slotref slot = slotat(slot_ref); if (slot) - push(int32(seg.glyphAttr(slot->gid(), glyph_attr))); + push(int32_t(seg.glyphAttr(slot->gid(), glyph_attr))); ENDOP STARTOP(push_glyph_metric) declare_params(3); - const unsigned int glyph_attr = uint8(param[0]); - const int slot_ref = int8(param[1]); - const signed int attr_level = uint8(param[2]); + const unsigned int glyph_attr = uint8_t(param[0]); + const int slot_ref = int8_t(param[1]); + const signed int attr_level = uint8_t(param[2]); slotref slot = slotat(slot_ref); if (slot) push(seg.getGlyphMetric(slot, glyph_attr, attr_level, dir)); @@ -471,48 +471,48 @@ STARTOP(push_feat) declare_params(2); - const unsigned int feat = uint8(param[0]); - const int slot_ref = int8(param[1]); + const unsigned int feat = uint8_t(param[0]); + const int slot_ref = int8_t(param[1]); slotref slot = slotat(slot_ref); if (slot) { - uint8 fid = seg.charinfo(slot->original())->fid(); + uint8_t fid = seg.charinfo(slot->original())->fid(); push(seg.getFeature(fid, feat)); } ENDOP STARTOP(push_att_to_gattr_obs) declare_params(2); - const unsigned int glyph_attr = uint8(param[0]); - const int slot_ref = int8(param[1]); + const unsigned int glyph_attr = uint8_t(param[0]); + const int slot_ref = int8_t(param[1]); slotref slot = slotat(slot_ref); if (slot) { slotref att = slot->attachedTo(); if (att) slot = att; - push(int32(seg.glyphAttr(slot->gid(), glyph_attr))); + push(int32_t(seg.glyphAttr(slot->gid(), glyph_attr))); } ENDOP STARTOP(push_att_to_glyph_metric) declare_params(3); - const unsigned int glyph_attr = uint8(param[0]); - const int slot_ref = int8(param[1]); - const signed int attr_level = uint8(param[2]); + const unsigned int glyph_attr = uint8_t(param[0]); + const int slot_ref = int8_t(param[1]); + const signed int attr_level = uint8_t(param[2]); slotref slot = slotat(slot_ref); if (slot) { slotref att = slot->attachedTo(); if (att) slot = att; - push(int32(seg.getGlyphMetric(slot, glyph_attr, attr_level, dir))); + push(int32_t(seg.getGlyphMetric(slot, glyph_attr, attr_level, dir))); } ENDOP STARTOP(push_islot_attr) declare_params(3); - const attrCode slat = attrCode(uint8(param[0])); - const int slot_ref = int8(param[1]), - idx = uint8(param[2]); + const attrCode slat = attrCode(uint8_t(param[0])); + const int slot_ref = int8_t(param[1]), + idx = uint8_t(param[2]); if ((slat == gr_slatPosX || slat == gr_slatPosY) && (flags & POSITIONED) == 0) { seg.positionSlots(0, *smap.begin(), *(smap.end()-1), seg.currdir()); @@ -533,7 +533,7 @@ #endif STARTOP(pop_ret) - const uint32 ret = pop(); + const uint32_t ret = pop(); EXIT(ret); ENDOP @@ -547,16 +547,16 @@ STARTOP(iattr_set) declare_params(2); - const attrCode slat = attrCode(uint8(param[0])); - const uint8 idx = uint8(param[1]); + const attrCode slat = attrCode(uint8_t(param[0])); + const uint8_t idx = uint8_t(param[1]); const int val = pop(); is->setAttr(&seg, slat, idx, val, smap); ENDOP STARTOP(iattr_add) declare_params(2); - const attrCode slat = attrCode(uint8(param[0])); - const uint8 idx = uint8(param[1]); + const attrCode slat = attrCode(uint8_t(param[0])); + const uint8_t idx = uint8_t(param[1]); const int val = pop(); if ((slat == gr_slatPosX || slat == gr_slatPosY) && (flags & POSITIONED) == 0) { @@ -569,8 +569,8 @@ STARTOP(iattr_sub) declare_params(2); - const attrCode slat = attrCode(uint8(param[0])); - const uint8 idx = uint8(param[1]); + const attrCode slat = attrCode(uint8_t(param[0])); + const uint8_t idx = uint8_t(param[1]); const int val = pop(); if ((slat == gr_slatPosX || slat == gr_slatPosY) && (flags & POSITIONED) == 0) { @@ -592,11 +592,11 @@ STARTOP(put_subs) declare_params(5); - const int slot_ref = int8(param[0]); - const unsigned int input_class = uint8(param[1]) << 8 - | uint8(param[2]); - const unsigned int output_class = uint8(param[3]) << 8 - | uint8(param[4]); + const int slot_ref = int8_t(param[0]); + const unsigned int input_class = uint8_t(param[1]) << 8 + | uint8_t(param[2]); + const unsigned int output_class = uint8_t(param[3]) << 8 + | uint8_t(param[4]); slotref slot = slotat(slot_ref); if (slot) { @@ -617,41 +617,41 @@ STARTOP(put_glyph) declare_params(2); - const unsigned int output_class = uint8(param[0]) << 8 - | uint8(param[1]); + const unsigned int output_class = uint8_t(param[0]) << 8 + | uint8_t(param[1]); is->setGlyph(&seg, seg.getClassGlyph(output_class, 0)); ENDOP STARTOP(push_glyph_attr) declare_params(3); - const unsigned int glyph_attr = uint8(param[0]) << 8 - | uint8(param[1]); - const int slot_ref = int8(param[2]); + const unsigned int glyph_attr = uint8_t(param[0]) << 8 + | uint8_t(param[1]); + const int slot_ref = int8_t(param[2]); slotref slot = slotat(slot_ref); if (slot) - push(int32(seg.glyphAttr(slot->gid(), glyph_attr))); + push(int32_t(seg.glyphAttr(slot->gid(), glyph_attr))); ENDOP STARTOP(push_att_to_glyph_attr) declare_params(3); - const unsigned int glyph_attr = uint8(param[0]) << 8 - | uint8(param[1]); - const int slot_ref = int8(param[2]); + const unsigned int glyph_attr = uint8_t(param[0]) << 8 + | uint8_t(param[1]); + const int slot_ref = int8_t(param[2]); slotref slot = slotat(slot_ref); if (slot) { slotref att = slot->attachedTo(); if (att) slot = att; - push(int32(seg.glyphAttr(slot->gid(), glyph_attr))); + push(int32_t(seg.glyphAttr(slot->gid(), glyph_attr))); } ENDOP STARTOP(temp_copy) slotref newSlot = seg.newSlot(); if (!newSlot || !is) DIE; - int16 *tempUserAttrs = newSlot->userAttrs(); + int16_t *tempUserAttrs = newSlot->userAttrs(); memcpy(newSlot, is, sizeof(Slot)); - memcpy(tempUserAttrs, is->userAttrs(), seg.numAttrs() * sizeof(uint16)); + memcpy(tempUserAttrs, is->userAttrs(), seg.numAttrs() * sizeof(uint16_t)); newSlot->userAttrs(tempUserAttrs); newSlot->markCopied(true); *map = newSlot; @@ -671,21 +671,21 @@ STARTOP(setbits) declare_params(4); - const uint16 m = uint16(param[0]) << 8 - | uint8(param[1]); - const uint16 v = uint16(param[2]) << 8 - | uint8(param[3]); + const uint16_t m = uint16_t(param[0]) << 8 + | uint8_t(param[1]); + const uint16_t v = uint16_t(param[2]) << 8 + | uint8_t(param[3]); *sp = ((*sp) & ~m) | v; ENDOP STARTOP(set_feat) declare_params(2); - const unsigned int feat = uint8(param[0]); - const int slot_ref = int8(param[1]); + const unsigned int feat = uint8_t(param[0]); + const int slot_ref = int8_t(param[1]); slotref slot = slotat(slot_ref); if (slot) { - uint8 fid = seg.charinfo(slot->original())->fid(); + uint8_t fid = seg.charinfo(slot->original())->fid(); seg.setFeature(fid, feat, pop()); } ENDOP
diff --git a/src/json.cpp b/src/json.cpp index 25f2190..440d291 100644 --- a/src/json.cpp +++ b/src/json.cpp
@@ -53,8 +53,6 @@ }; } -const std::nullptr_t json::null = nullptr; - inline void json::context(const char current) throw() {
diff --git a/tests/bittwiddling/bits.cpp b/tests/bittwiddling/bits.cpp index 4f1f3f7..6fdfe06 100644 --- a/tests/bittwiddling/bits.cpp +++ b/tests/bittwiddling/bits.cpp
@@ -28,17 +28,17 @@ sparse classe is working correctly. -----------------------------------------------------------------------------*/ -#include <cassert> +// #include <cassert> +#include <cstddef> +#include <cstdint> #include <iomanip> #include <iostream> #include <limits> -#include <string> -#include "inc/Main.h" #include "inc/bits.h" using namespace graphite2; -#if defined(__x86_64__) || defined(_WIN64) +#if (UINTPTR_MAX == UINT64_MAX) #define HAS_64BIT #endif @@ -51,8 +51,8 @@ #define pat64(b) pat32(b), pat32(ffffffff##b) #define patterns(bw) \ - uint##bw const u##bw##_pat[] = {0, pat##bw(UL) }; \ - int##bw const * s##bw##_pat = reinterpret_cast<int##bw const *>(u##bw##_pat) + uint##bw##_t const u##bw##_pat[] = {0, pat##bw(UL) }; \ + int##bw##_t const * s##bw##_pat = reinterpret_cast<int##bw##_t const *>(u##bw##_pat) //#define BENCHMARK 40000000 #if defined BENCHMARK @@ -61,9 +61,6 @@ #define benchmark() #endif - -typedef unsigned long long uint64; -typedef signed long long int64; namespace { patterns(8); @@ -117,8 +114,6 @@ int main(int argc , char *argv[]) { - assert(sizeof(uint64) == 8); - benchmark() { // Test bit_set_count
diff --git a/tests/comparerenderer/FeatureParser.h b/tests/comparerenderer/FeatureParser.h index eec8c4a..c475f83 100644 --- a/tests/comparerenderer/FeatureParser.h +++ b/tests/comparerenderer/FeatureParser.h
@@ -29,14 +29,14 @@ unsigned int uId; }; -typedef struct +struct FeatureSetting { FeatID m_id; union { signed short m_sValue; unsigned short m_uValue; }; -} FeatureSetting; +}; class FeatureParser {
diff --git a/tests/comparerenderer/RenderedLine.h b/tests/comparerenderer/RenderedLine.h index 649fb63..b7cf32a 100644 --- a/tests/comparerenderer/RenderedLine.h +++ b/tests/comparerenderer/RenderedLine.h
@@ -26,7 +26,7 @@ class RenderedLine; -typedef enum { +enum LineDifference { IDENTICAL = 0, MORE_GLYPHS = 1, LESS_GLYPHS = 2, @@ -34,7 +34,7 @@ DIFFERENT_GLYPHS = 8, DIFFERENT_POSITIONS = 16, ALL_DIFFERENCE_TYPES = MORE_GLYPHS | LESS_GLYPHS | DIFFERENT_ADVANCE | DIFFERENT_GLYPHS | DIFFERENT_POSITIONS -} LineDifference; +}; const char * DIFFERENCE_DESC[] = { "same",//0
diff --git a/tests/comparerenderer/RendererOptions.h b/tests/comparerenderer/RendererOptions.h index 38955f9..679b597 100644 --- a/tests/comparerenderer/RendererOptions.h +++ b/tests/comparerenderer/RendererOptions.h
@@ -24,12 +24,12 @@ class Option { public: - typedef enum { + enum OptionType { OPTION_BOOL, OPTION_STRING, OPTION_INT, OPTION_FLOAT - } OptionType; + }; Option(const char * shortOpt, const char * longOpt, const char * desc, OptionType type) : m_shortOption(shortOpt), m_longOption(longOpt), m_description(desc), m_type(type), m_position(-1) @@ -58,7 +58,7 @@ }; // enum must be in same order as rendererOptions -typedef enum { +enum OptionId { OptTextFile, OptFontFile, OptSize, @@ -84,7 +84,7 @@ OptFeatures, OptAltFeatures, OptQuiet -} OptionId; +}; static Option rendererOptions[] = { Option("-t", "--text", "Text file", Option::OPTION_STRING),
diff --git a/tests/endian/endiantest.cpp b/tests/endian/endiantest.cpp index b4fa196..bccdfff 100644 --- a/tests/endian/endiantest.cpp +++ b/tests/endian/endiantest.cpp
@@ -31,22 +31,12 @@ Adding -DHAVE_64_LONG to your compilers command line will test 64bit wide integers in addition to 32, 16 and 8 bit. -----------------------------------------------------------------------------*/ -#include <cstdlib> +#include <cstdint> #include <string> #include "inc/Endian.h" -typedef unsigned char uint8; -typedef signed char int8; -typedef short unsigned int uint16; -typedef short signed int int16; -typedef unsigned int uint32; -typedef signed int int32; -#if defined(HAVE_64_LONG) -typedef long unsigned int uint64; -typedef long signed int int64; -#else -typedef void uint64; -typedef void int64; +#if (UINTPTR_MAX == UINT64_MAX) + #define HAS_64BIT #endif template <typename T8, typename T4, typename T2, typename T1> @@ -60,12 +50,15 @@ t &= be::swap<T2>(be::swap<T2>(T2(0xFFEEU))) == T2(0xFFEEU); t &= le::swap<T2>(le::swap<T2>(T2(0xFFEEU))) == T2(0xFFEEU); t &= be::swap<T2>(T2(0xFFEEU)) == le::swap<T2>(T2(0xEEFFU)); -#if defined(HAVE_64_LONG) t &= be::swap<T4>(be::swap<T4>(T4(0xDEADBEEFU))) == T4(0xDEADBEEFU); t &= le::swap<T4>(le::swap<T4>(T4(0xDEADBEEFU))) == T4(0xDEADBEEFU); t &= be::swap<T4>(T4(0xDEADBEEFU)) == le::swap<T4>(T4(0xEFBEADDEU)); +#if defined(HAS_64BIT) + t &= be::swap<T8>(be::swap<T8>(T8(0x0123456789ABCDEF))) == T8(0x0123456789ABCDEF); + t &= le::swap<T8>(le::swap<T8>(T8(0x0123456789ABCDEF))) == T8(0x0123456789ABCDEF); + t &= be::swap<T8>(T8(0x0123456789ABCDEF)) == le::swap<T8>(T8(0xEFCDAB8967452301)); #endif - return t; + return t; } @@ -76,7 +69,7 @@ 0xEF,0xCD,0xAB,0x89,0x67,0x45,0x23,0x01}; bool t = true; -#if defined(HAVE_64_LONG) +#if defined(HAS_64BIT) for (size_t r = rounds; r; --r) { const unsigned char *p = data; @@ -138,11 +131,11 @@ const size_t rounds = 1UL << atoi(argv[1]); int r = 0; - if (!test_swaps<uint64, uint32, uint16, uint8>() - || !test_swaps<int64, int32, int16, int8>()) + if (!test_swaps<uint64_t, uint32_t, uint16_t, uint8_t>() + || !test_swaps<int64_t, int32_t, int16_t, int8_t>()) return 5; - if (r == 0) r = test_reads<uint64, uint32, uint16, uint8>(rounds); - if (r == 0) r = test_reads<int64, int32, int16, int8>(rounds); + if (r == 0) r = test_reads<uint64_t, uint32_t, uint16_t, uint8_t>(rounds); + if (r == 0) r = test_reads<int64_t, int32_t, int16_t, int8_t>(rounds); return r; }
diff --git a/tests/featuremap/featuremaptest.cpp b/tests/featuremap/featuremaptest.cpp index afbf339..3e9e74e 100644 --- a/tests/featuremap/featuremaptest.cpp +++ b/tests/featuremap/featuremaptest.cpp
@@ -258,7 +258,7 @@ testAssertEqual("test feat label %hu %hu\n", ref->getNameId(), table.m_defs[i].m_label); size_t settingsIndex = (table.m_defs[i].m_settingsOffset - sizeof(FeatHeader) - (sizeof(FeatDefn) * table.m_header.m_numFeat)) / sizeof(FeatSetting); - for (uint16 j = 0; j < table.m_defs[i].m_numFeatSettings; j++) + for (uint16_t j = 0; j < table.m_defs[i].m_numFeatSettings; j++) { testAssertEqual("setting label %hu %hu\n", ref->getSettingName(j), table.m_settings[settingsIndex+j].m_label);
diff --git a/tests/grlist/grlisttest.cpp b/tests/grlist/grlisttest.cpp index 23fc78a..6b50337 100644 --- a/tests/grlist/grlisttest.cpp +++ b/tests/grlist/grlisttest.cpp
@@ -1,8 +1,6 @@ #include <cstdlib> #include <cstdio> #include <cassert> -#include "inc/Main.h" - #include <vector> #include "inc/List.h"
diff --git a/tests/nametabletest/nametabletest.cpp b/tests/nametabletest/nametabletest.cpp index b285080..7b9f3ef 100644 --- a/tests/nametabletest/nametabletest.cpp +++ b/tests/nametabletest/nametabletest.cpp
@@ -37,16 +37,16 @@ { TtfUtil::Sfnt::FontNames m_nameHeader; TtfUtil::Sfnt::NameRecord m_records[5]; - uint8 m_textData[27]; + uint8_t m_textData[27]; }; struct NameTestB { TtfUtil::Sfnt::FontNames m_nameHeader; TtfUtil::Sfnt::NameRecord m_records[7]; - uint16 m_langTagCount; + uint16_t m_langTagCount; TtfUtil::Sfnt::LangTagRecord m_languages[2]; - uint8 m_textData[59]; + uint8_t m_textData[59]; }; NameTestA testA = { @@ -100,12 +100,12 @@ #pragma pack(pop) -void testName(void * data, size_t length, uint16 langId, - uint16 actualLang, uint16 nameId, const char * utf8Text) +void testName(void * data, size_t length, uint16_t langId, + uint16_t actualLang, uint16_t nameId, const char * utf8Text) { NameTable name(data, length); - uint16 lang = langId; - uint32 strLen = 0; + uint16_t lang = langId; + uint32_t strLen = 0; char * n = reinterpret_cast<char*>(name.getName(lang, nameId, gr_utf8, strLen)); if ((n == NULL) || (strncmp(n, utf8Text, strLen) != 0)) { @@ -121,10 +121,10 @@ } } -void testLangId(void * data, size_t length, const char * id, uint16 expected) +void testLangId(void * data, size_t length, const char * id, uint16_t expected) { NameTable table(data, length); - uint16 lId = table.getLanguageId(id); + uint16_t lId = table.getLanguageId(id); if (lId != expected) { fprintf(stderr, "%s lang id: %d expected: %d\n", id, lId, expected); @@ -134,26 +134,26 @@ template <class T> T * toBigEndian(T & table) { T * bigEndian = gralloc<T>(1); - bigEndian->m_nameHeader.format = be::swap<uint16>(table.m_nameHeader.format); - bigEndian->m_nameHeader.count = be::swap<uint16>(table.m_nameHeader.count); - bigEndian->m_nameHeader.string_offset = be::swap<uint16>(table.m_nameHeader.string_offset); + bigEndian->m_nameHeader.format = be::swap<uint16_t>(table.m_nameHeader.format); + bigEndian->m_nameHeader.count = be::swap<uint16_t>(table.m_nameHeader.count); + bigEndian->m_nameHeader.string_offset = be::swap<uint16_t>(table.m_nameHeader.string_offset); - for (uint16 i = 0; i < table.m_nameHeader.count; i++) + for (uint16_t i = 0; i < table.m_nameHeader.count; i++) { - bigEndian->m_records[i].platform_id = be::swap<uint16>(table.m_records[i].platform_id); - bigEndian->m_records[i].platform_specific_id = be::swap<uint16>(table.m_records[i].platform_specific_id); - bigEndian->m_records[i].language_id = be::swap<uint16>(table.m_records[i].language_id); - bigEndian->m_records[i].name_id = be::swap<uint16>(table.m_records[i].name_id); - bigEndian->m_records[i].length = be::swap<uint16>(table.m_records[i].length); - bigEndian->m_records[i].offset = be::swap<uint16>(table.m_records[i].offset); + bigEndian->m_records[i].platform_id = be::swap<uint16_t>(table.m_records[i].platform_id); + bigEndian->m_records[i].platform_specific_id = be::swap<uint16_t>(table.m_records[i].platform_specific_id); + bigEndian->m_records[i].language_id = be::swap<uint16_t>(table.m_records[i].language_id); + bigEndian->m_records[i].name_id = be::swap<uint16_t>(table.m_records[i].name_id); + bigEndian->m_records[i].length = be::swap<uint16_t>(table.m_records[i].length); + bigEndian->m_records[i].offset = be::swap<uint16_t>(table.m_records[i].offset); } - bigEndian->m_nameHeader.name_record[0].platform_id = be::swap<uint16>(table.m_nameHeader.name_record[0].platform_id); - bigEndian->m_nameHeader.name_record[0].platform_specific_id = be::swap<uint16>(table.m_nameHeader.name_record[0].platform_specific_id); - bigEndian->m_nameHeader.name_record[0].language_id = be::swap<uint16>(table.m_nameHeader.name_record[0].language_id); - bigEndian->m_nameHeader.name_record[0].name_id = be::swap<uint16>(table.m_nameHeader.name_record[0].name_id); - bigEndian->m_nameHeader.name_record[0].length = be::swap<uint16>(table.m_nameHeader.name_record[0].length); - bigEndian->m_nameHeader.name_record[0].offset = be::swap<uint16>(table.m_nameHeader.name_record[0].offset); + bigEndian->m_nameHeader.name_record[0].platform_id = be::swap<uint16_t>(table.m_nameHeader.name_record[0].platform_id); + bigEndian->m_nameHeader.name_record[0].platform_specific_id = be::swap<uint16_t>(table.m_nameHeader.name_record[0].platform_specific_id); + bigEndian->m_nameHeader.name_record[0].language_id = be::swap<uint16_t>(table.m_nameHeader.name_record[0].language_id); + bigEndian->m_nameHeader.name_record[0].name_id = be::swap<uint16_t>(table.m_nameHeader.name_record[0].name_id); + bigEndian->m_nameHeader.name_record[0].length = be::swap<uint16_t>(table.m_nameHeader.name_record[0].length); + bigEndian->m_nameHeader.name_record[0].offset = be::swap<uint16_t>(table.m_nameHeader.name_record[0].offset); memcpy(bigEndian->m_textData, table.m_textData, sizeof(table.m_textData) ); return bigEndian; @@ -162,11 +162,11 @@ template <class T> T * toBigEndian1(T & table) { T * bigEndian = toBigEndian<T>(table); - bigEndian->m_langTagCount = be::swap<uint16>(table.m_langTagCount); + bigEndian->m_langTagCount = be::swap<uint16_t>(table.m_langTagCount); for (size_t i = 0; i < table.m_langTagCount; i++) { - bigEndian->m_languages[i] = be::swap<uint16>(table.m_languages[i]); - bigEndian->m_languages[i] = be::swap<uint16>(table.m_languages[i]); + bigEndian->m_languages[i] = be::swap<uint16_t>(table.m_languages[i]); + bigEndian->m_languages[i] = be::swap<uint16_t>(table.m_languages[i]); } }
diff --git a/tests/sparsetest/sparsetest.cpp b/tests/sparsetest/sparsetest.cpp index de66e71..e2339fe 100644 --- a/tests/sparsetest/sparsetest.cpp +++ b/tests/sparsetest/sparsetest.cpp
@@ -123,13 +123,13 @@ std::cout << "key range:\t" << data[0].first << "-" << data_end[-1].first << std::endl << "key space size: " << data_end[-1].first - data[0].first << std::endl - << "linear uint16 array:" << std::endl + << "linear uint16_t array:" << std::endl << "\tcapacity: " << data_end[-1].first+1 << std::endl << "\tresidency: " << sizeof(data)/sizeof(sparse::value_type) << std::endl << "\tfill ratio: " << 100.0f*(sizeof(data)/sizeof(sparse::value_type)/float(data_end[-1].first+1)) << "%" << std::endl - << "\tsize: " << (data_end[-1].first+1)*sizeof(uint16) << std::endl + << "\tsize: " << (data_end[-1].first+1)*sizeof(uint16_t) << std::endl - << "sparse uint16 array:" << std::endl + << "sparse uint16_t array:" << std::endl << "\tcapacity: " << sp.capacity() << std::endl << "\tresidency: " << sp.capacity() << std::endl << "\tfill ratio: " << 100.0f << "%" << std::endl
diff --git a/tests/vm/basic_test.cpp b/tests/vm/basic_test.cpp index bd40400..7a0ebae 100644 --- a/tests/vm/basic_test.cpp +++ b/tests/vm/basic_test.cpp
@@ -12,7 +12,7 @@ using namespace vm; typedef Machine::Code Code; -const byte simple_prog[] = +const uint8_t simple_prog[] = { PUSH_BYTE, 43, PUSH_BYTE, 42, @@ -50,7 +50,7 @@ class graphite2::Segment {}; -//std::vector<byte> fuzzer(int); +//std::vector<uint8_t> fuzzer(int); int main(int argc, char *argv[]) @@ -71,7 +71,7 @@ std::cout << "simple program size: " << sizeof(simple_prog)+1 << " bytes" << std::endl; // Replicate the code copies times. - std::vector<byte> big_prog; + std::vector<uint8_t> big_prog; big_prog.push_back(simple_prog[0]); big_prog.push_back(simple_prog[1]); for(; copies; --copies) @@ -103,7 +103,7 @@ // run the program Segment seg; Slot s1; - uint32 ret = 0; + uint32_t ret = 0; SlotMap smap(seg, 0, 0); Machine m(smap); smap.pushSlot(&s1); @@ -149,10 +149,10 @@ } -std::vector<byte> random_sequence(size_t n) +std::vector<uint8_t> random_sequence(size_t n) { std::vector<bool> done(n); - std::vector<byte> seq(n); + std::vector<uint8_t> seq(n); srand(static_cast<unsigned int>(time(NULL))); @@ -163,7 +163,7 @@ if (done[r]) continue; done[r] = true; - seq[r] = byte(r); + seq[r] = uint8_t(r); --n; } @@ -171,9 +171,9 @@ } /* -std::vector<byte> fuzzer(int n) +std::vector<uint8_t> fuzzer(int n) { - std::vector<byte> code(256); + std::vector<uint8_t> code(256); std::vector<bool> covered(256); // Track stack depth to ensure we don't create programs that