Skip to content

Commit 47a8402

Browse files
committed
Define the last scalar offset instead of hard coding it
1 parent 76fbb3c commit 47a8402

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

stdlib/public/stubs/Unicode/Apple/ScalarPropsData.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7420,6 +7420,8 @@ static const __swift_uint32_t _swift_stdlib_word_indices[12866] = {
74207420
0x13139,
74217421
};
74227422

7423+
#define NAMES_LAST_SCALAR_OFFSET 215884
7424+
74237425
static const __swift_uint8_t _swift_stdlib_names[215884] = {
74247426
0xFF, 0xA3, 0x2, 0xFF, 0x76, 0x2, 0x2B, 0xFF, 0x36, 0x2, 0x2B, 0x1D, 0x1, 0xFF, 0x1B, 0x5, 0x1,
74257427
0xFF, 0x28, 0x6, 0x1, 0xFF, 0x74, 0x4, 0xFF, 0x45, 0x4, 0x27, 0xFF, 0xB7, 0x1, 0x25, 0xFF, 0xB7,

stdlib/public/stubs/Unicode/Common/ScalarPropsData.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7391,6 +7391,8 @@ static const __swift_uint32_t _swift_stdlib_word_indices[12866] = {
73917391
0x130FC, 0x130FE, 0x13103, 0x13108, 0x1310D, 0x13111, 0x1311A, 0x13127, 0x1312B, 0x13131, 0x1313A,
73927392
};
73937393

7394+
#define NAMES_LAST_SCALAR_OFFSET 215884
7395+
73947396
static const __swift_uint8_t _swift_stdlib_names[215884] = {
73957397
0xFF, 0xA7, 0x2, 0xFF, 0x77, 0x2, 0x2B, 0xFF, 0x3A, 0x2, 0x2B, 0x1D, 0x1, 0xFF, 0xDD, 0x4, 0x1,
73967398
0xFF, 0x7C, 0x6, 0x1, 0xFF, 0x9F, 0x4, 0xFF, 0x46, 0x4, 0x27, 0xFF, 0xB6, 0x1, 0x25, 0xFF, 0xB6,

stdlib/public/stubs/Unicode/UnicodeScalarProps.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,8 @@ __swift_intptr_t _swift_stdlib_getScalarName(__swift_uint32_t scalar,
252252
}
253253
} else {
254254
// This is the last element in the array which represents the last scalar
255-
// name that Unicode defines (excluding variation selectors). This is
256-
// U+E007F at the moment whose name is 'CANCEL TAG'. We add 4 because
257-
// 'CANCEL' is found outside the byte area for words, but tag does.
258-
// The resulting word indices look like this: [..., 0xFF, _, _, 0xXX];
259-
nextScalarOffset = scalarOffset + 4;
255+
// name that Unicode defines (excluding variation selectors).
256+
nextScalarOffset = NAMES_LAST_SCALAR_OFFSET;
260257
}
261258

262259
auto nameSize = nextScalarOffset - scalarOffset;

utils/gen-unicode-data/Sources/GenScalarProps/Names.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func emitScalarNames(
160160
}
161161

162162
result += """
163-
#define NAMES_SCALARS_MAX_INDEX \(scalars.count - 1)
163+
#define NAMES_LAST_SCALAR_OFFSET \(nameBytes.count)
164164
165165
166166
"""
@@ -204,6 +204,12 @@ func emitScalars(
204204
}
205205
}
206206

207+
result += """
208+
#define NAMES_SCALARS_MAX_INDEX \(scalars.count - 1)
209+
210+
211+
"""
212+
207213
emitCollection(scalars, name: "_swift_stdlib_names_scalars", into: &result)
208214

209215
return scalarSetIndices

0 commit comments

Comments
 (0)