diff --git a/src/hb-aat-map.hh b/src/hb-aat-map.hh index 3d5ad0e64..f103d276c 100644 --- a/src/hb-aat-map.hh +++ b/src/hb-aat-map.hh @@ -84,7 +84,7 @@ struct hb_aat_map_builder_t hb_face_t *face; public: - hb_vector_t features; + hb_sorted_vector_t features; }; diff --git a/src/hb-array.hh b/src/hb-array.hh index 70053b4e7..3339ad23d 100644 --- a/src/hb-array.hh +++ b/src/hb-array.hh @@ -46,6 +46,8 @@ struct hb_array_t : */ hb_array_t () : arrayZ (nullptr), length (0) {} hb_array_t (Type *array_, unsigned int length_) : arrayZ (array_), length (length_) {} + hb_array_t (const hb_array_t &o) : arrayZ (o.arrayZ), length (o.length) {} + hb_array_t (const hb_array_t &o) : arrayZ (o.arrayZ), length (o.length) {} template hb_array_t (Type (&array_)[length_]) : arrayZ (array_), length (length_) {} @@ -203,6 +205,8 @@ struct hb_sorted_array_t : hb_sorted_array_t () : hb_array_t () {} hb_sorted_array_t (const hb_array_t &o) : hb_array_t (o) {} + hb_sorted_array_t (const hb_sorted_array_t &o) : hb_array_t (o) {} + hb_sorted_array_t (const hb_sorted_array_t &o) : hb_array_t (o) {} hb_sorted_array_t (Type *array_, unsigned int length_) : hb_array_t (array_, length_) {} template hb_sorted_array_t (Type (&array_)[length_]) : hb_array_t (array_) {} diff --git a/src/hb-meta.hh b/src/hb-meta.hh index bea24b9a1..57defdee9 100644 --- a/src/hb-meta.hh +++ b/src/hb-meta.hh @@ -37,15 +37,18 @@ template static inline T hb_declval (); -template struct hb_remove_const { typedef T value; }; -template struct hb_remove_const { typedef T value; }; -#define hb_remove_const(T) typename hb_remove_const::value -template struct hb_remove_reference { typedef T value; }; -template struct hb_remove_reference { typedef T value; }; -#define hb_remove_reference(T) typename hb_remove_reference::value -template struct hb_remove_pointer { typedef T value; }; -template struct hb_remove_pointer { typedef T value; }; -#define hb_remove_pointer(T) typename hb_remove_pointer::value +template struct hb_match_const { typedef T type; enum { matched = false }; }; +template struct hb_match_const { typedef T type; enum { matched = true }; }; +#define hb_remove_const(T) typename hb_match_const::type +#define hb_is_const(T) hb_match_const::matched +template struct hb_match_reference { typedef T type; enum { matched = false }; }; +template struct hb_match_reference { typedef T type; enum { matched = true }; }; +#define hb_remove_reference(T) typename hb_match_reference::type +#define hb_is_reference(T) hb_match_reference::matched +template struct hb_match_pointer { typedef T type; enum { matched = false }; }; +template struct hb_match_pointer { typedef T type; enum { matched = true }; }; +#define hb_remove_pointer(T) typename hb_match_pointer::type +#define hb_is_pointer(T) hb_match_pointer::matched /* Void! For when we need a expression-type of void. */ @@ -64,7 +67,7 @@ struct hb_enable_if {}; template struct hb_enable_if { typedef T type; }; -#define hb_enable_if(Cond) typename hb_enable_if::type* = nullptr +#define hb_enable_if(Cond) typename hb_enable_if<(Cond)>::type* = nullptr #define hb_enable_if_t(Cond, Type) typename hb_enable_if<(Cond), Type>::type diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index 93dabf14a..047959675 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -827,7 +827,7 @@ struct CoverageFormat1 } template - hb_enable_if_t (hb_is_iterator (Iterator, const GlyphID), + hb_enable_if_t (hb_is_sorted_iterator (Iterator, const GlyphID), bool) serialize (hb_serialize_context_t *c, Iterator glyphs) { @@ -896,7 +896,7 @@ struct CoverageFormat2 } template - hb_enable_if_t (hb_is_iterator (Iterator, const GlyphID), + hb_enable_if_t (hb_is_sorted_iterator (Iterator, const GlyphID), bool) serialize (hb_serialize_context_t *c, Iterator glyphs) { @@ -1047,7 +1047,7 @@ struct Coverage } template - hb_enable_if_t (hb_is_iterator (Iterator, const GlyphID), + hb_enable_if_t (hb_is_sorted_iterator (Iterator, const GlyphID), bool) serialize (hb_serialize_context_t *c, Iterator glyphs) { @@ -1240,7 +1240,7 @@ struct ClassDefFormat1 TRACE_SUBSET (this); const hb_set_t &glyphset = *c->plan->glyphset; const hb_map_t &glyph_map = *c->plan->glyph_map; - hb_vector_t glyphs; + hb_sorted_vector_t glyphs; hb_vector_t klasses; hb_codepoint_t start = startGlyph; diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index da080ef94..6a4c0b4b0 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -36,7 +36,7 @@ namespace OT { static inline void SingleSubst_serialize (hb_serialize_context_t *c, - hb_array_t glyphs, + hb_sorted_array_t glyphs, hb_array_t substitutes); struct SingleSubstFormat1 @@ -92,7 +92,7 @@ struct SingleSubstFormat1 } bool serialize (hb_serialize_context_t *c, - hb_array_t glyphs, + hb_sorted_array_t glyphs, int delta) { TRACE_SERIALIZE (this); @@ -107,7 +107,7 @@ struct SingleSubstFormat1 TRACE_SUBSET (this); const hb_set_t &glyphset = *c->plan->glyphset; const hb_map_t &glyph_map = *c->plan->glyph_map; - hb_vector_t from; + hb_sorted_vector_t from; hb_vector_t to; hb_codepoint_t delta = deltaGlyphID; for (/*TODO(C++11)auto*/Coverage::iter_t iter = (this+coverage).iter (); iter; iter++) @@ -189,7 +189,7 @@ struct SingleSubstFormat2 } bool serialize (hb_serialize_context_t *c, - hb_array_t glyphs, + hb_sorted_array_t glyphs, hb_array_t substitutes) { TRACE_SERIALIZE (this); @@ -204,7 +204,7 @@ struct SingleSubstFormat2 TRACE_SUBSET (this); const hb_set_t &glyphset = *c->plan->glyphset; const hb_map_t &glyph_map = *c->plan->glyph_map; - hb_vector_t from; + hb_sorted_vector_t from; hb_vector_t to; for (/*TODO(C++11)auto*/Coverage::iter_t iter = (this+coverage).iter (); iter; iter++) { @@ -238,7 +238,7 @@ struct SingleSubstFormat2 struct SingleSubst { bool serialize (hb_serialize_context_t *c, - hb_array_t glyphs, + hb_sorted_array_t glyphs, hb_array_t substitutes) { TRACE_SERIALIZE (this); @@ -286,7 +286,7 @@ struct SingleSubst static inline void SingleSubst_serialize (hb_serialize_context_t *c, - hb_array_t glyphs, + hb_sorted_array_t glyphs, hb_array_t substitutes) { c->start_embed ()->serialize (c, glyphs, substitutes); } @@ -335,10 +335,10 @@ struct Sequence } bool serialize (hb_serialize_context_t *c, - hb_array_t glyphs) + hb_array_t subst) { TRACE_SERIALIZE (this); - return_trace (substitute.serialize (c, glyphs)); + return_trace (substitute.serialize (c, subst)); } bool sanitize (hb_sanitize_context_t *c) const @@ -398,7 +398,7 @@ struct MultipleSubstFormat1 } bool serialize (hb_serialize_context_t *c, - hb_array_t glyphs, + hb_sorted_array_t glyphs, hb_array_t substitute_len_list, hb_array_t substitute_glyphs_list) { @@ -444,7 +444,7 @@ struct MultipleSubstFormat1 struct MultipleSubst { bool serialize (hb_serialize_context_t *c, - hb_array_t glyphs, + hb_sorted_array_t glyphs, hb_array_t substitute_len_list, hb_array_t substitute_glyphs_list) { @@ -514,10 +514,10 @@ struct AlternateSet } bool serialize (hb_serialize_context_t *c, - hb_array_t glyphs) + hb_array_t alts) { TRACE_SERIALIZE (this); - return_trace (alternates.serialize (c, glyphs)); + return_trace (alternates.serialize (c, alts)); } bool sanitize (hb_sanitize_context_t *c) const @@ -582,7 +582,7 @@ struct AlternateSubstFormat1 } bool serialize (hb_serialize_context_t *c, - hb_array_t glyphs, + hb_sorted_array_t glyphs, hb_array_t alternate_len_list, hb_array_t alternate_glyphs_list) { @@ -628,7 +628,7 @@ struct AlternateSubstFormat1 struct AlternateSubst { bool serialize (hb_serialize_context_t *c, - hb_array_t glyphs, + hb_sorted_array_t glyphs, hb_array_t alternate_len_list, hb_array_t alternate_glyphs_list) { @@ -917,7 +917,7 @@ struct LigatureSubstFormat1 } bool serialize (hb_serialize_context_t *c, - hb_array_t first_glyphs, + hb_sorted_array_t first_glyphs, hb_array_t ligature_per_first_glyph_count_list, hb_array_t ligatures_list, hb_array_t component_count_list, @@ -968,7 +968,7 @@ struct LigatureSubstFormat1 struct LigatureSubst { bool serialize (hb_serialize_context_t *c, - hb_array_t first_glyphs, + hb_sorted_array_t first_glyphs, hb_array_t ligature_per_first_glyph_count_list, hb_array_t ligatures_list, hb_array_t component_count_list, @@ -1320,7 +1320,7 @@ struct SubstLookup : Lookup bool serialize_single (hb_serialize_context_t *c, uint32_t lookup_props, - hb_array_t glyphs, + hb_sorted_array_t glyphs, hb_array_t substitutes) { TRACE_SERIALIZE (this); @@ -1330,7 +1330,7 @@ struct SubstLookup : Lookup bool serialize_multiple (hb_serialize_context_t *c, uint32_t lookup_props, - hb_array_t glyphs, + hb_sorted_array_t glyphs, hb_array_t substitute_len_list, hb_array_t substitute_glyphs_list) { @@ -1344,7 +1344,7 @@ struct SubstLookup : Lookup bool serialize_alternate (hb_serialize_context_t *c, uint32_t lookup_props, - hb_array_t glyphs, + hb_sorted_array_t glyphs, hb_array_t alternate_len_list, hb_array_t alternate_glyphs_list) { @@ -1358,7 +1358,7 @@ struct SubstLookup : Lookup bool serialize_ligature (hb_serialize_context_t *c, uint32_t lookup_props, - hb_array_t first_glyphs, + hb_sorted_array_t first_glyphs, hb_array_t ligature_per_first_glyph_count_list, hb_array_t ligatures_list, hb_array_t component_count_list, diff --git a/src/hb-ot-map.hh b/src/hb-ot-map.hh index 28407c217..132da55c7 100644 --- a/src/hb-ot-map.hh +++ b/src/hb-ot-map.hh @@ -167,7 +167,7 @@ struct hb_ot_map_t hb_mask_t global_mask; - hb_vector_t features; + hb_sorted_vector_t features; hb_vector_t lookups[2]; /* GSUB/GPOS */ hb_vector_t stages[2]; /* GSUB/GPOS */ }; diff --git a/src/hb-ot-shape-complex-arabic-fallback.hh b/src/hb-ot-shape-complex-arabic-fallback.hh index 74eebc506..471a2014e 100644 --- a/src/hb-ot-shape-complex-arabic-fallback.hh +++ b/src/hb-ot-shape-complex-arabic-fallback.hh @@ -88,7 +88,7 @@ arabic_fallback_synthesize_lookup_single (const hb_ot_shape_plan_t *plan HB_UNUS OT::SubstLookup *lookup = c.start_serialize (); bool ret = lookup->serialize_single (&c, OT::LookupFlag::IgnoreMarks, - hb_array (glyphs, num_glyphs), + hb_sorted_array (glyphs, num_glyphs), hb_array (substitutes, num_glyphs)); c.end_serialize (); /* TODO sanitize the results? */ @@ -163,7 +163,7 @@ arabic_fallback_synthesize_lookup_ligature (const hb_ot_shape_plan_t *plan HB_UN OT::SubstLookup *lookup = c.start_serialize (); bool ret = lookup->serialize_ligature (&c, OT::LookupFlag::IgnoreMarks, - hb_array (first_glyphs, num_first_glyphs), + hb_sorted_array (first_glyphs, num_first_glyphs), hb_array (ligature_per_first_glyph_count_list, num_first_glyphs), hb_array (ligature_list, num_ligatures), hb_array (component_count_list, num_ligatures), diff --git a/src/hb-set.hh b/src/hb-set.hh index ea27eb92c..713f6ecbe 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -186,7 +186,7 @@ struct hb_set_t hb_object_header_t header; bool successful; /* Allocations successful */ mutable unsigned int population; - hb_vector_t page_map; + hb_sorted_vector_t page_map; hb_vector_t pages; void init_shallow () diff --git a/src/hb-vector.hh b/src/hb-vector.hh index 5a2c7bf46..d4c48586c 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -115,15 +115,6 @@ struct hb_vector_t hb_sorted_array_t as_sorted_array () const { return hb_sorted_array (arrayZ(), length); } - hb_array_t sorted_sub_array (unsigned int start_offset, unsigned int count) const - { return as_sorted_array ().sorted_sub_array (start_offset, count);} - hb_array_t sorted_sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) const - { return as_sorted_array ().sorted_sub_array (start_offset, count);} - hb_array_t sorted_sub_array (unsigned int start_offset, unsigned int count) - { return as_sorted_array ().sorted_sub_array (start_offset, count);} - hb_array_t sorted_sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */) - { return as_sorted_array ().sorted_sub_array (start_offset, count);} - template explicit_operator T * () { return arrayZ(); } template explicit_operator const T * () const { return arrayZ(); } @@ -247,19 +238,34 @@ struct hb_vector_t template const Type *lsearch (const T &x, const Type *not_found = nullptr) const { return as_array ().lsearch (x, not_found); } +}; + +template +struct hb_sorted_vector_t : hb_vector_t +{ + hb_sorted_array_t< Type> as_array () { return hb_sorted_array (this->arrayZ(), this->length); } + hb_sorted_array_t as_array () const { return hb_sorted_array (this->arrayZ(), this->length); } + + /* Iterator. */ + typedef hb_sorted_array_t const_iter_t; + typedef hb_sorted_array_t< Type> iter_t; + const_iter_t iter () const { return as_array (); } + const_iter_t citer () const { return as_array (); } + iter_t iter () { return as_array (); } + operator iter_t () { return iter (); } + operator const_iter_t () const { return iter (); } template Type *bsearch (const T &x, Type *not_found = nullptr) - { return as_sorted_array ().bsearch (x, not_found); } + { return as_array ().bsearch (x, not_found); } template const Type *bsearch (const T &x, const Type *not_found = nullptr) const - { return as_sorted_array ().bsearch (x, not_found); } + { return as_array ().bsearch (x, not_found); } template bool bfind (const T &x, unsigned int *i = nullptr, hb_bfind_not_found_t not_found = HB_BFIND_NOT_FOUND_DONT_STORE, unsigned int to_store = (unsigned int) -1) const - { return as_sorted_array ().bfind (x, i, not_found, to_store); } + { return as_array ().bfind (x, i, not_found, to_store); } }; - #endif /* HB_VECTOR_HH */