Additional uses of gpointer for GObject



Some while ago, we discussed the cases in gobject.h where gpointer
is used where GObject would normally be present.

As I recall, we came up with the following principles:

  A) g_object_ref() and g_object_unref() would be special cased as
    a) not really methods, so they can be "special"

  B) Additional places where proper typing would make the chained-varargs
    style of GTK+ programming painful would also be permitted.

    (This style is used extensively in BEAST, GLE, and very occasionally 
    elsewhere.)

So, I just went over the remaining cases in GObject with these
principles in mind:

===
  gpointer  g_object_new               (GType         object_type,
                                        const gchar  *first_property_name,
                                        ...);
===

OK, by B)

===
  gpointer  g_object_new_valist        (GType         object_type,
                                        const gchar  *first_property_name,
                                        va_list       var_args);
===

Return value should be GObject:

 this function would never be used in chained varargs
 locations - it's basically only going to be used in small amounts
 of specific code.

===
  gpointer  g_object_set               (gpointer      object,
                                        const gchar  *first_property_name,
                                        ...);
===

Return value should be removed

  I don't see when you'd want to chain the results of g_object_set().

First parameter probably should be GObject
  
  You shouldn't need to chain to this function very often if at all - 
  you can pass any properties to g_object_object(). Also, if you are
  chaining, the return value of g_object_new() is a gpointer
  already

===
  void      g_object_get               (gpointer      object,
                                        const gchar  *first_property_name,
                                        ...);
===

First parameter should be GObject 

  This function isn't involved in chaining.

===
  gpointer  g_object_connect           (gpointer      object,
                                        const gchar  *signal_spec,
                                        ...);
===

Return value OK, by B)

First parameter should be changed to GObject

 When chaining, the return value from g_object_new() is already
 a pointer.

===
  gpointer  g_object_disconnect        (gpointer      object,
                                        const gchar  *signal_spec,
                                        ...);
===

Return value should be removed

 This function would never need to be chained

First parameter should be a GObject

 This function isn't involved in chaining - it's just a GObject
 method.

===
  gpointer  g_object_ref               (gpointer      object);
  void      g_object_unref             (gpointer      object);
===

OK by A).

===
  gpointer  g_value_get_object         (const GValue *value);
===

Return value should be gpointer - though maybe can be snuck in as
gpointer on the principle that casting return values is more
painful than parameters.

===
  GClosure* g_cclosure_new_object      (GCallback     callback_func,
                                        gpointer      object);
===

Second parameter should be GObject

 Not a function that is going to be used chained

===
  GClosure* g_cclosure_new_object_swap (GCallback     callback_func,
                                        gpointer      object);
===

Second parameter should be GObject

 Not a function that is going to be used chained

===
  guint     g_signal_connect_object    (gpointer      instance,
                                        const gchar  *detailed_signal,
                                        GCallback     c_handler,
                                        gpointer      gobject,
                                        gboolean      swapped,
                                        gboolean      after);
===

Fourth parameter should be GObject

 Not a function that is going to be used chained





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