From dab5e1ddaf60e5abaef4274507f1b03366c4166b Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Sun, 6 Jun 2010 13:01:26 -0300 Subject: [PATCH] [girepository] Move GIErrorDomainInfo out of ginfo.ch --- Makefile.am | 4 ++- gierrordomaininfo.c | 87 +++++++++++++++++++++++++++++++++++++++++++++ gierrordomaininfo.h | 44 +++++++++++++++++++++++ ginfo.c | 62 -------------------------------- girepository.h | 10 +----- 5 files changed, 135 insertions(+), 72 deletions(-) create mode 100644 gierrordomaininfo.c create mode 100644 gierrordomaininfo.h diff --git a/Makefile.am b/Makefile.am index 260d05da2..db5e6d4d0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,6 +3,7 @@ girepo_HEADERS = \ giarginfo.h \ gibaseinfo.h \ gicallableinfo.h \ + gierrordomaininfo.h \ gifunctioninfo.h \ girepository.h \ girffi.h \ @@ -18,8 +19,9 @@ libgirepository_1_0_la_SOURCES = \ gfield.c \ giarginfo.c \ gibaseinfo.c \ - gifunctioninfo.c \ gicallableinfo.c \ + gierrordomaininfo.c \ + gifunctioninfo.c \ ginfo.c \ ginvoke.c \ girepository.c \ diff --git a/gierrordomaininfo.c b/gierrordomaininfo.c new file mode 100644 index 000000000..aa06719ff --- /dev/null +++ b/gierrordomaininfo.c @@ -0,0 +1,87 @@ +/* GObject introspection: ErrorDomain 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" + +/** + * SECTION:gierrordomaininfo + * @Short_description: Struct representing an error domain + * @Title: GIErrorDomainInfo + * + * A GIErrorDomainInfo struct represents a domain of a #GError. + * An error domain is associated with a #GQuark and contains a pointer + * to an enum with all the error codes. + */ + +/** + * g_error_domain_info_get_quark: + * @info: a #GIErrorDomainInfo + * + * Obtain a string representing the quark for this error domain. + * %NULL will be returned if the type tag is wrong or if a quark is + * missing in the typelib. + * + * Returns: the quark represented as a string or %NULL + */ +const gchar * +g_error_domain_info_get_quark (GIErrorDomainInfo *info) +{ + GIRealInfo *rinfo = (GIRealInfo *)info; + ErrorDomainBlob *blob; + + g_return_val_if_fail (info != NULL, NULL); + g_return_val_if_fail (GI_IS_ERROR_DOMAIN_INFO (info), NULL); + + blob = (ErrorDomainBlob *)&rinfo->typelib->data[rinfo->offset]; + + return g_typelib_get_string (rinfo->typelib, blob->get_quark); +} + +/** + * g_error_domain_info_get_codes: + * @info: a #GIErrorDomainInfo + * + * Obtain the enum containing all the error codes for this error domain. + * The return value will have a #GIInfoType of %GI_INFO_TYPE_ERROR_DOMAIN + * + * Returns: (transfer full): the error domain or %NULL if type tag is wrong, + * free the struct with g_base_info_unref() when done. + */ +GIInterfaceInfo * +g_error_domain_info_get_codes (GIErrorDomainInfo *info) +{ + GIRealInfo *rinfo = (GIRealInfo *)info; + ErrorDomainBlob *blob; + + g_return_val_if_fail (info != NULL, NULL); + g_return_val_if_fail (GI_IS_ERROR_DOMAIN_INFO (info), NULL); + + blob = (ErrorDomainBlob *)&rinfo->typelib->data[rinfo->offset]; + + return (GIInterfaceInfo *) _g_info_from_entry (rinfo->repository, + rinfo->typelib, blob->error_codes); +} + + diff --git a/gierrordomaininfo.h b/gierrordomaininfo.h new file mode 100644 index 000000000..9c2968bc1 --- /dev/null +++ b/gierrordomaininfo.h @@ -0,0 +1,44 @@ +/* GObject introspection: Error Domain + * + * 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 __GIERRORDOMAININFO_H__ +#define __GIERRORDOMAININFO_H__ + +#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +#define GI_IS_ERROR_DOMAIN_INFO(info) \ + (g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_ERROR_DOMAIN) + +const gchar * g_error_domain_info_get_quark (GIErrorDomainInfo *info); +GIInterfaceInfo * g_error_domain_info_get_codes (GIErrorDomainInfo *info); + + +G_END_DECLS + + +#endif /* __GIERRORDOMAININFO_H__ */ + diff --git a/ginfo.c b/ginfo.c index 47cbd0086..3859aab90 100644 --- a/ginfo.c +++ b/ginfo.c @@ -29,68 +29,6 @@ #include "girepository-private.h" -/* GIErrorDomainInfo functions */ - -/** - * SECTION:gierrordomaininfo - * @Short_description: Struct representing an error domain - * @Title: GIErrorDomainInfo - * - * A GIErrorDomainInfo struct represents a domain of a #GError. - * An error domain is associated with a #GQuark and contains a pointer - * to an enum with all the error codes. - */ - -/** - * g_error_domain_info_get_quark: - * @info: a #GIErrorDomainInfo - * - * Obtain a string representing the quark for this error domain. - * %NULL will be returned if the type tag is wrong or if a quark is - * missing in the typelib. - * - * Returns: the quark represented as a string or %NULL - */ -const gchar * -g_error_domain_info_get_quark (GIErrorDomainInfo *info) -{ - GIRealInfo *rinfo = (GIRealInfo *)info; - ErrorDomainBlob *blob; - - g_return_val_if_fail (info != NULL, NULL); - g_return_val_if_fail (GI_IS_ERROR_DOMAIN_INFO (info), NULL); - - blob = (ErrorDomainBlob *)&rinfo->typelib->data[rinfo->offset]; - - return g_typelib_get_string (rinfo->typelib, blob->get_quark); -} - -/** - * g_error_domain_info_get_codes: - * @info: a #GIErrorDomainInfo - * - * Obtain the enum containing all the error codes for this error domain. - * The return value will have a #GIInfoType of %GI_INFO_TYPE_ERROR_DOMAIN - * - * Returns: (transfer full): the error domain or %NULL if type tag is wrong, - * free the struct with g_base_info_unref() when done. - */ -GIInterfaceInfo * -g_error_domain_info_get_codes (GIErrorDomainInfo *info) -{ - GIRealInfo *rinfo = (GIRealInfo *)info; - ErrorDomainBlob *blob; - - g_return_val_if_fail (info != NULL, NULL); - g_return_val_if_fail (GI_IS_ERROR_DOMAIN_INFO (info), NULL); - - blob = (ErrorDomainBlob *)&rinfo->typelib->data[rinfo->offset]; - - return (GIInterfaceInfo *) _g_info_from_entry (rinfo->repository, - rinfo->typelib, blob->error_codes); -} - - /* GIEnumInfo and GIValueInfo functions */ /** diff --git a/girepository.h b/girepository.h index 30a2fdea8..89a66b999 100644 --- a/girepository.h +++ b/girepository.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -148,15 +149,6 @@ void gi_cclosure_marshal_generic (GClosure *closure, gpointer invocation_hint, gpointer marshal_data); -/* GIErrorDomainInfo */ - -#define GI_IS_ERROR_DOMAIN_INFO(info) \ - (g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_ERROR_DOMAIN) - -const gchar * g_error_domain_info_get_quark (GIErrorDomainInfo *info); -GIInterfaceInfo * g_error_domain_info_get_codes (GIErrorDomainInfo *info); - - /* GIValueInfo */ #define GI_IS_VALUE_INFO(info) \