Skip to content

Commit f3f3a73

Browse files
authored
Merge pull request swiftlang#4629 from etcwilde/ewilde/cpp-interop-foundation-import
Add definition for _Bool in C++ mode
2 parents 7504fdf + 9277186 commit f3f3a73

File tree

6 files changed

+17
-16
lines changed

6 files changed

+17
-16
lines changed

CoreFoundation/Base.subproj/CFBase.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@
6666

6767
#if defined(__GNUC__) || TARGET_OS_WIN32
6868
#include <stdint.h>
69-
#include <stdbool.h>
7069
#endif
7170

71+
#include <stdbool.h>
72+
7273
#if __BLOCKS__ && (TARGET_OS_OSX || TARGET_OS_IPHONE)
7374
#include <Block.h>
7475
#endif
@@ -80,7 +81,7 @@
8081
#if !defined(__MACTYPES__)
8182
#if !defined(_OS_OSTYPES_H)
8283
#if DEPLOYMENT_RUNTIME_SWIFT
83-
typedef _Bool Boolean;
84+
typedef bool Boolean;
8485
#else
8586
typedef unsigned char Boolean;
8687
#endif

CoreFoundation/Base.subproj/CFOverflow.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#if __has_include(<os/overflow.h>)
1616
#include <os/overflow.h>
1717
#else
18-
static _Bool __os_warn_unused(_Bool x) __attribute__((__warn_unused_result__));
19-
static _Bool __os_warn_unused(_Bool x) { return x; }
18+
static bool __os_warn_unused(bool x) __attribute__((__warn_unused_result__));
19+
static bool __os_warn_unused(bool x) { return x; }
2020

2121
#if __has_builtin(__builtin_add_overflow) && \
2222
__has_builtin(__builtin_sub_overflow) && \

