Skip to content

Metadata

tevelee edited this page Jul 25, 2026 · 2 revisions

Metadata

Metadata refers to the Swift metadata records in a given binary. All metadata records include a value witness table, which describe how to properly copy, destroy, etc. the memory of a type, along with a given "kind".

public protocol Metadata 

Default Implementations

rawKind

The unprocessed metadata kind word stored by the runtime.

public var rawKind: Int 

Values above the runtime's enumerated-kind range are Objective-C ISA pointers. Values within that range can be introduced by newer Swift runtimes, so prefer knownKind before relying on kind for dispatch.

knownKind

The known metadata kind, or nil for a future enumerated kind.

public var knownKind: MetadataKind? 

isTypeMetadata

Whether this record is metadata for a type and therefore has value witnesses. ISA-pointer class metadata is always type metadata.

public var isTypeMetadata: Bool 

type

The type that this metadata represents.

public var type: Any.Type 

vwt

The value witness table for this type metadata.

public var vwt: ValueWitnessTable 

enumVwt

The enum value witness table for this enum metadata.

public var enumVwt: EnumValueWitnessTable 

kind

The kind of metadata this is.

public var kind: MetadataKind 

allocateBoxForExistential(in:)

Given a pointer to some existential container, allocate a box on the heap for the container to put the type's value in.

public func allocateBoxForExistential(
    in container: UnsafeMutablePointer<AnyExistentialContainer>
  ) -> UnsafeRawPointer 

Parameters

  • container: Pointer to some existential container.

Returns

A pointer to the newly allocated buffer. If the value is stored inline, then this is a pointer to the container's data field.

Requirements

ptr

Backing metadata pointer.

var ptr: UnsafeRawPointer 
Types
Protocols
Global Typealiases
Global Variables
Global Functions

Clone this wiki locally