Skip to content

Commit 9a5ea12

Browse files
authored
Merge pull request #4973 from jckarter/nsnumber-bridging-3.0
[3.0] SE-0139: Bridge all standard number types to NSNumber.
2 parents 487c5da + 1570ad1 commit 9a5ea12

File tree

14 files changed

+613
-826
lines changed

14 files changed

+613
-826
lines changed

include/swift/AST/ASTContext.h

Lines changed: 5 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -367,48 +367,14 @@ class ASTContext {
367367
ProtocolDecl *getErrorDecl() const;
368368
CanType getExceptionType() const;
369369

370-
/// Retrieve the declaration of Swift.Bool.
371-
NominalTypeDecl *getBoolDecl() const;
372-
373-
/// Retrieve the declaration of Swift.Int.
374-
NominalTypeDecl *getIntDecl() const;
375-
376-
/// Retrieve the declaration of Swift.UInt.
377-
NominalTypeDecl *getUIntDecl() const;
378-
379-
/// Retrieve the declaration of Swift.Float.
380-
NominalTypeDecl *getFloatDecl() const;
381-
382-
/// Retrieve the declaration of Swift.Double.
383-
NominalTypeDecl *getDoubleDecl() const;
384-
385-
/// Retrieve the declaration of Swift.String.
386-
NominalTypeDecl *getStringDecl() const;
387-
388-
/// Retrieve the declaration of Swift.Array<T>.
389-
NominalTypeDecl *getArrayDecl() const;
390-
391-
/// Retrieve the declaration of Swift.Set<T>.
392-
NominalTypeDecl *getSetDecl() const;
393-
394-
/// Retrieve the declaration of Swift.Sequence<T>.
395-
NominalTypeDecl *getSequenceDecl() const;
396-
397-
/// Retrieve the declaration of Swift.Dictionary<K, V>.
398-
NominalTypeDecl *getDictionaryDecl() const;
399-
400-
/// Retrieve the declaration of Swift.AnyHashable.
401-
NominalTypeDecl *getAnyHashableDecl() const;
370+
#define KNOWN_STDLIB_TYPE_DECL(NAME, DECL_CLASS, NUM_GENERIC_PARAMS) \
371+
/** Retrieve the declaration of Swift.NAME. */ \
372+
DECL_CLASS *get##NAME##Decl() const;
373+
#include "swift/AST/KnownStdlibTypes.def"
402374

403375
/// Retrieve the declaration of Swift.Optional or ImplicitlyUnwrappedOptional.
404376
EnumDecl *getOptionalDecl(OptionalTypeKind kind) const;
405377

406-
/// Retrieve the declaration of Swift.Optional<T>.
407-
EnumDecl *getOptionalDecl() const;
408-
409-
/// Retrieve the declaration of Swift.ImplicitlyUnwrappedOptional<T>.
410-
EnumDecl *getImplicitlyUnwrappedOptionalDecl() const;
411-
412378
/// Retrieve the declaration of Swift.Optional<T>.Some.
413379
EnumElementDecl *getOptionalSomeDecl() const;
414380

@@ -424,35 +390,10 @@ class ASTContext {
424390
EnumElementDecl *getOptionalSomeDecl(OptionalTypeKind kind) const;
425391
EnumElementDecl *getOptionalNoneDecl(OptionalTypeKind kind) const;
426392

427-
/// Retrieve the declaration of Swift.OptionSet.
428-
NominalTypeDecl *getOptionSetDecl() const;
429-
430-
/// Retrieve the declaration of Swift.COpaquePointer.
431-
NominalTypeDecl *getOpaquePointerDecl() const;
432-
433-
/// Retrieve the declaration of Swift.UnsafeMutableRawPointer.
434-
NominalTypeDecl *getUnsafeMutableRawPointerDecl() const;
435-
436-
/// Retrieve the declaration of Swift.UnsafeRawPointer.
437-
NominalTypeDecl *getUnsafeRawPointerDecl() const;
438-
439-
/// Retrieve the declaration of Swift.UnsafeMutablePointer<T>.
440-
NominalTypeDecl *getUnsafeMutablePointerDecl() const;
441-
442-
/// Retrieve the declaration of Swift.UnsafePointer<T>.
443-
NominalTypeDecl *getUnsafePointerDecl() const;
444-
445-
/// Retrieve the declaration of Swift.AutoreleasingUnsafeMutablePointer<T>.
446-
NominalTypeDecl *getAutoreleasingUnsafeMutablePointerDecl() const;
447-
448-
/// Retrieve the declaration of Swift.Unmanaged<T>.
449-
NominalTypeDecl *getUnmanagedDecl() const;
450-
451393
/// Retrieve the declaration of the "pointee" property of a pointer type.
452394
VarDecl *getPointerPointeePropertyDecl(PointerTypeKind ptrKind) const;
453395

454-
/// Retrieve the declaration of Swift.Never.
455-
NominalTypeDecl *getNeverDecl() const;
396+
/// Retrieve the type Swift.Never.
456397
CanType getNeverType() const;
457398

458399
/// Retrieve the declaration of Swift.Void.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
//===--- KnownStdlibTypes.cpp - Common standard library types -------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This xmacro generates code for common standard library types the compiler
14+
// has special knowledge of.
15+
//
16+
//===----------------------------------------------------------------------===//
17+
18+
#ifndef KNOWN_STDLIB_TYPE_DECL
19+
/// KNOWN_STDLIB_TYPE_DECL(NAME, DECL_CLASS, NUM_GENERIC_PARAMS)
20+
///
21+
/// The macro is expanded for each known standard library type. NAME is
22+
/// bound to the unqualified name of the type. DECL_CLASS is bound to the
23+
/// Decl subclass it is expected to be an instance of. NUM_GENERIC_PARAMS is
24+
/// bound to the number of generic parameters the type is expected to have.
25+
#define KNOWN_STDLIB_TYPE_DECL(NAME, DECL_CLASS, NUM_GENERIC_PARAMS)
26+
#endif
27+
28+
KNOWN_STDLIB_TYPE_DECL(Bool, NominalTypeDecl, 0)
29+
30+
KNOWN_STDLIB_TYPE_DECL(Int, NominalTypeDecl, 0)
31+
KNOWN_STDLIB_TYPE_DECL(Int64, NominalTypeDecl, 0)
32+
KNOWN_STDLIB_TYPE_DECL(Int32, NominalTypeDecl, 0)
33+
KNOWN_STDLIB_TYPE_DECL(Int16, NominalTypeDecl, 0)
34+
KNOWN_STDLIB_TYPE_DECL(Int8, NominalTypeDecl, 0)
35+
36+
KNOWN_STDLIB_TYPE_DECL(UInt, NominalTypeDecl, 0)
37+
KNOWN_STDLIB_TYPE_DECL(UInt64, NominalTypeDecl, 0)
38+
KNOWN_STDLIB_TYPE_DECL(UInt32, NominalTypeDecl, 0)
39+
KNOWN_STDLIB_TYPE_DECL(UInt16, NominalTypeDecl, 0)
40+
KNOWN_STDLIB_TYPE_DECL(UInt8, NominalTypeDecl, 0)
41+
42+
KNOWN_STDLIB_TYPE_DECL(Float, NominalTypeDecl, 0)
43+
KNOWN_STDLIB_TYPE_DECL(Double, NominalTypeDecl, 0)
44+
45+
KNOWN_STDLIB_TYPE_DECL(String, NominalTypeDecl, 0)
46+
KNOWN_STDLIB_TYPE_DECL(Array, NominalTypeDecl, 1)
47+
KNOWN_STDLIB_TYPE_DECL(Set, NominalTypeDecl, 1)
48+
KNOWN_STDLIB_TYPE_DECL(Sequence, NominalTypeDecl, 1)
49+
KNOWN_STDLIB_TYPE_DECL(Dictionary, NominalTypeDecl, 2)
50+
KNOWN_STDLIB_TYPE_DECL(AnyHashable, NominalTypeDecl, 0)
51+
52+
KNOWN_STDLIB_TYPE_DECL(Optional, EnumDecl, 1)
53+
KNOWN_STDLIB_TYPE_DECL(ImplicitlyUnwrappedOptional, EnumDecl, 1)
54+
55+
KNOWN_STDLIB_TYPE_DECL(OptionSet, NominalTypeDecl, 1)
56+
57+
KNOWN_STDLIB_TYPE_DECL(UnsafeMutableRawPointer, NominalTypeDecl, 0)
58+
KNOWN_STDLIB_TYPE_DECL(UnsafeRawPointer, NominalTypeDecl, 0)
59+
KNOWN_STDLIB_TYPE_DECL(UnsafeMutablePointer, NominalTypeDecl, 1)
60+
KNOWN_STDLIB_TYPE_DECL(UnsafePointer, NominalTypeDecl, 1)
61+
KNOWN_STDLIB_TYPE_DECL(OpaquePointer, NominalTypeDecl, 0)
62+
KNOWN_STDLIB_TYPE_DECL(AutoreleasingUnsafeMutablePointer, NominalTypeDecl, 1)
63+
64+
KNOWN_STDLIB_TYPE_DECL(Unmanaged, NominalTypeDecl, 1)
65+
66+
KNOWN_STDLIB_TYPE_DECL(Never, NominalTypeDecl, 0)
67+
68+
#undef KNOWN_STDLIB_TYPE_DECL

0 commit comments

Comments
 (0)