Re: G_DEFINE_TYPE macros

W liście z sob, 17-07-2004, godz. 23:22, Ryan McDougall pisze: 
> > 	I have some questions about how the macros are suppose to be used: 
> > 
> > Why is parent_class declared static in the expansion? I don't think I've
> > ever read where this is required or even a good idea.

because it's purely for the convenience of implementation code, there's
no need to export that variable

> > How does one add class_finalize or base_init/_finalize to the GTypeInfo?
> > It seems that only class_init and instance_init are specified.

in G_TYPE_DEFINE(), yes. You need to write boilerplate manually if you
want to specify them.

> In addendum, why are the the functions declared static? Is that
> necessary or just good practise?

It's necessary good practice ;). They are private functions, so they
should not either clutter global namespace, or be accessible from
outside. This is good practice, but in bigger chunks of code (such as
GTK+) it quickly becomes necessary, just to preserve ABI compat if
nothing else.

In general, if you don't have good reason to _not_ make given global
static (ie. it's not part of public interface), it means it should be
made static. You can always make something public if needed, but the
opposite is not easy (or even possible in stable release)


"Tautologizm to coś tautologicznego"
     Mathrick <mathrick swat pl>

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