@@ -79,6 +79,16 @@ struct RuntimeTarget<4> {
79
79
using StoredSize = uint32_t ;
80
80
using StoredPointerDifference = int32_t ;
81
81
static constexpr size_t PointerSize = 4 ;
82
+
83
+ #if SWIFT_OBJC_INTEROP
84
+ static constexpr bool ObjCInterop = true ;
85
+ template <typename T>
86
+ using TargetAnyClassMetadata = TargetAnyClassMetadataObjCInterop<T>;
87
+ #else
88
+ static constexpr bool ObjCInterop = false ;
89
+ template <typename T>
90
+ using TargetAnyClassMetadata = TargetAnyClassMetadata<T>;
91
+ #endif
82
92
};
83
93
84
94
template <>
@@ -91,6 +101,16 @@ struct RuntimeTarget<8> {
91
101
using StoredSize = uint64_t ;
92
102
using StoredPointerDifference = int64_t ;
93
103
static constexpr size_t PointerSize = 8 ;
104
+
105
+ #if SWIFT_OBJC_INTEROP
106
+ static constexpr bool ObjCInterop = true ;
107
+ template <typename T>
108
+ using TargetAnyClassMetadata = TargetAnyClassMetadataObjCInterop<T>;
109
+ #else
110
+ static constexpr bool ObjCInterop = false ;
111
+ template <typename T>
112
+ using TargetAnyClassMetadata = TargetAnyClassMetadata<T>;
113
+ #endif
94
114
};
95
115
96
116
namespace reflection {
@@ -540,6 +560,14 @@ namespace {
540
560
541
561
using TypeContextDescriptor = TargetTypeContextDescriptor<InProcess>;
542
562
563
+ template <unsigned PointerSize>
564
+ using ExternalTypeContextDescriptor
565
+ #if SWIFT_OBJC_INTEROP
566
+ = TargetTypeContextDescriptor<External<WithObjCInterop<RuntimeTarget<PointerSize>>>>;
567
+ #else
568
+ = TargetTypeContextDescriptor<External<NoObjCInterop<RuntimeTarget<PointerSize>>>>;
569
+ #endif
570
+
543
571
// FIXME: https://bugs.swift.org/browse/SR-1155
544
572
#pragma clang diagnostic push
545
573
#pragma clang diagnostic ignored "-Winvalid-offsetof"
@@ -2106,7 +2134,15 @@ using ProtocolRequirement = TargetProtocolRequirement<InProcess>;
2106
2134
2107
2135
template <typename Runtime> struct TargetProtocolDescriptor ;
2108
2136
using ProtocolDescriptor = TargetProtocolDescriptor<InProcess>;
2109
-
2137
+
2138
+ template <unsigned PointerSize>
2139
+ using ExternalProtocolDescriptor
2140
+ #if SWIFT_OBJC_INTEROP
2141
+ = TargetProtocolDescriptor<External<WithObjCInterop<RuntimeTarget<PointerSize>>>>;
2142
+ #else
2143
+ = TargetProtocolDescriptor<External<NoObjCInterop<RuntimeTarget<PointerSize>>>>;
2144
+ #endif
2145
+
2110
2146
// / A witness table for a protocol.
2111
2147
// /
2112
2148
// / With the exception of the initial protocol conformance descriptor,
@@ -2722,6 +2758,16 @@ struct TargetProtocolConformanceDescriptor final
2722
2758
return TypeRef.getTypeDescriptor (getTypeKind ());
2723
2759
}
2724
2760
2761
+ constexpr inline auto
2762
+ getTypeDescriptorOffset () const -> typename Runtime::StoredSize {
2763
+ return offsetof (typename std::remove_reference<decltype (*this )>::type, TypeRef);
2764
+ }
2765
+
2766
+ constexpr inline auto
2767
+ getProtocolDescriptorOffset () const -> typename Runtime::StoredSize {
2768
+ return offsetof (typename std::remove_reference<decltype (*this )>::type, Protocol);
2769
+ }
2770
+
2725
2771
TargetContextDescriptor<Runtime> * __ptrauth_swift_type_descriptor *
2726
2772
_getTypeDescriptorLocation () const {
2727
2773
if (getTypeKind () != TypeReferenceKind::IndirectTypeDescriptor)
@@ -2840,9 +2886,21 @@ using TargetProtocolConformanceRecord =
2840
2886
2841
2887
using ProtocolConformanceRecord = TargetProtocolConformanceRecord<InProcess>;
2842
2888
2889
+ template <unsigned PointerSize>
2843
2890
using ExternalProtocolConformanceDescriptor
2844
- = TargetProtocolConformanceDescriptor<External<RuntimeTarget<8 >>>;
2845
- using ExternalProtocolConformanceRecord = TargetProtocolConformanceRecord<External<RuntimeTarget<8 >>>;
2891
+ #if SWIFT_OBJC_INTEROP
2892
+ = TargetProtocolConformanceDescriptor<External<WithObjCInterop<RuntimeTarget<PointerSize>>>>;
2893
+ #else
2894
+ = TargetProtocolConformanceDescriptor<External<NoObjCInterop<RuntimeTarget<PointerSize>>>>;
2895
+ #endif
2896
+
2897
+ template <unsigned PointerSize>
2898
+ using ExternalProtocolConformanceRecord
2899
+ #if SWIFT_OBJC_INTEROP
2900
+ = TargetProtocolConformanceRecord<External<WithObjCInterop<RuntimeTarget<PointerSize>>>>;
2901
+ #else
2902
+ = TargetProtocolConformanceRecord<External<NoObjCInterop<RuntimeTarget<PointerSize>>>>;
2903
+ #endif
2846
2904
2847
2905
template <typename Runtime>
2848
2906
struct TargetGenericContext ;
@@ -2893,6 +2951,13 @@ struct TargetContextDescriptor {
2893
2951
};
2894
2952
2895
2953
using ContextDescriptor = TargetContextDescriptor<InProcess>;
2954
+ template <unsigned PointerSize>
2955
+ using ExternalContextDescriptor
2956
+ #if SWIFT_OBJC_INTEROP
2957
+ = TargetContextDescriptor<External<WithObjCInterop<RuntimeTarget<PointerSize>>>>;
2958
+ #else
2959
+ = TargetContextDescriptor<External<NoObjCInterop<RuntimeTarget<PointerSize>>>>;
2960
+ #endif
2896
2961
2897
2962
inline bool isCImportedModuleName (llvm::StringRef name) {
2898
2963
// This does not include MANGLING_MODULE_CLANG_IMPORTER because that's
@@ -3417,6 +3482,11 @@ struct TargetProtocolDescriptor final
3417
3482
NumRequirements};
3418
3483
}
3419
3484
3485
+ constexpr inline auto
3486
+ getNameOffset () const -> typename Runtime::StoredSize {
3487
+ return offsetof (typename std::remove_reference<decltype (*this )>::type, Name);
3488
+ }
3489
+
3420
3490
// / Retrieve the requirement base descriptor address.
3421
3491
ConstTargetPointer<Runtime, TargetProtocolRequirement<Runtime>>
3422
3492
getRequirementBaseDescriptor () const {
@@ -4081,6 +4151,11 @@ class TargetTypeContextDescriptor
4081
4151
// / type's metadata. The returned value is measured in sizeof(StoredPointer).
4082
4152
int32_t getGenericArgumentOffset () const ;
4083
4153
4154
+ constexpr inline auto
4155
+ getNameOffset () const -> typename Runtime::StoredSize {
4156
+ return offsetof (typename std::remove_reference<decltype (*this )>::type, Name);
4157
+ }
4158
+
4084
4159
// / Return the start of the generic arguments array in the nominal
4085
4160
// / type's metadata. The returned value is measured in sizeof(StoredPointer).
4086
4161
const TargetMetadata<Runtime> * const *getGenericArguments (
0 commit comments