Skip to content

Commit 3a498ca

Browse files
mikeashairspeedswift
authored andcommitted
[RemoteMirror] Add comments to the new APIs and types.
rdar://problem/55481578
1 parent ad09919 commit 3a498ca

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

include/swift/SwiftRemoteMirror/SwiftRemoteMirror.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,15 @@ SWIFT_REMOTE_MIRROR_LINKAGE
288288
size_t swift_reflection_demangle(const char *MangledName, size_t Length,
289289
char *OutDemangledName, size_t MaxLength);
290290

291+
/// Iterate over the process's protocol conformance cache.
292+
///
293+
/// Calls the passed in Call function for each protocol conformance found in
294+
/// the conformance cache. The function is passed the type which conforms and
295+
/// the protocol it conforms to. The ContextPtr is passed through unchanged.
296+
///
297+
/// Returns NULL on success. On error, returns a pointer to a C string
298+
/// describing the error. This pointer remains valid until the next
299+
/// swift_reflection call on the given context.
291300
SWIFT_REMOTE_MIRROR_LINKAGE
292301
const char *swift_reflection_iterateConformanceCache(
293302
SwiftReflectionContextRef ContextRef,
@@ -296,13 +305,27 @@ const char *swift_reflection_iterateConformanceCache(
296305
void *ContextPtr),
297306
void *ContextPtr);
298307

308+
/// Iterate over the process's metadata allocations.
309+
///
310+
/// Calls the passed in Call function for each metadata allocation. The function
311+
/// is passed a structure that describes the allocation. The ContextPtr is
312+
/// passed through unchanged.
313+
///
314+
/// Returns NULL on success. On error, returns a pointer to a C string
315+
/// describing the error. This pointer remains valid until the next
316+
/// swift_reflection call on the given context.
299317
SWIFT_REMOTE_MIRROR_LINKAGE
300318
const char *swift_reflection_iterateMetadataAllocations(
301319
SwiftReflectionContextRef ContextRef,
302320
void (*Call)(swift_metadata_allocation_t Allocation,
303321
void *ContextPtr),
304322
void *ContextPtr);
305323

324+
/// Given a metadata allocation, return the metadata it points to. Returns NULL
325+
/// on failure. Despite the name, not all allocations point to metadata.
326+
/// Currently, this will return a metadata only for allocations with tag
327+
/// SWIFT_GENERIC_METADATA_CACHE_ALLOCATION. Support for additional tags may be
328+
/// added in the future. The caller must gracefully handle failure.
306329
SWIFT_REMOTE_MIRROR_LINKAGE
307330
swift_reflection_ptr_t swift_reflection_allocationMetadataPointer(
308331
SwiftReflectionContextRef ContextRef,

include/swift/SwiftRemoteMirror/SwiftRemoteMirrorTypes.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,19 @@ enum swift_metadata_allocation_tag {
145145
SWIFT_GENERIC_METADATA_CACHE_ALLOCATION = 14,
146146
};
147147

148-
// Tags other than those defined in swift_metadata_allocation_tag will be used
149-
// and must be treated as unknown.
150148
typedef int swift_metadata_allocation_tag_t;
151149

150+
/// A metadata allocation made by the Swift runtime.
152151
typedef struct swift_metadata_allocation {
152+
/// The allocation's tag, which describes what kind of allocation it is. This
153+
/// may be one of the values in swift_metadata_allocation_tag, or something
154+
/// else, in which case the tag should be considered unknown.
153155
swift_metadata_allocation_tag_t Tag;
156+
157+
/// A pointer to the start of the allocation in the remote process.
154158
swift_reflection_ptr_t Ptr;
159+
160+
/// The size of the allocation in bytes.
155161
unsigned Size;
156162
} swift_metadata_allocation_t;
157163

0 commit comments

Comments
 (0)