ICU4C Proposal: Improved Error Handling For ParagraphLayout

Eric Mader <[email protected]> Tue, 04 Nov 2003 13:51:20 -0800
Newsgroups gmane.comp.lib.icu.general
Message-ID <[email protected]>
Here's a new prototype for the ParagraphLayout constructor, which 
includes an LEErrorCode parameter so that the constructor can report any 
errors encountered during construction.

This was done because the constructor calls in internal method which 
calls LEFontInstance::getSubFont, which can return errors. If these 
errors are not caught and reported, the internal method will go into an 
infinite loop. If the error is caught, it should be reported to the 
caller of the constructor to indicate that the object is incomplete and 
should not be used.

This proposal expires on 11/11/2003.

Here's the new prototype:

     /**
      * Construct a <code>ParagraphLayout</code> object for a styled 
paragraph. The paragraph is specified
      * as runs of text all in the same font. An 
<code>LEFontInstance</code> object and a limit offset
      * are specified for each font run. The limit offset is the offset 
of the character immediately
      * after the font run.
      *
      * Clients can optionally specify directional runs and / or script 
runs. If these aren't specified
      * they will be computed.
	 *
	 * If any errors are encountered during construction, 
<code>status</code> will be set, and the object
	 * will be set to be empty.
      *
      * @param chars is an array of the characters in the paragraph
      *
      * @param count is the number of characters in the paragraph.
      *
      * @param fontRuns a pointer to a <code>FontRuns</code> object 
representing the font runs.
      *
      * @param levelRuns is a pointer to a <code>ValueRuns</code> object 
representing the directional levels.
      *        If this pointer in <code>NULL</code> the levels will be 
determined by running the Unicde
      *        Bidi algorithm.
      *
      * @param scriptRuns is a pointer to a <code>ValueRuns</code> 
object representing script runs.
      *        If this pointer in <code>NULL</code> the script runs will 
be determined using the
      *        Unicode code points.
      *
      * @param localeRuns is a pointer to a <code>LocaleRuns</code> 
object representing locale runs.
      *        The <code>Locale</code> objects are used to determind the 
language of the text. If this
      *        pointer is <code>NULL</code> the default locale will be 
used for all of the text.
      *
      * @param paragraphLevel is the directionality of the paragraph, as 
in the UBiDi object.
      *
      * @param vertical is <code>true</code> if the paragraph should be 
set vertically.
      *
	 * @param status will be set to any error code encountered during 
construction.
      *
      * @see ubidi.h
      * @see LEFontInstance.h
      * @see LayoutEngine.h
      * @see RunArrays.h
      *
      * @draft ICU 2.8
      */
     ParagraphLayout(const LEUnicode chars[], le_int32 count,
                     const FontRuns *fontRuns,
                     const ValueRuns *levelRuns,
                     const ValueRuns *scriptRuns,
                     const LocaleRuns *localeRuns,
                     UBiDiLevel paragraphLevel, le_bool vertical,
					LEErrorCode &status);


Regards,
Eric Mader
IBM GCoC - San José
5600 Cottle Rd.  M/S 50-2/B11
San Jose, CA 95193