1616#include "swift/Basic/Compiler.h"
1717#include "swift/Basic/Nullability.h"
1818
19- // NOTE: DO NOT #include any stdlib headers here. e.g. <stdint.h>. Those are
20- // part of "Darwin"/"Glibc" module, so when a Swift file imports this header,
21- // it causes importing the "Darwin"/"Glibc" overlay module. That violates
22- // layering. i.e. Darwin overlay is created by Swift compiler.
23-
24- // NOTE: Partially ported from SwiftShim's SwiftStdint.h. We cannot include
25- // that header here because it belongs to the runtime, but we need the same
26- // logic for interoperability with Swift code in the compiler itself.
27- // stdint.h is provided by Clang, but it dispatches to libc's stdint.h. As a
28- // result, using stdint.h here would pull in Darwin module (which includes
29- // libc). This creates a dependency cycle, so we can't use stdint.h in
30- // SwiftShims.
31- // On Linux, the story is different. We get the error message
32- // "/usr/include/x86_64-linux-gnu/sys/types.h:146:10: error: 'stddef.h' file not
33- // found"
34- // This is a known Clang/Ubuntu bug.
35-
36- // Clang has been defining __INTxx_TYPE__ macros for a long time.
37- // __UINTxx_TYPE__ are defined only since Clang 3.5.
38- #if defined(_MSC_VER ) && !defined(__clang__ )
39- typedef __int64 __swiftc_int64_t ;
40- typedef unsigned __int64 __swiftc_uint64_t ;
41- typedef int __swiftc_int32_t ;
42- typedef unsigned int __swiftc_uint32_t ;
43- #elif !defined(__APPLE__ ) && !defined(__linux__ ) && !defined(__OpenBSD__ ) && !defined(__wasi__ )
19+ #include <stddef.h>
4420#include <stdint.h>
45- typedef int64_t __swiftc_int64_t ;
46- typedef uint64_t __swiftc_uint64_t ;
47- typedef int32_t __swiftc_int32_t ;
48- typedef uint32_t __swiftc_uint32_t ;
49- typedef intptr_t __swiftc_intptr_t ;
50- typedef uintptr_t __swiftc_uintptr_t ;
51- #else
52- typedef __INT64_TYPE__ __swiftc_int64_t ;
53- #ifdef __UINT64_TYPE__
54- typedef __UINT64_TYPE__ __swiftc_uint64_t ;
55- #else
56- typedef unsigned __INT64_TYPE__ __swiftc_uint64_t ;
57- #endif
58-
59- typedef __INT32_TYPE__ __swiftc_int32_t ;
60- #ifdef __UINT32_TYPE__
61- typedef __UINT32_TYPE__ __swiftc_uint32_t ;
62- #else
63- typedef unsigned __INT32_TYPE__ __swiftc_uint32_t ;
64- #endif
65- #endif
66-
67- #define __swiftc_join3 (a ,b ,c ) a ## b ## c
68-
69- #define __swiftc_intn_t (n ) __swiftc_join3(__swiftc_int, n, _t)
70- #define __swiftc_uintn_t (n ) __swiftc_join3(__swiftc_uint, n, _t)
71-
72- #if defined(_MSC_VER ) && !defined(__clang__ )
73- #if defined(_WIN64 )
74- typedef __swiftc_int64_t SwiftInt ;
75- typedef __swiftc_uint64_t SwiftUInt ;
76- #elif defined(_WIN32 )
77- typedef __swiftc_int32_t SwiftInt ;
78- typedef __swiftc_uint32_t SwiftUInt ;
79- #else
80- #error unknown windows pointer width
81- #endif
82- #else
83- typedef __swiftc_intn_t (__INTPTR_WIDTH__ ) SwiftInt ;
84- typedef __swiftc_uintn_t (__INTPTR_WIDTH__ ) SwiftUInt ;
85- #endif
8621
8722SWIFT_BEGIN_NULLABILITY_ANNOTATIONS
8823
@@ -103,7 +38,7 @@ SWIFT_BEGIN_ASSUME_NONNULL
10338
10439typedef struct BridgedData {
10540 const char * _Nullable baseAddress ;
106- SwiftUInt size ;
41+ size_t size ;
10742} BridgedData ;
10843
10944void BridgedData_free (BridgedData data );
@@ -132,31 +67,31 @@ _Bool JSON_value_getAsNull(void *valuePtr);
13267_Bool JSON_value_getAsBoolean (void * valuePtr , _Bool * result );
13368_Bool JSON_value_getAsString (void * valuePtr , BridgedData * result );
13469_Bool JSON_value_getAsDouble (void * valuePtr , double * result );
135- _Bool JSON_value_getAsInteger (void * valuePtr , long long * result );
70+ _Bool JSON_value_getAsInteger (void * valuePtr , int64_t * result );
13671_Bool JSON_value_getAsObject (void * valuePtr , void * _Nullable * _Nonnull result );
13772_Bool JSON_value_getAsArray (void * valuePtr , void * _Nullable * _Nonnull result );
13873
139- unsigned long JSON_object_getSize (void * objectPtr );
140- BridgedData JSON_object_getKey (void * objectPtr , unsigned long i );
74+ size_t JSON_object_getSize (void * objectPtr );
75+ BridgedData JSON_object_getKey (void * objectPtr , size_t i );
14176_Bool JSON_object_hasKey (void * objectPtr , const char * key );
14277void * JSON_object_getValue (void * objectPtr , const char * key );
14378
144- long long JSON_array_getSize (void * arrayPtr );
145- void * JSON_array_getValue (void * arrayPtr , long long index );
79+ size_t JSON_array_getSize (void * arrayPtr );
80+ void * JSON_array_getValue (void * arrayPtr , size_t index );
14681
14782void JSON_value_emplaceNull (void * valuePtr );
14883void JSON_value_emplaceBoolean (void * valuePtr , _Bool value );
14984void JSON_value_emplaceString (void * valuePtr , const char * value );
15085void JSON_value_emplaceDouble (void * valuePtr , double value );
151- void JSON_value_emplaceInteger (void * valuePtr , long long value );
86+ void JSON_value_emplaceInteger (void * valuePtr , int64_t value );
15287void * JSON_value_emplaceNewObject (void * valuePtr );
15388void * JSON_value_emplaceNewArray (void * valuePtr );
15489
15590void JSON_object_setNull (void * objectPtr , const char * key );
15691void JSON_object_setBoolean (void * objectPtr , const char * key , _Bool value );
15792void JSON_object_setString (void * objectPtr , const char * key , const char * value );
15893void JSON_object_setDouble (void * objectPtr , const char * key , double value );
159- void JSON_object_setInteger (void * objectPtr , const char * key , long long value );
94+ void JSON_object_setInteger (void * objectPtr , const char * key , int64_t value );
16095void * JSON_object_setNewObject (void * objectPtr , const char * key );
16196void * JSON_object_setNewArray (void * objectPtr , const char * key );
16297void * JSON_object_setNewValue (void * objectPtr , const char * key );
@@ -165,7 +100,7 @@ void JSON_array_pushNull(void *arrayPtr);
165100void JSON_array_pushBoolean (void * arrayPtr , _Bool value );
166101void JSON_array_pushString (void * arrayPtr , const char * value );
167102void JSON_array_pushDouble (void * arrayPtr , double value );
168- void JSON_array_pushInteger (void * arrayPtr , long long value );
103+ void JSON_array_pushInteger (void * arrayPtr , int64_t value );
169104void * JSON_array_pushNewObject (void * arrayPtr );
170105void * JSON_array_pushNewArray (void * arrayPtr );
171106void * JSON_array_pushNewValue (void * arrayPtr );
0 commit comments