Re: $model->iter_next fix



On Tue, 2003-11-18 at 16:00, Torsten Schoenfeld wrote:
In case that convinced you, I've attached a patch that enables
$iter->copy.

i see your paltry one-function patch and raise you a base method patch.



"muppet, what are you babbling about?"

GtkTreeIter, GtkTreePath, GtkTextIter, GdkColor, GdkEvent, GdkRectangle,
and several others are all "boxed" types, that is, they are plain C
structures that have been wrapped with a GType descended from GBoxed. 
this type provides a generic way to copy and free arbitrary structures
by knowing the GType and nothing else about the pointer.

surely this sounds like a good thing, right?

advantages: one boxed implementation takes care of 22 types in Gtk2,
plus whatever else in other bindings. saves on code space, free
implementations --   if we use Glib::Boxed::copy we can actually
*remove* code from the bindings while increasing the effective number of
methods bound.

disadvantages: must look up the type of the reference from the blessed
class; this is slower, and it's possible to trick the type system by
re-blessing without setting @ISA properly.

despite the disadvantages, i've had this method implemented in my
working copy at home for several months, which is why i never noticed
that the TreeIter's copy was missing.  i haven't had any problems out of
it.

play with the method[1] in the attached patch and let me know what you
think.  if you can come up with a benchmark, that would be quite spiffy.



[1] to ensure that you're using the base method and not another one
higher up, try commenting out gdk_event_copy() or gtk_text_iter_copy()
and then try using them.


-- 
muppet <scott at asofyet dot org>

Attachment: boxed_copy.patch
Description: Text Data



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