Re: New destructors implementation
| From: | Zeev Suraski | Date: | Thu, 05 Feb 2004 07:51:02 +0000 |
| Subject: | Re: New destructors implementation | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-7604@lists.php.net to get a copy of this message | ||
At 02:00 05/02/2004, Marcus Boerger wrote:
Hello Zeev, Thursday, February 5, 2004, 12:24:47 AM, you wrote: At 23:45 04/02/2004, Andrei Zmievski wrote:Internal objects as in the ones in reflection and similar? Yes. But I'd imagine that for most other objects which completely overload the behavior, you wouldn't need that. Generally, if your object should be able to call __destruct() *AND* it's a PHP-style object (has the same structure), it should use that callback, otherwise - not. Be advised that your __destruct() mustn't actually render the object unusuable to the degree that PHP would crash if it touches it. It *may* be referenced after __destruct() is called (it would be an error on the author's part to do that, but nothing will prevent him from doing that). Zeevof theOn Wed, 04 Feb 2004, Andi Gutmans wrote:3. The APIs have changed to allow for this new mechanism. Insteadprevious dtor callback, which was supposed to both call thedestructor andfree the object's storage, there are now two separate callbacks - dtor (call the destructor) and free_storage (guess). Generally, for classes which implement PHP-style objects, you should implement both of these callbacks (though you can probably use the standard dtor callback). For overloaded classes such as SimpleXML, COM, etc. - you will most likelyfree_storageonlyhave to implement the free_storage callback, as there's no destructor per-se. We already went over all the overloaded classes in the php-srcCVSand moved most of the dtor callbacks to free_storage. Note that the interface is slightly different between these two callbacks -doesn't receive the object handle.If it's a PHP-style object, then you can use zend_objects_destroy_object as your destructor callback (when calling zend_objects_store_put()), in which case __destruct() will be called. That's how the regular PHP objects do it. So my guess is that for most internal objects we need to do so?Is there an automatic call to __destruct() method then? Because I'd like my PHP-GTK objects to have that method called upon destruction and I don't feel like reimplementing the mechanism for doing that.