[gifieldinfo] Document, indent and check params

Document the remaining functions, indent to match coding style
and check so that all info params are set and of the right type.
This commit is contained in:
Johan Dahlin 2010-06-06 13:35:14 -03:00
parent f05d309f57
commit 94d52d910c

View File

@ -43,9 +43,13 @@ GIFieldInfoFlags
g_field_info_get_flags (GIFieldInfo *info)
{
GIFieldInfoFlags flags;
GIRealInfo *rinfo = (GIRealInfo *)info;
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
FieldBlob *blob;
g_return_val_if_fail (info != NULL, 0);
g_return_val_if_fail (GI_IS_FIELD_INFO (info), 0);
blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
flags = 0;
@ -58,32 +62,73 @@ g_field_info_get_flags (GIFieldInfo *info)
return flags;
}
/**
* g_field_info_get_size:
* @info: a #GIFieldInfo
*
* Obtain the size in bits of the field member, this is how
* much space you need to allocate to store the field.
*
* Returns: the field size
*/
gint
g_field_info_get_size (GIFieldInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
FieldBlob *blob;
g_return_val_if_fail (info != NULL, 0);
g_return_val_if_fail (GI_IS_FIELD_INFO (info), 0);
blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->bits;
}
/**
* g_field_info_get_offset:
* @info: a #GIFieldInfo
*
* Obtain the offset in bits of the field member, this is relative
* to the beginning of the struct or union.
*
* Returns: the field offset
*/
gint
g_field_info_get_offset (GIFieldInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
FieldBlob *blob;
g_return_val_if_fail (info != NULL, 0);
g_return_val_if_fail (GI_IS_FIELD_INFO (info), 0);
blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
return blob->struct_offset;
}
/**
* g_field_info_get_type:
*
* Obtain the type of a field as a #GITypeInfo.
*
* Returns: (transfer full): the #GITypeInfo. Free the struct by calling
* g_base_info_unref() when done.
*/
GITypeInfo *
g_field_info_get_type (GIFieldInfo *info)
{
GIRealInfo *rinfo = (GIRealInfo *)info;
Header *header = (Header *)rinfo->typelib->data;
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
FieldBlob *blob;
GIRealInfo *type_info;
g_return_val_if_fail (info != NULL, NULL);
g_return_val_if_fail (GI_IS_FIELD_INFO (info), NULL);
blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
if (blob->has_embedded_type)
{
type_info = (GIRealInfo *) g_info_new (GI_INFO_TYPE_TYPE,
@ -119,6 +164,9 @@ g_field_info_get_field (GIFieldInfo *field_info,
GITypeInfo *type_info;
gboolean result = FALSE;
g_return_val_if_fail (field_info != NULL, FALSE);
g_return_val_if_fail (GI_IS_FIELD_INFO (field_info), FALSE);
if ((g_field_info_get_flags (field_info) & GI_FIELD_IS_READABLE) == 0)
return FALSE;
@ -330,6 +378,9 @@ g_field_info_set_field (GIFieldInfo *field_info,
GITypeInfo *type_info;
gboolean result = FALSE;
g_return_val_if_fail (field_info != NULL, FALSE);
g_return_val_if_fail (GI_IS_FIELD_INFO (field_info), FALSE);
if ((g_field_info_get_flags (field_info) & GI_FIELD_IS_WRITABLE) == 0)
return FALSE;