Lines Matching refs:scriptRun
30 #define STACK_IS_EMPTY(scriptRun) ((scriptRun)->pushCount <= 0)
31 #define STACK_IS_NOT_EMPTY(scriptRun) (! STACK_IS_EMPTY(scriptRun))
32 #define TOP(scriptRun) ((scriptRun)->parenStack[(scriptRun)->parenSP])
33 #define SYNC_FIXUP(scriptRun) ((scriptRun)->fixupCount = 0)
78 static void push(UScriptRun *scriptRun, int32_t pairIndex, UScriptCode scriptCode)
80 scriptRun->pushCount = LIMIT_INC(scriptRun->pushCount);
81 scriptRun->fixupCount = LIMIT_INC(scriptRun->fixupCount);
83 scriptRun->parenSP = INC1(scriptRun->parenSP);
84 scriptRun->parenStack[scriptRun->parenSP].pairIndex = pairIndex;
85 scriptRun->parenStack[scriptRun->parenSP].scriptCode = scriptCode;
88 static void pop(UScriptRun *scriptRun)
90 if (STACK_IS_EMPTY(scriptRun)) {
94 if (scriptRun->fixupCount > 0) {
95 scriptRun->fixupCount -= 1;
98 scriptRun->pushCount -= 1;
99 scriptRun->parenSP = DEC1(scriptRun->parenSP);
104 if (STACK_IS_EMPTY(scriptRun)) {
105 scriptRun->parenSP = -1;
109 static void fixup(UScriptRun *scriptRun, UScriptCode scriptCode)
111 int32_t fixupSP = DEC(scriptRun->parenSP, scriptRun->fixupCount);
113 while (scriptRun->fixupCount-- > 0) {
115 scriptRun->parenStack[fixupSP].scriptCode = scriptCode;
219 uscript_closeRun(UScriptRun *scriptRun)
221 if (scriptRun != NULL) {
222 uprv_free(scriptRun);
227 uscript_resetRun(UScriptRun *scriptRun)
229 if (scriptRun != NULL) {
230 scriptRun->scriptStart = 0;
231 scriptRun->scriptLimit = 0;
232 scriptRun->scriptCode = USCRIPT_INVALID_CODE;
233 scriptRun->parenSP = -1;
234 scriptRun->pushCount = 0;
235 scriptRun->fixupCount = 0;
240 uscript_setRunText(UScriptRun *scriptRun, const UChar *src, int32_t length, UErrorCode *pErrorCode)
246 if (scriptRun == NULL || length < 0 || ((src == NULL) != (length == 0))) {
251 scriptRun->textArray = src;
252 scriptRun->textLength = length;
254 uscript_resetRun(scriptRun);
258 uscript_nextRun(UScriptRun *scriptRun, int32_t *pRunStart, int32_t *pRunLimit, UScriptCode *pRunScript)
263 if (scriptRun == NULL || scriptRun->scriptLimit >= scriptRun->textLength) {
267 SYNC_FIXUP(scriptRun);
268 scriptRun->scriptCode = USCRIPT_COMMON;
270 for (scriptRun->scriptStart = scriptRun->scriptLimit; scriptRun->scriptLimit < scriptRun->textLength; scriptRun->scriptLimit += 1) {
271 UChar high = scriptRun->textArray[scriptRun->scriptLimit];
280 if (high >= 0xD800 && high <= 0xDBFF && scriptRun->scriptLimit < scriptRun->textLength - 1) {
281 UChar low = scriptRun->textArray[scriptRun->scriptLimit + 1];
289 scriptRun->scriptLimit += 1;
306 push(scriptRun, pairIndex, scriptRun->scriptCode);
310 while (STACK_IS_NOT_EMPTY(scriptRun) && TOP(scriptRun).pairIndex != pi) {
311 pop(scriptRun);
314 if (STACK_IS_NOT_EMPTY(scriptRun)) {
315 sc = TOP(scriptRun).scriptCode;
320 if (sameScript(scriptRun->scriptCode, sc)) {
321 if (scriptRun->scriptCode <= USCRIPT_INHERITED && sc > USCRIPT_INHERITED) {
322 scriptRun->scriptCode = sc;
324 fixup(scriptRun, scriptRun->scriptCode);
332 pop(scriptRun);
340 scriptRun->scriptLimit -= 1;
349 *pRunStart = scriptRun->scriptStart;
353 *pRunLimit = scriptRun->scriptLimit;
357 *pRunScript = scriptRun->scriptCode;