From ea84884773b3a09824a1284f34f442f78acb7259 Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Sun, 6 Jun 2010 22:48:08 -0300 Subject: [giconstantinfo] Document and check parameters --- girepository/giconstantinfo.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'girepository/giconstantinfo.c') 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) -- cgit v1.2.1