Re: GType::register RFE

i love replying to myself, it makes me look crazy.

muppet said:
i don't dispute your need to be able to run stuff at class_init time --- what
i'm saying is that there's no need to put that stuff into a function, because
any code placed immediately after Glib::Type::register will run after the
class has been initialized.

to clarify, according to
, the class_init runs last, that is, after your base_inits --- so as long as
you execute your class_init stuff before you go on to create more classes that
may inherit from it, you're fine.  with this, the typical setup of a perl
module is fine.

sorry to beat a dead horse --- that's probably the fifth time i've said it,
but i feel like it's not coming out the way i want to.

 (and if not, you can force it to exist when you
get into an xsub called there.)

in fact, to prove this to myself, i wrote an extra little xsub in Glib::Type:

  do_something_strange_and_unnatural (class, const char * package)
        GType gtype;
        GTypeClass * class;
        gtype = gperl_type_from_package (package);
        class = g_type_class_peek (gtype);
        warn ("  %s => %s %d\n", package, g_type_name (gtype), gtype);
        warn ("  0x%p => %s\n", class, g_type_name (G_TYPE_FROM_CLASS (class)));

then i called this from various INIT_BASE and post-registration spots, and
never got anything i didn't expect.

an implementation of that algorithm, and a sample program, and a t-directory
test version of the sample are attached.

looks like it contained a vestigal INIT_CLASS that won't be called.  bad
muppet, no cookie.

muppet <scott at asofyet dot org>

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