Skip to content

Commit dcebf64

Browse files
authored
Merge pull request #85808 from DougGregor/unicode-data-without-shims
Move Unicode Data declarations from SwiftShims to `@_extern(c)`
2 parents b73676e + be4d2ad commit dcebf64

File tree

13 files changed

+157
-139
lines changed

13 files changed

+157
-139
lines changed

Runtimes/Core/SwiftShims/swift/shims/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ install(FILES
2222
System.h
2323
Target.h
2424
ThreadLocalStorage.h
25-
UnicodeData.h
2625
Visibility.h
2726
_SwiftConcurrency.h
2827
_SwiftDistributed.h

stdlib/public/SwiftShims/swift/shims/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ set(sources
2121
System.h
2222
Target.h
2323
ThreadLocalStorage.h
24-
UnicodeData.h
2524
Visibility.h
2625
_SwiftConcurrency.h
2726
_SwiftDistributed.h

stdlib/public/SwiftShims/swift/shims/UnicodeData.h

Lines changed: 0 additions & 126 deletions
This file was deleted.

stdlib/public/SwiftShims/swift/shims/module.modulemap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ module SwiftShims {
2020
header "System.h"
2121
header "Target.h"
2222
header "ThreadLocalStorage.h"
23-
header "UnicodeData.h"
2423
header "Visibility.h"
2524
export *
2625
}

stdlib/public/core/UnicodeData.swift

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,109 @@ extension Unicode {
191191
}
192192
}
193193
}
194+
195+
//===----------------------------------------------------------------------===//
196+
// Utilities
197+
//===----------------------------------------------------------------------===//
198+
199+
@_extern(c)
200+
func _swift_stdlib_getMphIdx(
201+
_ scalar: UInt32,
202+
_ levels: Int,
203+
_ keys: UnsafePointer<UInt64>,
204+
_ ranks: UnsafePointer<UInt16>,
205+
_ sizes: UnsafePointer<UInt16>
206+
) -> Int
207+
208+
@_extern(c)
209+
func _swift_stdlib_getScalarBitArrayIdx(
210+
_ scalar: UInt32,
211+
_ bitArrays: UnsafePointer<UInt64>,
212+
_ ranks: UnsafePointer<UInt16>
213+
) -> Int
214+
215+
//===----------------------------------------------------------------------===//
216+
// Normalization
217+
//===----------------------------------------------------------------------===//
218+
@_extern(c)
219+
func _swift_stdlib_getNormData(_ scalar: UInt32) -> UInt16
220+
221+
@_extern(c)
222+
func _swift_stdlib_getDecompositionEntry(_ scalar: UInt32) -> UInt32
223+
224+
@_extern(c)
225+
func _swift_stdlib_getComposition(_ x: UInt32, _ y: UInt32) -> UInt32
226+
227+
@_extern(c)
228+
var _swift_stdlib_nfd_decompositions: UnsafePointer<UInt8>?
229+
230+
//===----------------------------------------------------------------------===//
231+
// Grapheme Breaking
232+
//===----------------------------------------------------------------------===//
233+
234+
@_extern(c)
235+
func _swift_stdlib_getGraphemeBreakProperty(_ scalar: UInt32) -> UInt8
236+
237+
@_extern(c)
238+
func _swift_stdlib_isInCB_Consonant(_ scalar: UInt32) -> Bool
239+
240+
//===----------------------------------------------------------------------===//
241+
// Word Breaking
242+
//===----------------------------------------------------------------------===//
243+
244+
@_extern(c)
245+
func _swift_stdlib_getWordBreakProperty(_ scalar: UInt32) -> UInt8
246+
247+
//===----------------------------------------------------------------------===//
248+
// Unicode.Scalar.Properties
249+
//===----------------------------------------------------------------------===//
250+
251+
@_extern(c)
252+
func _swift_stdlib_getBinaryProperties(_ scalar: UInt32) -> UInt64
253+
254+
@_extern(c)
255+
func _swift_stdlib_getNumericType(_ scalar: UInt32) -> UInt8
256+
257+
@_extern(c)
258+
func _swift_stdlib_getNumericValue(_ scalar: UInt32) -> Double
259+
260+
@_extern(c)
261+
func _swift_stdlib_getNameAlias(_ scalar: UInt32) -> UnsafePointer<UInt8>?
262+
263+
@_extern(c)
264+
func _swift_stdlib_getMapping(_ scalar: UInt32, _ mapping: UInt8) -> Int32
265+
266+
@_extern(c)
267+
func _swift_stdlib_getSpecialMapping(
268+
_ scalar: UInt32,
269+
_ mapping: UInt8,
270+
_ length: UnsafeMutablePointer<Int>
271+
) -> UnsafePointer<UInt8>?
272+
273+
@_extern(c)
274+
func _swift_stdlib_getScalarName(
275+
_ scalar: UInt32,
276+
_ buffer: UnsafeMutablePointer<UInt8>?,
277+
_ capacity: Int
278+
) -> Int
279+
280+
@_extern(c)
281+
func _swift_stdlib_getAge(_ scalar: UInt32) -> UInt16
282+
283+
@_extern(c)
284+
func _swift_stdlib_getGeneralCategory(_ scalar: UInt32) -> UInt8
285+
286+
@_extern(c)
287+
func _swift_stdlib_getScript(_ scalar: UInt32) -> UInt8
288+
289+
@_extern(c)
290+
func _swift_stdlib_getScriptExtensions(
291+
_ scalar: UInt32,
292+
_ count: UnsafeMutablePointer<UInt8>
293+
) -> UnsafeMutablePointer<UInt8>?
294+
295+
@_extern(c)
296+
func _swift_stdlib_getCaseMapping(
297+
_ scalar: UInt32,
298+
_ buffer: UnsafeMutablePointer<UInt32>
299+
)

