summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2010-06-06 13:06:30 -0300
committerJohan Dahlin <johan@gnome.org>2010-06-06 13:09:08 -0300
commitb23af3a7cf01ae93da16fb144e350889c03bd592 (patch)
tree957d290bf404ee73f55f7dc51f5c42a9340ee80e
parentbb10200e76c99ff3695cd5dc85bba875642b99d2 (diff)
downloadgobject-introspection-b23af3a7cf01ae93da16fb144e350889c03bd592.tar.gz
[girepository] Move GIEnumInfo out of ginfo.ch
-rw-r--r--girepository/Makefile.am2
-rw-r--r--girepository/gienuminfo.c136
-rw-r--r--girepository/gienuminfo.h51
-rw-r--r--girepository/ginfo.c112
-rw-r--r--girepository/girepository.h19
5 files changed, 190 insertions, 130 deletions
diff --git a/girepository/Makefile.am b/girepository/Makefile.am
index db5e6d4d..836f28a0 100644
--- a/girepository/Makefile.am
+++ b/girepository/Makefile.am
@@ -3,6 +3,7 @@ girepo_HEADERS = \
giarginfo.h \
gibaseinfo.h \
gicallableinfo.h \
+ gienuminfo.h \
gierrordomaininfo.h \
gifunctioninfo.h \
girepository.h \
@@ -20,6 +21,7 @@ libgirepository_1_0_la_SOURCES = \
giarginfo.c \
gibaseinfo.c \
gicallableinfo.c \
+ gienuminfo.c \
gierrordomaininfo.c \
gifunctioninfo.c \
ginfo.c \
diff --git a/girepository/gienuminfo.c b/girepository/gienuminfo.c
new file mode 100644
index 00000000..ac8f0924
--- /dev/null
+++ b/girepository/gienuminfo.c
@@ -0,0 +1,136 @@
+/* GObject introspection: Enum 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 <glib.h>
+
+#include <girepository.h>
+#include "girepository-private.h"
+#include "gitypelib-internal.h"
+
+/**
+ * SECTION:gienuminfo
+ * @Short_description: Structs representing an enumeration and its values
+ * @Title: GIEnumInfo
+ *
+ * A GIEnumInfo represents an enumeration and a GIValueInfo struct represents a value
+ * of an enumeration. The GIEnumInfo contains a set of values and a type
+ * The GIValueInfo is fetched by calling g_enum_info_get_value() on a #GIEnumInfo.
+ */
+
+/**
+* g_enum_info_get_n_values:
+* @info: a #GIEnumInfo
+*
+* Obtain the number of values this enumeration contains.
+*
+* Returns: the number of enumeration values
+*/
+gint
+g_enum_info_get_n_values (GIEnumInfo *info)
+{
+ GIRealInfo *rinfo = (GIRealInfo *)info;
+ EnumBlob *blob;
+
+ g_return_val_if_fail (info != NULL, 0);
+ g_return_val_if_fail (GI_IS_ENUM_INFO (info), 0);
+
+ blob = (EnumBlob *)&rinfo->typelib->data[rinfo->offset];
+
+ return blob->n_values;
+}
+
+/**
+ * g_enum_info_get_value:
+ * @info: a #GIEnumInfo
+ * @n: index of value to fetch
+ *
+ * Obtain a value for this enumeration.
+ *
+ * Returns: (transfer full): the enumeration value or %NULL if type tag is wrong,
+ * free the struct with g_base_info_unref() when done.
+ */
+GIValueInfo *
+g_enum_info_get_value (GIEnumInfo *info,
+ gint n)
+{
+ GIRealInfo *rinfo = (GIRealInfo *)info;
+ Header *header;
+ gint offset;
+
+ g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (GI_IS_ENUM_INFO (info), NULL);
+
+ header = (Header *)rinfo->typelib->data;
+ offset = rinfo->offset + header->enum_blob_size
+ + n * header->value_blob_size;
+
+ return (GIValueInfo *) g_info_new (GI_INFO_TYPE_VALUE, (GIBaseInfo*)info, rinfo->typelib, offset);
+}
+
+/**
+ * g_enum_info_get_storage_type:
+ * @info: a #GIEnumInfo
+ *
+ * Obtain the tag of the type used for the enum in the C ABI. This will
+ * will be a signed or unsigned integral type.
+
+ * Note that in the current implementation the width of the type is
+ * computed correctly, but the signed or unsigned nature of the type
+ * may not match the sign of the type used by the C compiler.
+ *
+ * Return Value: the storage type for the enumeration
+ */
+GITypeTag
+g_enum_info_get_storage_type (GIEnumInfo *info)
+{
+ GIRealInfo *rinfo = (GIRealInfo *)info;
+ EnumBlob *blob;
+
+ g_return_val_if_fail (info != NULL, GI_TYPE_TAG_BOOLEAN);
+ g_return_val_if_fail (GI_IS_ENUM_INFO (info), GI_TYPE_TAG_BOOLEAN);
+
+ blob = (EnumBlob *)&rinfo->typelib->data[rinfo->offset];
+
+ return blob->storage_type;
+}
+
+/**
+ * g_value_info_get_value:
+ * @info: a #GIValueInfo
+ *
+ * Obtain the enumeration value of the #GIValueInfo.
+ *
+ * Returns: the enumeration value
+ */
+glong
+g_value_info_get_value (GIValueInfo *info)
+{
+ GIRealInfo *rinfo = (GIRealInfo *)info;
+ ValueBlob *blob;
+
+ g_return_val_if_fail (info != NULL, -1);
+ g_return_val_if_fail (GI_IS_VALUE_INFO (info), -1);
+
+ blob = (ValueBlob *)&rinfo->typelib->data[rinfo->offset];
+
+ return (glong)blob->value;
+}
+
diff --git a/girepository/gienuminfo.h b/girepository/gienuminfo.h
new file mode 100644
index 00000000..211ea6ef
--- /dev/null
+++ b/girepository/gienuminfo.h
@@ -0,0 +1,51 @@
+/* GObject introspection: Enum and Enum values
+ *
+ * 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 __GIENUMINFO_H__
+#define __GIENUMINFO_H__
+
+#if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION)
+#error "Only <girepository.h> can be included directly."
+#endif
+
+#include <gitypes.h>
+
+G_BEGIN_DECLS
+
+#define GI_IS_ENUM_INFO(info) \
+ ((g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_ENUM) || \
+ (g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_FLAGS))
+
+#define GI_IS_VALUE_INFO(info) \
+ (g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_VALUE)
+
+gint g_enum_info_get_n_values (GIEnumInfo *info);
+GIValueInfo * g_enum_info_get_value (GIEnumInfo *info,
+ gint n);
+GITypeTag g_enum_info_get_storage_type (GIEnumInfo *info);
+
+glong g_value_info_get_value (GIValueInfo *info);
+
+G_END_DECLS
+
+
+#endif /* __GIENUMINFO_H__ */
+
diff --git a/girepository/ginfo.c b/girepository/ginfo.c
index 3859aab9..5c5d0e4c 100644
--- a/girepository/ginfo.c
+++ b/girepository/ginfo.c
@@ -28,118 +28,6 @@
#include "gitypelib-internal.h"
#include "girepository-private.h"
-
-/* GIEnumInfo and GIValueInfo functions */
-
-/**
- * SECTION:gienuminfo
- * @Short_description: Structs representing an enumeration and its values
- * @Title: GIEnumInfo
- *
- * A GIEnumInfo represents an enumeration and a GIValueInfo struct represents a value
- * of an enumeration. The GIEnumInfo contains a set of values and a type
- * The GIValueInfo is fetched by calling g_enum_info_get_value() on a #GIEnumInfo.
- */
-
-/**
-* g_enum_info_get_n_values:
-* @info: a #GIEnumInfo
-*
-* Obtain the number of values this enumeration contains.
-*
-* Returns: the number of enumeration values
-*/
-gint
-g_enum_info_get_n_values (GIEnumInfo *info)
-{
- GIRealInfo *rinfo = (GIRealInfo *)info;
- EnumBlob *blob;
-
- g_return_val_if_fail (info != NULL, 0);
- g_return_val_if_fail (GI_IS_ENUM_INFO (info), 0);
-
- blob = (EnumBlob *)&rinfo->typelib->data[rinfo->offset];
-
- return blob->n_values;
-}
-
-/**
- * g_enum_info_get_value:
- * @info: a #GIEnumInfo
- * @n: index of value to fetch
- *
- * Obtain a value for this enumeration.
- *
- * Returns: (transfer full): the enumeration value or %NULL if type tag is wrong,
- * free the struct with g_base_info_unref() when done.
- */
-GIValueInfo *
-g_enum_info_get_value (GIEnumInfo *info,
- gint n)
-{
- GIRealInfo *rinfo = (GIRealInfo *)info;
- Header *header;
- gint offset;
-
- g_return_val_if_fail (info != NULL, NULL);
- g_return_val_if_fail (GI_IS_ENUM_INFO (info), NULL);
-
- header = (Header *)rinfo->typelib->data;
- offset = rinfo->offset + header->enum_blob_size
- + n * header->value_blob_size;
-
- return (GIValueInfo *) g_info_new (GI_INFO_TYPE_VALUE, (GIBaseInfo*)info, rinfo->typelib, offset);
-}
-
-/**
- * g_enum_info_get_storage_type:
- * @info: a #GIEnumInfo
- *
- * Obtain the tag of the type used for the enum in the C ABI. This will
- * will be a signed or unsigned integral type.
-
- * Note that in the current implementation the width of the type is
- * computed correctly, but the signed or unsigned nature of the type
- * may not match the sign of the type used by the C compiler.
- *
- * Return Value: the storage type for the enumeration
- */
-GITypeTag
-g_enum_info_get_storage_type (GIEnumInfo *info)
-{
- GIRealInfo *rinfo = (GIRealInfo *)info;
- EnumBlob *blob;
-
- g_return_val_if_fail (info != NULL, GI_TYPE_TAG_BOOLEAN);
- g_return_val_if_fail (GI_IS_ENUM_INFO (info), GI_TYPE_TAG_BOOLEAN);
-
- blob = (EnumBlob *)&rinfo->typelib->data[rinfo->offset];
-
- return blob->storage_type;
-}
-
-/**
- * g_value_info_get_value:
- * @info: a #GIValueInfo
- *
- * Obtain the enumeration value of the #GIValueInfo.
- *
- * Returns: the enumeration value
- */
-glong
-g_value_info_get_value (GIValueInfo *info)
-{
- GIRealInfo *rinfo = (GIRealInfo *)info;
- ValueBlob *blob;
-
- g_return_val_if_fail (info != NULL, -1);
- g_return_val_if_fail (GI_IS_VALUE_INFO (info), -1);
-
- blob = (ValueBlob *)&rinfo->typelib->data[rinfo->offset];
-
- return (glong)blob->value;
-}
-
/* GIFieldInfo functions */
/**
diff --git a/girepository/girepository.h b/girepository/girepository.h
index 89a66b99..c9ebca6d 100644
--- a/girepository/girepository.h
+++ b/girepository/girepository.h
@@ -29,6 +29,7 @@
#include <giarginfo.h>
#include <gibaseinfo.h>
#include <gicallableinfo.h>
+#include <gienuminfo.h>
#include <gierrordomaininfo.h>
#include <gifunctioninfo.h>
#include <gitypeinfo.h>
@@ -149,13 +150,6 @@ void gi_cclosure_marshal_generic (GClosure *closure,
gpointer invocation_hint,
gpointer marshal_data);
-/* GIValueInfo */
-
-#define GI_IS_VALUE_INFO(info) \
- (g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_VALUE)
-
-glong g_value_info_get_value (GIValueInfo *info);
-
/* GIFieldInfo */
@@ -227,17 +221,6 @@ const gchar * g_registered_type_info_get_type_name (GIRegisteredTypeInf
const gchar * g_registered_type_info_get_type_init (GIRegisteredTypeInfo *info);
GType g_registered_type_info_get_g_type (GIRegisteredTypeInfo *info);
-/* GIEnumInfo */
-
-#define GI_IS_ENUM_INFO(info) \
- ((g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_ENUM) || \
- (g_base_info_get_type((GIBaseInfo*)info) == GI_INFO_TYPE_FLAGS))
-
-gint g_enum_info_get_n_values (GIEnumInfo *info);
-GIValueInfo * g_enum_info_get_value (GIEnumInfo *info,
- gint n);
-GITypeTag g_enum_info_get_storage_type (GIEnumInfo *info);
-
/* GIObjectInfo */
#define GI_IS_OBJECT_INFO(info) \