subclassing Glib::Boxed



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]