Re: Questioning non-NULL boxed types



[ Discussion is of removing the boxed_init function for the two boxed types
  in GObject that have one; no boxed types in atk/pango/gtk+ have a boxed_init
  function ]

Owen Taylor <otaylor redhat com> writes:

> Basically, my opinion is that if we get rid of the boxed_init parameter
> to g_boxed_type_register_static, then this is a good change. We have
> the very simple notion that Boxed types are pointers with a copy/free
> function, and can always be NULL. Language bindings can then map all
> boxed types in essentially the same way.
> 
> It's a nice simplification of the idea of a boxed type.
> 
> If we don't get rid of the boxed_init function, then I really don't care
> much one way or the other, since I don't have any uses in mind for either
> the GString or GValueArray types. There is some danger that boxed types with 
> non-NULL boxed_init function might need custom handling in language bindings,
> or things may act a little suprising. (Setting a GString typed property
> to undef in Perl would not be an error but result to it being set to a
> zero-length string.)

One thing that possibly needs to be taken into account here is that libbonobo
actually does use boxed_init functions for two types:

                type = g_boxed_type_register_static ("BonoboCorbaAny", corba_any_init,
                                                     corba_any_copy, corba_any_free, TRUE);

                type = g_boxed_type_register_static ("BonoboCorbaException", corba_exception_init,
                                                     corba_exception_copy, corba_exception_free, TRUE);

While not allowing NULL here does map better to CORBA, which only allows 'nil'
for object references, it doesn't look like to me that allowing NULL for these
would cause any more problems than it would for, say, G_TYPE_STRING. In most (all?)
cases, these types are being used for closure callbacks from the Bonobo core,
so the Bonobo core simply needs to not put NULLs where they dont' belong.

Regards,
                                                    Owen




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