Re: gtk2-perl / easily accessing objects properties



Dermot Musgrove wrote:

I agree with this - I am always attaching hash keys/values to objects
that I have constructed.

This brings up another question - why is a widget held as a blessed do{}
rather than a hash as was done in Gtk-Perl? Data::Dumper outputs a
widget as bless( do{\(my $o = 137539536)}, 'Gtk2::Button' )

and I cannot add hash keys/values to this as I used to do when the
widget refs were held as
   bless( { '_gtk' => 137252624 }, 'Gtk::Button' );

the "bless( do{\(my $o = 137539536)}, 'Gtk2::Button' )" is how Data::Dumper represents a blessed pointer value stored as a reference. that is, the typemap turns the actual pointer value into a reference via sv_setref_pv, as described in perlxstut (i believe). (i use this method on another project...)

the original GtkPerl uses a special bit of code to create a hash. it's a bit more work to get the value in and out of XS, but you have the advantage of being able to tie arbitrary perl structures into the hash.

i won't speak for the original gtkperl authors, but i think one motivation for using the hash method might be to avoid some of the DESTROY funkiness that gc and i were debating before.


i had another point, but it's late and it has slipped my mind.  sorry.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]