Skip to content

Commit 941ec1e

Browse files
committed
SwiftRemoteMirror: Add reflection metadata version query API
rdar://problem/27251582
1 parent c2c1b84 commit 941ec1e

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

include/swift/Reflection/Records.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include "swift/Basic/RelativePointer.h"
2121

22+
const uint16_t SWIFT_REFLECTION_METADATA_VERSION = 1;
23+
2224
namespace swift {
2325
namespace reflection {
2426

include/swift/SwiftRemoteMirror/SwiftRemoteMirror.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
extern "C" {
3737
#endif
3838

39+
/// Get the metadata version supported by the Remote Mirror library.
40+
uint16_t
41+
swift_reflection_getSupportedMetadataVersion();
42+
3943
/// \returns An opaque reflection context.
4044
SwiftReflectionContextRef
4145
swift_reflection_createReflectionContext(

stdlib/public/SwiftRemoteMirror/SwiftRemoteMirror.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ using namespace swift::remote;
2222
using NativeReflectionContext
2323
= ReflectionContext<External<RuntimeTarget<sizeof(uintptr_t)>>>;
2424

25+
uint16_t
26+
swift_reflection_getSupportedMetadataVersion() {
27+
return SWIFT_REFLECTION_METADATA_VERSION;
28+
}
29+
2530
SwiftReflectionContextRef
2631
swift_reflection_createReflectionContext(void *ReaderContext,
2732
PointerSizeFunction getPointerSize,

tools/swift-reflection-test/swift-reflection-test.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,5 +465,8 @@ int main(int argc, char *argv[]) {
465465

466466
const char *BinaryFilename = argv[1];
467467

468+
uint16_t Version = swift_reflection_getSupportedMetadataVersion();
469+
printf("Metadata version: %u\n", Version);
470+
468471
return doDumpHeapInstance(BinaryFilename);
469472
}

0 commit comments

Comments
 (0)