Skip to content

swift_allocObject(______)

0x41c edited this page Feb 28, 2022 · 1 revision

swift_allocObject(_:_:_:)

For swift_allocObject (in this version of the function signature) you pass in UnsafeRawPointer Once we get all the metadata bridged replace it with ClassMetadata or similar type. Also, I'm not sure enough about how the alignment mask works to explain it. If someone feels like documenting it, that would be amazing. (zoomer problem)

@_silgen_name("swift_allocObject")
public func swift_allocObject(
    _ type: Any.Type,
    _ size: Int,
    _ alignMask: Int
) -> UnsafeRawPointer

Creates an object of the specified swift class type. This does not take the default size of the type specified in the metadata into account,so size must be specified by the caller. For size independant allocations, use: swift_allocBox

Parameters

  • type: The type of the object to allocate.
  • size: The size of the object to allocate.
  • alignMask: The mask used to determine the size of the aligned allocation

Returns

A pointer to the semi-initialized object

Types
Protocols
Global Typealiases
Global Functions
Clone this wiki locally