[open] small fixes, including not using unions for main structs

This commit is contained in:
Behdad Esfahbod 2007-07-06 02:03:26 -04:00
parent 151df44346
commit 5b2e947fd2
1 changed files with 29 additions and 25 deletions

View File

@ -506,29 +506,31 @@ struct CoverageFormat2 {
* long */ * long */
}; };
union Coverage { struct Coverage {
DEFINE_NON_INSTANTIABLE(Coverage); DEFINE_NON_INSTANTIABLE(Coverage);
inline unsigned int get_size (void) const { inline unsigned int get_size (void) const {
switch (coverageFormat) { switch (u.coverageFormat) {
case 1: return format1.get_size (); case 1: return u.format1.get_size ();
case 2: return format2.get_size (); case 2: return u.format2.get_size ();
default:return sizeof (coverageFormat); default:return sizeof (u.coverageFormat);
} }
} }
/* Returns -1 if not covered. */ /* Returns -1 if not covered. */
inline int get_coverage (uint16_t glyph_id) const { inline int get_coverage (uint16_t glyph_id) const {
switch (coverageFormat) { switch (u.coverageFormat) {
case 1: return format1.get_coverage(glyph_id); case 1: return u.format1.get_coverage(glyph_id);
case 2: return format2.get_coverage(glyph_id); case 2: return u.format2.get_coverage(glyph_id);
default:return -1; default:return -1;
} }
} }
union {
USHORT coverageFormat; /* Format identifier */ USHORT coverageFormat; /* Format identifier */
CoverageFormat1 format1; CoverageFormat1 format1;
CoverageFormat2 format2; CoverageFormat2 format2;
} u;
}; };
/* /*
@ -589,25 +591,27 @@ struct ClassDef {
DEFINE_NON_INSTANTIABLE(ClassDef); DEFINE_NON_INSTANTIABLE(ClassDef);
inline unsigned int get_size (void) const { inline unsigned int get_size (void) const {
switch (classFormat) { switch (u.classFormat) {
case 1: return format1.get_size (); case 1: return u.format1.get_size ();
case 2: return format2.get_size (); case 2: return u.format2.get_size ();
default:return sizeof (classFormat); default:return sizeof (u.classFormat);
} }
} }
/* Returns 0 if not found. */ /* Returns 0 if not found. */
inline int get_class (uint16_t glyph_id) const { inline int get_class (uint16_t glyph_id) const {
switch (classFormat) { switch (u.classFormat) {
case 1: format1.get_class(glyph_id); case 1: u.format1.get_class(glyph_id);
case 2: format2.get_class(glyph_id); case 2: u.format2.get_class(glyph_id);
default:return 0; default:return 0;
} }
} }
union {
USHORT classFormat; /* Format identifier */ USHORT classFormat; /* Format identifier */
ClassDefFormat1 format1; ClassDefFormat1 format1;
ClassDefFormat2 format2; ClassDefFormat2 format2;
} u;
}; };
/* /*
@ -627,7 +631,7 @@ struct Device {
} }
} }
inline int get_delta (int ppem_size) { inline int get_delta (int ppem_size) const {
if (ppem_size >= startSize && ppem_size <= endSize && if (ppem_size >= startSize && ppem_size <= endSize &&
deltaFormat >= 1 && deltaFormat <= 3) { deltaFormat >= 1 && deltaFormat <= 3) {
int s = ppem_size - startSize; int s = ppem_size - startSize;
@ -673,14 +677,14 @@ struct GSUBGPOSHeader {
DEFINE_LIST_ACCESSOR(Feature, feature);/* get_feature_list and feature(i) */ DEFINE_LIST_ACCESSOR(Feature, feature);/* get_feature_list and feature(i) */
DEFINE_LIST_ACCESSOR(Lookup, lookup); /* get_lookup_list and lookup(i) */ DEFINE_LIST_ACCESSOR(Lookup, lookup); /* get_lookup_list and lookup(i) */
Fixed_Version version; /* Version of the GSUB table-initially set to Fixed_Version version; /* Version of the GSUB/GPOS table--initially set
* 0x00010000 */ * to 0x00010000 */
Offset scriptList; /* Offset to ScriptList table-from beginning of Offset scriptList; /* Offset to ScriptList table--from beginning of
* GSUB table */ * GSUB/GPOS table */
Offset featureList; /* Offset to FeatureList table-from beginning of Offset featureList; /* Offset to FeatureList table--from beginning of
* GSUB table */ * GSUB/GPOS table */
Offset lookupList; /* Offset to LookupList table-from beginning of Offset lookupList; /* Offset to LookupList table--from beginning of
* GSUB table */ * GSUB/GPOS table */
}; };
#endif /* HARFBUZZ_OPEN_PRIVATE_H */ #endif /* HARFBUZZ_OPEN_PRIVATE_H */