/*
*******************************************************************************
*
-* Copyright (C) 2004-2010, International Business Machines
+* Copyright (C) 2004-2014, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
#include "unicode/udata.h" /* UDataInfo */
#include "ucmndata.h" /* DataHeader */
#include "udatamem.h"
-#include "umutex.h"
#include "uassert.h"
#include "cmemory.h"
#include "utrie2.h"
const int32_t *indexes;
const uint32_t *mirrors;
const uint8_t *jgArray;
+ const uint8_t *jgArray2;
UTrie2 trie;
uint8_t formatVersion[4];
};
-/* ubidi_props_data.c is machine-generated by genbidi --csource */
-#include "ubidi_props_data.c"
+/* ubidi_props_data.h is machine-generated by genbidi --csource */
+#define INCLUDED_FROM_UBIDI_PROPS_C
+#include "ubidi_props_data.h"
/* UBiDiProps singleton ----------------------------------------------------- */
start=bdp->indexes[UBIDI_IX_JG_START];
limit=bdp->indexes[UBIDI_IX_JG_LIMIT];
jgArray=bdp->jgArray;
- prev=0;
- while(start<limit) {
- jg=*jgArray++;
- if(jg!=prev) {
- sa->add(sa->set, start);
- prev=jg;
+ for(;;) {
+ prev=0;
+ while(start<limit) {
+ jg=*jgArray++;
+ if(jg!=prev) {
+ sa->add(sa->set, start);
+ prev=jg;
+ }
+ ++start;
+ }
+ if(prev!=0) {
+ /* add the limit code point if the last value was not 0 (it is now start==limit) */
+ sa->add(sa->set, limit);
+ }
+ if(limit==bdp->indexes[UBIDI_IX_JG_LIMIT]) {
+ /* switch to the second Joining_Group range */
+ start=bdp->indexes[UBIDI_IX_JG_START2];
+ limit=bdp->indexes[UBIDI_IX_JG_LIMIT2];
+ jgArray=bdp->jgArray2;
+ } else {
+ break;
}
- ++start;
- }
- if(prev!=0) {
- /* add the limit code point if the last value was not 0 (it is now start==limit) */
- sa->add(sa->set, limit);
}
/* add code points with hardcoded properties, plus the ones following them */
return (max&UBIDI_MAX_JG_MASK)>>UBIDI_MAX_JG_SHIFT;
case UCHAR_JOINING_TYPE:
return (max&UBIDI_JT_MASK)>>UBIDI_JT_SHIFT;
+ case UCHAR_BIDI_PAIRED_BRACKET_TYPE:
+ return (max&UBIDI_BPT_MASK)>>UBIDI_BPT_SHIFT;
default:
return -1; /* undefined */
}
return (UBool)UBIDI_GET_FLAG(props, UBIDI_IS_MIRRORED_SHIFT);
}
-U_CFUNC UChar32
-ubidi_getMirror(const UBiDiProps *bdp, UChar32 c) {
- uint16_t props=UTRIE2_GET16(&bdp->trie, c);
- int32_t delta=((int16_t)props)>>UBIDI_MIRROR_DELTA_SHIFT;
+static UChar32
+getMirror(const UBiDiProps *bdp, UChar32 c, uint16_t props) {
+ int32_t delta=UBIDI_GET_MIRROR_DELTA(props);
if(delta!=UBIDI_ESC_MIRROR_DELTA) {
return c+delta;
} else {
}
}
+U_CFUNC UChar32
+ubidi_getMirror(const UBiDiProps *bdp, UChar32 c) {
+ uint16_t props=UTRIE2_GET16(&bdp->trie, c);
+ return getMirror(bdp, c, props);
+}
+
U_CFUNC UBool
ubidi_isBidiControl(const UBiDiProps *bdp, UChar32 c) {
uint16_t props=UTRIE2_GET16(&bdp->trie, c);
limit=bdp->indexes[UBIDI_IX_JG_LIMIT];
if(start<=c && c<limit) {
return (UJoiningGroup)bdp->jgArray[c-start];
+ }
+ start=bdp->indexes[UBIDI_IX_JG_START2];
+ limit=bdp->indexes[UBIDI_IX_JG_LIMIT2];
+ if(start<=c && c<limit) {
+ return (UJoiningGroup)bdp->jgArray2[c-start];
+ }
+ return U_JG_NO_JOINING_GROUP;
+}
+
+U_CFUNC UBidiPairedBracketType
+ubidi_getPairedBracketType(const UBiDiProps *bdp, UChar32 c) {
+ uint16_t props=UTRIE2_GET16(&bdp->trie, c);
+ return (UBidiPairedBracketType)((props&UBIDI_BPT_MASK)>>UBIDI_BPT_SHIFT);
+}
+
+U_CFUNC UChar32
+ubidi_getPairedBracket(const UBiDiProps *bdp, UChar32 c) {
+ uint16_t props=UTRIE2_GET16(&bdp->trie, c);
+ if((props&UBIDI_BPT_MASK)==0) {
+ return c;
} else {
- return U_JG_NO_JOINING_GROUP;
+ return getMirror(bdp, c, props);
}
}
u_charMirror(UChar32 c) {
return ubidi_getMirror(&ubidi_props_singleton, c);
}
+
+U_STABLE UChar32 U_EXPORT2
+u_getBidiPairedBracket(UChar32 c) {
+ return ubidi_getPairedBracket(&ubidi_props_singleton, c);
+}