diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index 0e7696ef3..e5a16be5b 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,7 @@ +2002-10-15 Matthias Clasen + + * gobject/gobject-sections.txt: Add g_type_interface_prerequisites. + 2002-10-14 Matthias Clasen * gobject/Makefile.am (dist-hook): diff --git a/docs/reference/gobject/gobject-sections.txt b/docs/reference/gobject/gobject-sections.txt index 023a81ce5..efe9e10a5 100644 --- a/docs/reference/gobject/gobject-sections.txt +++ b/docs/reference/gobject/gobject-sections.txt @@ -55,6 +55,7 @@ g_type_interface_peek g_type_interface_peek_parent g_type_children g_type_interfaces +g_type_interface_prerequisites g_type_set_qdata g_type_get_qdata g_type_query diff --git a/gobject/ChangeLog b/gobject/ChangeLog index 9c3e55d0e..d31dd819c 100644 --- a/gobject/ChangeLog +++ b/gobject/ChangeLog @@ -1,3 +1,8 @@ +2002-10-15 Matthias Clasen + + * gtype.c (g_type_interface_prerequisites): New function to obtain + the prerequisites of an interface type. + Sat Oct 12 22:02:32 2002 Tim Janik * merged up from 2.0: diff --git a/gobject/gtype.c b/gobject/gtype.c index f5d341e9f..f9d0edd4e 100644 --- a/gobject/gtype.c +++ b/gobject/gtype.c @@ -1220,6 +1220,52 @@ g_type_interface_add_prerequisite (GType interface_type, } } +/** + * g_type_interface_prerequisites: + * @interface_type: an interface type + * @n_prerequisites: location to return the number of prerequisites, or %NULL + * + * Returns the prerequisites of an interfaces type. + * + * Return value: a newly-allocated zero-terminated array of #GType containing + * the prerequisites of @interface_type + **/ +GType* /* free result */ +g_type_interface_prerequisites (GType interface_type, + guint *n_prerequisites) +{ + TypeNode *iface; + + g_return_val_if_fail (G_TYPE_IS_INTERFACE (interface_type), NULL); + + iface = lookup_type_node_I (interface_type); + if (iface) + { + GType *prerequisites; + guint i; + + G_READ_LOCK (&type_rw_lock); + prerequisites = g_new (GType, IFACE_NODE_N_PREREQUISITES (iface) + 1); + for (i = 0; i < IFACE_NODE_N_PREREQUISITES (iface); i++) + prerequisites[i] = IFACE_NODE_PREREQUISITES (iface)[i]; + prerequisites[i] = 0; + + if (n_prerequisites) + *n_prerequisites = IFACE_NODE_N_PREREQUISITES (iface); + G_READ_UNLOCK (&type_rw_lock); + + return prerequisites; + } + else + { + if (n_prerequisites) + *n_prerequisites = 0; + + return NULL; + } +} + + static IFaceHolder* type_iface_peek_holder_L (TypeNode *iface, GType instance_type) diff --git a/gobject/gtype.h b/gobject/gtype.h index 9c9ea0910..70570f5bb 100644 --- a/gobject/gtype.h +++ b/gobject/gtype.h @@ -295,6 +295,8 @@ void g_type_add_interface_dynamic (GType instance_type, GTypePlugin *plugin); void g_type_interface_add_prerequisite (GType interface_type, GType prerequisite_type); +GType *g_type_interface_prerequisites (GType interface_type, + guint *n_prerequisites); /* --- protected (for fundamental type implementations) --- */