Extension class inherit from PHP class
[email protected] (Trevan Richins)
| Newsgroups | php.pecl.dev |
|---|---|
| Message-ID | <[email protected]> |
I'm wondering if it is possible to have a class defined in a C extension inherit from a class defined in PHP. I've been able to make a working example, but running it with debug enabled shows a bunch of memory leaks. All my extension does right now is:
Define a PHP function "define_native_class"
In "define_native_class", will call INIT_CLASS_ENTRY, zend_lookup_class to get the PHP parent class entry, and then zend_register_internal_class_ex
My example file looks like:
<?php
Class Parent {
}
define_native_class("Child");
class Grandchild extends Child {
}
?>
If I change the class Grandchild to not extend Child, memory leaks still exist. If I comment out the line zend_register_internal_class_ex, memory leaks go away.
Is there something that I'm missing or is this even possible? If you are wondering why I'm doing this, it is an attempt to speed up legacy code. I plan to move slow methods from Grandchild to Child while leaving the normal hierarchy intact.
Thanks,
Trevan