subclassing Glib::Boxed
- From: Kevin Ryde <user42 zip com au>
- To: gtk-perl-list gnome org
- Subject: subclassing Glib::Boxed
- Date: Wed, 16 Apr 2008 11:33:45 +1000
If I was crazy enough to want to subclass one of the Glib::Boxed types,
eg. Gtk2::Gdk::Color, where would be a good place to hang some extra
instance data? I see boxed is a scalar ref, and I guess adding to a
class using that is a general perl question, though maybe the
Glib::Boxed docs could point in the right direction.
The closest I got was thinking to hold stuff separately, looked up by
address, eg.
my %data;
sub mymethod {
my ($self) = @_;
my $key = $self+0;
$data{$key} = something;
}
sub DESTROY {
delete $data{$key};
...
}
which of course is inaccessible to any further subclasses, but in my
case that'd be ok. Is there a better way?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]