Skip to content

ValueWitnessTable

Azoy edited this page May 6, 2021 · 2 revisions

ValueWitnessTable

The value witness table is a table of function pointers that describe how to properly copy, destroy, etc. memory for a given type. It also contains type layout information about the type including size, stride, and alignment.

public struct ValueWitnessTable: LayoutWrapper 

ABI Stability: Stable since the following

| macOS | iOS/tvOS | watchOS | Linux | Windows |
|-------|----------|---------|-------|---------|
| 10.14 | 12.2     | 5.2     | NA    | NA      |

Inheritance

LayoutWrapper

Properties

size

The size in bytes that this type represents in memory.

public var size: Int 

stride

The required size in bytes needed to represent an element if this type were in an array.

public var stride: Int 

flags

The flags describing this value witness table.

public var flags: Flags 

extraInhabitantCount

The number of extra inhabitants in this type.

public var extraInhabitantCount: Int 

Methods

initializeBufferWithCopyOfBuffer(_:_:)

Given a buffer an instance of the type in the source buffer, initialize the destination buffer with a copy of the source.

public func initializeBufferWithCopyOfBuffer(
    _ dest: UnsafeMutableRawPointer,
    _ source: UnsafeMutableRawPointer
  ) 

Parameters

  • dest: The desintation buffer.
  • source: The source buffer with the instance.

destroy(_:)

Given an instance of this type, destroy it. The resulting pointer is now an invalid instance.

public func destroy(_ value: UnsafeMutableRawPointer) 

Parameters

  • value: An instance of this type.

initializeWithCopy(_:_:)

Given an invalid instance of this type and a valid instance of this type, copy the source instance into the destination.

public func initializeWithCopy(
    _ dest: UnsafeMutableRawPointer,
    _ source: UnsafeMutableRawPointer
  ) 

Parameters

  • dest: An invalid instance of type.
  • source: An instance of type.

assignWithCopy(_:_:)

Given a valid instance of this type and another valid instance of this type, copy the contents from the source into the destination.

public func assignWithCopy(
    _ dest: UnsafeMutableRawPointer,
    _ source: UnsafeMutableRawPointer
  ) 

Parameters

  • dest: An instance of type whose contents are going to be overwritten.
  • source: An instance of type.

initializeWithTake(_:_:)

Given an invalid instance of this type and a valid instance of this type, initialize the destination by destroying the source instance.

public func initializeWithTake(
    _ dest: UnsafeMutableRawPointer,
    _ source: UnsafeMutableRawPointer
  ) 

Parameters

  • dest: An invalid instance of type.
  • source: An instance of type.

assignWithTake(_:_:)

Given a valid instance of this type and another valid instance of this type, copy the contents from the source instance into the destination while also destroying the source instance.

public func assignWithTake(
    _ dest: UnsafeMutableRawPointer,
    _ source: UnsafeMutableRawPointer
  ) 

Parameters

  • dest: An instance of type.
  • source: An instance of type.

getEnumTagSinglePayload(_:_:)

Given an instance of an enum case who has a single payload of this type, get the case tag of the enum.

public func getEnumTagSinglePayload(
    _ instance: UnsafeRawPointer,
    _ numEmptyCases: UInt32
  ) -> UInt32 

Parameters

  • instance: The enum case instance.
  • numEmptyCases: The number of cases without payloads in this enum.

Returns

The enum case tag for the payload containing this type.

storeEnumTagSinglePayload(_:_:_:)

Given some uninitialzed data of an enum case who has a single payload of this type, store the tag in the data.

public func storeEnumTagSinglePayload(
    _ instance: UnsafeMutableRawPointer,
    _ tag: UInt32,
    _ numEmptyCases: UInt32
  ) 

Parameters

  • instance: The uninitialized instance of the enum case.
  • tag: The enum case tag number for the payload with this type.
  • numEmptyCases: The number of cases without payloads in this enum.
Types
Protocols
Global Variables
Global Functions
Clone this wiki locally