Re: Calling Parent Constructor from Extending Class

From: Date: Fri, 24 Sep 2010 21:16:18 +0000
Subject: Re: Calling Parent Constructor from Extending Class
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-7688@lists.php.net to get a copy of this message
On Sat, Sep 25, 2010 at 12:22 AM, Mark Skilbeck <markskilbeck@gmail.com> wrote: > Hi, All. > > So, I'm wrapping libnotify as my first extension, and would like to extend > GObject for PHP's GObject class so that I can use the signal functionality > of it (libnotify's NotifyNotification class does this - so I should, too). > > Now, before I tried implementing this, I simply had the create_object member > point to my 'new'[1] function to set up the object[2]. > > I then went on to having my Notification class extend the GObject class by > doing: > zend_register_internal_class_ex(..., gobject_ce_gobject, ...) > > Using reflection I can see that my class properly inherits the methods of > GObject. However, they segfault. This is, I believe, caused because GObject > class hasn't been initialized. I stuck a printf() in the GObject 'new' > method[3], and received no output. > > How should I go about doing this? Is there a design flaw here, because I > cannot think of a way to do this? Or I may just be too tired and overlooking > something. Or I may just suck. > > Let me know! Just reuse gobject_gobject_object structure and initializer from gobject-for-php. You don't need your own structure. NotifyNotification extends GObject in GLib hierarchy, so it will just work. -- Alexey Zakhlestin, http://twitter.com/jimi_dini http://www.milkfarmsoft.com/

« previous php.pecl.dev (#7688) next »