ubidiimp.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. ******************************************************************************
  5. *
  6. * Copyright (C) 1999-2016, International Business Machines
  7. * Corporation and others. All Rights Reserved.
  8. *
  9. ******************************************************************************
  10. * file name: ubidiimp.h
  11. * encoding: UTF-8
  12. * tab size: 8 (not used)
  13. * indentation:4
  14. *
  15. * created on: 1999aug06
  16. * created by: Markus W. Scherer, updated by Matitiahu Allouche
  17. */
  18. #ifndef UBIDIIMP_H
  19. #define UBIDIIMP_H
  20. #include "unicode/utypes.h"
  21. #include "unicode/ubidi.h"
  22. #include "unicode/uchar.h"
  23. #include "ubidi_props.h"
  24. /* miscellaneous definitions ---------------------------------------------- */
  25. // ICU-20853=ICU-20935 Solaris #defines CS and ES in sys/regset.h
  26. #ifdef CS
  27. # undef CS
  28. #endif
  29. #ifdef ES
  30. # undef ES
  31. #endif
  32. typedef uint8_t DirProp;
  33. typedef uint32_t Flags;
  34. /* Comparing the description of the BiDi algorithm with this implementation
  35. is easier with the same names for the BiDi types in the code as there.
  36. See UCharDirection in uchar.h .
  37. */
  38. enum {
  39. L= U_LEFT_TO_RIGHT, /* 0 */
  40. R= U_RIGHT_TO_LEFT, /* 1 */
  41. EN= U_EUROPEAN_NUMBER, /* 2 */
  42. ES= U_EUROPEAN_NUMBER_SEPARATOR, /* 3 */
  43. ET= U_EUROPEAN_NUMBER_TERMINATOR, /* 4 */
  44. AN= U_ARABIC_NUMBER, /* 5 */
  45. CS= U_COMMON_NUMBER_SEPARATOR, /* 6 */
  46. B= U_BLOCK_SEPARATOR, /* 7 */
  47. S= U_SEGMENT_SEPARATOR, /* 8 */
  48. WS= U_WHITE_SPACE_NEUTRAL, /* 9 */
  49. ON= U_OTHER_NEUTRAL, /* 10 */
  50. LRE=U_LEFT_TO_RIGHT_EMBEDDING, /* 11 */
  51. LRO=U_LEFT_TO_RIGHT_OVERRIDE, /* 12 */
  52. AL= U_RIGHT_TO_LEFT_ARABIC, /* 13 */
  53. RLE=U_RIGHT_TO_LEFT_EMBEDDING, /* 14 */
  54. RLO=U_RIGHT_TO_LEFT_OVERRIDE, /* 15 */
  55. PDF=U_POP_DIRECTIONAL_FORMAT, /* 16 */
  56. NSM=U_DIR_NON_SPACING_MARK, /* 17 */
  57. BN= U_BOUNDARY_NEUTRAL, /* 18 */
  58. FSI=U_FIRST_STRONG_ISOLATE, /* 19 */
  59. LRI=U_LEFT_TO_RIGHT_ISOLATE, /* 20 */
  60. RLI=U_RIGHT_TO_LEFT_ISOLATE, /* 21 */
  61. PDI=U_POP_DIRECTIONAL_ISOLATE, /* 22 */
  62. ENL, /* EN after W7 */ /* 23 */
  63. ENR, /* EN not subject to W7 */ /* 24 */
  64. dirPropCount
  65. };
  66. /* Sometimes, bit values are more appropriate
  67. to deal with directionality properties.
  68. Abbreviations in these macro names refer to names
  69. used in the BiDi algorithm.
  70. */
  71. #define DIRPROP_FLAG(dir) (1UL<<(dir))
  72. #define PURE_DIRPROP(prop) ((prop)&~0xE0) ?????????????????????????
  73. /* special flag for multiple runs from explicit embedding codes */
  74. #define DIRPROP_FLAG_MULTI_RUNS (1UL<<31)
  75. /* are there any characters that are LTR or RTL? */
  76. #define MASK_LTR (DIRPROP_FLAG(L)|DIRPROP_FLAG(EN)|DIRPROP_FLAG(ENL)|DIRPROP_FLAG(ENR)|DIRPROP_FLAG(AN)|DIRPROP_FLAG(LRE)|DIRPROP_FLAG(LRO)|DIRPROP_FLAG(LRI))
  77. #define MASK_RTL (DIRPROP_FLAG(R)|DIRPROP_FLAG(AL)|DIRPROP_FLAG(RLE)|DIRPROP_FLAG(RLO)|DIRPROP_FLAG(RLI))
  78. #define MASK_R_AL (DIRPROP_FLAG(R)|DIRPROP_FLAG(AL))
  79. #define MASK_STRONG_EN_AN (DIRPROP_FLAG(L)|DIRPROP_FLAG(R)|DIRPROP_FLAG(AL)|DIRPROP_FLAG(EN)|DIRPROP_FLAG(AN))
  80. /* explicit embedding codes */
  81. #define MASK_EXPLICIT (DIRPROP_FLAG(LRE)|DIRPROP_FLAG(LRO)|DIRPROP_FLAG(RLE)|DIRPROP_FLAG(RLO)|DIRPROP_FLAG(PDF))
  82. /* explicit isolate codes */
  83. #define MASK_ISO (DIRPROP_FLAG(LRI)|DIRPROP_FLAG(RLI)|DIRPROP_FLAG(FSI)|DIRPROP_FLAG(PDI))
  84. #define MASK_BN_EXPLICIT (DIRPROP_FLAG(BN)|MASK_EXPLICIT)
  85. /* paragraph and segment separators */
  86. #define MASK_B_S (DIRPROP_FLAG(B)|DIRPROP_FLAG(S))
  87. /* all types that are counted as White Space or Neutral in some steps */
  88. #define MASK_WS (MASK_B_S|DIRPROP_FLAG(WS)|MASK_BN_EXPLICIT|MASK_ISO)
  89. /* types that are neutrals or could becomes neutrals in (Wn) */
  90. #define MASK_POSSIBLE_N (DIRPROP_FLAG(ON)|DIRPROP_FLAG(CS)|DIRPROP_FLAG(ES)|DIRPROP_FLAG(ET)|MASK_WS)
  91. /*
  92. * These types may be changed to "e",
  93. * the embedding type (L or R) of the run,
  94. * in the BiDi algorithm (N2)
  95. */
  96. #define MASK_EMBEDDING (DIRPROP_FLAG(NSM)|MASK_POSSIBLE_N)
  97. /* the dirProp's L and R are defined to 0 and 1 values in UCharDirection */
  98. #define GET_LR_FROM_LEVEL(level) ((DirProp)((level)&1))
  99. #define IS_DEFAULT_LEVEL(level) ((level)>=0xfe)
  100. /*
  101. * The following bit is used for the directional isolate status.
  102. * Stack entries corresponding to isolate sequences are greater than ISOLATE.
  103. */
  104. #define ISOLATE 0x0100
  105. U_CFUNC UBiDiLevel
  106. ubidi_getParaLevelAtIndex(const UBiDi *pBiDi, int32_t index);
  107. #define GET_PARALEVEL(ubidi, index) \
  108. ((UBiDiLevel)(!(ubidi)->defaultParaLevel || (index)<(ubidi)->paras[0].limit ? \
  109. (ubidi)->paraLevel : ubidi_getParaLevelAtIndex((ubidi), (index))))
  110. /* number of paras entries allocated initially without malloc */
  111. #define SIMPLE_PARAS_COUNT 10
  112. /* number of isolate entries allocated initially without malloc */
  113. #define SIMPLE_ISOLATES_COUNT 5
  114. /* number of isolate run entries for paired brackets allocated initially without malloc */
  115. #define SIMPLE_OPENINGS_COUNT 20
  116. #define CR 0x000D
  117. #define LF 0x000A
  118. /* Run structure for reordering --------------------------------------------- */
  119. enum {
  120. LRM_BEFORE=1,
  121. LRM_AFTER=2,
  122. RLM_BEFORE=4,
  123. RLM_AFTER=8
  124. };
  125. typedef struct Para {
  126. int32_t limit;
  127. int32_t level;
  128. } Para;
  129. enum { /* flags for Opening.flags */
  130. FOUND_L=DIRPROP_FLAG(L),
  131. FOUND_R=DIRPROP_FLAG(R)
  132. };
  133. typedef struct Opening {
  134. int32_t position; /* position of opening bracket */
  135. int32_t match; /* matching char or -position of closing bracket */
  136. int32_t contextPos; /* position of last strong char found before opening */
  137. uint16_t flags; /* bits for L or R/AL found within the pair */
  138. UBiDiDirection contextDir; /* L or R according to last strong char before opening */
  139. uint8_t filler; /* to complete a nice multiple of 4 chars */
  140. } Opening;
  141. typedef struct IsoRun {
  142. int32_t contextPos; /* position of char determining context */
  143. uint16_t start; /* index of first opening entry for this run */
  144. uint16_t limit; /* index after last opening entry for this run */
  145. UBiDiLevel level; /* level of this run */
  146. DirProp lastStrong; /* bidi class of last strong char found in this run */
  147. DirProp lastBase; /* bidi class of last base char found in this run */
  148. UBiDiDirection contextDir; /* L or R to use as context for following openings */
  149. } IsoRun;
  150. typedef struct BracketData {
  151. UBiDi *pBiDi;
  152. /* array of opening entries which should be enough in most cases; no malloc() */
  153. Opening simpleOpenings[SIMPLE_OPENINGS_COUNT];
  154. Opening *openings; /* pointer to current array of entries */
  155. int32_t openingsCount; /* number of allocated entries */
  156. int32_t isoRunLast; /* index of last used entry */
  157. /* array of nested isolated sequence entries; can never excess UBIDI_MAX_EXPLICIT_LEVEL
  158. + 1 for index 0, + 1 for before the first isolated sequence */
  159. IsoRun isoRuns[UBIDI_MAX_EXPLICIT_LEVEL+2];
  160. UBool isNumbersSpecial; /* reordering mode for NUMBERS_SPECIAL */
  161. } BracketData;
  162. typedef struct Isolate {
  163. int32_t startON;
  164. int32_t start1;
  165. int32_t state;
  166. int16_t stateImp;
  167. } Isolate;
  168. typedef struct Run {
  169. int32_t logicalStart, /* first character of the run; b31 indicates even/odd level */
  170. visualLimit, /* last visual position of the run +1 */
  171. insertRemove; /* if >0, flags for inserting LRM/RLM before/after run,
  172. if <0, count of bidi controls within run */
  173. } Run;
  174. /* in a Run, logicalStart will get this bit set if the run level is odd */
  175. #define INDEX_ODD_BIT (1UL<<31)
  176. #define MAKE_INDEX_ODD_PAIR(index, level) ((index)|((int32_t)((level)&1)<<31))
  177. #define ADD_ODD_BIT_FROM_LEVEL(x, level) ((x)|=((int32_t)((level)&1)<<31))
  178. #define REMOVE_ODD_BIT(x) ((x)&=~INDEX_ODD_BIT)
  179. #define GET_INDEX(x) ((x)&~INDEX_ODD_BIT)
  180. #define GET_ODD_BIT(x) ((uint32_t)(x)>>31)
  181. #define IS_ODD_RUN(x) ((UBool)(((x)&INDEX_ODD_BIT)!=0))
  182. #define IS_EVEN_RUN(x) ((UBool)(((x)&INDEX_ODD_BIT)==0))
  183. U_CFUNC UBool
  184. ubidi_getRuns(UBiDi *pBiDi, UErrorCode *pErrorCode);
  185. /** BiDi control code points */
  186. enum {
  187. ZWNJ_CHAR=0x200c,
  188. ZWJ_CHAR,
  189. LRM_CHAR,
  190. RLM_CHAR,
  191. LRE_CHAR=0x202a,
  192. RLE_CHAR,
  193. PDF_CHAR,
  194. LRO_CHAR,
  195. RLO_CHAR,
  196. LRI_CHAR=0x2066,
  197. RLI_CHAR,
  198. FSI_CHAR,
  199. PDI_CHAR
  200. };
  201. #define IS_BIDI_CONTROL_CHAR(c) (((uint32_t)(c)&0xfffffffc)==ZWNJ_CHAR || (uint32_t)((c)-LRE_CHAR)<5 || (uint32_t)((c)-LRI_CHAR)<4)
  202. /* InsertPoints structure for noting where to put BiDi marks ---------------- */
  203. typedef struct Point {
  204. int32_t pos; /* position in text */
  205. int32_t flag; /* flag for LRM/RLM, before/after */
  206. } Point;
  207. typedef struct InsertPoints {
  208. int32_t capacity; /* number of points allocated */
  209. int32_t size; /* number of points used */
  210. int32_t confirmed; /* number of points confirmed */
  211. UErrorCode errorCode; /* for eventual memory shortage */
  212. Point *points; /* pointer to array of points */
  213. } InsertPoints;
  214. /* UBiDi structure ----------------------------------------------------------- */
  215. struct UBiDi {
  216. /* pointer to parent paragraph object (pointer to self if this object is
  217. * a paragraph object); set to NULL in a newly opened object; set to a
  218. * real value after a successful execution of ubidi_setPara or ubidi_setLine
  219. */
  220. const UBiDi * pParaBiDi;
  221. /* alias pointer to the current text */
  222. const UChar *text;
  223. /* length of the current text */
  224. int32_t originalLength;
  225. /* if the UBIDI_OPTION_STREAMING option is set, this is the length
  226. * of text actually processed by ubidi_setPara, which may be shorter than
  227. * the original length.
  228. * Otherwise, it is identical to the original length.
  229. */
  230. int32_t length;
  231. /* if the UBIDI_OPTION_REMOVE_CONTROLS option is set, and/or
  232. * marks are allowed to be inserted in one of the reordering mode, the
  233. * length of the result string may be different from the processed length.
  234. */
  235. int32_t resultLength;
  236. /* memory sizes in bytes */
  237. int32_t dirPropsSize, levelsSize, openingsSize, parasSize, runsSize, isolatesSize;
  238. /* allocated memory */
  239. DirProp *dirPropsMemory;
  240. UBiDiLevel *levelsMemory;
  241. Opening *openingsMemory;
  242. Para *parasMemory;
  243. Run *runsMemory;
  244. Isolate *isolatesMemory;
  245. /* indicators for whether memory may be allocated after ubidi_open() */
  246. UBool mayAllocateText, mayAllocateRuns;
  247. /* arrays with one value per text-character */
  248. DirProp *dirProps;
  249. UBiDiLevel *levels;
  250. /* are we performing an approximation of the "inverse BiDi" algorithm? */
  251. UBool isInverse;
  252. /* are we using the basic algorithm or its variation? */
  253. UBiDiReorderingMode reorderingMode;
  254. /* UBIDI_REORDER_xxx values must be ordered so that all the regular
  255. * logical to visual modes come first, and all inverse BiDi modes
  256. * come last.
  257. */
  258. #define UBIDI_REORDER_LAST_LOGICAL_TO_VISUAL UBIDI_REORDER_NUMBERS_SPECIAL
  259. /* bitmask for reordering options */
  260. uint32_t reorderingOptions;
  261. /* must block separators receive level 0? */
  262. UBool orderParagraphsLTR;
  263. /* the paragraph level */
  264. UBiDiLevel paraLevel;
  265. /* original paraLevel when contextual */
  266. /* must be one of UBIDI_DEFAULT_xxx or 0 if not contextual */
  267. UBiDiLevel defaultParaLevel;
  268. /* context data */
  269. const UChar *prologue;
  270. int32_t proLength;
  271. const UChar *epilogue;
  272. int32_t epiLength;
  273. /* the following is set in ubidi_setPara, used in processPropertySeq */
  274. const struct ImpTabPair * pImpTabPair; /* pointer to levels state table pair */
  275. /* the overall paragraph or line directionality - see UBiDiDirection */
  276. UBiDiDirection direction;
  277. /* flags is a bit set for which directional properties are in the text */
  278. Flags flags;
  279. /* lastArabicPos is index to the last AL in the text, -1 if none */
  280. int32_t lastArabicPos;
  281. /* characters after trailingWSStart are WS and are */
  282. /* implicitly at the paraLevel (rule (L1)) - levels may not reflect that */
  283. int32_t trailingWSStart;
  284. /* fields for paragraph handling */
  285. int32_t paraCount; /* set in getDirProps() */
  286. /* filled in getDirProps() */
  287. Para *paras;
  288. /* for relatively short text, we only need a tiny array of paras (no malloc()) */
  289. Para simpleParas[SIMPLE_PARAS_COUNT];
  290. /* fields for line reordering */
  291. int32_t runCount; /* ==-1: runs not set up yet */
  292. Run *runs;
  293. /* for non-mixed text, we only need a tiny array of runs (no malloc()) */
  294. Run simpleRuns[1];
  295. /* maximum or current nesting depth of isolate sequences */
  296. /* Within resolveExplicitLevels() and checkExplicitLevels(), this is the maximal
  297. nesting encountered.
  298. Within resolveImplicitLevels(), this is the index of the current isolates
  299. stack entry. */
  300. int32_t isolateCount;
  301. Isolate *isolates;
  302. /* for simple text, have a small stack (no malloc()) */
  303. Isolate simpleIsolates[SIMPLE_ISOLATES_COUNT];
  304. /* for inverse Bidi with insertion of directional marks */
  305. InsertPoints insertPoints;
  306. /* for option UBIDI_OPTION_REMOVE_CONTROLS */
  307. int32_t controlCount;
  308. /* for Bidi class callback */
  309. UBiDiClassCallback *fnClassCallback; /* action pointer */
  310. const void *coClassCallback; /* context pointer */
  311. };
  312. #define IS_VALID_PARA(x) ((x) && ((x)->pParaBiDi==(x)))
  313. #define IS_VALID_PARA_OR_LINE(x) ((x) && ((x)->pParaBiDi==(x) || (((x)->pParaBiDi) && (x)->pParaBiDi->pParaBiDi==(x)->pParaBiDi)))
  314. typedef union {
  315. DirProp *dirPropsMemory;
  316. UBiDiLevel *levelsMemory;
  317. Opening *openingsMemory;
  318. Para *parasMemory;
  319. Run *runsMemory;
  320. Isolate *isolatesMemory;
  321. } BidiMemoryForAllocation;
  322. /* Macros for initial checks at function entry */
  323. #define RETURN_IF_NULL_OR_FAILING_ERRCODE(pErrcode, retvalue) UPRV_BLOCK_MACRO_BEGIN { \
  324. if((pErrcode)==NULL || U_FAILURE(*pErrcode)) return retvalue; \
  325. } UPRV_BLOCK_MACRO_END
  326. #define RETURN_IF_NOT_VALID_PARA(bidi, errcode, retvalue) UPRV_BLOCK_MACRO_BEGIN { \
  327. if(!IS_VALID_PARA(bidi)) { \
  328. errcode=U_INVALID_STATE_ERROR; \
  329. return retvalue; \
  330. } \
  331. } UPRV_BLOCK_MACRO_END
  332. #define RETURN_IF_NOT_VALID_PARA_OR_LINE(bidi, errcode, retvalue) UPRV_BLOCK_MACRO_BEGIN { \
  333. if(!IS_VALID_PARA_OR_LINE(bidi)) { \
  334. errcode=U_INVALID_STATE_ERROR; \
  335. return retvalue; \
  336. } \
  337. } UPRV_BLOCK_MACRO_END
  338. #define RETURN_IF_BAD_RANGE(arg, start, limit, errcode, retvalue) UPRV_BLOCK_MACRO_BEGIN { \
  339. if((arg)<(start) || (arg)>=(limit)) { \
  340. (errcode)=U_ILLEGAL_ARGUMENT_ERROR; \
  341. return retvalue; \
  342. } \
  343. } UPRV_BLOCK_MACRO_END
  344. #define RETURN_VOID_IF_NULL_OR_FAILING_ERRCODE(pErrcode) UPRV_BLOCK_MACRO_BEGIN { \
  345. if((pErrcode)==NULL || U_FAILURE(*pErrcode)) return; \
  346. } UPRV_BLOCK_MACRO_END
  347. #define RETURN_VOID_IF_NOT_VALID_PARA(bidi, errcode) UPRV_BLOCK_MACRO_BEGIN { \
  348. if(!IS_VALID_PARA(bidi)) { \
  349. errcode=U_INVALID_STATE_ERROR; \
  350. return; \
  351. } \
  352. } UPRV_BLOCK_MACRO_END
  353. #define RETURN_VOID_IF_NOT_VALID_PARA_OR_LINE(bidi, errcode) UPRV_BLOCK_MACRO_BEGIN { \
  354. if(!IS_VALID_PARA_OR_LINE(bidi)) { \
  355. errcode=U_INVALID_STATE_ERROR; \
  356. return; \
  357. } \
  358. } UPRV_BLOCK_MACRO_END
  359. #define RETURN_VOID_IF_BAD_RANGE(arg, start, limit, errcode) UPRV_BLOCK_MACRO_BEGIN { \
  360. if((arg)<(start) || (arg)>=(limit)) { \
  361. (errcode)=U_ILLEGAL_ARGUMENT_ERROR; \
  362. return; \
  363. } \
  364. } UPRV_BLOCK_MACRO_END
  365. /* helper function to (re)allocate memory if allowed */
  366. U_CFUNC UBool
  367. ubidi_getMemory(BidiMemoryForAllocation *pMemory, int32_t *pSize, UBool mayAllocate, int32_t sizeNeeded);
  368. /* helper macros for each allocated array in UBiDi */
  369. #define getDirPropsMemory(pBiDi, length) \
  370. ubidi_getMemory((BidiMemoryForAllocation *)&(pBiDi)->dirPropsMemory, &(pBiDi)->dirPropsSize, \
  371. (pBiDi)->mayAllocateText, (length))
  372. #define getLevelsMemory(pBiDi, length) \
  373. ubidi_getMemory((BidiMemoryForAllocation *)&(pBiDi)->levelsMemory, &(pBiDi)->levelsSize, \
  374. (pBiDi)->mayAllocateText, (length))
  375. #define getRunsMemory(pBiDi, length) \
  376. ubidi_getMemory((BidiMemoryForAllocation *)&(pBiDi)->runsMemory, &(pBiDi)->runsSize, \
  377. (pBiDi)->mayAllocateRuns, (length)*sizeof(Run))
  378. /* additional macros used by ubidi_open() - always allow allocation */
  379. #define getInitialDirPropsMemory(pBiDi, length) \
  380. ubidi_getMemory((BidiMemoryForAllocation *)&(pBiDi)->dirPropsMemory, &(pBiDi)->dirPropsSize, \
  381. true, (length))
  382. #define getInitialLevelsMemory(pBiDi, length) \
  383. ubidi_getMemory((BidiMemoryForAllocation *)&(pBiDi)->levelsMemory, &(pBiDi)->levelsSize, \
  384. true, (length))
  385. #define getInitialOpeningsMemory(pBiDi, length) \
  386. ubidi_getMemory((BidiMemoryForAllocation *)&(pBiDi)->openingsMemory, &(pBiDi)->openingsSize, \
  387. true, (length)*sizeof(Opening))
  388. #define getInitialParasMemory(pBiDi, length) \
  389. ubidi_getMemory((BidiMemoryForAllocation *)&(pBiDi)->parasMemory, &(pBiDi)->parasSize, \
  390. true, (length)*sizeof(Para))
  391. #define getInitialRunsMemory(pBiDi, length) \
  392. ubidi_getMemory((BidiMemoryForAllocation *)&(pBiDi)->runsMemory, &(pBiDi)->runsSize, \
  393. true, (length)*sizeof(Run))
  394. #define getInitialIsolatesMemory(pBiDi, length) \
  395. ubidi_getMemory((BidiMemoryForAllocation *)&(pBiDi)->isolatesMemory, &(pBiDi)->isolatesSize, \
  396. true, (length)*sizeof(Isolate))
  397. #endif