Skip to content

Conversation

@davidcole1340
Copy link
Collaborator

Currently types which cannot be owned directly are owned through wrapper types, such as ZendString -> ZendStr, OwnedHashTable -> HashTable, ClassObject -> ZendObject, since they are allocated using the Zend memory manager and cannot be stored in a box.

This PR introduces a new type ZBox<T> and a new trait ZBoxable. A type allocated using the Zend memory manager will implement ZBoxable, and can then be stored inside a ZBox<T>.

There are no 'safe' constructor methods on ZBox. These are to be implemented on the boxed types. For example, ZendStr has a function from_c_str which returns a ZBox<ZendStr>.

@davidcole1340 davidcole1340 marked this pull request as ready for review October 3, 2021 07:35
@davidcole1340
Copy link
Collaborator Author

At the moment I've only implemented ZBoxable for ZendStr but will do after a quick review. Can be implemented on the following types:

  • HashTable
  • ZendObject
  • ZendClassObject

@davidcole1340 davidcole1340 linked an issue Oct 5, 2021 that may be closed by this pull request
@davidcole1340 davidcole1340 merged commit 3403cba into master Oct 5, 2021
@davidcole1340 davidcole1340 deleted the zbox branch October 5, 2021 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace class object MaybeUninit with Option Replace ownership wrapper types with ZBox<T>

2 participants