mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This replaces a number of `#include`-s like this:
```
#include "../../../stdlib/public/SwiftShims/Visibility.h"
```
with this:
```
#include "swift/shims/Visibility.h"
```
This is needed to allow SwiftCompilerSources to use C++ headers which include SwiftShims headers. Currently trying to do that results in errors:
```
swift/swift/include/swift/Demangling/../../../stdlib/public/SwiftShims/module.modulemap:1:8: error: redefinition of module 'SwiftShims'
module SwiftShims {
^
Builds.noindex/swift/swift/bootstrapping0/lib/swift/shims/module.modulemap:1:8: note: previously defined here
module SwiftShims {
^
```
This happens because the headers in both the source dir and the build dir refer to SwiftShims headers by relative path, and both the source root and the build root contain SwiftShims headers (which are equivalent, but since they are located in different dirs, Clang treats them as different modules).
66 lines
2.1 KiB
C
66 lines
2.1 KiB
C
//===--- FoundationShims.h - Foundation declarations for core stdlib ------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2017 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// In order to prevent a circular module dependency between the core
|
|
// standard library and the Foundation overlay, we import these
|
|
// declarations as part of SwiftShims.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_STDLIB_SHIMS_FOUNDATIONSHIMS_H
|
|
#define SWIFT_STDLIB_SHIMS_FOUNDATIONSHIMS_H
|
|
|
|
//===--- Layout-compatible clones of Foundation structs -------------------===//
|
|
// Ideally we would declare the same names as Foundation does, but
|
|
// Swift's module importer is not yet tolerant of the same struct
|
|
// coming in from two different Clang modules
|
|
// (rdar://problem/16294674). Instead, we copy the definitions here
|
|
// and then do horrible unsafeBitCast trix to make them usable where required.
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "SwiftStdint.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct {
|
|
__swift_intptr_t location;
|
|
__swift_intptr_t length;
|
|
} _SwiftNSRange;
|
|
|
|
#ifdef __OBJC2__
|
|
typedef struct {
|
|
unsigned long state;
|
|
id __unsafe_unretained _Nullable * _Nullable itemsPtr;
|
|
unsigned long * _Nullable mutationsPtr;
|
|
unsigned long extra[5];
|
|
} _SwiftNSFastEnumerationState;
|
|
#endif
|
|
|
|
// This struct is layout-compatible with NSOperatingSystemVersion.
|
|
typedef struct {
|
|
__swift_intptr_t majorVersion;
|
|
__swift_intptr_t minorVersion;
|
|
__swift_intptr_t patchVersion;
|
|
} _SwiftNSOperatingSystemVersion;
|
|
|
|
SWIFT_RUNTIME_STDLIB_API
|
|
_SwiftNSOperatingSystemVersion _swift_stdlib_operatingSystemVersion() __attribute__((const));
|
|
|
|
#ifdef __cplusplus
|
|
} // extern "C"
|
|
#endif
|
|
|
|
#endif // SWIFT_STDLIB_SHIMS_FOUNDATIONSHIMS_H
|
|
|