From resources to zend_object

jgmdev
Created by: jgmdev
Date: 06/04/2012 @ 2:33:13 pm
Views: 1535

On previous wxphp code a property resource was added to each wxWidgets wrapper php object in order to store the native wxWidgets object. This property was named wxResource and you could do things like $object->wxResource or unset($object->wxResource) leading to application errors.

Johannes (a php developer) told me about extending the zend_object in order to add custom data to it, so now the custom zend object includes the pointer to the native object, a flag that indicates if user initialized and the type of object, for code that needs to check the object is of appropriate type on methods parameter check.

Elizabeth (php-gtk mantainer) told me resources are slow and gave me some example code to retrieve the custom zend object by using zend_object_store_get_object(zval*) as other examples to handle older php versions that don't support object_properties_init().

So I took the time this past weekend to modify the code generator and implemented the usage of custom zend_object. The push to github was of 115 file changes, something that would take more than 1 and half day if done by hand.

The extension seems to run faster now (or maybe is my imagination) some benchmarking would be nice but I don't have time for it.

On the coming days I will try to re-enable wxRichTextCtrl (a component that has grow too much on wxWidgets 2.9) and when I finish this I will try to make a new release of the extension.

Comments