Re: __gtype and constants
| From: | Alan Knowles | Date: | Wed, 18 Aug 2004 02:56:54 +0000 |
| Subject: | Re: __gtype and constants | ||
| References: | 1 2 3 4 5 | Groups: | php.gtk.dev |
| Request: | Send a blank email to php-gtk-dev+get-734@lists.php.net to get a copy of this message | ||
Andrei Zmievski wrote:
On Mon, 16 Aug 2004, Alan Knowles wrote:From a documentation and code readibilty angle, these magic vars are always a little difficult to understand. alot of those look like they should be part of the reflection stuff ??? __doc__ = $x = new ReflectionClass($object); $x->getDoc();I don't know if we can modify the default ReflectionClass to do this. I though we could inject stuff into the phpdoc block area?
That's an interesting subject.. it's kind of like an observer pattern, python's syntax for it is really nasty ;) class myObject extends GObject { function mysignal_default_signal_hander($self, $var1) {__signals = GSignal::list_in_object($object);It's not just for listing them, it's also for specifying them upon registration. For example see http://cvs.gnome.org/viewcvs/gnome-python/pygtk/examples/gobject/signal.py?rev=1.4&view=auto The self.__gobject_init__() is what looks in __signals to see how they should be registered.
.... default implementation....} function __construct() {
$s = new GSignal($this,'mysignal', G_SIGNAL_RUN_FIRST, 'mysignal_handler');
echo $s->id; // gets the signal ID..
}
function some_info() {
$id = GSignal::lookup($this,'mysignal');
$name = GSignal::lookup_name($this,1);
$array = GSignal::list_names($this,1);
$array = GSignal::list_ids($this,1);
}
function emitsomthing() {
GSignal::emit($this,'mysignal',....some args...)} }
ah.. I see what you are getting at.. - the only kludge I can think of here.. function __construct() {__properties = $x = new ReflectionClass($object); $x->getUserDefinedProperties();Same thing here. Perhaps we could come up with a different way of registering them..
$p = new GParam($this,'propname');
$p->default = .....
$p->flags = .....
}
of course in C# we would be doing
$this += new GParam('propname');
:)
Regards
Alan
I'm still annoyed you snuck __get / __set / __call in rather than using a new language construct :)Heh, I didn't sneak them in, I just wrote ext/overload! I wish we had a language construct too. - Andrei