Skip to content

Commit 31aeb64

Browse files
committed
Make a .def file for ObjCSelectorFamily
1 parent 5f94043 commit 31aeb64

File tree

3 files changed

+34
-15
lines changed

3 files changed

+34
-15
lines changed

include/swift/AST/Identifier.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -592,19 +592,10 @@ class DeclName {
592592
"only for use within the debugger");
593593
};
594594

595-
/// Apply a macro FAMILY(Name, Prefix) to all ObjC selector families.
596-
#define FOREACH_OBJC_SELECTOR_FAMILY(FAMILY) \
597-
FAMILY(Alloc, "alloc") \
598-
FAMILY(Copy, "copy") \
599-
FAMILY(Init, "init") \
600-
FAMILY(MutableCopy, "mutableCopy") \
601-
FAMILY(New, "new")
602-
603595
enum class ObjCSelectorFamily : unsigned {
604596
None,
605-
#define GET_LABEL(LABEL, PREFIX) LABEL,
606-
FOREACH_OBJC_SELECTOR_FAMILY(GET_LABEL)
607-
#undef GET_LABEL
597+
#define OBJC_SELECTOR_FAMILY(LABEL, PREFIX) LABEL,
598+
#include "swift/AST/ObjCSelectorFamily.def"
608599
};
609600

610601
/// Represents an Objective-C selector.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//===--- ObjCSelectorFamily.def - Objective-C Selector Families - C++ ---*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This file defines macros used for macro-metaprogramming with Objective-C
14+
// selector families, categories of Objective-C methods with special ARC
15+
// semantics.
16+
//
17+
//===----------------------------------------------------------------------===//
18+
19+
#ifndef OBJC_SELECTOR_FAMILY
20+
#define OBJC_SELECTOR_FAMILY(LABEL, PREFIX)
21+
#endif
22+
23+
OBJC_SELECTOR_FAMILY(Alloc, "alloc")
24+
OBJC_SELECTOR_FAMILY(Copy, "copy")
25+
OBJC_SELECTOR_FAMILY(Init, "init")
26+
OBJC_SELECTOR_FAMILY(MutableCopy, "mutableCopy")
27+
OBJC_SELECTOR_FAMILY(New, "new")
28+
29+
#undef OBJC_SELECTOR_FAMILY

lib/AST/Identifier.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,9 @@ ObjCSelectorFamily ObjCSelector::getSelectorFamily() const {
218218
};
219219

220220
if (false) /*for #define purposes*/;
221-
#define CHECK_PREFIX(LABEL, PREFIX) \
222-
else if (hasPrefix(text, PREFIX)) return ObjCSelectorFamily::LABEL;
223-
FOREACH_OBJC_SELECTOR_FAMILY(CHECK_PREFIX)
224-
#undef CHECK_PREFIX
221+
#define OBJC_SELECTOR_FAMILY(LABEL, PREFIX) \
222+
else if (hasPrefix(text, PREFIX)) return ObjCSelectorFamily::LABEL;
223+
#include "swift/AST/ObjCSelectorFamily.def"
225224
else return ObjCSelectorFamily::None;
226225
}
227226

0 commit comments

Comments
 (0)