Remove redundant typedefs for fixed width types
diff --git a/CMakeLists.txt b/CMakeLists.txt index 496712d..8a767ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -11,6 +11,8 @@ option(BUILD_SHARED_LIBS "Make library a shared library instead of static" ON) enable_language(CXX C) +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED 99) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED 11)
diff --git a/gr2fonttest/UtfCodec.cpp b/gr2fonttest/UtfCodec.cpp index c7b71e8..1585f12 100644 --- a/gr2fonttest/UtfCodec.cpp +++ b/gr2fonttest/UtfCodec.cpp
@@ -33,7 +33,7 @@ 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
diff --git a/gr2fonttest/UtfCodec.h b/gr2fonttest/UtfCodec.h index c0207f8..a505c80 100644 --- a/gr2fonttest/UtfCodec.h +++ b/gr2fonttest/UtfCodec.h
@@ -29,25 +29,19 @@ #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; +typedef uint8_t byte; 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(); }; @@ -57,16 +51,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; } @@ -78,13 +72,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 @@ -96,13 +90,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 (0xD800 > uh || uh > 0xDFFF) { return uh; } - const uint32 ul = cp[1]; + const uint32_t ul = cp[1]; if (uh > 0xDBFF || 0xDC00 > ul || ul > 0xDFFF) { l = -1; return 0xFFFD; } ++l; return (uh<<10) + ul + surrogate_offset; @@ -114,15 +108,15 @@ struct _utf_codec<8> { private: - static const int8 sz_lut[16]; + static const int8_t sz_lut[16]; static const byte mask_lut[5]; 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; } @@ -131,9 +125,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; @@ -165,7 +159,7 @@ typedef _utf_codec<sizeof(C)*8> codec; C * cp; - mutable int8 sl; + mutable int8_t sl; public: typedef C codeunit_type; @@ -211,8 +205,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/gr2fonttest/gr2FontTest.cpp b/gr2fonttest/gr2FontTest.cpp index e32b4dd..1af9487 100644 --- a/gr2fonttest/gr2FontTest.cpp +++ b/gr2fonttest/gr2FontTest.cpp
@@ -47,13 +47,13 @@ { public: - Gr2TextSrc(const gr_uint32* base, size_t len) : m_buff(base), m_len(len) { } + Gr2TextSrc(const uint32_t* base, size_t len) : m_buff(base), m_len(len) { } gr_encform utfEncodingForm() const { return gr_utf32; } size_t getLength() const { return m_len; } const void* get_utf_buffer_begin() const { return m_buff; } private: - const gr_uint32* m_buff; + const uint32_t* m_buff; size_t m_len; }; @@ -488,17 +488,17 @@ return (argError) ? false : true; } -typedef gr_uint32 tag_t; +typedef uint32_t tag_t; void Parameters::printFeatures(const gr_face * face) const { - gr_uint16 numFeatures = gr_face_n_fref(face); + uint16_t numFeatures = gr_face_n_fref(face); fprintf(log, "%d features\n", numFeatures); - gr_uint16 langId = 0x0409; - for (gr_uint16 i = 0; i < numFeatures; i++) + uint16_t langId = 0x0409; + for (uint16_t i = 0; i < numFeatures; i++) { const gr_feature_ref * f = gr_face_fref(face, i); - gr_uint32 length = 0; + uint32_t length = 0; char * label = reinterpret_cast<char *>(gr_fref_label(f, &langId, gr_utf8, &length)); const tag_t featId = gr_fref_id(f); if (label) @@ -516,19 +516,19 @@ else fprintf(log, "%d\n", featId); gr_label_destroy(reinterpret_cast<void*>(label)); - gr_uint16 numSettings = gr_fref_n_values(f); - for (gr_uint16 j = 0; j < numSettings; j++) + uint16_t numSettings = gr_fref_n_values(f); + for (uint16_t j = 0; j < numSettings; j++) { - gr_int16 value = gr_fref_value(f, j); + int16_t value = gr_fref_value(f, j); label = reinterpret_cast<char *>(gr_fref_value_label (f, j, &langId, gr_utf8, &length)); fprintf(log, "\t%d\t%s\n", value, label); gr_label_destroy(reinterpret_cast<void*>(label)); } } - gr_uint16 numLangs = gr_face_n_languages(face); + uint16_t numLangs = gr_face_n_languages(face); fprintf(log, "Feature Languages:"); - for (gr_uint16 i = 0; i < numLangs; i++) + for (uint16_t i = 0; i < numLangs; i++) { const tag_t lang_id = gr_face_lang_by_index(face, i); fprintf(log, "\t"); @@ -564,7 +564,7 @@ const char * name = features; const char * valueText = NULL; size_t nameLength = 0; - gr_int32 value = 0; + int32_t value = 0; const gr_feature_ref* ref = NULL; tag_t feat_id = 0; for (size_t i = 0; i < featureLength; i++)
diff --git a/include/graphite2/Font.h b/include/graphite2/Font.h index 3e8214d..fbd8686 100644 --- a/include/graphite2/Font.h +++ b/include/graphite2/Font.h
@@ -68,9 +68,9 @@ /** Holds information about a particular Graphite silf table that has been loaded */ struct gr_faceinfo { - gr_uint16 extra_ascent; /**< The extra_ascent in the GDL, in design units */ - gr_uint16 extra_descent; /**< The extra_descent in the GDL, in design units */ - gr_uint16 upem; /**< The design units for the font */ + uint16_t extra_ascent; /**< The extra_ascent in the GDL, in design units */ + uint16_t extra_descent; /**< The extra_descent in the GDL, in design units */ + uint16_t upem; /**< The design units for the font */ enum gr_space_contextuals { gr_space_unknown = 0, /**< no information is known. */ gr_space_none = 1, /**< the space character never occurs in any rules. */ @@ -170,20 +170,20 @@ */ GR2_DEPRECATED_API gr_face* gr_make_face_with_seg_cache(const void* appFaceHandle, gr_get_table_fn getTable, unsigned int segCacheMaxSize, unsigned int faceOptions); -/** Convert a tag in a string into a gr_uint32 +/** Convert a tag in a string into a uint32_t * - * @return gr_uint32 tag, zero padded + * @return uint32_t tag, zero padded * @param str a nul terminated string of which at most the first 4 characters are read */ -GR2_API gr_uint32 gr_str_to_tag(const char *str); +GR2_API uint32_t gr_str_to_tag(const char *str); -/** Convert a gr_uint32 tag into a string +/** Convert a uint32_t tag into a string * * @param tag contains the tag to convert * @param str is a pointer to a char array of at least size 4 bytes. The first 4 bytes of this array * will be overwritten by this function. No nul is appended. */ -GR2_API void gr_tag_to_str(gr_uint32 tag, char *str); +GR2_API void gr_tag_to_str(uint32_t tag, char *str); /** Get feature values for a given language or default * @@ -195,7 +195,7 @@ * langname is right 0 padded and assumes lowercase. Thus the en langauge * would be 0x656E0000. Langname may also be space padded, thus 0x656E2020. */ -GR2_API gr_feature_val* gr_face_featureval_for_lang(const gr_face* pFace, gr_uint32 langname); +GR2_API gr_feature_val* gr_face_featureval_for_lang(const gr_face* pFace, uint32_t langname); /** Get feature reference for a given feature id from a face * @@ -204,19 +204,19 @@ * @param pFace Font face to get information on. * @param featId Feature id tag to get reference to. */ -GR2_API const gr_feature_ref* gr_face_find_fref(const gr_face* pFace, gr_uint32 featId); +GR2_API const gr_feature_ref* gr_face_find_fref(const gr_face* pFace, uint32_t featId); /** Returns number of feature references in a face **/ -GR2_API gr_uint16 gr_face_n_fref(const gr_face* pFace); +GR2_API uint16_t gr_face_n_fref(const gr_face* pFace); /** Returns feature reference at given index in face **/ -GR2_API const gr_feature_ref* gr_face_fref(const gr_face* pFace, gr_uint16 i); +GR2_API const gr_feature_ref* gr_face_fref(const gr_face* pFace, uint16_t i); /** Return number of languages the face knows about **/ GR2_API unsigned short gr_face_n_languages(const gr_face* pFace); /** Returns a language id corresponding to a language of given index in the face **/ -GR2_API gr_uint32 gr_face_lang_by_index(const gr_face* pFace, gr_uint16 i); +GR2_API uint32_t gr_face_lang_by_index(const gr_face* pFace, uint16_t i); /** Destroy the given face and free its memory **/ GR2_API void gr_face_destroy(gr_face *face); @@ -225,7 +225,7 @@ GR2_API unsigned short gr_face_n_glyphs(const gr_face* pFace); /** Returns a faceinfo for the face and script **/ -GR2_API const gr_faceinfo *gr_face_info(const gr_face *pFace, gr_uint32 script); +GR2_API const gr_faceinfo *gr_face_info(const gr_face *pFace, uint32_t script); /** Returns whether the font supports a given Unicode character * @@ -234,7 +234,7 @@ * @param usv Unicode Scalar Value of character to test * @param script Tag of script for selecting which set of pseudo glyphs to test. May be NULL. */ -GR2_API int gr_face_is_char_supported(const gr_face *pFace, gr_uint32 usv, gr_uint32 script); +GR2_API int gr_face_is_char_supported(const gr_face *pFace, uint32_t usv, uint32_t script); #ifndef GRAPHITE2_NFILEFACE /** Create gr_face from a font file @@ -270,7 +270,7 @@ * @param appFontHandle is the unique information passed to gr_make_font_with_advance() * @param glyphid is the glyph to retireve the hinted advance for. */ -typedef float (*gr_advance_fn)(const void* appFontHandle, gr_uint16 glyphid); +typedef float (*gr_advance_fn)(const void* appFontHandle, uint16_t glyphid); /** struct housing function pointers to manage font hinted metrics for the * graphite engine. */ @@ -326,7 +326,7 @@ * @param pfeatureref gr_feature_ref to the feature * @param feats gr_feature_val containing all the values */ -GR2_API gr_uint16 gr_fref_feature_value(const gr_feature_ref* pfeatureref, const gr_feature_val* feats); +GR2_API uint16_t gr_fref_feature_value(const gr_feature_ref* pfeatureref, const gr_feature_val* feats); /** set a feature value * @@ -335,13 +335,13 @@ * @param val value to set the feature to * @param pDest the gr_feature_val containing all the values for all the features */ -GR2_API int gr_fref_set_feature_value(const gr_feature_ref* pfeatureref, gr_uint16 val, gr_feature_val* pDest); +GR2_API int gr_fref_set_feature_value(const gr_feature_ref* pfeatureref, uint16_t val, gr_feature_val* pDest); /** Returns the id tag for a gr_feature_ref **/ -GR2_API gr_uint32 gr_fref_id(const gr_feature_ref* pfeatureref); +GR2_API uint32_t gr_fref_id(const gr_feature_ref* pfeatureref); /** Returns number of values a feature may take, given a gr_feature_ref **/ -GR2_API gr_uint16 gr_fref_n_values(const gr_feature_ref* pfeatureref); +GR2_API uint16_t gr_fref_n_values(const gr_feature_ref* pfeatureref); /** Returns the value associated with a particular value in a feature * @@ -349,7 +349,7 @@ * @param pfeatureref gr_feature_ref of the feature of interest * @param settingno Index up to the return value of gr_fref_n_values() of the value */ -GR2_API gr_int16 gr_fref_value(const gr_feature_ref* pfeatureref, gr_uint16 settingno); +GR2_API int16_t gr_fref_value(const gr_feature_ref* pfeatureref, uint16_t settingno); /** Returns a string of the UI name of a feature * @@ -360,7 +360,7 @@ * @param utf Encoding form for the string * @param length Used to return the length of the string returned in bytes. */ -GR2_API void* gr_fref_label(const gr_feature_ref* pfeatureref, gr_uint16 *langId, enum gr_encform utf, gr_uint32 *length); +GR2_API void* gr_fref_label(const gr_feature_ref* pfeatureref, uint16_t *langId, enum gr_encform utf, uint32_t *length); /** Return a UI string for a possible value of a feature * @@ -373,7 +373,7 @@ * @param utf Encoding form for the string * @param length Returns the length of the string returned in bytes. */ -GR2_API void* gr_fref_value_label(const gr_feature_ref* pfeatureref, gr_uint16 settingno/*rather than a value*/, gr_uint16 *langId, enum gr_encform utf, gr_uint32 *length); +GR2_API void* gr_fref_value_label(const gr_feature_ref* pfeatureref, uint16_t settingno/*rather than a value*/, uint16_t *langId, enum gr_encform utf, uint32_t *length); /** Destroy a previously returned label string **/ GR2_API void gr_label_destroy(void * label);
diff --git a/include/graphite2/Segment.h b/include/graphite2/Segment.h index 0e24f5d..607e124 100644 --- a/include/graphite2/Segment.h +++ b/include/graphite2/Segment.h
@@ -266,7 +266,7 @@ * right (0) and whether to run the internal bidi pass, if a font requests it. * See enum gr_bidirtl for details. */ -GR2_API gr_segment* gr_make_seg(const gr_font* font, const gr_face* face, gr_uint32 script, const gr_feature_val* pFeats, enum gr_encform enc, const void* pStart, size_t nChars, int dir); +GR2_API gr_segment* gr_make_seg(const gr_font* font, const gr_face* face, uint32_t script, const gr_feature_val* pFeats, enum gr_encform enc, const void* pStart, size_t nChars, int dir); /** Destroys a segment, freeing the memory. * @@ -431,7 +431,7 @@ * Given a slot and an attribute along with a possible subattribute, return the * corresponding value in the slot. See enum gr_attrCode for details of each attribute. */ -GR2_API int gr_slot_attr(const gr_slot* p/*not NULL*/, const gr_segment* pSeg/*not NULL*/, enum gr_attrCode index, gr_uint8 subindex); //tbd - do we need to expose this? +GR2_API int gr_slot_attr(const gr_slot* p/*not NULL*/, const gr_segment* pSeg/*not NULL*/, enum gr_attrCode index, uint8_t subindex); //tbd - do we need to expose this? /** Returns whether text may be inserted before this glyph. *
diff --git a/include/graphite2/Types.h b/include/graphite2/Types.h index 916c911..f7548aa 100644 --- a/include/graphite2/Types.h +++ b/include/graphite2/Types.h
@@ -27,17 +27,10 @@ #pragma once #include <stddef.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; +#include <stdint.h> 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 cf4b1cb..91045fdc 100644 --- a/src/Code.cpp +++ b/src/Code.cpp
@@ -68,12 +68,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 @@ -97,25 +97,25 @@ 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(); + void analyse_opcode(const opcode, const int8_t * 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(); + 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(); bool test_attr(attrCode attr) 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; limits & _max; enum passtype _passtype; int _stack_depth; bool _in_ctxt_item; - int16 _slotref; + int16_t _slotref; context _contexts[NUMCONTEXTS]; byte _max_ref; }; @@ -124,8 +124,8 @@ struct Machine::Code::decoder::limits { const byte * bytecode; - const uint8 pre_context; - const uint16 rule_length, + const uint8_t pre_context; + const uint16_t rule_length, classes, glyf_attrs, features; @@ -146,7 +146,7 @@ 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, + uint8_t pre_context, uint16_t rule_length, const Silf & silf, const Face & face, enum passtype pt, byte * * 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) @@ -259,7 +259,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; @@ -336,13 +336,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 : @@ -366,12 +366,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; @@ -398,7 +398,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); test_attr(attrCode(bc[0])); @@ -407,25 +407,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]); } test_attr(attrCode(bc[0])); @@ -456,27 +456,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); @@ -487,7 +487,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) { @@ -496,7 +496,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 : @@ -517,7 +517,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 : @@ -584,8 +584,8 @@ { 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; @@ -670,7 +670,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); @@ -678,7 +678,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) { @@ -765,7 +765,7 @@ } -int32 Machine::Code::run(Machine & m, ShapingContext::map_t::iterator & slot_in, slotref & slot_out) const +int32_t Machine::Code::run(Machine & m, ShapingContext::map_t::iterator & slot_in, slotref & slot_out) const { // assert(_own); assert(*this); // Check we are actually runnable
diff --git a/src/Collider.cpp b/src/Collider.cpp index d775d56..535312b 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; @@ -762,7 +762,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) @@ -1066,15 +1066,15 @@ // 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; const sparse &p = glyphFace->attrs(); _flags = p[aCol]; - _limit = Rect(Position(int16(p[aCol+1]), int16(p[aCol+2])), - Position(int16(p[aCol+3]), int16(p[aCol+4]))); + _limit = Rect(Position(int16_t(p[aCol+1]), int16_t(p[aCol+2])), + Position(int16_t(p[aCol+3]), int16_t(p[aCol+4]))); _margin = p[aCol+5]; _marginWt = p[aCol+6];
diff --git a/src/Face.cpp b/src/Face.cpp index d30ddd7..3d1a20c 100644 --- a/src/Face.cpp +++ b/src/Face.cpp
@@ -81,14 +81,14 @@ delete m_pNames; } -float Face::default_glyph_advance(const void* font_ptr, gr_uint16 glyphid) +float Face::default_glyph_advance(const void* font_ptr, uint16_t glyphid) { const Font & font = *reinterpret_cast<const Font *>(font_ptr); 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 @@ -127,13 +127,13 @@ const byte * 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]; @@ -141,8 +141,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); @@ -218,7 +218,7 @@ #endif } -const Silf *Face::chooseSilf(uint32 script) const +const Silf *Face::chooseSilf(uint32_t script) const { if (m_numSilf == 0) return NULL; @@ -228,12 +228,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)) { @@ -265,7 +265,7 @@ return m_pNames; } -uint16 Face::languageForLocale(const char * locale) const +uint16_t Face::languageForLocale(const char * locale) const { nameTable(); if (m_pNames) @@ -275,7 +275,7 @@ -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), _sz(0), _compressed(false) { _p = static_cast<const byte *>((*_f->m_ops.get_table)(_f->m_appFaceHandle, n, &_sz)); @@ -286,7 +286,7 @@ return; } - if (be::peek<uint32>(_p) >= version) + if (be::peek<uint32_t>(_p) >= version) decompress(); } @@ -310,16 +310,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; size_t uncompressed_size = 0; const byte * p = _p; - const uint32 version = be::read<uint32>(p); // Table version number. + 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; @@ -333,7 +333,7 @@ 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; } @@ -346,7 +346,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..dbc7640 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 byte * 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; @@ -106,10 +106,10 @@ const byte *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) { @@ -201,8 +201,8 @@ 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,9 +211,9 @@ 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; @@ -222,8 +222,8 @@ // 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 282bdc1..4f2b721 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<W> & operator ++ () { - ++_n; be::skip<uint16>(_v); + ++_n; be::skip<uint16_t>(_v); if (_n == run()) advance_entry(); return *this; } @@ -66,7 +66,7 @@ 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: @@ -74,8 +74,8 @@ 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]); @@ -203,7 +203,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 @@ -277,17 +277,17 @@ 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); + 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? @@ -300,7 +300,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(); @@ -308,7 +308,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; @@ -377,36 +377,36 @@ const byte * 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); + 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) @@ -414,16 +414,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(byte)+sizeof(uint16_t) + || gloce - glocs > _num_attrs*(2*sizeof(byte)+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)); } @@ -433,52 +433,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; 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); + 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; @@ -486,7 +486,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 5b861a9..feaa399 100644 --- a/src/Intervals.cpp +++ b/src/Intervals.cpp
@@ -58,7 +58,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.; @@ -97,7 +97,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; @@ -153,7 +153,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 8ca1a67..4f766e2 100644 --- a/src/Justifier.cpp +++ b/src/Justifier.cpp
@@ -167,14 +167,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; @@ -242,7 +242,7 @@ auto eSlot = slots().insert(pos, Slot(numAttrs())); if (eSlot == slots().end()) return eSlot; - const uint16 gid = silf()->endLineGlyphid(); + const uint16_t gid = silf()->endLineGlyphid(); const GlyphFace * theGlyph = m_face->glyphs().glyphSafe(gid); eSlot->glyph(*this, gid, theGlyph);
diff --git a/src/NameTable.cpp b/src/NameTable.cpp index d42b7f9..220506f 100644 --- a/src/NameTable.cpp +++ b/src/NameTable.cpp
@@ -32,7 +32,7 @@ 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) @@ -44,14 +44,14 @@ 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,22 +84,22 @@ 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; @@ -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 ceea23f..1f9bf85 100644 --- a/src/Pass.cpp +++ b/src/Pass.cpp
@@ -122,7 +122,7 @@ } 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) + GR_MAYBE_UNUSED Face & face, passtype pt, GR_MAYBE_UNUSED uint32_t version, Error &e) { const byte * p = pass_start, * const pass_end = p + pass_length; @@ -141,19 +141,19 @@ m_iMaxLoop = be::read<byte>(p); if (m_iMaxLoop < 1) m_iMaxLoop = 1; be::skip<byte>(p,2); // skip maxContext & maxBackup - m_numRules = be::read<uint16>(p); + 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 byte * 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) @@ -164,56 +164,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); + be::skip<uint16_t>(p, numRanges*3); const byte * const o_rule_map = p; - be::skip<uint16>(p, m_numSuccess + 1); + 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 byte *>(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 size_t numEntries = be::peek<uint16_t>(o_rule_map + m_numSuccess*sizeof(uint16_t)); const byte * const rule_map = p; - be::skip<uint16>(p, numEntries); + 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); + 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 byte * const precontext = p; be::skip<byte>(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 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 byte * 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); 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<byte>(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<byte>(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); @@ -223,7 +223,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); @@ -243,13 +243,13 @@ 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, + const byte *precontext, const uint16_t * sort_key, + const uint16_t * o_constraint, const byte *rc_data, + const uint16_t * o_action, const byte * 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 byte * const ac_data_end = ac_data + be::peek<uint16_t>(o_action + m_numRules); + const byte * const rc_data_end = rc_data + be::peek<uint16_t>(o_constraint + m_numRules); precontext += m_numRules; sort_key += m_numRules; @@ -258,16 +258,16 @@ // 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); + * 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, @@ -279,15 +279,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 @@ -327,7 +327,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; } @@ -343,7 +343,7 @@ #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 @@ -351,14 +351,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)); @@ -367,10 +367,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)); @@ -380,11 +380,11 @@ State * s = m_states, * const success_begin = m_states + m_numStates - m_numSuccess; - const Rules::Entry * rule_map_end = m_ruleMap + be::peek<uint16>(o_rule_map + m_numSuccess*sizeof(uint16)); + const Rules::Entry * 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) { - Rules::Entry * 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); + Rules::Entry * 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)) { @@ -403,14 +403,14 @@ bool Pass::readRanges(const byte * 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; @@ -493,8 +493,8 @@ if (m_maxPreCtxt < m_minPreCtxt) return false; - uint16 state = m_startStates[m_maxPreCtxt - ctxt.context()]; - uint8 free_slots = ShapingContext::MAX_SLOTS; + uint16_t state = m_startStates[m_maxPreCtxt - ctxt.context()]; + uint8_t free_slots = ShapingContext::MAX_SLOTS; do { assert(!slot->deleted()); @@ -506,7 +506,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[gid]]; if (state >= m_successStart) rules.accumulate_rules(m_states[state]); @@ -674,7 +674,7 @@ ctxt.reset(dummy, 0); ctxt.pushSlot(ctxt.segment.slots().begin()); auto map = ctxt.map.begin(); - const uint32 ret = m_cPConstraint.run(m, map, dummy); + const uint32_t ret = m_cPConstraint.run(m, map, dummy); #if !defined GRAPHITE2_NTRACING json * const dbgout = ctxt.segment.getFace()->logger(); @@ -703,7 +703,7 @@ { if (!map[0].is_valid()) continue; auto slot_out = *map; - const int32 ret = r.constraint->run(m, map, slot_out); + const int32_t ret = r.constraint->run(m, map, slot_out); if (!ret || m.status() != Machine::finished) return false; } @@ -721,7 +721,7 @@ slot_out = *map; ctxt.highpassed(false); - int32 ret = codeptr->run(m, map, slot_out); + int32_t ret = codeptr->run(m, map, slot_out); if (m.status() != Machine::finished) {
diff --git a/src/Segment.cpp b/src/Segment.cpp index 88df754..c95978e 100644 --- a/src/Segment.cpp +++ b/src/Segment.cpp
@@ -43,7 +43,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_srope(face->chooseSilf(script)->numUser(), face->chooseSilf(script)->numJustLevels()), m_charinfo(new CharInfo[numchars]), m_collisions(NULL), @@ -110,7 +110,7 @@ // Ensure any unkown bidi classes are set for the reversal algorithm. for (auto & slot: m_srope) { if (slot.bidiClass() == -1) - slot.bidiClass(int8(glyphAttr(slot.gid(), m_silf->aBidi()))); + slot.bidiClass(int8_t(glyphAttr(slot.gid(), m_silf->aBidi()))); } m_srope.reverse(); @@ -333,8 +333,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); } @@ -357,7 +357,7 @@ return true; } -void Segment::doMirror(uint16 aMirror) +void Segment::doMirror(uint16_t aMirror) { for (auto & s: slots()) {
diff --git a/src/ShapingContext.cpp b/src/ShapingContext.cpp index 78c19ba..e357601 100644 --- a/src/ShapingContext.cpp +++ b/src/ShapingContext.cpp
@@ -30,7 +30,7 @@ using namespace graphite2; -ShapingContext::ShapingContext(Segment & seg, uint8 direction, size_t maxSize) +ShapingContext::ShapingContext(Segment & seg, uint8_t direction, size_t maxSize) : segment(seg), dbgout(seg.getFace() ? seg.getFace()->logger() : nullptr), //in(seg.slots().num_user_attrs(), seg.slots().num_just_levels()),
diff --git a/src/Silf.cpp b/src/Silf.cpp index 2c304a9..d3025fc 100644 --- a/src/Silf.cpp +++ b/src/Silf.cpp
@@ -37,7 +37,7 @@ using namespace graphite2; -namespace { static const uint32 ERROROFFSET = 0xFFFFFFFF; } +namespace { static const uint32_t ERROROFFSET = 0xFFFFFFFF; } Silf::Silf() throw() : m_passes(0), @@ -90,7 +90,7 @@ } -bool Silf::readGraphite(const byte * const silf_start, size_t lSilf, Face& face, uint32 version) +bool Silf::readGraphite(const byte * const silf_start, size_t lSilf, Face& face, uint32_t version) { const byte * p = silf_start, * const silf_end = p + lSilf; @@ -103,28 +103,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)) { @@ -136,28 +136,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); } } - 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); + 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<byte>(p,3); - be::skip<uint16>(p, be::read<uint8>(p)); // don't need critical features yet + be::skip<uint16_t>(p, be::read<uint8_t>(p)); // don't need critical features yet be::skip<byte>(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 + 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 byte * o_passes = p; - uint32 passes_start = be::read<uint32>(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) @@ -174,20 +174,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); @@ -198,8 +198,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) @@ -231,45 +231,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 byte *&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 byte *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; @@ -278,20 +278,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] @@ -303,18 +303,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) @@ -323,11 +323,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; } @@ -336,11 +336,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) @@ -355,12 +355,12 @@ } -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 { size_t maxSize = seg.slotCount() * MAX_SEG_GROWTH_FACTOR; ShapingContext ctxt(seg, m_dir, maxSize); vm::Machine m(ctxt); - 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 6d3198c..72afc51 100644 --- a/src/Slot.cpp +++ b/src/Slot.cpp
@@ -93,7 +93,7 @@ for (int i = target_num_justs - 1; i >= 0; --i) { Justinfo *justs = seg.silf()->justAttrs() + i; - int16 *v = m_attrs.just_info() + i * NUMJUSTPARAMS; + int16_t *v = m_attrs.just_info() + i * NUMJUSTPARAMS; v[0] = seg.glyphAttr(gid(), justs->attrStretch()); v[1] = seg.glyphAttr(gid(), justs->attrShrink()); v[2] = seg.glyphAttr(gid(), justs->attrStep()); @@ -180,7 +180,7 @@ } -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) { // assert(false); SlotCollision *coll = NULL; @@ -255,7 +255,7 @@ return res; } -int32 Slot::clusterMetric(const Segment & seg, metrics metric, uint8 attrLevel, bool rtl) const +int32_t Slot::clusterMetric(const Segment & seg, metrics metric, uint8_t attrLevel, bool rtl) const { if (glyph() >= seg.getFace()->glyphs().numGlyphs()) return 0; @@ -273,25 +273,25 @@ switch (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; } @@ -299,7 +299,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_slatJStretch && ind < gr_slatJStretch + 20 && ind != gr_slatJWidth) { @@ -373,7 +373,7 @@ c-> x ; c->setFlags(c->flags() & ~SlotCollision::COLL_KNOWN); } \ break; } -void Slot::setAttr(Segment & seg, attrCode ind, uint8 subindex, int16 value, const ShapingContext & ctxt) +void Slot::setAttr(Segment & seg, attrCode ind, uint8_t subindex, int16_t value, const ShapingContext & ctxt) { if (ind == gr_slatUserDefnV1) { @@ -394,7 +394,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 < ctxt.map.size() && ctxt.map[idx].is_valid()) { auto other = &*ctxt.map[idx]; @@ -476,7 +476,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; @@ -496,7 +496,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 (!has_justify()) { @@ -540,7 +540,7 @@ return true; } -void Slot::glyph(Segment & seg, uint16 glyphid, const GlyphFace * theGlyph) +void Slot::glyph(Segment & seg, uint16_t glyphid, const GlyphFace * theGlyph) { m_glyphid = glyphid; m_bidiCls = -1; @@ -566,7 +566,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); }
diff --git a/src/TtfUtil.cpp b/src/TtfUtil.cpp index 2eb46a1..885ee2e 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) @@ -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 byte *>(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; } } @@ -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); } /*---------------------------------------------------------------------------------------------- @@ -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 (OVERFLOW_OFFSET_CHECK(pByte, nGlyfOffset) || nGlyfOffset >= nTableLen - sizeof(Sfnt::Glyph)) return NULL; - return const_cast<uint8 *>(pByte + nGlyfOffset); + return const_cast<uint8_t *>(pByte + nGlyfOffset); } /*---------------------------------------------------------------------------------------------- @@ -1339,12 +1339,12 @@ return false; // skip over bounding box data & point to byte count of instructions (hints) - const uint8 * pbGlyph = reinterpret_cast<const uint8 *> + 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 @@ -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;
diff --git a/src/UtfCodec.cpp b/src/UtfCodec.cpp index a944bbf..5b600c4 100644 --- a/src/UtfCodec.cpp +++ b/src/UtfCodec.cpp
@@ -33,7 +33,7 @@ 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
diff --git a/src/gr_face.cpp b/src/gr_face.cpp index 712aa11..cd84397 100644 --- a/src/gr_face.cpp +++ b/src/gr_face.cpp
@@ -76,7 +76,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; @@ -119,9 +119,9 @@ return gr_make_face_with_ops(appFaceHandle, &ops, faceOptions); } -gr_uint32 gr_str_to_tag(const char *str) +uint32_t 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; @@ -133,7 +133,7 @@ return res; } -void gr_tag_to_str(gr_uint32 tag, char *str) +void gr_tag_to_str(uint32_t tag, char *str) { if (!str) return; @@ -144,7 +144,7 @@ *str = '\0'; } -gr_feature_val* gr_face_featureval_for_lang(const gr_face* pFace, gr_uint32 langname/*0 means clone default*/) //clones the features. if none for language, clones the default +gr_feature_val* gr_face_featureval_for_lang(const gr_face* pFace, uint32_t langname/*0 means clone default*/) //clones the features. if none for language, clones the default { assert(pFace); langname = zeropad(langname); @@ -152,7 +152,7 @@ } -const gr_feature_ref* gr_face_find_fref(const gr_face* pFace, gr_uint32 featId) //When finished with the FeatureRef, call destroy_FeatureRef +const gr_feature_ref* gr_face_find_fref(const gr_face* pFace, uint32_t featId) //When finished with the FeatureRef, call destroy_FeatureRef { assert(pFace); featId = zeropad(featId); @@ -166,7 +166,7 @@ return pFace->numFeatures(); } -const gr_feature_ref* gr_face_fref(const gr_face* pFace, gr_uint16 i) //When finished with the FeatureRef, call destroy_FeatureRef +const gr_feature_ref* gr_face_fref(const gr_face* pFace, uint16_t i) //When finished with the FeatureRef, call destroy_FeatureRef { assert(pFace); const FeatureRef* pRef = pFace->feature(i); @@ -179,7 +179,7 @@ return pFace->theSill().numLanguages(); } -gr_uint32 gr_face_lang_by_index(const gr_face* pFace, gr_uint16 i) +uint32_t gr_face_lang_by_index(const gr_face* pFace, uint16_t i) { assert(pFace); return pFace->theSill().getLangName(i); @@ -192,7 +192,7 @@ } -gr_uint16 gr_face_name_lang_for_locale(gr_face *face, const char * locale) +uint16_t gr_face_name_lang_for_locale(gr_face *face, const char * locale) { if (face) { @@ -206,7 +206,7 @@ return pFace->glyphs().numGlyphs(); } -const gr_faceinfo *gr_face_info(const gr_face *pFace, gr_uint32 script) +const gr_faceinfo *gr_face_info(const gr_face *pFace, uint32_t script) { if (!pFace) return 0; const Silf *silf = pFace->chooseSilf(script); @@ -214,10 +214,10 @@ return 0; } -int gr_face_is_char_supported(const gr_face* pFace, gr_uint32 usv, gr_uint32 script) +int gr_face_is_char_supported(const gr_face* pFace, uint32_t usv, uint32_t script) { const Cmap & cmap = pFace->cmap(); - gr_uint16 gid = cmap[usv]; + uint16_t gid = cmap[usv]; if (!gid) { const Silf * silf = pFace->chooseSilf(script);
diff --git a/src/gr_features.cpp b/src/gr_features.cpp index a560e05..24fc009 100644 --- a/src/gr_features.cpp +++ b/src/gr_features.cpp
@@ -35,7 +35,7 @@ extern "C" { -gr_uint16 gr_fref_feature_value(const gr_feature_ref* pfeatureref, const gr_feature_val* feats) //returns 0 if either pointer is NULL +uint16_t gr_fref_feature_value(const gr_feature_ref* pfeatureref, const gr_feature_val* feats) //returns 0 if either pointer is NULL { if (!pfeatureref || !feats) return 0; @@ -43,7 +43,7 @@ } -int gr_fref_set_feature_value(const gr_feature_ref* pfeatureref, gr_uint16 val, gr_feature_val* pDest) +int gr_fref_set_feature_value(const gr_feature_ref* pfeatureref, uint16_t val, gr_feature_val* pDest) { if (!pfeatureref || !pDest) return 0; @@ -51,7 +51,7 @@ } -gr_uint32 gr_fref_id(const gr_feature_ref* pfeatureref) //returns 0 if pointer is NULL +uint32_t gr_fref_id(const gr_feature_ref* pfeatureref) //returns 0 if pointer is NULL { if (!pfeatureref) return 0; @@ -60,7 +60,7 @@ } -gr_uint16 gr_fref_n_values(const gr_feature_ref* pfeatureref) +uint16_t gr_fref_n_values(const gr_feature_ref* pfeatureref) { if(!pfeatureref) return 0; @@ -68,7 +68,7 @@ } -gr_int16 gr_fref_value(const gr_feature_ref* pfeatureref, gr_uint16 settingno) +int16_t gr_fref_value(const gr_feature_ref* pfeatureref, uint16_t settingno) { if(!pfeatureref || (settingno >= pfeatureref->getNumSettings())) { @@ -78,7 +78,7 @@ } -void* gr_fref_label(const gr_feature_ref* pfeatureref, gr_uint16 *langId, gr_encform utf, gr_uint32 *length) +void* gr_fref_label(const gr_feature_ref* pfeatureref, uint16_t *langId, gr_encform utf, uint32_t *length) { if(!pfeatureref) { @@ -86,7 +86,7 @@ length = 0; return NULL; } - uint16 label = pfeatureref->getNameId(); + uint16_t label = pfeatureref->getNameId(); NameTable * names = pfeatureref->getFace().nameTable(); if (!names) { @@ -98,8 +98,8 @@ } -void* gr_fref_value_label(const gr_feature_ref*pfeatureref, gr_uint16 setting, - gr_uint16 *langId, gr_encform utf, gr_uint32 *length) +void* gr_fref_value_label(const gr_feature_ref*pfeatureref, uint16_t setting, + uint16_t *langId, gr_encform utf, uint32_t *length) { if(!pfeatureref || (setting >= pfeatureref->getNumSettings())) { @@ -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 fea9939..7ace8f6 100644 --- a/src/gr_logging.cpp +++ b/src/gr_logging.cpp
@@ -248,10 +248,10 @@ return j << json::close; } -void graphite2::objectid::set_name(void const * addr, uint16 generation) noexcept +void graphite2::objectid::set_name(void const * addr, uint16_t generation) noexcept { - uint32 const p = uint32(reinterpret_cast<size_t>(addr)); - sprintf(name, "%.4x-%.2x-%.4hx", uint16(p >> 16), generation, uint16(p)); + uint32_t const p = uint32_t(reinterpret_cast<size_t>(addr)); + sprintf(name, "%.4x-%.2x-%.4hx", uint16_t(p >> 16), generation, uint16_t(p)); name[sizeof name-1] = 0; }
diff --git a/src/gr_segment.cpp b/src/gr_segment.cpp index bba5740..92424dd 100644 --- a/src/gr_segment.cpp +++ b/src/gr_segment.cpp
@@ -34,7 +34,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; @@ -58,7 +58,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) { @@ -101,7 +101,7 @@ } -gr_segment* gr_make_seg(const gr_font *font, const gr_face *face, gr_uint32 script, const gr_feature_val* pFeats, gr_encform enc, const void* pStart, size_t nChars, int dir) +gr_segment* gr_make_seg(const gr_font *font, const gr_face *face, uint32_t script, const gr_feature_val* pFeats, gr_encform enc, const void* pStart, size_t nChars, int dir) { if (!face) return nullptr;
diff --git a/src/gr_slot.cpp b/src/gr_slot.cpp index bbb2cdb..7b5192b 100644 --- a/src/gr_slot.cpp +++ b/src/gr_slot.cpp
@@ -147,7 +147,7 @@ return p->index(); } -int gr_slot_attr(const gr_slot* h/*not NULL*/, const gr_segment* pSeg/*not NULL*/, gr_attrCode index, gr_uint8 subindex) +int gr_slot_attr(const gr_slot* h/*not NULL*/, const gr_segment* pSeg/*not NULL*/, gr_attrCode index, uint8_t subindex) { assert(h); assert(pSeg);
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 3675171..7913948 100644 --- a/src/inc/Code.h +++ b/src/inc/Code.h
@@ -90,7 +90,7 @@ 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 &, + uint8_t pre_context, uint16_t rule_length, const Silf &, const Face &, enum passtype pt, byte * * 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, ShapingContext::map_t::iterator & slot_in, slotref & slot_out) const; + int32_t run(Machine &m, ShapingContext::map_t::iterator & slot_in, slotref & slot_out) const; CLASS_NEW_DELETE; };
diff --git a/src/inc/Collider.h b/src/inc/Collider.h index 2c948a8..e480049 100644 --- a/src/inc/Collider.h +++ b/src/inc/Collider.h
@@ -25,6 +25,7 @@ of the License or (at your option) any later version. */ #pragma once +#include <cstdint> #include <iterator> #include "inc/vector.hpp" @@ -38,8 +39,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 @@ -102,19 +103,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 @@ -162,9 +163,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/Face.h b/src/inc/Face.h index 10a12d2..44a3a72 100644 --- a/src/inc/Face.h +++ b/src/inc/Face.h
@@ -58,7 +58,7 @@ public: class Table; - static float default_glyph_advance(const void* face_ptr, gr_uint16 glyphid); + static float default_glyph_advance(const void* face_ptr, uint16_t glyphid); Face(const void* appFaceHandle/*non-NULL*/, const gr_face_ops & ops); virtual ~Face(); @@ -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); } @@ -179,7 +179,7 @@ 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() throw(); Table(const Table && rhs) throw();
diff --git a/src/inc/FeatureMap.h b/src/inc/FeatureMap.h index 142a00e7..d8f2dd9 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,8 +87,8 @@ 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 @@ -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; } + const FeatureRef *findFeatureRef(uint32_t name) const; + FeatureRef *feature(uint16_t 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; }; + 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 893e036..11ce807 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(size_t num, const FeatureMap & pMap) : vector<uint32>(num), m_pMap(&pMap) {} - FeatureVal(const FeatureVal & rhs) : vector<uint32>(rhs), m_pMap(rhs.m_pMap) {} + FeatureVal(size_t 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 ee6ad34..31a944f 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 42958c6..e945f54 100644 --- a/src/inc/Intervals.h +++ b/src/inc/Intervals.h
@@ -62,7 +62,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 0423053..6b6524d 100644 --- a/src/inc/Machine.h +++ b/src/inc/Machine.h
@@ -132,7 +132,7 @@ struct opcode_t { instr impl[2]; - uint8 param_sz; + uint8_t param_sz; char name[MAX_NAME_LEN]; }; @@ -141,7 +141,7 @@ { public: struct regbank; - typedef int32 stack_t; + typedef int32_t stack_t; static size_t const STACK_ORDER = 10, STACK_MAX = 1 << STACK_ORDER, STACK_GUARD = 2; @@ -189,7 +189,7 @@ slotref * is; slotref * const isb; slotref os; - int8 positioned; + int8_t positioned; }; inline Machine::Machine(ShapingContext & ctxt) throw()
diff --git a/src/inc/Main.h b/src/inc/Main.h index bd8e905..5c0e705 100644 --- a/src/inc/Main.h +++ b/src/inc/Main.h
@@ -35,14 +35,7 @@ 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; +typedef uint8_t byte; #ifdef GRAPHITE2_TELEMETRY struct telemetry
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 f34f3e4..7b6dd3b 100644 --- a/src/inc/Pass.h +++ b/src/inc/Pass.h
@@ -52,7 +52,7 @@ ~Pass(); bool readPass(const byte * pPass, size_t pass_length, size_t subtable_base, Face & face, - enum passtype pt, uint32 version, Error &e); + enum passtype pt, uint32_t version, Error &e); bool runGraphite(vm::Machine & m, ShapingContext & ctxt, bool reverse) const; void init(Silf *silf) { m_silf = silf; } byte collisionLoops() const { return m_numCollRuns; } @@ -65,13 +65,13 @@ 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, + const byte *precontext, const uint16_t * sort_key, + const uint16_t * o_constraint, const byte *constraint_data, + const uint16_t * o_action, const byte * 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; + uint16_t glyphToCol(const uint16_t gid) const; bool runFSM(ShapingContext & ctxt, vm::const_slotref slot, Rules &rules) const; void dumpRuleEventConsidered(ShapingContext const & ctxt, Rules::const_iterator first, Rules::const_iterator const & last) const; void dumpRuleEventOutput(ShapingContext const & ctxt, Rule const & r, SlotBuffer::const_iterator const, SlotBuffer::const_iterator const) const; @@ -85,11 +85,11 @@ float &ymin, float &ymax, json *const dbgout) const; const Silf * m_silf; - uint16 * m_cols; + uint16_t * m_cols; Rule * m_rules; // rules Rules::Entry * 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; @@ -97,13 +97,13 @@ 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; + 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; byte m_minPreCtxt; byte m_maxPreCtxt; byte m_colThreshold;
diff --git a/src/inc/Rule.h b/src/inc/Rule.h index 4941a81..abe5d26 100644 --- a/src/inc/Rule.h +++ b/src/inc/Rule.h
@@ -39,7 +39,7 @@ unsigned short sort; byte preContext; #ifndef NDEBUG - uint16 rule_idx; + uint16_t rule_idx; #endif Rule();
diff --git a/src/inc/Segment.h b/src/inc/Segment.h index ed6fa60..8e5c6c1 100644 --- a/src/inc/Segment.h +++ b/src/inc/Segment.h
@@ -82,16 +82,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; } void appendSlot(int i, int cid, int gid, int fid, size_t coffset); SlotBuffer::iterator newSlot(); void freeSlot(SlotBuffer::iterator); @@ -105,32 +105,32 @@ void associateChars(int offset, size_t num); void linkClusters(); - 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 const *iSlot, metrics 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 const *iSlot, metrics 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 size_t 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); - void doMirror(uint16 aMirror); + void bidiPass(int paradir, uint8_t aMirror); + void doMirror(uint16_t aMirror); SlotBuffer::iterator addLineEnd(SlotBuffer::iterator nSlot); void delLineEnd(SlotBuffer::iterator s); void reverseSlots(); @@ -140,7 +140,7 @@ SlotCollision *collisionInfo(Slot const & s) const { return m_collisions ? m_collisions + s.index() : nullptr; } 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(SlotBuffer::iterator pSlot, const Font *font, float width, enum justFlags flags, SlotBuffer::iterator pFirst, SlotBuffer::iterator pLast); @@ -162,8 +162,8 @@ 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 }; @@ -181,7 +181,7 @@ } inline -int32 Segment::getGlyphMetric(Slot const * iSlot, metrics metric, uint8 attrLevel, bool rtl) const { +int32_t Segment::getGlyphMetric(Slot const * iSlot, metrics metric, uint8_t attrLevel, bool rtl) const { if (attrLevel > 0) { auto is = iSlot->base();
diff --git a/src/inc/ShapingContext.hpp b/src/inc/ShapingContext.hpp index 1a27157..66eed97 100644 --- a/src/inc/ShapingContext.hpp +++ b/src/inc/ShapingContext.hpp
@@ -63,7 +63,7 @@ json * const dbgout; map_t map; SlotBuffer in; - uint8 const dir; + uint8_t const dir; private: const_slotref _highwater;
diff --git a/src/inc/Silf.h b/src/inc/Silf.h index f5f047b..553a584 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; + bool readGraphite(const byte * 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; size_t 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_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; } size_t numPasses() const { return m_numPasses; } - uint8 maxCompPerLig() const { return m_iMaxComp; } + uint8_t maxCompPerLig() const { return m_iMaxComp; } size_t numClasses() const { return m_nClass; } byte flags() const { return m_flags; } byte dir() const { return m_dir; } size_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 byte *p, size_t data_len, uint32_t version, Error &e); + template<typename T> inline uint32_t readClassOffsets(const byte *&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 df36fa9..21efcb3 100644 --- a/src/inc/Slot.h +++ b/src/inc/Slot.h
@@ -52,15 +52,15 @@ Position m_attach; // attachment point on us Position m_with; // attachment point position on parent float m_just; // Justification inserted space - 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 m_glyphid; // glyph id - uint16 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 + uint16_t m_glyphid; // glyph id + uint16_t m_realglyphid; byte m_attLevel; // attachment level byte m_bidiLevel; // bidirectional level - int8 m_bidiCls; // bidirectional class + int8_t m_bidiCls; // bidirectional class struct { bool deleted: 1, inserted: 1, @@ -160,8 +160,8 @@ // Glyph uint16_t gid() const { return m_glyphid; } uint16_t glyph() const { return m_realglyphid ? m_realglyphid : m_glyphid; } - void glyph(Segment &seg, uint16 glyphid, const GlyphFace * theGlyph = nullptr); -// void setRealGid(uint16 realGid) { m_realglyphid = realGid; } + void glyph(Segment &seg, uint16_t glyphid, const GlyphFace * theGlyph = nullptr); +// void setRealGid(uint16_t realGid) { m_realglyphid = realGid; } // Positioning Position const & origin() const { return m_position; } @@ -179,8 +179,8 @@ // Slot ordering - 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; } int before() const { return m_before; } void before(int ind) { m_before = ind; } int after() const { return m_after; } @@ -203,25 +203,25 @@ bool clusterhead() const { return m_flags.clusterhead ;} // Bidi - uint8 bidiLevel() const { return m_bidiLevel; } - void bidiLevel(uint8 level) { m_bidiLevel = level; } - int8 bidiClass() const { return m_bidiCls; } - void bidiClass(int8 cls) { m_bidiCls = cls; } + uint8_t bidiLevel() const { return m_bidiLevel; } + void bidiLevel(uint8_t level) { m_bidiLevel = level; } + int8_t bidiClass() const { return m_bidiCls; } + void bidiClass(int8_t cls) { m_bidiCls = cls; } // Operations Position update_cluster_metric(Segment const & seg, bool const rtl, bool const is_final, float & clsb, float & crsb, unsigned depth=100); 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); - int32 clusterMetric(Segment const & seg, metrics metric, uint8 attrLevel, bool rtl) const; + Position finalise(const Segment & seg, const Font* font, Position & base, Rect & bbox, uint8_t attrLevel, float & clusterMin, bool rtl, bool isFinal, int depth = 0); + int32_t clusterMetric(Segment const & seg, metrics metric, uint8_t attrLevel, bool rtl) const; // Attributes - void setAttr(Segment & seg, attrCode ind, uint8 subindex, int16 val, const ShapingContext & map); - int getAttr(const Segment &seg, attrCode ind, uint8 subindex) const; - int16 const *userAttrs() const { return m_attrs.user_attributes(); } + void setAttr(Segment & seg, attrCode ind, uint8_t subindex, int16_t val, const ShapingContext & map); + int getAttr(const Segment &seg, attrCode ind, uint8_t subindex) const; + int16_t const *userAttrs() const { return m_attrs.user_attributes(); } // // Justification - int getJustify(const Segment &seg, uint8 level, uint8 subindex) const; - void setJustify(Segment &seg, uint8 level, uint8 subindex, int16 value); + 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); float just() const { return m_just; } void just(float j) { m_just = j; }
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 ae67915..be11835 100644 --- a/src/inc/TtfTypes.h +++ b/src/inc/TtfTypes.h
@@ -25,6 +25,7 @@ of the License or (at your option) any later version. */ #pragma once +#include <cstdint> /*--------------------------------------------------------------------*//*:Ignore this sentence. File: TtfTypes.h @@ -51,20 +52,15 @@ //********************************************************************************************** // 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 uint8_t byte; +typedef int int32_t; -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 +82,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 +108,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 +140,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 +157,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 +167,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 +189,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 +206,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 +234,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, @@ -270,11 +266,11 @@ 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 +283,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 +307,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 +326,7 @@ struct NameRecord { - uint16 platform_id, + uint16_t platform_id, platform_specific_id, language_id, name_id, @@ -346,13 +342,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 +357,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 +373,7 @@ struct SimpleGlyph : Glyph { - uint16 end_pts_of_contours[1]; + uint16_t end_pts_of_contours[1]; enum { OnCurve = 0x01, @@ -393,7 +389,7 @@ struct CompoundGlyph : Glyph { - uint16 flags, + uint16_t flags, glyph_index; enum {
diff --git a/src/inc/UtfCodec.h b/src/inc/UtfCodec.h index 24a343d..ef0ee4e 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 * const 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,14 +95,14 @@ } 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; } if (uh > 0xDBFF) { l = -1; return 0xFFFD; } - const uint32 ul = cp[1]; + const uint32_t ul = cp[1]; if (ul < 0xDC00 || ul > 0xDFFF) { l = -1; return 0xFFFD; } ++l; return (uh<<10) + ul + surrogate_offset; @@ -113,7 +113,7 @@ { const ptrdiff_t n = e-s; if (n <= 0) return n == 0; - const uint32 u = *(e-1); // Get the last codepoint + const uint32_t u = *(e-1); // Get the last codepoint return (u < 0xD800 || u > 0xDBFF); } }; @@ -123,15 +123,15 @@ struct _utf_codec<8> { private: - static const int8 sz_lut[16]; + static const int8_t sz_lut[16]; static const byte 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; } @@ -140,9 +140,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; @@ -192,7 +192,7 @@ typedef _utf_codec<sizeof(C)*8> codec; C * cp; - mutable int8 sl; + mutable int8_t sl; public: typedef C codeunit_type; @@ -244,8 +244,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 78c4cb7..a4ff123 100644 --- a/src/inc/bits.h +++ b/src/inc/bits.h
@@ -41,15 +41,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<> @@ -142,7 +142,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/debug.h b/src/inc/debug.h index a4a8b24..968fb94 100644 --- a/src/inc/debug.h +++ b/src/inc/debug.h
@@ -52,7 +52,7 @@ objectid(SlotBuffer::const_iterator const s) noexcept; objectid(Segment const & seg) noexcept { set_name(&seg, 0); } private: - void set_name(void const * addr, uint16 generation) noexcept; + void set_name(void const * addr, uint16_t generation) noexcept; }; inline
diff --git a/src/inc/opcodes.h b/src/inc/opcodes.h index 19b33af..47fd380 100644 --- a/src/inc/opcodes.h +++ b/src/inc/opcodes.h
@@ -67,8 +67,8 @@ // #define NOT_IMPLEMENTED assert(false) // #define NOT_IMPLEMENTED -#define binop(op) const uint32 a = pop(); *reg.sp = uint32(*reg.sp) op a -#define sbinop(op) const int32 a = pop(); *reg.sp = int32(*reg.sp) op a +#define binop(op) const uint32_t a = pop(); *reg.sp = uint32_t(*reg.sp) op a +#define sbinop(op) const int32_t a = pop(); *reg.sp = int32_t(*reg.sp) op a #define use_params(n) reg.dp += (n) #define declare_params(n) const byte * param = reg.dp; \ @@ -97,34 +97,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 @@ -141,36 +141,36 @@ ENDOP STARTOP(div_) - const int32 b = pop(); - const int32 a = int32(*reg.sp); - if (b == 0 || (a == std::numeric_limits<int32>::min() && b == -1)) DIE; - *reg.sp = int32(*reg.sp) / b; + const int32_t b = pop(); + const int32_t a = int32_t(*reg.sp); + if (b == 0 || (a == std::numeric_limits<int32_t>::min() && b == -1)) DIE; + *reg.sp = int32_t(*reg.sp) / b; ENDOP STARTOP(min_) - const int32 a = pop(), b = *reg.sp; + const int32_t a = pop(), b = *reg.sp; if (a < b) *reg.sp = a; ENDOP STARTOP(max_) - const int32 a = pop(), b = *reg.sp; + const int32_t a = pop(), b = *reg.sp; if (a > b) *reg.sp = a; ENDOP STARTOP(neg) - *reg.sp = uint32(-int32(*reg.sp)); + *reg.sp = uint32_t(-int32_t(*reg.sp)); ENDOP STARTOP(trunc8) - *reg.sp = uint8(*reg.sp); + *reg.sp = uint8_t(*reg.sp); ENDOP STARTOP(trunc16) - *reg.sp = uint16(*reg.sp); + *reg.sp = uint16_t(*reg.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 @@ -225,7 +225,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) @@ -235,16 +235,16 @@ STARTOP(put_glyph_8bit_obs) declare_params(1); - const unsigned int output_class = uint8(*param); + const unsigned int output_class = uint8_t(*param); reg.os->glyph(reg.seg, reg.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 != reg.seg.slots().end()) { @@ -255,7 +255,7 @@ STARTOP(put_copy) declare_params(1); - const int slot_ref = int8(*param); + const int slot_ref = int8_t(*param); if (reg.os != reg.seg.slots().end() && !reg.os->deleted()) { auto ref = slotat(slot_ref); @@ -338,8 +338,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; @@ -361,9 +361,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 (reg.isb + is_arg != reg.is) { @@ -375,14 +375,14 @@ STARTOP(attr_set) declare_params(1); - auto const slat = Slot::attrCode(uint8(*param)); + auto const slat = Slot::attrCode(uint8_t(*param)); int const val = pop(); reg.os->setAttr(reg.seg, slat, 0, val, reg.ctxt); ENDOP STARTOP(attr_add) declare_params(1); - auto const slat = Slot::attrCode(uint8(*param)); + auto const slat = Slot::attrCode(uint8_t(*param)); uint32_t const val = pop(); position_context(slat) uint32_t res = uint32_t(reg.os->getAttr(reg.seg, slat, 0)); @@ -391,7 +391,7 @@ STARTOP(attr_sub) declare_params(1); - auto const slat = Slot::attrCode(uint8(*param)); + auto const slat = Slot::attrCode(uint8_t(*param)); uint32_t const val = pop(); position_context(slat) uint32_t res = uint32_t(reg.os->getAttr(reg.seg, slat, 0)); @@ -400,7 +400,7 @@ STARTOP(attr_set_slot) declare_params(1); - auto const slat = Slot::attrCode(uint8(*param)); + auto const slat = Slot::attrCode(uint8_t(*param)); int const offset = int(reg.is - reg.ctxt.map.begin())*int(slat == gr_slatAttTo); int const val = pop() + offset; reg.os->setAttr(reg.seg, slat, offset, val, reg.ctxt); @@ -408,16 +408,16 @@ STARTOP(iattr_set_slot) declare_params(2); - auto const slat = Slot::attrCode(uint8(param[0])); - uint8 const idx = uint8(param[1]); + auto const slat = Slot::attrCode(uint8_t(param[0])); + uint8_t const idx = uint8_t(param[1]); int const val = int(pop() + (reg.is - reg.ctxt.map.begin())*int(slat == gr_slatAttTo)); reg.os->setAttr(reg.seg, slat, idx, val, reg.ctxt); ENDOP STARTOP(push_slot_attr) declare_params(2); - auto const slat = Slot::attrCode(uint8(param[0])); - int const slot_ref = int8(param[1]); + auto const slat = Slot::attrCode(uint8_t(param[0])); + int const slot_ref = int8_t(param[1]); position_context(slat) slotref slot = slotat(slot_ref); if (slot != reg.seg.slots().end()) @@ -429,18 +429,18 @@ STARTOP(push_glyph_attr_obs) declare_params(2); - unsigned int const glyph_attr = uint8(param[0]); - int const slot_ref = int8(param[1]); + unsigned int const glyph_attr = uint8_t(param[0]); + int const slot_ref = int8_t(param[1]); slotref slot = slotat(slot_ref); if (slot != reg.seg.slots().end()) - push(int32(reg.seg.glyphAttr(slot->gid(), glyph_attr))); + push(int32_t(reg.seg.glyphAttr(slot->gid(), glyph_attr))); ENDOP STARTOP(push_glyph_metric) declare_params(3); const auto glyph_attr = metrics(param[0]); - const int slot_ref = int8(param[1]); - const signed int attr_level = uint8(param[2]); + const int slot_ref = int8_t(param[1]); + const signed int attr_level = uint8_t(param[2]); slotref slot = slotat(slot_ref); if (slot != reg.seg.slots().end()) push(reg.seg.getGlyphMetric(&*slot, glyph_attr, attr_level, reg.ctxt.dir)); @@ -448,48 +448,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 != reg.seg.slots().end()) { - uint8 fid = reg.seg.charinfo(slot->original())->fid(); + uint8_t fid = reg.seg.charinfo(slot->original())->fid(); push(reg.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 != reg.seg.slots().end()) { auto att = slot->attachedTo(); auto & ref = att ? *att : *slot; - push(int32(reg.seg.glyphAttr(ref.gid(), glyph_attr))); + push(int32_t(reg.seg.glyphAttr(ref.gid(), glyph_attr))); } ENDOP STARTOP(push_att_to_glyph_metric) declare_params(3); const auto glyph_attr = metrics(param[0]); - const int slot_ref = int8(param[1]); - const signed int attr_level = uint8(param[2]); + const int slot_ref = int8_t(param[1]); + const signed int attr_level = uint8_t(param[2]); slotref slot = slotat(slot_ref); if (slot != reg.seg.slots().end()) { auto parent = slot->attachedTo(); if (!parent) parent = &*slot; - push(int32(reg.seg.getGlyphMetric(parent, glyph_attr, attr_level, reg.ctxt.dir))); + push(int32_t(reg.seg.getGlyphMetric(parent, glyph_attr, attr_level, reg.ctxt.dir))); } ENDOP STARTOP(push_islot_attr) declare_params(3); - auto const slat = Slot::attrCode(uint8(param[0])); - int const slot_ref = int8(param[1]), - idx = uint8(param[2]); + auto const slat = Slot::attrCode(uint8_t(param[0])); + int const slot_ref = int8_t(param[1]), + idx = uint8_t(param[2]); position_context(slat) slotref slot = slotat(slot_ref); if (slot != reg.seg.slots().end()) @@ -506,7 +506,7 @@ #endif STARTOP(pop_ret) - const uint32 ret = pop(); + const uint32_t ret = pop(); EXIT(ret); ENDOP @@ -520,16 +520,16 @@ STARTOP(iattr_set) declare_params(2); - auto const slat = Slot::attrCode(uint8(param[0])); - uint8 const idx = uint8(param[1]); + auto const slat = Slot::attrCode(uint8_t(param[0])); + uint8_t const idx = uint8_t(param[1]); int const val = pop(); reg.os->setAttr(reg.seg, slat, idx, val, reg.ctxt); ENDOP STARTOP(iattr_add) declare_params(2); - auto const slat = Slot::attrCode(uint8(param[0])); - uint8 const idx = uint8(param[1]); + auto const slat = Slot::attrCode(uint8_t(param[0])); + uint8_t const idx = uint8_t(param[1]); uint32_t const val = pop(); position_context(slat) uint32_t res = uint32_t(reg.os->getAttr(reg.seg, slat, idx)); @@ -538,8 +538,8 @@ STARTOP(iattr_sub) declare_params(2); - auto const slat = Slot::attrCode(uint8(param[0])); - uint8 const idx = uint8(param[1]); + auto const slat = Slot::attrCode(uint8_t(param[0])); + uint8_t const idx = uint8_t(param[1]); uint32_t const val = pop(); position_context(slat) uint32_t res = uint32_t(reg.os->getAttr(reg.seg, slat, idx)); @@ -557,11 +557,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 != reg.seg.slots().end()) { @@ -582,32 +582,32 @@ 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]); reg.os->glyph(reg.seg, reg.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 != reg.seg.slots().end()) - push(int32(reg.seg.glyphAttr(slot->gid(), glyph_attr))); + push(int32_t(reg.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 != reg.seg.slots().end()) { auto att = slot->attachedTo(); auto & ref = att ? *att : *slot; - push(int32(reg.seg.glyphAttr(ref.gid(), glyph_attr))); + push(int32_t(reg.seg.glyphAttr(ref.gid(), glyph_attr))); } ENDOP @@ -615,9 +615,9 @@ #if 0 reg.seg.slots().push_back(Slot()); auto slot = --reg.seg.slots().end(); - int16 *tempUserAttrs = slot->userAttrs(); + int16_t *tempUserAttrs = slot->userAttrs(); memcpy(®.seg.slots().back(), &*reg.os, sizeof(Slot)); - memcpy(tempUserAttrs, reg.os->userAttrs(), reg.seg.numAttrs() * sizeof(uint16)); + memcpy(tempUserAttrs, reg.os->userAttrs(), reg.seg.numAttrs() * sizeof(uint16_t)); slot->userAttrs(tempUserAttrs); slot->copied(true); reg.seg.slots().erase(slot); @@ -650,21 +650,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]); *reg.sp = ((*reg.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 != reg.seg.slots().end()) { - uint8 fid = reg.seg.charinfo(slot->original())->fid(); + uint8_t fid = reg.seg.charinfo(slot->original())->fid(); reg.seg.setFeature(fid, feat, pop()); } ENDOP
diff --git a/tests/bittwiddling/bits.cpp b/tests/bittwiddling/bits.cpp index 02a74e8..80fc659 100644 --- a/tests/bittwiddling/bits.cpp +++ b/tests/bittwiddling/bits.cpp
@@ -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
diff --git a/tests/endian/endiantest.cpp b/tests/endian/endiantest.cpp index b4fa196..0f2fdbb 100644 --- a/tests/endian/endiantest.cpp +++ b/tests/endian/endiantest.cpp
@@ -35,12 +35,12 @@ #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; +typedef unsigned char uint8_t; +typedef signed char int8_t; +typedef short unsigned int uint16_t; +typedef short signed int int16_t; +typedef unsigned int uint32_t; +typedef signed int int32_t; #if defined(HAVE_64_LONG) typedef long unsigned int uint64; typedef long signed int int64; @@ -138,11 +138,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, uint32_t, uint16_t, uint8_t>() + || !test_swaps<int64, 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, uint32_t, uint16_t, uint8_t>(rounds); + if (r == 0) r = test_reads<int64, int32_t, int16_t, int8_t>(rounds); return r; }
diff --git a/tests/examples/features.c b/tests/examples/features.c index f9e3706..3bf79ba 100644 --- a/tests/examples/features.c +++ b/tests/examples/features.c
@@ -4,9 +4,9 @@ int main(int argc, char **argv) { - gr_uint16 i; - gr_uint16 langId = 0x0409; - gr_uint32 lang = 0; + uint16_t i; + uint16_t langId = 0x0409; + uint32_t lang = 0; char idtag[5] = {0, 0, 0, 0, 0}; /*<1>*/ gr_feature_val *features = NULL; gr_face *face = gr_make_file_face(argv[1], 0); @@ -20,10 +20,10 @@ for (i = 0; i < num; ++i) { const gr_feature_ref *fref = gr_face_fref(face, i); /*<3>*/ - gr_uint32 length = 0; + uint32_t length = 0; char *label = gr_fref_label(fref, &langId, gr_utf8, &length); /*<4>*/ - gr_uint32 id = gr_fref_id(fref); /*<5>*/ - gr_uint16 val = gr_fref_feature_value(fref, features); + uint32_t id = gr_fref_id(fref); /*<5>*/ + uint16_t val = gr_fref_feature_value(fref, features); int numval = gr_fref_n_values(fref); int j;
diff --git a/tests/featuremap/featuremaptest.cpp b/tests/featuremap/featuremaptest.cpp index 7ba52a7..b53d838 100644 --- a/tests/featuremap/featuremaptest.cpp +++ b/tests/featuremap/featuremaptest.cpp
@@ -140,27 +140,27 @@ struct FeatHeader { - _be<gr_uint16> m_major; - _be<gr_uint16> m_minor; - _be<gr_uint16> m_numFeat; - _be<gr_uint16> m_reserved1; - _be<gr_uint32> m_reserved2; + _be<uint16_t> m_major; + _be<uint16_t> m_minor; + _be<uint16_t> m_numFeat; + _be<uint16_t> m_reserved1; + _be<uint32_t> m_reserved2; }; struct FeatDefn { - _be<gr_uint32> m_featId; - _be<gr_uint16> m_numFeatSettings; - _be<gr_uint16> m_reserved1; - _be<gr_uint32> m_settingsOffset; - _be<gr_uint16> m_flags; - _be<gr_uint16> m_label; + _be<uint32_t> m_featId; + _be<uint16_t> m_numFeatSettings; + _be<uint16_t> m_reserved1; + _be<uint32_t> m_settingsOffset; + _be<uint16_t> m_flags; + _be<uint16_t> m_label; }; struct FeatSetting { - _be<gr_int16> m_value; - _be<gr_uint16> m_label; + _be<int16_t> m_value; + _be<uint16_t> m_label; }; struct FeatTableTestA
diff --git a/tests/nametabletest/nametabletest.cpp b/tests/nametabletest/nametabletest.cpp index 5584b81..47ab5fd 100644 --- a/tests/nametabletest/nametabletest.cpp +++ b/tests/nametabletest/nametabletest.cpp
@@ -36,16 +36,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]; }; #pragma pack(pop) @@ -99,12 +99,12 @@ } }; -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)) { @@ -120,10 +120,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); @@ -133,26 +133,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; @@ -161,11 +161,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 b42682c..5a55042 100644 --- a/tests/vm/basic_test.cpp +++ b/tests/vm/basic_test.cpp
@@ -106,7 +106,7 @@ // run the program auto dummy_segment = grzeroalloc<Segment>(1); SlotBuffer sb; - uint32 ret = 0; + uint32_t ret = 0; ShapingContext ctxt(*dummy_segment, 0, 0); Machine m(ctxt); ctxt.pushSlot(sb.newSlot());