summaryrefslogtreecommitdiff
path: root/girepository/gienuminfo.c
diff options
context:
space:
mode:
authorTorsten Schönfeld <kaffeetisch@gmx.de>2011-08-13 17:28:30 +0200
committerTorsten Schönfeld <kaffeetisch@gmx.de>2011-08-16 18:43:23 +0200
commit169b206cbb4b347e4b17854e8f0c62a40404f803 (patch)
tree929ddaefcedf7c9d4778ea355e58f0b1cc2f2f96 /girepository/gienuminfo.c
parent64848acb817369436d629d153c5750789c0addc3 (diff)
downloadgobject-introspection-169b206cbb4b347e4b17854e8f0c62a40404f803.tar.gz
Allow enums and bitfields to have static methods
This uses the same backcompat machinery that was introduced for static methods for non-class types, so this change does not break users of the existing presentations. New libgirepository API: g_enum_info_get_n_methods g_enum_info_get_method https://bugzilla.gnome.org/show_bug.cgi?id=656499
Diffstat (limited to 'girepository/gienuminfo.c')
-rw-r--r--girepository/gienuminfo.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/girepository/gienuminfo.c b/girepository/gienuminfo.c
index 338a46ee..90b19a96 100644
--- a/girepository/gienuminfo.c
+++ b/girepository/gienuminfo.c
@@ -112,6 +112,61 @@ g_enum_info_get_value (GIEnumInfo *info,
}
/**
+ * g_enum_info_get_n_methods:
+ * @info: a #GIEnumInfo
+ *
+ * Obtain the number of methods that this enum type has.
+ *
+ * Returns: number of methods
+ */
+gint
+g_enum_info_get_n_methods (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_methods;
+}
+
+/**
+ * g_enum_info_get_method:
+ * @info: a #GIEnumInfo
+ * @n: index of method to get
+ *
+ * Obtain an enum type method at index @n.
+ *
+ * Returns: (transfer full): the #GIFunctionInfo. Free the struct by calling
+ * g_base_info_unref() when done.
+ */
+GIFunctionInfo *
+g_enum_info_get_method (GIEnumInfo *info,
+ gint n)
+{
+ gint offset;
+ GIRealInfo *rinfo = (GIRealInfo *)info;
+ Header *header;
+ EnumBlob *blob;
+
+ g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (GI_IS_ENUM_INFO (info), NULL);
+
+ header = (Header *)rinfo->typelib->data;
+ blob = (EnumBlob *)&rinfo->typelib->data[rinfo->offset];
+
+ offset = rinfo->offset + header->enum_blob_size
+ + blob->n_values * header->value_blob_size
+ + n * header->function_blob_size;
+
+ return (GIFunctionInfo *) g_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info,
+ rinfo->typelib, offset);
+}
+
+/**
* g_enum_info_get_storage_type:
* @info: a #GIEnumInfo
*