summaryrefslogtreecommitdiff
path: root/girepository/giconstantinfo.c
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2010-06-06 22:48:08 -0300
committerJohan Dahlin <johan@gnome.org>2010-06-06 22:48:08 -0300
commitea84884773b3a09824a1284f34f442f78acb7259 (patch)
treec226de2d93a83331acfe050b77bdf2ecba568862 /girepository/giconstantinfo.c
parentff1ab5e784998fbc8998dbc91cf42035d389c2d5 (diff)
downloadgobject-introspection-ea84884773b3a09824a1284f34f442f78acb7259.tar.gz
[giconstantinfo] Document and check parameters
Diffstat (limited to 'girepository/giconstantinfo.c')
-rw-r--r--girepository/giconstantinfo.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/girepository/giconstantinfo.c b/girepository/giconstantinfo.c
index 72cc0436..16237793 100644
--- a/girepository/giconstantinfo.c
+++ b/girepository/giconstantinfo.c
@@ -26,20 +26,59 @@
#include "gitypelib-internal.h"
#include "girffi.h"
+/**
+ * SECTION:giconstantinfo
+ * @Short_description: Struct representing a constant
+ * @Title: GIConstantInfo
+ *
+ * GIConstantInfo represents a constant. A constant has a type associated
+ * which can be obtained by calling g_constant_info_get_type() and a value,
+ * which can be obtained by calling g_constant_info_get_value().
+ */
+
+
+/**
+ * g_constant_info_get_type:
+ * @info: a #GIConstantInfo
+ *
+ * Obtain the type of the constant as a #GITypeInfo.
+ *
+ * Returns: (transfer full): the #GITypeInfo. Free the struct by calling
+ * g_base_info_unref() when done.
+ */
GITypeInfo *
g_constant_info_get_type (GIConstantInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
+ g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (GI_IS_CONSTANT_INFO (info), NULL);
+
return _g_type_info_new ((GIBaseInfo*)info, rinfo->typelib, rinfo->offset + 8);
}
+/**
+ * g_constant_info_get_value:
+ * @info: a #GIConstantInfo
+ * @value: (out): an argument
+ *
+ * Obtain the value associated with the #GIConstantInfo and store it in the
+ * @value parameter. @argument needs to be allocated before passing it in.
+ * The size of the constant value stored in @argument will be returned.
+ *
+ * Returns: size of the constant
+ */
gint
g_constant_info_get_value (GIConstantInfo *info,
GArgument *value)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
- ConstantBlob *blob = (ConstantBlob *)&rinfo->typelib->data[rinfo->offset];
+ ConstantBlob *blob;
+
+ g_return_val_if_fail (info != NULL, 0);
+ g_return_val_if_fail (GI_IS_CONSTANT_INFO (info), 0);
+
+ blob = (ConstantBlob *)&rinfo->typelib->data[rinfo->offset];
/* FIXME non-basic types ? */
if (blob->type.flags.reserved == 0 && blob->type.flags.reserved2 == 0)