]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/layout/TrimmedArrayProcessor2.cpp
ICU-57132.0.1.tar.gz
[apple/icu.git] / icuSources / layout / TrimmedArrayProcessor2.cpp
index c9a9b53de4a90aa60f18c4a751fc5f0aaaed898a..fb30994a202bfeb9828de5ca268a6dab7bbc8898 100644 (file)
@@ -21,22 +21,24 @@ TrimmedArrayProcessor2::TrimmedArrayProcessor2()
 {
 }
 
-TrimmedArrayProcessor2::TrimmedArrayProcessor2(const MorphSubtableHeader2 *morphSubtableHeader)
-  : NonContextualGlyphSubstitutionProcessor2(morphSubtableHeader)
+TrimmedArrayProcessor2::TrimmedArrayProcessor2(const LEReferenceTo<MorphSubtableHeader2> &morphSubtableHeader, LEErrorCode &success)
+  : NonContextualGlyphSubstitutionProcessor2(morphSubtableHeader, success)
 {
-    const NonContextualGlyphSubstitutionHeader2 *header = (const NonContextualGlyphSubstitutionHeader2 *) morphSubtableHeader;
+    const LEReferenceTo<NonContextualGlyphSubstitutionHeader2> header(morphSubtableHeader, success);
 
-    trimmedArrayLookupTable = (const TrimmedArrayLookupTable *) &header->table;
+    trimmedArrayLookupTable = LEReferenceTo<TrimmedArrayLookupTable>(morphSubtableHeader, success, &header->table);
     firstGlyph = SWAPW(trimmedArrayLookupTable->firstGlyph);
     lastGlyph = firstGlyph + SWAPW(trimmedArrayLookupTable->glyphCount);
+    valueArray = LEReferenceToArrayOf<LookupValue>(morphSubtableHeader, success, &trimmedArrayLookupTable->valueArray[0], LE_UNBOUNDED_ARRAY);
 }
 
 TrimmedArrayProcessor2::~TrimmedArrayProcessor2()
 {
 }
 
-void TrimmedArrayProcessor2::process(LEGlyphStorage &glyphStorage)
+void TrimmedArrayProcessor2::process(LEGlyphStorage &glyphStorage, LEErrorCode &success)
 {
+    if(LE_FAILURE(success)) return;
     le_int32 glyphCount = glyphStorage.getGlyphCount();
     le_int32 glyph;
 
@@ -45,7 +47,7 @@ void TrimmedArrayProcessor2::process(LEGlyphStorage &glyphStorage)
         TTGlyphID ttGlyph = (TTGlyphID) LE_GET_GLYPH(thisGlyph);
 
         if ((ttGlyph > firstGlyph) && (ttGlyph < lastGlyph)) {
-            TTGlyphID newGlyph = SWAPW(trimmedArrayLookupTable->valueArray[ttGlyph - firstGlyph]);
+            TTGlyphID newGlyph = SWAPW(valueArray(ttGlyph - firstGlyph, success));
 
             glyphStorage[glyph] = LE_SET_GLYPH(thisGlyph, newGlyph);
         }