Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ZBox<T> to replace owned variants #94

Merged
merged 6 commits into from
Oct 5, 2021
Merged

Add ZBox<T> to replace owned variants #94

merged 6 commits into from
Oct 5, 2021

Conversation

davidcole1340
Copy link
Owner

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
Owner 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>
1 participant