Skip to content

Commit 20f5304

Browse files
committed
Revised SwiftRemoteMirror C API
Some minor changes to the SwiftRemoteMirror C API, NFC yet.
1 parent c01e8ed commit 20f5304

File tree

4 files changed

+22
-38
lines changed

4 files changed

+22
-38
lines changed

include/swift/Reflection/ReflectionContext.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -680,18 +680,17 @@ class ReflectionContext {
680680
SWIFT_UNKNOWN,
681681
NULL,
682682
0,
683+
0,
683684
0
684685
};
685686
}
686687

687-
swift_fieldinfo_t getInfoForField(const TypeRef *TR, unsigned Index) {
688+
swift_childinfo_t getInfoForChild(const TypeRef *TR, unsigned Index) {
688689
// TODO
689690
return {
690-
NOTAPOINTER,
691691
0,
692692
NULL,
693693
0,
694-
0
695694
};
696695
}
697696
};

include/swift/SwiftRemoteMirror/SwiftRemoteMirror.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ swift_reflection_addReflectionInfo(SwiftReflectionContextRef ContextRef,
5656
swift_reflection_section_t assocty);
5757

5858

59-
/// Clear any caching of field type information for all known heap instances.
60-
void swift_reflection_clearCaches(SwiftReflectionContextRef Context);
61-
6259
/// Returns an opaque type reference for a metadata pointer, or
6360
/// NULL if one can't be constructed.
6461
swift_typeref_t
@@ -70,8 +67,8 @@ swift_typeinfo_t
7067
swift_reflection_infoForTypeRef(SwiftReflectionContextRef ContextRef,
7168
swift_typeref_t OpaqueTypeRef);
7269

73-
/// Returns the information about a stored property by index.
74-
swift_fieldinfo_t
70+
/// Returns the information about a child by index.
71+
swift_childinfo_t
7572
swift_reflection_infoForField(SwiftReflectionContextRef ContextRef,
7673
swift_typeref_t OpaqueTypeRef,
7774
unsigned Index);

include/swift/SwiftRemoteMirror/SwiftRemoteMirrorTypes.h

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,49 +39,42 @@ typedef struct swift_reflection_section_t {
3939
} swift_reflection_section_t;
4040

4141
/// The kind of a Swift type.
42-
typedef enum swift_typeref_kind_t {
43-
SWIFT_CLASS,
42+
typedef enum swift_layout_kind_t {
43+
SWIFT_STRONG_POINTER,
44+
SWIFT_WEAK_POINTER,
45+
SWIFT_UNOWNED_POINTER,
46+
SWIFT_UNMANAGED_POINTER,
4447
SWIFT_STRUCT,
4548
SWIFT_TUPLE,
49+
SWIFT_THICK_FUNCTION,
50+
SWIFT_THIN_FUNCTION,
51+
OBJC_BLOCK,
4652
SWIFT_CLOSURE_CONTEXT,
47-
SWIFT_DICTIONARY_OWNER,
48-
SWIFT_SET_OWNER,
49-
SWIFT_ARRAY_OWNER,
53+
SWIFT_BOX,
5054
SWIFT_UNKNOWN
5155
} swift_layout_kind_t;
5256

5357
/// A basic description of a Swift type's.
5458
typedef struct swift_typeinfo_t {
5559
swift_layout_kind_t LayoutKind;
5660

57-
/// The demangled type name.
58-
const char *TypeName;
61+
const char *MangledTypeName;
5962

6063
size_t Size;
61-
size_t Stride;
64+
size_t InstanceSize;
65+
size_t Alignment;
6266
} swift_typeinfo_t;
6367

64-
typedef enum swift_reference_kind_t {
65-
STRONG,
66-
WEAK,
67-
UNOWNED,
68-
UNMANAGED,
69-
NOTAPOINTER
70-
} swift_reference_kind_t;
71-
72-
typedef struct swift_fieldinfo_t {
73-
swift_reference_kind_t ReferenceKind;
68+
typedef struct swift_childinfo_t {
7469
swift_typeref_t TypeRef;
75-
const char *FieldName;
70+
const char *Name;
7671
size_t Offset;
77-
size_t Size;
78-
} swift_fieldinfo_t;
72+
} swift_childinfo_t;
7973

8074
/// \brief An opaque pointer to a context which maintains state and
8175
/// caching of reflection structure for heap instances.
8276
typedef struct SwiftReflectionContext *SwiftReflectionContextRef;
8377

84-
8578
#ifdef __cplusplus
8679
} // extern "C"
8780
#endif

stdlib/public/SwiftRemoteMirror/SwiftRemoteMirror.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ swift_reflection_addReflectionInfo(SwiftReflectionContextRef ContextRef,
5252
Context->addReflectionInfo(Info);
5353
}
5454

55-
void swift_reflection_clearCaches(SwiftReflectionContextRef ContextRef) {
56-
auto Context = reinterpret_cast<NativeReflectionContext *>(ContextRef);
57-
Context->clear();
58-
}
59-
6055
swift_typeref_t
6156
swift_reflection_typeRefForMetadata(SwiftReflectionContextRef ContextRef,
6257
uintptr_t metadata) {
@@ -87,12 +82,12 @@ swift_reflection_infoForTypeRef(SwiftReflectionContextRef ContextRef,
8782
return Context->getInfoForTypeRef(TR);
8883
}
8984

90-
swift_fieldinfo_t
91-
swift_reflection_infoForField(SwiftReflectionContextRef ContextRef,
85+
swift_childinfo_t
86+
swift_reflection_infoForChild(SwiftReflectionContextRef ContextRef,
9287
swift_typeref_t OpaqueTypeRef,
9388
unsigned Index) {
9489
auto Context = reinterpret_cast<NativeReflectionContext *>(ContextRef);
9590
auto TR = reinterpret_cast<TypeRef *>(OpaqueTypeRef);
96-
return Context->getInfoForField(TR, Index);
91+
return Context->getInfoForChild(TR, Index);
9792
}
9893

0 commit comments

Comments
 (0)