hb_face_t *face;
public:
- hb_vector_t<feature_info_t> features;
+ hb_sorted_vector_t<feature_info_t> features;
};
*/
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<hb_remove_const (Type)> &o) : arrayZ (o.arrayZ), length (o.length) {}
+ hb_array_t (const hb_array_t<const Type> &o) : arrayZ (o.arrayZ), length (o.length) {}
template <unsigned int length_> hb_array_t (Type (&array_)[length_]) : arrayZ (array_), length (length_) {}
hb_sorted_array_t () : hb_array_t<Type> () {}
hb_sorted_array_t (const hb_array_t<Type> &o) : hb_array_t<Type> (o) {}
+ hb_sorted_array_t (const hb_sorted_array_t<hb_remove_const (Type)> &o) : hb_array_t<Type> (o) {}
+ hb_sorted_array_t (const hb_sorted_array_t<const Type> &o) : hb_array_t<Type> (o) {}
hb_sorted_array_t (Type *array_, unsigned int length_) : hb_array_t<Type> (array_, length_) {}
template <unsigned int length_> hb_sorted_array_t (Type (&array_)[length_]) : hb_array_t<Type> (array_) {}
template <typename T> static inline T hb_declval ();
-template <typename T> struct hb_remove_const { typedef T value; };
-template <typename T> struct hb_remove_const<const T> { typedef T value; };
-#define hb_remove_const(T) typename hb_remove_const<T>::value
-template <typename T> struct hb_remove_reference { typedef T value; };
-template <typename T> struct hb_remove_reference<T &> { typedef T value; };
-#define hb_remove_reference(T) typename hb_remove_reference<T>::value
-template <typename T> struct hb_remove_pointer { typedef T value; };
-template <typename T> struct hb_remove_pointer<T *> { typedef T value; };
-#define hb_remove_pointer(T) typename hb_remove_pointer<T>::value
+template <typename T> struct hb_match_const { typedef T type; enum { matched = false }; };
+template <typename T> struct hb_match_const<const T> { typedef T type; enum { matched = true }; };
+#define hb_remove_const(T) typename hb_match_const<T>::type
+#define hb_is_const(T) hb_match_const<T>::matched
+template <typename T> struct hb_match_reference { typedef T type; enum { matched = false }; };
+template <typename T> struct hb_match_reference<T &> { typedef T type; enum { matched = true }; };
+#define hb_remove_reference(T) typename hb_match_reference<T>::type
+#define hb_is_reference(T) hb_match_reference<T>::matched
+template <typename T> struct hb_match_pointer { typedef T type; enum { matched = false }; };
+template <typename T> struct hb_match_pointer<T *> { typedef T type; enum { matched = true }; };
+#define hb_remove_pointer(T) typename hb_match_pointer<T>::type
+#define hb_is_pointer(T) hb_match_pointer<T>::matched
/* Void! For when we need a expression-type of void. */
template<typename T>
struct hb_enable_if<true, T> { typedef T type; };
-#define hb_enable_if(Cond) typename hb_enable_if<Cond>::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
}
template <typename Iterator>
- 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)
{
}
template <typename Iterator>
- 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)
{
}
template <typename Iterator>
- 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)
{
TRACE_SUBSET (this);
const hb_set_t &glyphset = *c->plan->glyphset;
const hb_map_t &glyph_map = *c->plan->glyph_map;
- hb_vector_t<GlyphID> glyphs;
+ hb_sorted_vector_t<GlyphID> glyphs;
hb_vector_t<HBUINT16> klasses;
hb_codepoint_t start = startGlyph;
static inline void SingleSubst_serialize (hb_serialize_context_t *c,
- hb_array_t<const GlyphID> glyphs,
+ hb_sorted_array_t<const GlyphID> glyphs,
hb_array_t<const GlyphID> substitutes);
struct SingleSubstFormat1
}
bool serialize (hb_serialize_context_t *c,
- hb_array_t<const GlyphID> glyphs,
+ hb_sorted_array_t<const GlyphID> glyphs,
int delta)
{
TRACE_SERIALIZE (this);
TRACE_SUBSET (this);
const hb_set_t &glyphset = *c->plan->glyphset;
const hb_map_t &glyph_map = *c->plan->glyph_map;
- hb_vector_t<GlyphID> from;
+ hb_sorted_vector_t<GlyphID> from;
hb_vector_t<GlyphID> to;
hb_codepoint_t delta = deltaGlyphID;
for (/*TODO(C++11)auto*/Coverage::iter_t iter = (this+coverage).iter (); iter; iter++)
}
bool serialize (hb_serialize_context_t *c,
- hb_array_t<const GlyphID> glyphs,
+ hb_sorted_array_t<const GlyphID> glyphs,
hb_array_t<const GlyphID> substitutes)
{
TRACE_SERIALIZE (this);
TRACE_SUBSET (this);
const hb_set_t &glyphset = *c->plan->glyphset;
const hb_map_t &glyph_map = *c->plan->glyph_map;
- hb_vector_t<GlyphID> from;
+ hb_sorted_vector_t<GlyphID> from;
hb_vector_t<GlyphID> to;
for (/*TODO(C++11)auto*/Coverage::iter_t iter = (this+coverage).iter (); iter; iter++)
{
struct SingleSubst
{
bool serialize (hb_serialize_context_t *c,
- hb_array_t<const GlyphID> glyphs,
+ hb_sorted_array_t<const GlyphID> glyphs,
hb_array_t<const GlyphID> substitutes)
{
TRACE_SERIALIZE (this);
static inline void
SingleSubst_serialize (hb_serialize_context_t *c,
- hb_array_t<const GlyphID> glyphs,
+ hb_sorted_array_t<const GlyphID> glyphs,
hb_array_t<const GlyphID> substitutes)
{ c->start_embed<SingleSubst> ()->serialize (c, glyphs, substitutes); }
}
bool serialize (hb_serialize_context_t *c,
- hb_array_t<const GlyphID> glyphs)
+ hb_array_t<const GlyphID> subst)
{
TRACE_SERIALIZE (this);
- return_trace (substitute.serialize (c, glyphs));
+ return_trace (substitute.serialize (c, subst));
}
bool sanitize (hb_sanitize_context_t *c) const
}
bool serialize (hb_serialize_context_t *c,
- hb_array_t<const GlyphID> glyphs,
+ hb_sorted_array_t<const GlyphID> glyphs,
hb_array_t<const unsigned int> substitute_len_list,
hb_array_t<const GlyphID> substitute_glyphs_list)
{
struct MultipleSubst
{
bool serialize (hb_serialize_context_t *c,
- hb_array_t<const GlyphID> glyphs,
+ hb_sorted_array_t<const GlyphID> glyphs,
hb_array_t<const unsigned int> substitute_len_list,
hb_array_t<const GlyphID> substitute_glyphs_list)
{
}
bool serialize (hb_serialize_context_t *c,
- hb_array_t<const GlyphID> glyphs)
+ hb_array_t<const GlyphID> alts)
{
TRACE_SERIALIZE (this);
- return_trace (alternates.serialize (c, glyphs));
+ return_trace (alternates.serialize (c, alts));
}
bool sanitize (hb_sanitize_context_t *c) const
}
bool serialize (hb_serialize_context_t *c,
- hb_array_t<const GlyphID> glyphs,
+ hb_sorted_array_t<const GlyphID> glyphs,
hb_array_t<const unsigned int> alternate_len_list,
hb_array_t<const GlyphID> alternate_glyphs_list)
{
struct AlternateSubst
{
bool serialize (hb_serialize_context_t *c,
- hb_array_t<const GlyphID> glyphs,
+ hb_sorted_array_t<const GlyphID> glyphs,
hb_array_t<const unsigned int> alternate_len_list,
hb_array_t<const GlyphID> alternate_glyphs_list)
{
}
bool serialize (hb_serialize_context_t *c,
- hb_array_t<const GlyphID> first_glyphs,
+ hb_sorted_array_t<const GlyphID> first_glyphs,
hb_array_t<const unsigned int> ligature_per_first_glyph_count_list,
hb_array_t<const GlyphID> ligatures_list,
hb_array_t<const unsigned int> component_count_list,
struct LigatureSubst
{
bool serialize (hb_serialize_context_t *c,
- hb_array_t<const GlyphID> first_glyphs,
+ hb_sorted_array_t<const GlyphID> first_glyphs,
hb_array_t<const unsigned int> ligature_per_first_glyph_count_list,
hb_array_t<const GlyphID> ligatures_list,
hb_array_t<const unsigned int> component_count_list,
bool serialize_single (hb_serialize_context_t *c,
uint32_t lookup_props,
- hb_array_t<const GlyphID> glyphs,
+ hb_sorted_array_t<const GlyphID> glyphs,
hb_array_t<const GlyphID> substitutes)
{
TRACE_SERIALIZE (this);
bool serialize_multiple (hb_serialize_context_t *c,
uint32_t lookup_props,
- hb_array_t<const GlyphID> glyphs,
+ hb_sorted_array_t<const GlyphID> glyphs,
hb_array_t<const unsigned int> substitute_len_list,
hb_array_t<const GlyphID> substitute_glyphs_list)
{
bool serialize_alternate (hb_serialize_context_t *c,
uint32_t lookup_props,
- hb_array_t<const GlyphID> glyphs,
+ hb_sorted_array_t<const GlyphID> glyphs,
hb_array_t<const unsigned int> alternate_len_list,
hb_array_t<const GlyphID> alternate_glyphs_list)
{
bool serialize_ligature (hb_serialize_context_t *c,
uint32_t lookup_props,
- hb_array_t<const GlyphID> first_glyphs,
+ hb_sorted_array_t<const GlyphID> first_glyphs,
hb_array_t<const unsigned int> ligature_per_first_glyph_count_list,
hb_array_t<const GlyphID> ligatures_list,
hb_array_t<const unsigned int> component_count_list,
hb_mask_t global_mask;
- hb_vector_t<feature_map_t> features;
+ hb_sorted_vector_t<feature_map_t> features;
hb_vector_t<lookup_map_t> lookups[2]; /* GSUB/GPOS */
hb_vector_t<stage_map_t> stages[2]; /* GSUB/GPOS */
};
OT::SubstLookup *lookup = c.start_serialize<OT::SubstLookup> ();
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? */
OT::SubstLookup *lookup = c.start_serialize<OT::SubstLookup> ();
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),
hb_object_header_t header;
bool successful; /* Allocations successful */
mutable unsigned int population;
- hb_vector_t<page_map_t> page_map;
+ hb_sorted_vector_t<page_map_t> page_map;
hb_vector_t<page_t> pages;
void init_shallow ()
hb_sorted_array_t<const Type> as_sorted_array () const
{ return hb_sorted_array (arrayZ(), length); }
- hb_array_t<const Type> sorted_sub_array (unsigned int start_offset, unsigned int count) const
- { return as_sorted_array ().sorted_sub_array (start_offset, count);}
- hb_array_t<const Type> 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<Type> sorted_sub_array (unsigned int start_offset, unsigned int count)
- { return as_sorted_array ().sorted_sub_array (start_offset, count);}
- hb_array_t<Type> sorted_sub_array (unsigned int start_offset, unsigned int *count = nullptr /* IN/OUT */)
- { return as_sorted_array ().sorted_sub_array (start_offset, count);}
-
template <typename T> explicit_operator T * () { return arrayZ(); }
template <typename T> explicit_operator const T * () const { return arrayZ(); }
template <typename T>
const Type *lsearch (const T &x, const Type *not_found = nullptr) const
{ return as_array ().lsearch (x, not_found); }
+};
+
+template <typename Type>
+struct hb_sorted_vector_t : hb_vector_t<Type>
+{
+ hb_sorted_array_t< Type> as_array () { return hb_sorted_array (this->arrayZ(), this->length); }
+ hb_sorted_array_t<const Type> as_array () const { return hb_sorted_array (this->arrayZ(), this->length); }
+
+ /* Iterator. */
+ typedef hb_sorted_array_t<const Type> 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 <typename T>
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 <typename T>
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 <typename T>
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 */