Skip to content

Commit efce6fc

Browse files
committed
[Runtime] NFC: Adopt reference storage type meta-programming macros
1 parent da506fc commit efce6fc

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

stdlib/public/runtime/MetadataLookup.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,20 +1007,12 @@ class DecodedMetadataBuilder {
10071007
return BuiltType();
10081008
}
10091009

1010-
BuiltType createUnownedStorageType(BuiltType base) {
1011-
ReferenceOwnership.setUnowned();
1012-
return base;
1013-
}
1014-
1015-
BuiltType createUnmanagedStorageType(BuiltType base) {
1016-
ReferenceOwnership.setUnmanaged();
1017-
return base;
1018-
}
1019-
1020-
BuiltType createWeakStorageType(BuiltType base) {
1021-
ReferenceOwnership.setWeak();
1022-
return base;
1010+
#define REF_STORAGE(Name, ...) \
1011+
BuiltType create##Name##StorageType(BuiltType base) { \
1012+
ReferenceOwnership.set##Name(); \
1013+
return base; \
10231014
}
1015+
#include "swift/AST/ReferenceStorage.def"
10241016

10251017
BuiltType createSILBoxType(BuiltType base) const {
10261018
// FIXME: Implement.

stdlib/public/runtime/Private.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,10 @@ class TypeReferenceOwnership {
4343
public:
4444
constexpr TypeReferenceOwnership() : Data(0) {}
4545

46-
bool isWeak() const { return Data & Weak; }
47-
bool isUnowned() const { return Data & Unowned; }
48-
bool isUnmanaged() const { return Data & Unmanaged; }
49-
50-
void setWeak() { Data |= Weak; }
51-
52-
void setUnowned() { Data |= Unowned; }
53-
54-
void setUnmanaged() { Data |= Unmanaged; }
46+
#define REF_STORAGE(Name, ...) \
47+
void set##Name() { Data |= Name; } \
48+
bool is##Name() const { return Data & Name; }
49+
#include "swift/AST/ReferenceStorage.def"
5550
};
5651

5752
/// Type information consists of metadata and its ownership info,

0 commit comments

Comments
 (0)