Re: [RFC][PATCH] Small enhancement for Glib::Object::Subclass
- From: "Ross McFarland" <rwmcfa1 neces com>
- To: "Jan Hudec" <bulb ucw cz>
- Cc: gtk-perl-list gnome org
- Subject: Re: [RFC][PATCH] Small enhancement for Glib::Object::Subclass
- Date: Tue, 11 May 2004 14:32:42 -0400 (EDT)
Jan Hudec said:
Hello All,
When subclassing a widget, it's probably not uncommon that setting or
getting at least one property needs to be treated specialy, but for some
other properties the default behaviour (just storing it in the hash) is
ok. Or perhaps even for the special property get can do with the default
implementation. Therefore I suggest following enhancement for the
default SET_PROPERTY/GET_PROPERTY methods:
If SET_<property-name>/GET_<property-name> method exists, it is called.
Otherwise, the property is set to/retrieved from the hash.
I would actualy like set_/get_ prefixes better (such methods are more
suited to be called directly), but the following patch uses SET_/GET_
because that is less likely to break existing stuff.
basically my question is what is insufficent/wrong about doing things like this:
sub GET_PROPERTY
{
my ($self, $pspec) = @_;
my $name = $psepc->get_name;
if ($name eq 'special_case')
{
# whatever magic you want/need goes here
return $self->GET_OTHER_PROPERTY ($psepc);
}
else
{
return $self->{$name};
}
}
rather than having the extra overhead of looking for the sub with the upper
cased version of the property name.
PS: Should I add the patch to the BTS on sourceforge too?
no need.
--
-rm
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]