X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/729e4ab9bc6618bc3d8a898e575df7f4019e29ca..ef6cf650f4a75c3f97de06b51fa104f2069b9ea2:/icuSources/layout/ClassDefinitionTables.cpp?ds=sidebyside diff --git a/icuSources/layout/ClassDefinitionTables.cpp b/icuSources/layout/ClassDefinitionTables.cpp index 471a2b3e..9d04d2a5 100644 --- a/icuSources/layout/ClassDefinitionTables.cpp +++ b/icuSources/layout/ClassDefinitionTables.cpp @@ -1,6 +1,6 @@ /* * - * (C) Copyright IBM Corp. 1998-2010 - All Rights Reserved + * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved * */ @@ -12,49 +12,51 @@ U_NAMESPACE_BEGIN -le_int32 ClassDefinitionTable::getGlyphClass(LEGlyphID glyphID) const +le_int32 ClassDefinitionTable::getGlyphClass(const LETableReference& base, LEGlyphID glyphID, LEErrorCode &success) const { - switch(SWAPW(classFormat)) { + LEReferenceTo thisRef(base, success); + if (LE_FAILURE(success)) return 0; + + switch(SWAPW(classFormat)) { case 0: return 0; case 1: { - const ClassDefFormat1Table *f1Table = (const ClassDefFormat1Table *) this; - - return f1Table->getGlyphClass(glyphID); + const LEReferenceTo f1Table(thisRef, success); + return f1Table->getGlyphClass(f1Table, glyphID, success); } case 2: { - const ClassDefFormat2Table *f2Table = (const ClassDefFormat2Table *) this; - - return f2Table->getGlyphClass(glyphID); + const LEReferenceTo f2Table(thisRef, success); + return f2Table->getGlyphClass(f2Table, glyphID, success); } default: return 0; - } + } } -le_bool ClassDefinitionTable::hasGlyphClass(le_int32 glyphClass) const +le_bool ClassDefinitionTable::hasGlyphClass(const LETableReference &base, le_int32 glyphClass, LEErrorCode &success) const { + LEReferenceTo thisRef(base, success); + if (LE_FAILURE(success)) return 0; + switch(SWAPW(classFormat)) { case 0: return 0; case 1: { - const ClassDefFormat1Table *f1Table = (const ClassDefFormat1Table *) this; - - return f1Table->hasGlyphClass(glyphClass); + const LEReferenceTo f1Table(thisRef, success); + return f1Table->hasGlyphClass(f1Table, glyphClass, success); } case 2: { - const ClassDefFormat2Table *f2Table = (const ClassDefFormat2Table *) this; - - return f2Table->hasGlyphClass(glyphClass); + const LEReferenceTo f2Table(thisRef, success); + return f2Table->hasGlyphClass(f2Table, glyphClass, success); } default: @@ -62,26 +64,32 @@ le_bool ClassDefinitionTable::hasGlyphClass(le_int32 glyphClass) const } } -le_int32 ClassDefFormat1Table::getGlyphClass(LEGlyphID glyphID) const +le_int32 ClassDefFormat1Table::getGlyphClass(const LETableReference& base, LEGlyphID glyphID, LEErrorCode &success) const { + if(LE_FAILURE(success)) return 0; + + le_uint16 count = SWAPW(glyphCount); + LEReferenceToArrayOf classValueArrayRef(base, success, &classValueArray[0], count); TTGlyphID ttGlyphID = (TTGlyphID) LE_GET_GLYPH(glyphID); TTGlyphID firstGlyph = SWAPW(startGlyph); - TTGlyphID lastGlyph = firstGlyph + SWAPW(glyphCount); + TTGlyphID lastGlyph = firstGlyph + count; - if (ttGlyphID >= firstGlyph && ttGlyphID < lastGlyph) { - return SWAPW(classValueArray[ttGlyphID - firstGlyph]); + if (LE_SUCCESS(success) && ttGlyphID >= firstGlyph && ttGlyphID < lastGlyph) { + return SWAPW( classValueArrayRef(ttGlyphID - firstGlyph, success) ); } return 0; } -le_bool ClassDefFormat1Table::hasGlyphClass(le_int32 glyphClass) const +le_bool ClassDefFormat1Table::hasGlyphClass(const LETableReference &base, le_int32 glyphClass, LEErrorCode &success) const { - le_uint16 count = SWAPW(glyphCount); + if(LE_FAILURE(success)) return 0; + le_uint16 count = SWAPW(glyphCount); + LEReferenceToArrayOf classValueArrayRef(base, success, &classValueArray[0], count); int i; - for (i = 0; i < count; i += 1) { - if (SWAPW(classValueArray[i]) == glyphClass) { + for (i = 0; LE_SUCCESS(success)&& (i < count); i += 1) { + if (SWAPW(classValueArrayRef(i,success)) == glyphClass) { return TRUE; } } @@ -89,27 +97,31 @@ le_bool ClassDefFormat1Table::hasGlyphClass(le_int32 glyphClass) const return FALSE; } -le_int32 ClassDefFormat2Table::getGlyphClass(LEGlyphID glyphID) const +le_int32 ClassDefFormat2Table::getGlyphClass(const LETableReference& base, LEGlyphID glyphID, LEErrorCode &success) const { + if(LE_FAILURE(success)) return 0; TTGlyphID ttGlyph = (TTGlyphID) LE_GET_GLYPH(glyphID); le_uint16 rangeCount = SWAPW(classRangeCount); + LEReferenceToArrayOf classRangeRecordArrayRef(base, success, &classRangeRecordArray[0], rangeCount); le_int32 rangeIndex = - OpenTypeUtilities::getGlyphRangeIndex(ttGlyph, classRangeRecordArray, rangeCount); + OpenTypeUtilities::getGlyphRangeIndex(ttGlyph, classRangeRecordArrayRef, success); - if (rangeIndex < 0) { + if (rangeIndex < 0 || LE_FAILURE(success)) { return 0; } - return SWAPW(classRangeRecordArray[rangeIndex].rangeValue); + return SWAPW(classRangeRecordArrayRef(rangeIndex, success).rangeValue); } -le_bool ClassDefFormat2Table::hasGlyphClass(le_int32 glyphClass) const +le_bool ClassDefFormat2Table::hasGlyphClass(const LETableReference &base, le_int32 glyphClass, LEErrorCode &success) const { + if(LE_FAILURE(success)) return 0; le_uint16 rangeCount = SWAPW(classRangeCount); + LEReferenceToArrayOf classRangeRecordArrayRef(base, success, &classRangeRecordArray[0], rangeCount); int i; - for (i = 0; i < rangeCount; i += 1) { - if (SWAPW(classRangeRecordArray[i].rangeValue) == glyphClass) { + for (i = 0; i < rangeCount && LE_SUCCESS(success); i += 1) { + if (SWAPW(classRangeRecordArrayRef(i,success).rangeValue) == glyphClass) { return TRUE; } }