From baf36f793e3b94c95c9b69595369ac92ddbc4d65 Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Sun, 6 Jun 2010 19:28:35 -0300 Subject: [PATCH] [girepository] Move GIRegisteredTypeInfo out of ginfo.ch --- Makefile.am | 6 ++-- ginfo.c | 48 --------------------------- giregisteredtypeinfo.c | 75 ++++++++++++++++++++++++++++++++++++++++++ giregisteredtypeinfo.h | 51 ++++++++++++++++++++++++++++ girepository.h | 14 +------- 5 files changed, 131 insertions(+), 63 deletions(-) create mode 100644 giregisteredtypeinfo.c create mode 100644 giregisteredtypeinfo.h diff --git a/Makefile.am b/Makefile.am index 8fccc93ba..34cdfabfe 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,6 +7,7 @@ girepo_HEADERS = \ gierrordomaininfo.h \ gifieldinfo.h \ gifunctioninfo.h \ + giregisteredtypeinfo.h \ girepository.h \ girffi.h \ gitypeinfo.h \ @@ -27,15 +28,16 @@ libgirepository_1_0_la_SOURCES = \ gifunctioninfo.c \ ginfo.c \ ginvoke.c \ + giregisteredtypeinfo.c \ girepository.c \ girepository-private.h \ girffi.c \ girffi.h \ girffi-private.h \ - glib-compat.h \ gitypeinfo.c \ gitypelib.c \ - gitypelib-internal.h + gitypelib-internal.h \ + glib-compat.h libgirepository_1_0_la_CPPFLAGS = $(GIREPO_CFLAGS) libgirepository_1_0_la_LIBADD = $(GIREPO_LIBS) diff --git a/ginfo.c b/ginfo.c index 825ad5d65..5048431a0 100644 --- a/ginfo.c +++ b/ginfo.c @@ -28,54 +28,6 @@ #include "gitypelib-internal.h" #include "girepository-private.h" -/* GIRegisteredTypeInfo functions */ -const gchar * -g_registered_type_info_get_type_name (GIRegisteredTypeInfo *info) -{ - GIRealInfo *rinfo = (GIRealInfo *)info; - RegisteredTypeBlob *blob = (RegisteredTypeBlob *)&rinfo->typelib->data[rinfo->offset]; - - if (blob->gtype_name) - return g_typelib_get_string (rinfo->typelib, blob->gtype_name); - - return NULL; -} - -const gchar * -g_registered_type_info_get_type_init (GIRegisteredTypeInfo *info) -{ - GIRealInfo *rinfo = (GIRealInfo *)info; - RegisteredTypeBlob *blob = (RegisteredTypeBlob *)&rinfo->typelib->data[rinfo->offset]; - - if (blob->gtype_init) - return g_typelib_get_string (rinfo->typelib, blob->gtype_init); - - return NULL; -} - -GType -g_registered_type_info_get_g_type (GIRegisteredTypeInfo *info) -{ - const char *type_init; - GType (* get_type_func) (void); - GIRealInfo *rinfo = (GIRealInfo*)info; - - type_init = g_registered_type_info_get_type_init (info); - - if (type_init == NULL) - return G_TYPE_NONE; - else if (!strcmp (type_init, "intern")) - return G_TYPE_OBJECT; - - get_type_func = NULL; - if (!g_typelib_symbol (rinfo->typelib, - type_init, - (void**) &get_type_func)) - return G_TYPE_NONE; - - return (* get_type_func) (); -} - /* GIStructInfo functions */ gint g_struct_info_get_n_fields (GIStructInfo *info) diff --git a/giregisteredtypeinfo.c b/giregisteredtypeinfo.c new file mode 100644 index 000000000..944444f01 --- /dev/null +++ b/giregisteredtypeinfo.c @@ -0,0 +1,75 @@ +/* GObject introspection: Registered Type implementation + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include + +#include +#include "girepository-private.h" +#include "gitypelib-internal.h" +#include "girffi.h" + +const gchar * +g_registered_type_info_get_type_name (GIRegisteredTypeInfo *info) +{ + GIRealInfo *rinfo = (GIRealInfo *)info; + RegisteredTypeBlob *blob = (RegisteredTypeBlob *)&rinfo->typelib->data[rinfo->offset]; + + if (blob->gtype_name) + return g_typelib_get_string (rinfo->typelib, blob->gtype_name); + + return NULL; +} + +const gchar * +g_registered_type_info_get_type_init (GIRegisteredTypeInfo *info) +{ + GIRealInfo *rinfo = (GIRealInfo *)info; + RegisteredTypeBlob *blob = (RegisteredTypeBlob *)&rinfo->typelib->data[rinfo->offset]; + + if (blob->gtype_init) + return g_typelib_get_string (rinfo->typelib, blob->gtype_init); + + return NULL; +} + +GType +g_registered_type_info_get_g_type (GIRegisteredTypeInfo *info) +{ + const char *type_init; + GType (* get_type_func) (void); + GIRealInfo *rinfo = (GIRealInfo*)info; + + type_init = g_registered_type_info_get_type_init (info); + + if (type_init == NULL) + return G_TYPE_NONE; + else if (!strcmp (type_init, "intern")) + return G_TYPE_OBJECT; + + get_type_func = NULL; + if (!g_typelib_symbol (rinfo->typelib, + type_init, + (void**) &get_type_func)) + return G_TYPE_NONE; + + return (* get_type_func) (); +} + diff --git a/giregisteredtypeinfo.h b/giregisteredtypeinfo.h new file mode 100644 index 000000000..8a6332147 --- /dev/null +++ b/giregisteredtypeinfo.h @@ -0,0 +1,51 @@ +/* GObject introspection: Registered Type + * + * Copyright (C) 2005 Matthias Clasen + * Copyright (C) 2008,2009 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GIREGISTEREDTYPEINFO_H__ +#define __GIREGISTEREDTYPEINFO_H__ + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +/* GIRegisteredTypeInfo */ + +#define GI_IS_REGISTERED_TYPE_INFO(info) \ + ((g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_ENUM) || \ + (g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_INTERFACE) || \ + (g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_OBJECT) || \ + (g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_STRUCT) || \ + (g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_UNION)) + +const gchar * g_registered_type_info_get_type_name (GIRegisteredTypeInfo *info); +const gchar * g_registered_type_info_get_type_init (GIRegisteredTypeInfo *info); +GType g_registered_type_info_get_g_type (GIRegisteredTypeInfo *info); + +G_END_DECLS + + +#endif /* __GIREGISTEREDTYPEINFO_H__ */ + diff --git a/girepository.h b/girepository.h index d03845937..47d02b59c 100644 --- a/girepository.h +++ b/girepository.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -191,19 +192,6 @@ gsize g_struct_info_get_alignment (GIStructInfo *info); gboolean g_struct_info_is_gtype_struct (GIStructInfo *info); gboolean g_struct_info_is_foreign (GIStructInfo *info); -/* GIRegisteredTypeInfo */ - -#define GI_IS_REGISTERED_TYPE_INFO(info) \ - ((g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_ENUM) || \ - (g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_INTERFACE) || \ - (g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_OBJECT) || \ - (g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_STRUCT) || \ - (g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_UNION)) - -const gchar * g_registered_type_info_get_type_name (GIRegisteredTypeInfo *info); -const gchar * g_registered_type_info_get_type_init (GIRegisteredTypeInfo *info); -GType g_registered_type_info_get_g_type (GIRegisteredTypeInfo *info); - /* GIObjectInfo */ #define GI_IS_OBJECT_INFO(info) \