CoreFoundation/Base.subproj/ForFoundationOnly.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ typedef CF_ENUM(CFOptionFlags, _CFAllocatorHint) {
8484
#define NSISARGTYPE id _Nullable
8585
#else
8686
#define NSISARGTYPE void * _Nullable
87-
#define BOOL _Bool
87+
#define BOOL bool
8888
#endif
8989

9090
CF_EXPORT BOOL _NSIsNSArray(NSISARGTYPE arg);

CoreFoundation/Base.subproj/ForSwiftFoundationOnly.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,10 @@ CF_CROSS_PLATFORM_EXPORT void __CFURLComponentsDeallocate(CFTypeRef cf);
482482
typedef struct {
483483
void *_Nonnull memory;
484484
size_t capacity;
485-
_Bool onStack;
485+
bool onStack;
486486
} _ConditionalAllocationBuffer;
487487

488-
static inline _Bool _resizeConditionalAllocationBuffer(_ConditionalAllocationBuffer *_Nonnull buffer, size_t amt) {
488+
static inline bool _resizeConditionalAllocationBuffer(_ConditionalAllocationBuffer *_Nonnull buffer, size_t amt) {
489489
#if TARGET_OS_MAC
490490
size_t amount = malloc_good_size(amt);
491491
#else
@@ -509,7 +509,7 @@ static inline _Bool _resizeConditionalAllocationBuffer(_ConditionalAllocationBuf
509509
}
510510

511511
#if TARGET_OS_WASI
512-
static inline _Bool _withStackOrHeapBuffer(size_t amount, void (__attribute__((noescape)) ^ _Nonnull applier)(_ConditionalAllocationBuffer *_Nonnull)) {
512+
static inline bool _withStackOrHeapBuffer(size_t amount, void (__attribute__((noescape)) ^ _Nonnull applier)(_ConditionalAllocationBuffer *_Nonnull)) {
513513
_ConditionalAllocationBuffer buffer;
514514
buffer.capacity = amount;
515515
buffer.onStack = false;
@@ -520,7 +520,7 @@ static inline _Bool _withStackOrHeapBuffer(size_t amount, void (__attribute__((n
520520
return true;
521521
}
522522
#else
523-
static inline _Bool _withStackOrHeapBuffer(size_t amount, void (__attribute__((noescape)) ^ _Nonnull applier)(_ConditionalAllocationBuffer *_Nonnull)) {
523+
static inline bool _withStackOrHeapBuffer(size_t amount, void (__attribute__((noescape)) ^ _Nonnull applier)(_ConditionalAllocationBuffer *_Nonnull)) {
524524
_ConditionalAllocationBuffer buffer;
525525
#if TARGET_OS_MAC
526526
buffer.capacity = malloc_good_size(amount);
@@ -538,7 +538,7 @@ static inline _Bool _withStackOrHeapBuffer(size_t amount, void (__attribute__((n
538538
}
539539
#endif
540540

541-
static inline _Bool _withStackOrHeapBufferWithResultInArguments(size_t amount, void (__attribute__((noescape)) ^ _Nonnull applier)(void *_Nonnull memory, size_t capacity, _Bool onStack)) {
541+
static inline bool _withStackOrHeapBufferWithResultInArguments(size_t amount, void (__attribute__((noescape)) ^ _Nonnull applier)(void *_Nonnull memory, size_t capacity, bool onStack)) {
542542
return _withStackOrHeapBuffer(amount, ^(_ConditionalAllocationBuffer *buffer) {
543543
applier(buffer->memory, buffer->capacity, buffer->onStack);
544544
});
@@ -645,13 +645,13 @@ _stat_with_btime(const char *filename, struct stat *buffer, struct timespec *bti
645645

646646
static unsigned int const _CF_renameat2_RENAME_EXCHANGE = 1 << 1;
647647
#ifdef SYS_renameat2
648-
static _Bool const _CFHasRenameat2 = 1;
648+
static bool const _CFHasRenameat2 = 1;
649649
static inline int _CF_renameat2(int olddirfd, const char *_Nonnull oldpath,
650650
int newdirfd, const char *_Nonnull newpath, unsigned int flags) {
651651
return syscall(SYS_renameat2, olddirfd, oldpath, newdirfd, newpath, flags);
652652
}
653653
#else
654-
static _Bool const _CFHasRenameat2 = 0;
654+
static bool const _CFHasRenameat2 = 0;
655655
static inline int _CF_renameat2(int olddirfd, const char *_Nonnull oldpath,
656656
int newdirfd, const char *_Nonnull newpath, unsigned int flags) {
657657
return ENOSYS;

CoreFoundation/PlugIn.subproj/CFBundle_Grok.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
// Windows isspace implementation limits the input chars to < 256 in the ASCII range. It will
4848
// assert in debug builds. This is annoying. We merrily grok chars > 256.
49-
static inline _Bool _CF_isspace(int c) {
49+
static inline bool _CF_isspace(int c) {
5050
return (c == ' ' || c == '\t' || c == '\n' || c == '\r'|| c == '\v' || c == '\f');
5151
}
5252
#define isspace _CF_isspace

Darwin/shims/FoundationOverlayShims.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@
3737
typedef struct {
3838
void *_Nonnull memory;
3939
size_t capacity;
40-
_Bool onStack;
40+
bool onStack;
4141
} _ConditionalAllocationBuffer;
4242

43-
static inline _Bool _resizeConditionalAllocationBuffer(_ConditionalAllocationBuffer *_Nonnull buffer, size_t amt) {
43+
static inline bool _resizeConditionalAllocationBuffer(_ConditionalAllocationBuffer *_Nonnull buffer, size_t amt) {
4444
size_t amount = malloc_good_size(amt);
4545
if (amount <= buffer->capacity) { return true; }
4646
void *newMemory;
@@ -59,7 +59,7 @@ static inline _Bool _resizeConditionalAllocationBuffer(_ConditionalAllocationBuf
5959
return true;
6060
}
6161

62-
static inline _Bool _withStackOrHeapBuffer(size_t amount, void (__attribute__((noescape)) ^ _Nonnull applier)(_ConditionalAllocationBuffer *_Nonnull)) {
62+
static inline bool _withStackOrHeapBuffer(size_t amount, void (__attribute__((noescape)) ^ _Nonnull applier)(_ConditionalAllocationBuffer *_Nonnull)) {
6363
_ConditionalAllocationBuffer buffer;
6464
buffer.capacity = malloc_good_size(amount);
6565
buffer.onStack = (pthread_main_np() != 0 ? buffer.capacity < 2048 : buffer.capacity < 512);

0 commit comments

Comments
 (0)