Skip to content

Commit 2e6bda0

Browse files
committed
[+0-all-args] Document the swift exposed functions in Reflection.mm as being either methods or free functions.
Some of the free functions have method like names, so it is impossible to know whether or not the given functions use the method convention or the thin convention. At least now it is documented. rdar://34222540
1 parent b28c282 commit 2e6bda0

File tree

1 file changed

+64
-1
lines changed

1 file changed

+64
-1
lines changed

stdlib/public/runtime/Reflection.mm

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,13 @@ explicit String(NSString *s)
172172
#pragma clang diagnostic push
173173
#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
174174

175-
175+
// struct _MagicMirrorData {
176+
// internal var value: Any {
177+
// @_silgen_name("swift_MagicMirrorData_value")get
178+
// }
179+
// }
180+
//
181+
// Since this is a method, owner is passed in at +0.
176182
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
177183
AnyReturn swift_MagicMirrorData_value(HeapObject *owner,
178184
const OpaqueValue *value,
@@ -186,6 +192,14 @@ AnyReturn swift_MagicMirrorData_value(HeapObject *owner,
186192

187193
return AnyReturn(result);
188194
}
195+
196+
// struct _MagicMirrorData {
197+
// internal var valueType: Any.Type {
198+
// @_silgen_name("swift_MagicMirrorData_valueType")get
199+
// }
200+
// }
201+
//
202+
// Since this is a method, owner is passed in at +0.
189203
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
190204
const Metadata *swift_MagicMirrorData_valueType(HeapObject *owner,
191205
const OpaqueValue *value,
@@ -195,6 +209,14 @@ AnyReturn swift_MagicMirrorData_value(HeapObject *owner,
195209
}
196210

197211
#if SWIFT_OBJC_INTEROP
212+
213+
// struct _MagicMirrorData {
214+
// public var objcValue: Any {
215+
// @_silgen_name("swift_MagicMirrorData_objcValue")get
216+
// }
217+
// }
218+
//
219+
// Since this is a method, owner is at +0.
198220
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
199221
AnyReturn swift_MagicMirrorData_objcValue(HeapObject *owner,
200222
const OpaqueValue *value,
@@ -295,6 +317,13 @@ void swift_MagicMirrorData_summary(const Metadata *T, String *result) {
295317
}
296318
}
297319

320+
// struct _MagicMirrorData {
321+
// public var objcValueType: Any.Type {
322+
// @_silgen_name("swift_MagicMirrorData_objcValueType")get
323+
// }
324+
// }
325+
//
326+
// This is a method, so owner is at +0.
298327
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
299328
const Metadata *swift_MagicMirrorData_objcValueType(HeapObject *owner,
300329
const OpaqueValue *value,
@@ -351,6 +380,9 @@ static Mirror reflect(HeapObject *owner,
351380

352381
// -- Tuple destructuring.
353382

383+
// internal func _getTupleCount(_: _MagicMirrorData) -> Int
384+
//
385+
// This is a free standing function, not a method.
354386
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
355387
intptr_t swift_TupleMirror_count(HeapObject *owner,
356388
const OpaqueValue *value,
@@ -360,6 +392,10 @@ intptr_t swift_TupleMirror_count(HeapObject *owner,
360392
return Tuple->NumElements;
361393
}
362394

395+
/// internal func _getTupleChild<T>(_: Int, _: _MagicMirrorData) -> (T, _Mirror)
396+
///
397+
/// This is a free standing function, not a method.
398+
///
363399
/// \param owner passed at +1, consumed.
364400
/// \param value passed unowned.
365401
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
@@ -489,6 +525,9 @@ static bool loadSpecialReferenceStorage(HeapObject *owner,
489525

490526
// -- Struct destructuring.
491527

528+
// internal func _getStructCount(_: _MagicMirrorData) -> Int
529+
//
530+
// This is a free standing function, not a method.
492531
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
493532
intptr_t swift_StructMirror_count(HeapObject *owner,
494533
const OpaqueValue *value,
@@ -498,6 +537,9 @@ intptr_t swift_StructMirror_count(HeapObject *owner,
498537
return Struct->Description->Struct.NumFields;
499538
}
500539

540+
// internal func _getStructChild<T>(_: Int, _: _MagicMirrorData) -> (T, _Mirror)
541+
//
542+
// This is a free standing function, not a method.
501543
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
502544
void swift_StructMirror_subscript(String *outString,
503545
Mirror *outMirror,
@@ -524,6 +566,7 @@ void swift_StructMirror_subscript(String *outString,
524566

525567
assert(!fieldType.isIndirect() && "indirect struct fields not implemented");
526568

569+
// This only consumed owner if we succeed.
527570
if (loadSpecialReferenceStorage(owner, fieldData, fieldType, outMirror))
528571
return;
529572

@@ -576,6 +619,10 @@ static void getEnumMirrorInfo(const OpaqueValue *value,
576619
*indirectPtr = indirect;
577620
}
578621

622+
// internal func _swift_EnumMirror_caseName(
623+
// _ data: _MagicMirrorData) -> UnsafePointer<CChar>
624+
//
625+
// This is a free standing function.
579626
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
580627
const char *swift_EnumMirror_caseName(HeapObject *owner,
581628
const OpaqueValue *value,
@@ -596,6 +643,9 @@ static void getEnumMirrorInfo(const OpaqueValue *value,
596643
return getFieldName(Description.CaseNames, tag);
597644
}
598645

646+
// internal func _getEnumCaseName<T>(_ value: T) -> UnsafePointer<CChar>?
647+
//
648+
// This is a free standing function, not a method.
599649
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
600650
const char *swift_EnumCaseName(OpaqueValue *value, const Metadata *type) {
601651
// Build a magic mirror. Unconditionally destroy the value at the end.
@@ -622,6 +672,9 @@ static void getEnumMirrorInfo(const OpaqueValue *value,
622672
return result;
623673
}
624674

675+
// internal func _getEnumCount(_: _MagicMirrorData) -> Int
676+
//
677+
// This is a free standing function, not a method.
625678
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
626679
intptr_t swift_EnumMirror_count(HeapObject *owner,
627680
const OpaqueValue *value,
@@ -637,6 +690,9 @@ intptr_t swift_EnumMirror_count(HeapObject *owner,
637690
return (payloadType != nullptr) ? 1 : 0;
638691
}
639692

693+
// internal func _getEnumChild<T>(_: Int, _: _MagicMirrorData) -> (T, _Mirror)
694+
//
695+
// This is a free standing function, not a method.
640696
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
641697
void swift_EnumMirror_subscript(String *outString,
642698
Mirror *outMirror,
@@ -685,6 +741,9 @@ static Mirror getMirrorForSuperclass(const ClassMetadata *sup,
685741
const OpaqueValue *value,
686742
const Metadata *type);
687743

744+
// internal func _getClassCount(_: _MagicMirrorData) -> Int
745+
//
746+
// This is a free standing function, not a method.
688747
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
689748
intptr_t swift_ClassMirror_count(HeapObject *owner,
690749
const OpaqueValue *value,
@@ -701,6 +760,10 @@ intptr_t swift_ClassMirror_count(HeapObject *owner,
701760
return count;
702761
}
703762

763+
/// internal func _getClassChild<T>(_: Int, _: _MagicMirrorData) -> (T, _Mirror)
764+
///
765+
/// This is a free standing function, not a method.
766+
///
704767
/// \param owner passed at +1, consumed.
705768
/// \param value passed unowned.
706769
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE

0 commit comments

Comments
 (0)