mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Move Unicode Data declarations from SwiftShims to @_extern(c)
This eliminates UnicodeData.h from the public SwiftShims. A small part of it remains as a private header, but everything else moves into `@_extern(c)`.
This commit is contained in:
@@ -22,7 +22,6 @@ install(FILES
|
||||
System.h
|
||||
Target.h
|
||||
ThreadLocalStorage.h
|
||||
UnicodeData.h
|
||||
Visibility.h
|
||||
_SwiftConcurrency.h
|
||||
_SwiftDistributed.h
|
||||
|
||||
@@ -21,7 +21,6 @@ set(sources
|
||||
System.h
|
||||
Target.h
|
||||
ThreadLocalStorage.h
|
||||
UnicodeData.h
|
||||
Visibility.h
|
||||
_SwiftConcurrency.h
|
||||
_SwiftDistributed.h
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2021 Apple Inc. and the Swift project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See https://swift.org/LICENSE.txt for license information
|
||||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SWIFT_STDLIB_SHIMS_UNICODEDATA_H
|
||||
#define SWIFT_STDLIB_SHIMS_UNICODEDATA_H
|
||||
|
||||
#include "SwiftStdbool.h"
|
||||
#include "SwiftStdint.h"
|
||||
#include "Visibility.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SWIFT_STDLIB_LARGEST_NAME_COUNT 88
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Utilities
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
__swift_intptr_t _swift_stdlib_getMphIdx(__swift_uint32_t scalar,
|
||||
__swift_intptr_t levels,
|
||||
const __swift_uint64_t * const *keys,
|
||||
const __swift_uint16_t * const *ranks,
|
||||
const __swift_uint16_t * const sizes);
|
||||
|
||||
__swift_intptr_t _swift_stdlib_getScalarBitArrayIdx(__swift_uint32_t scalar,
|
||||
const __swift_uint64_t *bitArrays,
|
||||
const __swift_uint16_t *ranks);
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Normalization
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
__swift_uint16_t _swift_stdlib_getNormData(__swift_uint32_t scalar);
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
const __swift_uint8_t * const _swift_stdlib_nfd_decompositions;
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
__swift_uint32_t _swift_stdlib_getDecompositionEntry(__swift_uint32_t scalar);
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
__swift_uint32_t _swift_stdlib_getComposition(__swift_uint32_t x,
|
||||
__swift_uint32_t y);
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Grapheme Breaking
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
__swift_uint8_t _swift_stdlib_getGraphemeBreakProperty(__swift_uint32_t scalar);
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
__swift_bool _swift_stdlib_isInCB_Consonant(__swift_uint32_t scalar);
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Word Breaking
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
__swift_uint8_t _swift_stdlib_getWordBreakProperty(__swift_uint32_t scalar);
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Unicode.Scalar.Properties
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
__swift_uint64_t _swift_stdlib_getBinaryProperties(__swift_uint32_t scalar);
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
__swift_uint8_t _swift_stdlib_getNumericType(__swift_uint32_t scalar);
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
double _swift_stdlib_getNumericValue(__swift_uint32_t scalar);
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
const char *_swift_stdlib_getNameAlias(__swift_uint32_t scalar);
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
__swift_int32_t _swift_stdlib_getMapping(__swift_uint32_t scalar,
|
||||
__swift_uint8_t mapping);
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
const __swift_uint8_t *_swift_stdlib_getSpecialMapping(__swift_uint32_t scalar,
|
||||
__swift_uint8_t mapping,
|
||||
__swift_intptr_t *length);
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
__swift_intptr_t _swift_stdlib_getScalarName(__swift_uint32_t scalar,
|
||||
__swift_uint8_t *buffer,
|
||||
__swift_intptr_t capacity);
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
__swift_uint16_t _swift_stdlib_getAge(__swift_uint32_t scalar);
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
__swift_uint8_t _swift_stdlib_getGeneralCategory(__swift_uint32_t scalar);
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
__swift_uint8_t _swift_stdlib_getScript(__swift_uint32_t scalar);
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
const __swift_uint8_t *_swift_stdlib_getScriptExtensions(
|
||||
__swift_uint32_t scalar,
|
||||
__swift_uint8_t *count);
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
void _swift_stdlib_getCaseMapping(__swift_uint32_t scalar,
|
||||
__swift_uint32_t *buffer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // SWIFT_STDLIB_SHIMS_UNICODEDATA_H
|
||||
@@ -20,7 +20,6 @@ module SwiftShims {
|
||||
header "System.h"
|
||||
header "Target.h"
|
||||
header "ThreadLocalStorage.h"
|
||||
header "UnicodeData.h"
|
||||
header "Visibility.h"
|
||||
export *
|
||||
}
|
||||
|
||||
@@ -191,3 +191,109 @@ extension Unicode {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Utilities
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getMphIdx(
|
||||
_ scalar: UInt32,
|
||||
_ levels: Int,
|
||||
_ keys: UnsafePointer<UInt64>,
|
||||
_ ranks: UnsafePointer<UInt16>,
|
||||
_ sizes: UnsafePointer<UInt16>
|
||||
) -> Int
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getScalarBitArrayIdx(
|
||||
_ scalar: UInt32,
|
||||
_ bitArrays: UnsafePointer<UInt64>,
|
||||
_ ranks: UnsafePointer<UInt16>
|
||||
) -> Int
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Normalization
|
||||
//===----------------------------------------------------------------------===//
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getNormData(_ scalar: UInt32) -> UInt16
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getDecompositionEntry(_ scalar: UInt32) -> UInt32
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getComposition(_ x: UInt32, _ y: UInt32) -> UInt32
|
||||
|
||||
@_extern(c)
|
||||
var _swift_stdlib_nfd_decompositions: UnsafePointer<UInt8>?
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Grapheme Breaking
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getGraphemeBreakProperty(_ scalar: UInt32) -> UInt8
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_isInCB_Consonant(_ scalar: UInt32) -> Bool
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Word Breaking
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getWordBreakProperty(_ scalar: UInt32) -> UInt8
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Unicode.Scalar.Properties
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getBinaryProperties(_ scalar: UInt32) -> UInt64
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getNumericType(_ scalar: UInt32) -> UInt8
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getNumericValue(_ scalar: UInt32) -> Double
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getNameAlias(_ scalar: UInt32) -> UnsafePointer<UInt8>?
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getMapping(_ scalar: UInt32, _ mapping: UInt8) -> Int32
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getSpecialMapping(
|
||||
_ scalar: UInt32,
|
||||
_ mapping: UInt8,
|
||||
_ length: UnsafeMutablePointer<Int>
|
||||
) -> UnsafePointer<UInt8>?
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getScalarName(
|
||||
_ scalar: UInt32,
|
||||
_ buffer: UnsafeMutablePointer<UInt8>?,
|
||||
_ capacity: Int
|
||||
) -> Int
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getAge(_ scalar: UInt32) -> UInt16
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getGeneralCategory(_ scalar: UInt32) -> UInt8
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getScript(_ scalar: UInt32) -> UInt8
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getScriptExtensions(
|
||||
_ scalar: UInt32,
|
||||
_ count: UnsafeMutablePointer<UInt8>
|
||||
) -> UnsafeMutablePointer<UInt8>?
|
||||
|
||||
@_extern(c)
|
||||
func _swift_stdlib_getCaseMapping(
|
||||
_ scalar: UInt32,
|
||||
_ buffer: UnsafeMutablePointer<UInt32>
|
||||
)
|
||||
|
||||
@@ -1250,7 +1250,7 @@ extension Unicode.Scalar.Properties {
|
||||
}
|
||||
|
||||
// The longest name that Unicode defines is 88 characters long.
|
||||
let largestCount = Int(SWIFT_STDLIB_LARGEST_NAME_COUNT)
|
||||
let largestCount = 88
|
||||
|
||||
let name = unsafe String(_uninitializedCapacity: largestCount) { buffer in
|
||||
unsafe _swift_stdlib_getScalarName(
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "swift/shims/UnicodeData.h"
|
||||
#include "UnicodeData.h"
|
||||
#include <stdint.h>
|
||||
|
||||
// Every 4 byte chunks of data that we need to hash (in this case only ever
|
||||
|
||||
44
stdlib/public/stubs/Unicode/UnicodeData.h
Normal file
44
stdlib/public/stubs/Unicode/UnicodeData.h
Normal file
@@ -0,0 +1,44 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2021 Apple Inc. and the Swift project authors
|
||||
// Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
//
|
||||
// See https://swift.org/LICENSE.txt for license information
|
||||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef SWIFT_STDLIB_UNICODEDATA_H
|
||||
#define SWIFT_STDLIB_UNICODEDATA_H
|
||||
|
||||
#include "swift/shims/SwiftStdbool.h"
|
||||
#include "swift/shims/SwiftStdint.h"
|
||||
#include "swift/shims/Visibility.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Utilities
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
__swift_intptr_t _swift_stdlib_getMphIdx(__swift_uint32_t scalar,
|
||||
__swift_intptr_t levels,
|
||||
const __swift_uint64_t * const *keys,
|
||||
const __swift_uint16_t * const *ranks,
|
||||
const __swift_uint16_t * const sizes);
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
__swift_intptr_t _swift_stdlib_getScalarBitArrayIdx(__swift_uint32_t scalar,
|
||||
const __swift_uint64_t *bitArrays,
|
||||
const __swift_uint16_t *ranks);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // SWIFT_STDLIB_SHIMS_UNICODEDATA_H
|
||||
@@ -15,7 +15,7 @@
|
||||
#else
|
||||
#include "swift/Runtime/Debug.h"
|
||||
#endif
|
||||
#include "swift/shims/UnicodeData.h"
|
||||
#include "UnicodeData.h"
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "swift/Runtime/Debug.h"
|
||||
#endif
|
||||
|
||||
#include "swift/shims/UnicodeData.h"
|
||||
#include "UnicodeData.h"
|
||||
#include <stdint.h>
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "swift/Runtime/Debug.h"
|
||||
#endif
|
||||
|
||||
#include "swift/shims/UnicodeData.h"
|
||||
#include "UnicodeData.h"
|
||||
#include <stdint.h>
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#else
|
||||
#include "swift/Runtime/Debug.h"
|
||||
#endif
|
||||
#include "swift/shims/UnicodeData.h"
|
||||
#include "swift/shims/Visibility.h"
|
||||
#include <stdint.h>
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERNAL
|
||||
|
||||
@@ -245,10 +245,7 @@ func emitLargestNameCount(_ names: [(UInt32, String)], into result: inout String
|
||||
}
|
||||
|
||||
print("""
|
||||
Please copy and paste the following into 'stdlib/public/SwiftShims/swift/shims/UnicodeData.h':
|
||||
|
||||
#define SWIFT_STDLIB_LARGEST_NAME_COUNT \(largestCount)
|
||||
|
||||
Please update the longest name count in 'stdlib/public/core/UnicodeScalarProperties.swift' to \(largestCount)
|
||||
""")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user