mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge remote-tracking branch 'origin/main' into next
This commit is contained in:
@@ -43,6 +43,19 @@ void OStream_write(BridgedOStream os, BridgedStringRef str);
|
||||
|
||||
void freeBridgedStringRef(BridgedStringRef str);
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Source location
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
typedef struct {
|
||||
const unsigned char * _Nullable pointer;
|
||||
} BridgedSourceLoc;
|
||||
|
||||
typedef struct {
|
||||
BridgedSourceLoc start;
|
||||
SwiftInt byteLength;
|
||||
} BridgedCharSourceRange;
|
||||
|
||||
SWIFT_END_NULLABILITY_ANNOTATIONS
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -36,6 +36,27 @@ inline llvm::ArrayRef<T> getArrayRef(BridgedArrayRef bridged) {
|
||||
return {static_cast<const T *>(bridged.data), bridged.numElements};
|
||||
}
|
||||
|
||||
inline SourceLoc getSourceLoc(const BridgedSourceLoc &bridged) {
|
||||
return SourceLoc(
|
||||
llvm::SMLoc::getFromPointer((const char *)bridged.pointer));
|
||||
}
|
||||
|
||||
inline BridgedSourceLoc getBridgedSourceLoc(const SourceLoc &loc) {
|
||||
return {static_cast<const unsigned char *>(loc.getOpaquePointerValue())};
|
||||
}
|
||||
|
||||
inline CharSourceRange
|
||||
getCharSourceRange(const BridgedCharSourceRange &bridged) {
|
||||
auto start = getSourceLoc(bridged.start);
|
||||
return CharSourceRange(start, bridged.byteLength);
|
||||
}
|
||||
|
||||
inline BridgedCharSourceRange
|
||||
getBridgedCharSourceRange(const CharSourceRange &range) {
|
||||
auto start = getBridgedSourceLoc(range.getStart());
|
||||
return {start, range.getByteLength()};
|
||||
}
|
||||
|
||||
/// Copies the string in an malloc'ed memory and the caller is responsible for
|
||||
/// freeing it. 'freeBridgedStringRef()' is available in 'BasicBridging.h'
|
||||
inline BridgedStringRef
|
||||
|
||||
Reference in New Issue
Block a user