1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
//===--- MappedTypes.def - Automatically Mapped Type Database ---*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// This file defines the database of C types that are imported as swift stdlib
// types.
//
// MAP_TYPE(C_TYPE_NAME, C_TYPE_KIND, C_TYPE_BITWIDTH,
// SWIFT_MODULE_NAME, SWIFT_TYPE_NAME,
// CAN_BE_MISSING, C_NAME_MAPPING)
// - C_TYPE_NAME is the name of the C type.
// - C_TYPE_KIND is the expected kind of the C type (see MappedCTypeKind
// enum).
// - C_TYPE_BITWIDTH is the expected size of the C type; a zero value
// means "don't check".
// - SWIFT_MODULE_NAME is the name of the swift library module.
// - SWIFT_TYPE_NAME is the name of the corresponding stdlib type.
// - CAN_BE_MISSING is true if it is OK for swift type to be missing in the
// stdlib.
// - C_NAME_MAPPING specifies if we should create a typealias in the
// imported Clang module (see MappedTypeNameKind enum).
//
//===----------------------------------------------------------------------===//
#define MAP_STDLIB_TYPE(C_TYPE_NAME, C_TYPE_KIND, C_TYPE_BITWIDTH, \
SWIFT_TYPE_NAME, CAN_BE_MISSING, \
C_NAME_MAPPING) \
MAP_TYPE(C_TYPE_NAME, C_TYPE_KIND, C_TYPE_BITWIDTH, \
"Swift", SWIFT_TYPE_NAME, CAN_BE_MISSING, \
C_NAME_MAPPING)
// MacTypes.h defines typedefs UIntXX, SIntXX, FloatXX.
MAP_STDLIB_TYPE("UInt8", UnsignedInt, 8, "UInt8", false, DoNothing)
MAP_STDLIB_TYPE("UInt16", UnsignedInt, 16, "UInt16", false, DoNothing)
MAP_STDLIB_TYPE("UInt32", UnsignedInt, 32, "UInt32", false, DoNothing)
MAP_STDLIB_TYPE("UInt64", UnsignedInt, 64, "UInt64", false, DoNothing)
MAP_STDLIB_TYPE("SInt8", SignedInt, 8, "Int8", false, DoNothing)
MAP_STDLIB_TYPE("SInt16", SignedInt, 16, "Int16", false, DoNothing)
MAP_STDLIB_TYPE("SInt32", SignedInt, 32, "Int32", false, DoNothing)
MAP_STDLIB_TYPE("SInt64", SignedInt, 64, "Int64", false, DoNothing)
MAP_STDLIB_TYPE("Float32", FloatIEEEsingle, 32, "Float32", false,
DoNothing)
MAP_STDLIB_TYPE("Float64", FloatIEEEdouble, 64, "Float64", false,
DoNothing)
MAP_STDLIB_TYPE("Float80", FloatX87DoubleExtended, 80, "Float80", true,
DoNothing)
MAP_STDLIB_TYPE("Byte", UnsignedInt, 8, "UInt8", false, DoNothing)
MAP_STDLIB_TYPE("SignedByte", SignedInt, 8, "Int8", false, DoNothing)
MAP_STDLIB_TYPE("ItemCount", UnsignedWord, 0, "Int", false, DoNothing)
MAP_STDLIB_TYPE("ByteCount", UnsignedWord, 0, "Int", false, DoNothing)
MAP_STDLIB_TYPE("UniCharCount", UnsignedWord, 0, "Int", false, DoNothing)
MAP_TYPE("Boolean", UnsignedInt, 8, "Darwin", "DarwinBoolean", true,
DoNothing)
// stdint.h types.
MAP_STDLIB_TYPE("uint8_t", UnsignedInt, 8, "UInt8", false, DoNothing)
MAP_STDLIB_TYPE("uint16_t", UnsignedInt, 16, "UInt16", false, DoNothing)
MAP_STDLIB_TYPE("uint32_t", UnsignedInt, 32, "UInt32", false, DoNothing)
MAP_STDLIB_TYPE("uint64_t", UnsignedInt, 64, "UInt64", false, DoNothing)
MAP_STDLIB_TYPE("int8_t", SignedInt, 8, "Int8", false, DoNothing)
MAP_STDLIB_TYPE("int16_t", SignedInt, 16, "Int16", false, DoNothing)
MAP_STDLIB_TYPE("int32_t", SignedInt, 32, "Int32", false, DoNothing)
MAP_STDLIB_TYPE("int64_t", SignedInt, 64, "Int64", false, DoNothing)
MAP_STDLIB_TYPE("intptr_t", SignedWord, 0, "Int", false, DefineOnly)
MAP_STDLIB_TYPE("uintptr_t", UnsignedWord, 0, "UInt", false, DefineOnly)
// SwiftStdint.h defines its own copy of stdint.h types.
MAP_STDLIB_TYPE("__swift_uint8_t", UnsignedInt, 8, "UInt8", false,
DoNothing)
MAP_STDLIB_TYPE("__swift_uint16_t", UnsignedInt, 16, "UInt16", false,
DoNothing)
MAP_STDLIB_TYPE("__swift_uint32_t", UnsignedInt, 32, "UInt32", false,
DoNothing)
MAP_STDLIB_TYPE("__swift_uint64_t", UnsignedInt, 64, "UInt64", false,
DoNothing)
MAP_STDLIB_TYPE("__swift_int8_t", SignedInt, 8, "Int8", false, DoNothing)
MAP_STDLIB_TYPE("__swift_int16_t", SignedInt, 16, "Int16", false,
DoNothing)
MAP_STDLIB_TYPE("__swift_int32_t", SignedInt, 32, "Int32", false,
DoNothing)
MAP_STDLIB_TYPE("__swift_int64_t", SignedInt, 64, "Int64", false,
DoNothing)
MAP_STDLIB_TYPE("__swift_intptr_t", SignedWord, 0, "Int", false,
DefineOnly)
MAP_STDLIB_TYPE("__swift_uintptr_t", UnsignedWord, 0, "UInt", false,
DefineOnly)
// stddef.h types.
MAP_STDLIB_TYPE("ptrdiff_t", SignedWord, 0, "Int", false, DefineOnly)
MAP_STDLIB_TYPE("size_t", UnsignedWord, 0, "Int", false, DefineOnly)
MAP_STDLIB_TYPE("rsize_t", UnsignedWord, 0, "Int", false, DefineOnly)
// SwiftStddef.h defines its own copy of stddef.h types.
MAP_STDLIB_TYPE("__swift_ptrdiff_t", SignedWord, 0, "Int", false,
DefineOnly)
MAP_STDLIB_TYPE("__swift_size_t", UnsignedWord, 0, "Int", false,
DefineOnly)
MAP_STDLIB_TYPE("__swift_ssize_t", SignedWord, 0, "Int", false,
DefineOnly)
// POSIX sys/types.h.
MAP_STDLIB_TYPE("ssize_t", SignedWord, 0, "Int", false, DefineOnly)
MAP_STDLIB_TYPE("u_int8_t", UnsignedInt, 8, "UInt8", false, DoNothing)
MAP_STDLIB_TYPE("u_int16_t", UnsignedInt, 16, "UInt16", false, DoNothing)
MAP_STDLIB_TYPE("u_int32_t", UnsignedInt, 32, "UInt32", false, DoNothing)
MAP_STDLIB_TYPE("u_int64_t", UnsignedInt, 64, "UInt64", false, DoNothing)
// stdarg.h types.
// Note: this does not catch va_list on platforms where va_list is an array.
// There's an explicit workaround in ImportType.cpp's VisitDecayedType for that.
MAP_STDLIB_TYPE("va_list", VaList, 0, "CVaListPointer", false, DoNothing)
MAP_STDLIB_TYPE("__gnuc_va_list", VaList, 0, "CVaListPointer", false, DoNothing)
MAP_STDLIB_TYPE("__va_list", VaList, 0, "CVaListPointer", false, DoNothing)
// libkern/OSTypes.h types.
MAP_STDLIB_TYPE("UInt", UnsignedInt, 32, "CUnsignedInt", false, DoNothing)
MAP_STDLIB_TYPE("SInt", SignedInt, 32, "CInt", false, DoNothing)
// Dispatch types.
MAP_TYPE("dispatch_block_t", Block, 0, "Dispatch", "dispatch_block_t",
true, DoNothing)
MAP_TYPE("__swift_shims_dispatch_block_t", Block, 0, "Dispatch", "_DispatchBlock",
true, DoNothing)
MAP_TYPE("__swift_shims_dispatch_data_t", ObjCId, 0, "Dispatch", "dispatch_data_t",
true, DoNothing)
// Objective-C types.
MAP_TYPE("SEL", ObjCSel, 0, "ObjectiveC", "Selector", false, DoNothing)
MAP_STDLIB_TYPE("Class", ObjCClass, 0, "AnyClass", false, DoNothing)
MAP_STDLIB_TYPE(
swift::getSwiftName(KnownFoundationEntity::NSInteger),
SignedWord, 0, "Int", false, DefineOnly)
// Treat NSUInteger specially: exposing it as a typealias for "Int" would be
// confusing.
MAP_STDLIB_TYPE(
swift::getSwiftName(KnownFoundationEntity::NSUInteger),
UnsignedWord, 0, "Int", false, DoNothing)
// CGFloat.
MAP_TYPE("CGFloat", CGFloat, 0, "CoreGraphics", "CGFloat", false, DoNothing)
// CoreFoundation types.
// Note that we're preserving the typealias for CFIndex.
MAP_STDLIB_TYPE("CFTypeID", UnsignedWord, 0, "UInt", false, DefineAndUse)
MAP_STDLIB_TYPE("CFOptionFlags", UnsignedWord, 0, "UInt", false, DefineAndUse)
MAP_STDLIB_TYPE("CFHashCode", UnsignedWord, 0, "UInt", false, DefineAndUse)
MAP_STDLIB_TYPE("CFIndex", SignedWord, 0, "Int", false, DefineAndUse)
// Foundation types.
// FIXME: <rdar://problem/16074941> NSStringEncoding doesn't work on 32-bit
MAP_STDLIB_TYPE("NSStringEncoding", UnsignedWord, 0, "UInt", false, DoNothing)
#undef MAP_STDLIB_TYPE
#undef MAP_TYPE
|