[pango/harfbuzz-ng] [HB] Add HeadlessArrayTo<>
- From: Behdad Esfahbod <behdad src gnome org>
- To: svn-commits-list gnome org
- Subject: [pango/harfbuzz-ng] [HB] Add HeadlessArrayTo<>
- Date: Mon, 18 May 2009 05:49:17 -0400 (EDT)
commit ac227e24dd98e77da9d548d81ac9efa3afa4d816
Author: Behdad Esfahbod <behdad behdad org>
Date: Mon May 18 02:03:58 2009 -0400
[HB] Add HeadlessArrayTo<>
---
pango/opentype/hb-ot-layout-gsub-private.h | 10 ++++------
pango/opentype/hb-ot-layout-gsubgpos-private.h | 5 ++---
pango/opentype/hb-ot-layout-open-private.h | 19 +++++++++++++++++++
3 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/pango/opentype/hb-ot-layout-gsub-private.h b/pango/opentype/hb-ot-layout-gsub-private.h
index 1775c7c..a65a351 100644
--- a/pango/opentype/hb-ot-layout-gsub-private.h
+++ b/pango/opentype/hb-ot-layout-gsub-private.h
@@ -314,12 +314,10 @@ struct Ligature {
friend struct LigatureSet;
private:
- DEFINE_ARRAY_TYPE (GlyphID, component, (compCount ? compCount - 1 : 0));
-
inline bool substitute_ligature (LOOKUP_ARGS_DEF, bool is_mark) const {
unsigned int i, j;
- unsigned int count = compCount;
+ unsigned int count = component.len;
if (HB_UNLIKELY (buffer->in_pos + count > buffer->in_length ||
context_length < count))
@@ -336,7 +334,7 @@ struct Ligature {
property & LookupFlag::MarkAttachmentType))
is_mark = FALSE;
- if (HB_LIKELY (IN_GLYPH(j) != (*this)[i - 1]))
+ if (HB_LIKELY (IN_GLYPH(j) != component[i]))
return false;
}
if ( _hb_ot_layout_has_new_glyph_classes (layout) )
@@ -383,8 +381,8 @@ struct Ligature {
private:
GlyphID ligGlyph; /* GlyphID of ligature to substitute */
- USHORT compCount; /* Number of components in the ligature */
- GlyphID component[]; /* Array of component GlyphIDs--start
+ HeadlessArrayOf<GlyphID>
+ component; /* Array of component GlyphIDs--start
* with the second component--ordered
* in writing direction */
};
diff --git a/pango/opentype/hb-ot-layout-gsubgpos-private.h b/pango/opentype/hb-ot-layout-gsubgpos-private.h
index 8c061aa..e82941e 100644
--- a/pango/opentype/hb-ot-layout-gsubgpos-private.h
+++ b/pango/opentype/hb-ot-layout-gsubgpos-private.h
@@ -362,9 +362,8 @@ struct ChainRule {
backtrack; /* Array of backtracking values
* (to be matched before the input
* sequence) */
- USHORT inputCountX; /* Total number of values in the input
- * sequence (includes the first glyph) */
- USHORT inputX[]; /* Array of input values (start with
+ HeadlessArrayOf<USHORT>
+ inputX; /* Array of input values (start with
* second glyph) */
ArrayOf<USHORT>
lookaheadX; /* Array of lookahead values's (to be
diff --git a/pango/opentype/hb-ot-layout-open-private.h b/pango/opentype/hb-ot-layout-open-private.h
index 252a45e..1d025cf 100644
--- a/pango/opentype/hb-ot-layout-open-private.h
+++ b/pango/opentype/hb-ot-layout-open-private.h
@@ -348,6 +348,25 @@ struct ArrayOf {
if (HB_UNLIKELY (i >= len)) return Null(Type);
return array[i];
}
+ inline unsigned int get_size () const {
+ return sizeof (len) + len * sizeof (array[0]);
+ }
+
+ USHORT len;
+ Type array[];
+};
+
+/* An array with a USHORT number of elements,
+ * starting at second element. */
+template <typename Type>
+struct HeadlessArrayOf {
+ inline const Type& operator [] (unsigned int i) const {
+ if (HB_UNLIKELY (i >= len || !i)) return Null(Type);
+ return array[i-1];
+ }
+ inline unsigned int get_size () const {
+ return sizeof (len) + (len ? len - 1 : 0) * sizeof (array[0]);
+ }
USHORT len;
Type array[];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]