@@ -580,13 +580,39 @@ void swift_initStructMetadata(StructMetadata *self,
580
580
// /
581
581
// / This function is only intended to be called from the relocation function
582
582
// / of a resilient class pattern.
583
+ // /
584
+ // / The metadata completion function must complete the metadata by calling
585
+ // / swift_initClassMetadata().
583
586
SWIFT_RUNTIME_EXPORT
584
587
ClassMetadata *
585
588
swift_relocateClassMetadata (ClassDescriptor *descriptor,
586
589
ResilientClassMetadataPattern *pattern);
587
590
588
- // / Initialize the field offset vector for a dependent-layout class, using the
589
- // / "Universal" layout strategy.
591
+ // / Initialize various fields of the class metadata.
592
+ // /
593
+ // / Namely:
594
+ // / - The superclass field is set to \p super.
595
+ // / - If the class metadata was allocated at runtime, copies the
596
+ // / vtable entries from the superclass and installs the class's
597
+ // / own vtable entries and overrides of superclass vtable entries.
598
+ // / - Copies the field offsets and generic parameters and conformances
599
+ // / from the superclass.
600
+ // / - Initializes the field offsets using the runtime type layouts
601
+ // / passed in \p fieldTypes.
602
+ // /
603
+ // / This initialization pattern in the following cases:
604
+ // / - The class has generic ancestry, or resiliently-sized fields.
605
+ // / In this case the metadata was emitted statically but is incomplete,
606
+ // / because, the superclass field, generic parameters and conformances,
607
+ // / and field offset vector entries require runtime completion.
608
+ // /
609
+ // / - The class is not generic, and has resilient ancestry.
610
+ // / In this case the class metadata was allocated from a resilient
611
+ // / class metadata pattern by swift_relocateClassMetadata().
612
+ // /
613
+ // / - The class is generic.
614
+ // / In this case the class metadata was allocated from a generic
615
+ // / class metadata pattern by swift_allocateGenericClassMetadata().
590
616
SWIFT_RUNTIME_EXPORT
591
617
void swift_initClassMetadata (ClassMetadata *self,
592
618
ClassMetadata *super,
@@ -595,6 +621,24 @@ void swift_initClassMetadata(ClassMetadata *self,
595
621
const TypeLayout * const *fieldTypes,
596
622
size_t *fieldOffsets);
597
623
624
+ #if SWIFT_OBJC_INTEROP
625
+ // / Initialize various fields of the class metadata.
626
+ // /
627
+ // / This is a special function only used to re-initialize metadata of
628
+ // / classes that are visible to Objective-C and have resilient fields.
629
+ // /
630
+ // / This means the class does not have generic or resilient ancestry,
631
+ // / and is itself not generic. However, it might have fields whose
632
+ // / size is not known at compile time.
633
+ SWIFT_RUNTIME_EXPORT
634
+ void swift_updateClassMetadata (ClassMetadata *self,
635
+ ClassMetadata *super,
636
+ ClassLayoutFlags flags,
637
+ size_t numFields,
638
+ const TypeLayout * const *fieldTypes,
639
+ size_t *fieldOffsets);
640
+ #endif
641
+
598
642
// / Given class metadata, a class descriptor and a method descriptor, look up
599
643
// / and load the vtable entry from the given metadata. The metadata must be of
600
644
// / the same class or a subclass of the descriptor.
0 commit comments