[gobject-introspection] [giregisteredtypeinfo] Document and check parameters
- From: Johan Dahlin <johan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] [giregisteredtypeinfo] Document and check parameters
- Date: Mon, 7 Jun 2010 02:05:48 +0000 (UTC)
commit 82df98a74d83e39a7b120269e6cdb2c067c941ba
Author: Johan Dahlin <johan gnome org>
Date: Sun Jun 6 23:04:15 2010 -0300
[giregisteredtypeinfo] Document and check parameters
girepository/giregisteredtypeinfo.c | 61 +++++++++++++++++++++++++++++++++-
1 files changed, 59 insertions(+), 2 deletions(-)
---
diff --git a/girepository/giregisteredtypeinfo.c b/girepository/giregisteredtypeinfo.c
index 0f3493f..3f308d2 100644
--- a/girepository/giregisteredtypeinfo.c
+++ b/girepository/giregisteredtypeinfo.c
@@ -28,11 +28,40 @@
#include "gitypelib-internal.h"
#include "girffi.h"
+/**
+ * SECTION:giregisteredtypeinfo
+ * @Short_description: Struct representing a struct with a GType
+ * @Title: GIRegisteredTypeInfo
+ *
+ * GIRegisteredTypeInfo represents an entity with a GType associated. Could
+ * be either a #GIEnumInfo, #GIInterfaceInfo, #GIObjectInfo, #GIStructInfo or a
+ * #GIUnionInfo.
+ *
+ * A registered type info struct has a name and a type function.
+ * To get the name call g_registered_type_info_get_type_name().
+ * Most users want to call g_registered_type_info_get_g_type() and don't worry
+ * about the rest of the details.
+ */
+
+/**
+ * g_registered_type_info_get_type_name:
+ * @info: a #GIRegisteredTypeInfo
+ *
+ * Obtain the type name of the struct within the GObject type system.
+ * This type can be passed to g_type_name() to get a #GType.
+ *
+ * Returns: the type name
+ */
const gchar *
g_registered_type_info_get_type_name (GIRegisteredTypeInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
- RegisteredTypeBlob *blob = (RegisteredTypeBlob *)&rinfo->typelib->data[rinfo->offset];
+ RegisteredTypeBlob *blob;
+
+ g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (GI_IS_REGISTERED_TYPE_INFO (info), NULL);
+
+ blob = (RegisteredTypeBlob *)&rinfo->typelib->data[rinfo->offset];
if (blob->gtype_name)
return g_typelib_get_string (rinfo->typelib, blob->gtype_name);
@@ -40,11 +69,28 @@ g_registered_type_info_get_type_name (GIRegisteredTypeInfo *info)
return NULL;
}
+/**
+ * g_registered_type_info_get_type_init:
+ * @info: a #GIRegisteredTypeInfo
+ *
+ * Obtain the type init function for @info. The type init function is the
+ * function which will register the GType within the GObject type system.
+ * Usually this is not called by langauge bindings or applications, use
+ * g_registered_type_info_get_g_type() directly instead.
+ *
+ * Returns: the symbol name of the type init function, suitable for
+ * passing into g_module_symbol().
+ */
const gchar *
g_registered_type_info_get_type_init (GIRegisteredTypeInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
- RegisteredTypeBlob *blob = (RegisteredTypeBlob *)&rinfo->typelib->data[rinfo->offset];
+ RegisteredTypeBlob *blob;
+
+ g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (GI_IS_REGISTERED_TYPE_INFO (info), NULL);
+
+ blob = (RegisteredTypeBlob *)&rinfo->typelib->data[rinfo->offset];
if (blob->gtype_init)
return g_typelib_get_string (rinfo->typelib, blob->gtype_init);
@@ -52,6 +98,14 @@ g_registered_type_info_get_type_init (GIRegisteredTypeInfo *info)
return NULL;
}
+/**
+ * g_registered_type_info_get_g_type:
+ * @info: a #GIRegisteredTypeInfo
+ *
+ * Obtain the #GType for this registered type.
+ *
+ * Returns: the #GType.
+ */
GType
g_registered_type_info_get_g_type (GIRegisteredTypeInfo *info)
{
@@ -59,6 +113,9 @@ g_registered_type_info_get_g_type (GIRegisteredTypeInfo *info)
GType (* get_type_func) (void);
GIRealInfo *rinfo = (GIRealInfo*)info;
+ g_return_val_if_fail (info != NULL, G_TYPE_INVALID);
+ g_return_val_if_fail (GI_IS_REGISTERED_TYPE_INFO (info), G_TYPE_INVALID);
+
type_init = g_registered_type_info_get_type_init (info);
if (type_init == NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]