From e56744c9073bc9cf1127bad90b01a25236893e8f Mon Sep 17 00:00:00 2001 From: Mark Doffman Date: Mon, 10 Mar 2008 17:47:20 +0000 Subject: [PATCH] girepository/ginfo.c girepository/girepository.h tools/generate.c 2008-02-21 Mark Doffman * girepository/ginfo.c * girepository/girepository.h * tools/generate.c Add a function to check if an enum is registered or not. Previously anything testing this relied on the g-type string offset having a value of 0. * girepository/gmetadata.c * girepository/gmetadata.h * tools/generate.c Remove unneccesary or erroneous checks. There were two metadata validation checks which made sure that the blob sizes were the same as some magic numbers compiled into the code. This is wrong as it breaks any forwards compatibility that may be possible. Checks were also present that made sure that unregistered type blobs had a value of 0 in the g-type offset field. This is unneccessary. If a type blob is unregistered then any value in its g-type field is simply invalid. WARNING: This commit does not compile. It is a partial change. svn path=/trunk/; revision=132 --- girepository/tools/generate.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/girepository/tools/generate.c b/girepository/tools/generate.c index 0a3c3a5a3..7c4569759 100644 --- a/girepository/tools/generate.c +++ b/girepository/tools/generate.c @@ -574,16 +574,22 @@ write_enum_info (const gchar *namespace, FILE *file) { const gchar *name; - const gchar *type_name; - const gchar *type_init; + const gchar *type_name = NULL; + const gchar *type_init = NULL; gboolean deprecated; gint i; name = g_base_info_get_name ((GIBaseInfo *)info); deprecated = g_base_info_is_deprecated ((GIBaseInfo *)info); - type_name = g_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info); - type_init = g_registered_type_info_get_type_init ((GIRegisteredTypeInfo*)info); + /* Make sure this is a registered enum before filling out the + * GType information + */ + if (g_enum_info_is_registered ((GIEnumInfo *)info)) + { + type_name = g_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info); + type_init = g_registered_type_info_get_type_init ((GIRegisteredTypeInfo*)info); + } if (g_base_info_get_type ((GIBaseInfo *)info) == GI_INFO_TYPE_ENUM) g_fprintf (file, "