private:
inline bool single_substitute (hb_codepoint_t &glyph_id) const {
- switch (u.substFormat) {
- case 1: return u.format1.single_substitute (glyph_id);
- case 2: return u.format2.single_substitute (glyph_id);
+ switch (u.format) {
+ case 1: return u.format1->single_substitute (glyph_id);
+ case 2: return u.format2->single_substitute (glyph_id);
default:return false;
}
}
private:
union {
- USHORT substFormat; /* Format identifier */
- SingleSubstFormat1 format1;
- SingleSubstFormat2 format2;
+ USHORT format; /* Format identifier */
+ SingleSubstFormat1 format1[];
+ SingleSubstFormat2 format2[];
} u;
};
-DEFINE_NULL (SingleSubst, 2);
+ASSERT_SIZE (SingleSubst, 2);
struct Sequence {
private:
inline bool substitute (LOOKUP_ARGS_DEF) const {
- switch (u.substFormat) {
- case 1: return u.format1.substitute (LOOKUP_ARGS);
+ switch (u.format) {
+ case 1: return u.format1->substitute (LOOKUP_ARGS);
default:return false;
}
}
private:
union {
- USHORT substFormat; /* Format identifier */
- MultipleSubstFormat1 format1;
+ USHORT format; /* Format identifier */
+ MultipleSubstFormat1 format1[];
} u;
};
-DEFINE_NULL (MultipleSubst, 2);
+ASSERT_SIZE (MultipleSubst, 2);
typedef ArrayOf<GlyphID> AlternateSet; /* Array of alternate GlyphIDs--in
private:
inline bool substitute (LOOKUP_ARGS_DEF) const {
- switch (u.substFormat) {
- case 1: return u.format1.substitute (LOOKUP_ARGS);
+ switch (u.format) {
+ case 1: return u.format1->substitute (LOOKUP_ARGS);
default:return false;
}
}
private:
union {
- USHORT substFormat; /* Format identifier */
- AlternateSubstFormat1 format1;
+ USHORT format; /* Format identifier */
+ AlternateSubstFormat1 format1[];
} u;
};
-DEFINE_NULL (AlternateSubst, 2);
+ASSERT_SIZE (AlternateSubst, 2);
struct Ligature {
private:
inline bool substitute (LOOKUP_ARGS_DEF) const {
- switch (u.substFormat) {
- case 1: return u.format1.substitute (LOOKUP_ARGS);
+ switch (u.format) {
+ case 1: return u.format1->substitute (LOOKUP_ARGS);
default:return false;
}
}
private:
union {
- USHORT substFormat; /* Format identifier */
- LigatureSubstFormat1 format1;
+ USHORT format; /* Format identifier */
+ LigatureSubstFormat1 format1[];
} u;
};
-DEFINE_NULL (LigatureSubst, 2);
+ASSERT_SIZE (LigatureSubst, 2);
return this->apply (LOOKUP_ARGS, substitute_lookup);
}
};
-DEFINE_NULL (ContextSubst, 2);
+ASSERT_SIZE (ContextSubst, 2);
struct ChainSubRule {
private:
inline bool substitute (LOOKUP_ARGS_DEF) const {
- switch (u.substFormat) {
- case 1: return u.format1.substitute (LOOKUP_ARGS);
- case 2: return u.format2.substitute (LOOKUP_ARGS);
- case 3: return u.format3.substitute (LOOKUP_ARGS);
+ switch (u.format) {
+ case 1: return u.format1->substitute (LOOKUP_ARGS);
+ case 2: return u.format2->substitute (LOOKUP_ARGS);
+ case 3: return u.format3->substitute (LOOKUP_ARGS);
default:return false;
}
}
private:
union {
- USHORT substFormat; /* Format identifier */
- ChainContextSubstFormat1 format1;
- ChainContextSubstFormat2 format2;
- ChainContextSubstFormat3 format3;
+ USHORT format; /* Format identifier */
+ ChainContextSubstFormat1 format1[];
+ ChainContextSubstFormat2 format2[];
+ ChainContextSubstFormat3 format3[];
} u;
};
-DEFINE_NULL (ChainContextSubst, 2);
+ASSERT_SIZE (ChainContextSubst, 2);
struct ExtensionSubstFormat1 {
private:
inline unsigned int get_type (void) const { return extensionLookupType; }
+ inline unsigned int get_offset (void) const { return (extensionOffset[0] << 16) + extensionOffset[1]; }
inline bool substitute (LOOKUP_ARGS_DEF) const;
private:
USHORT extensionLookupType; /* Lookup type of subtable referenced
* by ExtensionOffset (i.e. the
* extension subtable). */
- ULONG extensionOffset; /* Offset to the extension subtable,
- * of lookup type subtable. */
+ USHORT extensionOffset[2]; /* Offset to the extension subtable,
+ * of lookup type subtable.
+ * Defined as two shorts to avoid
+ * alignment requirements. */
};
ASSERT_SIZE (ExtensionSubstFormat1, 8);
private:
inline unsigned int get_type (void) const {
- switch (u.substFormat) {
- case 1: return u.format1.get_type ();
+ switch (u.format) {
+ case 1: return u.format1->get_type ();
default:return 0;
}
}
inline bool substitute (LOOKUP_ARGS_DEF) const {
- switch (u.substFormat) {
- case 1: return u.format1.substitute (LOOKUP_ARGS);
+ switch (u.format) {
+ case 1: return u.format1->substitute (LOOKUP_ARGS);
default:return false;
}
}
private:
union {
- USHORT substFormat; /* Format identifier */
- ExtensionSubstFormat1 format1;
+ USHORT format; /* Format identifier */
+ ExtensionSubstFormat1 format1[];
} u;
};
-DEFINE_NULL (ExtensionSubst, 2);
+ASSERT_SIZE (ExtensionSubst, 2);
inline bool ExtensionSubstFormat1::substitute (LOOKUP_ARGS_DEF) const {
/* XXX either check in sanitize or here that the lookuptype is not 7 again,
* or we can loop indefinitely. */
- return (*(SubstLookupSubTable *)(((char *) this) + extensionOffset)).substitute (LOOKUP_ARGS,
+ return (*(SubstLookupSubTable *)(((char *) this) + get_offset ())).substitute (LOOKUP_ARGS,
get_type ());
}
protected:
bool apply (LOOKUP_ARGS_DEF, apply_lookup_func_t apply_func) const {
switch (u.format) {
- case 1: return u.format1.apply (LOOKUP_ARGS, apply_func);
- case 2: return u.format2.apply (LOOKUP_ARGS, apply_func);
- case 3: return u.format3.apply (LOOKUP_ARGS, apply_func);
+ case 1: return u.format1->apply (LOOKUP_ARGS, apply_func);
+ case 2: return u.format2->apply (LOOKUP_ARGS, apply_func);
+ case 3: return u.format3->apply (LOOKUP_ARGS, apply_func);
default:return false;
}
}
private:
union {
- USHORT format; /* Format identifier */
- ContextFormat1 format1;
- ContextFormat2 format2;
- ContextFormat3 format3;
+ USHORT format; /* Format identifier */
+ ContextFormat1 format1[];
+ ContextFormat2 format2[];
+ ContextFormat3 format3[];
} u;
};
-DEFINE_NULL (Context, 2);
+ASSERT_SIZE (Context, 2);
#endif /* HB_OT_LAYOUT_GSUBGPOS_PRIVATE_H */
/* Generic template for nul-content sizeof-sized Null objects. */
template <typename Type>
-struct NullSize {
- char bytes[sizeof (Type)];
-};
-template <typename Type>
struct Null {
- ASSERT_STATIC (sizeof (NullSize<Type>) <= sizeof (NullPool));
+ ASSERT_STATIC (sizeof (Type) <= sizeof (NullPool));
static inline const Type &get () { return (const Type&) *(const Type*) NullPool; }
};
-/* Specializaiton for nul-content arbitrary-sized Null objects. */
-#define DEFINE_NULL(Type, size) \
-template <> \
-struct NullSize <Type> { \
- char bytes[size]; \
-}
-
/* Specializaiton for arbitrary-content arbitrary-sized Null objects. */
#define DEFINE_NULL_DATA(Type, size, data) \
template <> \
struct Coverage {
unsigned int get_coverage (hb_codepoint_t glyph_id) const {
- switch (u.coverageFormat) {
- case 1: return u.format1.get_coverage(glyph_id);
- case 2: return u.format2.get_coverage(glyph_id);
+ switch (u.format) {
+ case 1: return u.format1->get_coverage(glyph_id);
+ case 2: return u.format2->get_coverage(glyph_id);
default:return NOT_COVERED;
}
}
private:
union {
- USHORT coverageFormat; /* Format identifier */
- CoverageFormat1 format1;
- CoverageFormat2 format2;
+ USHORT format; /* Format identifier */
+ CoverageFormat1 format1[];
+ CoverageFormat2 format2[];
} u;
};
-DEFINE_NULL (Coverage, 2);
+ASSERT_SIZE (Coverage, 2);
/*
* Class Definition Table
struct ClassDef {
hb_ot_layout_class_t get_class (hb_codepoint_t glyph_id) const {
- switch (u.classFormat) {
- case 1: return u.format1.get_class(glyph_id);
- case 2: return u.format2.get_class(glyph_id);
+ switch (u.format) {
+ case 1: return u.format1->get_class(glyph_id);
+ case 2: return u.format2->get_class(glyph_id);
default:return 0;
}
}
private:
union {
- USHORT classFormat; /* Format identifier */
- ClassDefFormat1 format1;
- ClassDefFormat2 format2;
+ USHORT format; /* Format identifier */
+ ClassDefFormat1 format1[];
+ ClassDefFormat2 format2[];
} u;
};
-DEFINE_NULL (ClassDef, 2);
+ASSERT_SIZE (ClassDef, 2);
/*
* Device Tables