zephir icon indicating copy to clipboard operation
zephir copied to clipboard

Embedding C Data into PHP objects.

Open rcmcdonald91 opened this issue 3 years ago • 0 comments

PHP internals supports a clever struct allocation hack that allows you to allocate arbitrary memory in front of zend_objects to store any C data. Then OffsetOf can be used to "find" this data later effectively allowing you to embed anything into a object. This is the NG replacement for the old resource type.

I'd like to start a discussion around supporting this in Zephir. As I believe it is a pretty significant shortcoming between the types of extensions one can write using the native C API vs the higher level Zephir DSL.

Maybe something like the function optimizers that we already have for calling C code. But an object optimizer that allows us to define the object structure and hook the object_handlers.

I understand PHP internals but Zephir internals is new to me

rcmcdonald91 avatar Aug 07 '22 15:08 rcmcdonald91