stdlib/public/core/UnicodeScalarProperties.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ extension Unicode.Scalar.Properties {
12501250
}
12511251

12521252
// The longest name that Unicode defines is 88 characters long.
1253-
let largestCount = Int(SWIFT_STDLIB_LARGEST_NAME_COUNT)
1253+
let largestCount = 88
12541254

12551255
let name = unsafe String(_uninitializedCapacity: largestCount) { buffer in
12561256
unsafe _swift_stdlib_getScalarName(

stdlib/public/stubs/Unicode/UnicodeData.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "swift/shims/UnicodeData.h"
13+
#include "UnicodeData.h"
1414
#include <stdint.h>
1515

1616
// Every 4 byte chunks of data that we need to hash (in this case only ever
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2021 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef SWIFT_STDLIB_UNICODEDATA_H
14+
#define SWIFT_STDLIB_UNICODEDATA_H
15+
16+
#include "swift/shims/SwiftStdbool.h"
17+
#include "swift/shims/SwiftStdint.h"
18+
#include "swift/shims/Visibility.h"
19+
20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
23+
24+
//===----------------------------------------------------------------------===//
25+
// Utilities
26+
//===----------------------------------------------------------------------===//
27+
28+
SWIFT_RUNTIME_STDLIB_INTERNAL
29+
__swift_intptr_t _swift_stdlib_getMphIdx(__swift_uint32_t scalar,
30+
__swift_intptr_t levels,
31+
const __swift_uint64_t * const *keys,
32+
const __swift_uint16_t * const *ranks,
33+
const __swift_uint16_t * const sizes);
34+
35+
SWIFT_RUNTIME_STDLIB_INTERNAL
36+
__swift_intptr_t _swift_stdlib_getScalarBitArrayIdx(__swift_uint32_t scalar,
37+
const __swift_uint64_t *bitArrays,
38+
const __swift_uint16_t *ranks);
39+
40+
#ifdef __cplusplus
41+
} // extern "C"
42+
#endif
43+
44+
#endif // SWIFT_STDLIB_SHIMS_UNICODEDATA_H

stdlib/public/stubs/Unicode/UnicodeGrapheme.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#else
1616
#include "swift/Runtime/Debug.h"
1717
#endif
18-
#include "swift/shims/UnicodeData.h"
18+
#include "UnicodeData.h"
1919
#include <stdint.h>
2020

2121

stdlib/public/stubs/Unicode/UnicodeNormalization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "swift/Runtime/Debug.h"
2323
#endif
2424

25-
#include "swift/shims/UnicodeData.h"
25+
#include "UnicodeData.h"
2626
#include <stdint.h>
2727

2828
SWIFT_RUNTIME_STDLIB_INTERNAL

0 commit comments

Comments
 (0)