Skip to content

Commit 15d2149

Browse files
committed
Reflection: Should not depend on header file from SwiftRemoteMirror, NFC
1 parent e3502e9 commit 15d2149

File tree

2 files changed

+38
-21
lines changed

2 files changed

+38
-21
lines changed

include/swift/Reflection/ReflectionContext.h

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
#include "swift/Remote/MemoryReader.h"
2222
#include "swift/Remote/MetadataReader.h"
2323
#include "swift/Reflection/Records.h"
24+
#include "swift/Reflection/TypeLowering.h"
2425
#include "swift/Reflection/TypeRef.h"
2526
#include "swift/Reflection/TypeRefBuilder.h"
26-
#include "swift/SwiftRemoteMirror/SwiftRemoteMirrorTypes.h"
2727

2828
#include <iostream>
2929
#include <vector>
@@ -80,24 +80,8 @@ class ReflectionContext
8080
getBuilder().addReflectionInfo(I);
8181
}
8282

83-
swift_typeinfo_t getInfoForTypeRef(const TypeRef *TR) {
84-
// TODO
85-
return {
86-
SWIFT_UNKNOWN,
87-
NULL,
88-
0,
89-
0,
90-
0
91-
};
92-
}
93-
94-
swift_childinfo_t getInfoForChild(const TypeRef *TR, unsigned Index) {
95-
// TODO
96-
return {
97-
0,
98-
NULL,
99-
0,
100-
};
83+
const TypeInfo *getTypeInfo(const TypeRef *TR) {
84+
return getBuilder().getTypeConverter().getTypeInfo(TR);
10185
}
10286
};
10387

stdlib/public/SwiftRemoteMirror/SwiftRemoteMirror.cpp

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1+
//===--- SwiftRemoteMirror.cpp - C wrapper for Reflection API -------------===//
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+
113
#include "swift/Reflection/ReflectionContext.h"
14+
#include "swift/Reflection/TypeLowering.h"
215
#include "swift/Remote/CMemoryReader.h"
316
#include "swift/SwiftRemoteMirror/SwiftRemoteMirror.h"
417

@@ -81,7 +94,18 @@ swift_reflection_infoForTypeRef(SwiftReflectionContextRef ContextRef,
8194
swift_typeref_t OpaqueTypeRef) {
8295
auto Context = reinterpret_cast<NativeReflectionContext *>(ContextRef);
8396
auto TR = reinterpret_cast<const TypeRef *>(OpaqueTypeRef);
84-
return Context->getInfoForTypeRef(TR);
97+
auto TI = Context->getTypeInfo(TR);
98+
99+
// TODO
100+
(void) TI;
101+
102+
return {
103+
SWIFT_UNKNOWN,
104+
NULL,
105+
0,
106+
0,
107+
0
108+
};
85109
}
86110

87111
swift_childinfo_t
@@ -90,6 +114,15 @@ swift_reflection_infoForChild(SwiftReflectionContextRef ContextRef,
90114
unsigned Index) {
91115
auto Context = reinterpret_cast<NativeReflectionContext *>(ContextRef);
92116
auto TR = reinterpret_cast<const TypeRef *>(OpaqueTypeRef);
93-
return Context->getInfoForChild(TR, Index);
117+
auto TI = Context->getTypeInfo(TR);
118+
119+
// TODO
120+
(void) TI;
121+
122+
return {
123+
0,
124+
NULL,
125+
0,
126+
};
94127
}
95128

0 commit comments

Comments
 (0)