mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 07:26:15 +01:00
[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:
parent
f05d309f57
commit
94d52d910c
127
gifieldinfo.c
127
gifieldinfo.c
@ -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;
|
||||
|
||||
@ -127,7 +175,7 @@ g_field_info_get_field (GIFieldInfo *field_info,
|
||||
|
||||
if (g_type_info_is_pointer (type_info))
|
||||
{
|
||||
value->v_pointer = G_STRUCT_MEMBER(gpointer, mem, offset);
|
||||
value->v_pointer = G_STRUCT_MEMBER (gpointer, mem, offset);
|
||||
result = TRUE;
|
||||
}
|
||||
else
|
||||
@ -139,57 +187,57 @@ g_field_info_get_field (GIFieldInfo *field_info,
|
||||
g_base_info_get_name ((GIBaseInfo *)field_info));
|
||||
break;
|
||||
case GI_TYPE_TAG_BOOLEAN:
|
||||
value->v_boolean = G_STRUCT_MEMBER(gboolean, mem, offset) != FALSE;
|
||||
value->v_boolean = G_STRUCT_MEMBER (gboolean, mem, offset) != FALSE;
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_INT8:
|
||||
case GI_TYPE_TAG_UINT8:
|
||||
value->v_uint8 = G_STRUCT_MEMBER(guint8, mem, offset);
|
||||
value->v_uint8 = G_STRUCT_MEMBER (guint8, mem, offset);
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_INT16:
|
||||
case GI_TYPE_TAG_UINT16:
|
||||
case GI_TYPE_TAG_SHORT:
|
||||
case GI_TYPE_TAG_USHORT:
|
||||
value->v_uint16 = G_STRUCT_MEMBER(guint16, mem, offset);
|
||||
value->v_uint16 = G_STRUCT_MEMBER (guint16, mem, offset);
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_INT32:
|
||||
case GI_TYPE_TAG_UINT32:
|
||||
case GI_TYPE_TAG_INT:
|
||||
case GI_TYPE_TAG_UINT:
|
||||
value->v_uint32 = G_STRUCT_MEMBER(guint32, mem, offset);
|
||||
value->v_uint32 = G_STRUCT_MEMBER (guint32, mem, offset);
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_INT64:
|
||||
case GI_TYPE_TAG_UINT64:
|
||||
value->v_uint64 = G_STRUCT_MEMBER(guint64, mem, offset);
|
||||
value->v_uint64 = G_STRUCT_MEMBER (guint64, mem, offset);
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_LONG:
|
||||
case GI_TYPE_TAG_ULONG:
|
||||
value->v_ulong = G_STRUCT_MEMBER(gulong, mem, offset);
|
||||
value->v_ulong = G_STRUCT_MEMBER (gulong, mem, offset);
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_SSIZE:
|
||||
case GI_TYPE_TAG_SIZE:
|
||||
case GI_TYPE_TAG_GTYPE:
|
||||
value->v_size = G_STRUCT_MEMBER(gsize, mem, offset);
|
||||
value->v_size = G_STRUCT_MEMBER (gsize, mem, offset);
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_FLOAT:
|
||||
value->v_float = G_STRUCT_MEMBER(gfloat, mem, offset);
|
||||
value->v_float = G_STRUCT_MEMBER (gfloat, mem, offset);
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_DOUBLE:
|
||||
value->v_double = G_STRUCT_MEMBER(gdouble, mem, offset);
|
||||
value->v_double = G_STRUCT_MEMBER (gdouble, mem, offset);
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_TIME_T:
|
||||
#if SIZEOF_TIME_T == 4
|
||||
value->v_int32 = G_STRUCT_MEMBER(time_t, mem, offset);
|
||||
value->v_int32 = G_STRUCT_MEMBER (time_t, mem, offset);
|
||||
#elif SIZEOF_TIME_T == 8
|
||||
value->v_int64 = G_STRUCT_MEMBER(time_t, mem, offset);
|
||||
value->v_int64 = G_STRUCT_MEMBER (time_t, mem, offset);
|
||||
#else
|
||||
# error "Unexpected size for time_t: not 4 or 8"
|
||||
#endif
|
||||
@ -235,31 +283,31 @@ g_field_info_get_field (GIFieldInfo *field_info,
|
||||
{
|
||||
case GI_TYPE_TAG_INT8:
|
||||
case GI_TYPE_TAG_UINT8:
|
||||
value->v_int = (gint)G_STRUCT_MEMBER(guint8, mem, offset);
|
||||
value->v_int = (gint)G_STRUCT_MEMBER (guint8, mem, offset);
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_INT16:
|
||||
case GI_TYPE_TAG_UINT16:
|
||||
case GI_TYPE_TAG_SHORT:
|
||||
case GI_TYPE_TAG_USHORT:
|
||||
value->v_int = (gint)G_STRUCT_MEMBER(guint16, mem, offset);
|
||||
value->v_int = (gint)G_STRUCT_MEMBER (guint16, mem, offset);
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_INT32:
|
||||
case GI_TYPE_TAG_UINT32:
|
||||
case GI_TYPE_TAG_INT:
|
||||
case GI_TYPE_TAG_UINT:
|
||||
value->v_int = (gint)G_STRUCT_MEMBER(guint32, mem, offset);
|
||||
value->v_int = (gint)G_STRUCT_MEMBER (guint32, mem, offset);
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_INT64:
|
||||
case GI_TYPE_TAG_UINT64:
|
||||
value->v_int = (gint)G_STRUCT_MEMBER(guint64, mem, offset);
|
||||
value->v_int = (gint)G_STRUCT_MEMBER (guint64, mem, offset);
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_LONG:
|
||||
case GI_TYPE_TAG_ULONG:
|
||||
value->v_int = (gint)G_STRUCT_MEMBER(gulong, mem, offset);
|
||||
value->v_int = (gint)G_STRUCT_MEMBER (gulong, mem, offset);
|
||||
result = TRUE;
|
||||
break;
|
||||
default:
|
||||
@ -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;
|
||||
|
||||
@ -345,57 +396,57 @@ g_field_info_set_field (GIFieldInfo *field_info,
|
||||
g_base_info_get_name ((GIBaseInfo *)field_info));
|
||||
break;
|
||||
case GI_TYPE_TAG_BOOLEAN:
|
||||
G_STRUCT_MEMBER(gboolean, mem, offset) = value->v_boolean != FALSE;
|
||||
G_STRUCT_MEMBER (gboolean, mem, offset) = value->v_boolean != FALSE;
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_INT8:
|
||||
case GI_TYPE_TAG_UINT8:
|
||||
G_STRUCT_MEMBER(guint8, mem, offset) = value->v_uint8;
|
||||
G_STRUCT_MEMBER (guint8, mem, offset) = value->v_uint8;
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_INT16:
|
||||
case GI_TYPE_TAG_UINT16:
|
||||
case GI_TYPE_TAG_SHORT:
|
||||
case GI_TYPE_TAG_USHORT:
|
||||
G_STRUCT_MEMBER(guint16, mem, offset) = value->v_uint16;
|
||||
G_STRUCT_MEMBER (guint16, mem, offset) = value->v_uint16;
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_INT32:
|
||||
case GI_TYPE_TAG_UINT32:
|
||||
case GI_TYPE_TAG_INT:
|
||||
case GI_TYPE_TAG_UINT:
|
||||
G_STRUCT_MEMBER(guint32, mem, offset) = value->v_uint32;
|
||||
G_STRUCT_MEMBER (guint32, mem, offset) = value->v_uint32;
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_INT64:
|
||||
case GI_TYPE_TAG_UINT64:
|
||||
G_STRUCT_MEMBER(guint64, mem, offset) = value->v_uint64;
|
||||
G_STRUCT_MEMBER (guint64, mem, offset) = value->v_uint64;
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_LONG:
|
||||
case GI_TYPE_TAG_ULONG:
|
||||
G_STRUCT_MEMBER(gulong, mem, offset)= value->v_ulong;
|
||||
G_STRUCT_MEMBER (gulong, mem, offset)= value->v_ulong;
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_SSIZE:
|
||||
case GI_TYPE_TAG_SIZE:
|
||||
case GI_TYPE_TAG_GTYPE:
|
||||
G_STRUCT_MEMBER(gsize, mem, offset) = value->v_size;
|
||||
G_STRUCT_MEMBER (gsize, mem, offset) = value->v_size;
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_FLOAT:
|
||||
G_STRUCT_MEMBER(gfloat, mem, offset) = value->v_float;
|
||||
G_STRUCT_MEMBER (gfloat, mem, offset) = value->v_float;
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_DOUBLE:
|
||||
G_STRUCT_MEMBER(gdouble, mem, offset)= value->v_double;
|
||||
G_STRUCT_MEMBER (gdouble, mem, offset)= value->v_double;
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_TIME_T:
|
||||
#if SIZEOF_TIME_T == 4
|
||||
G_STRUCT_MEMBER(time_t, mem, offset) = value->v_int32;
|
||||
G_STRUCT_MEMBER (time_t, mem, offset) = value->v_int32;
|
||||
#elif SIZEOF_TIME_T == 8
|
||||
G_STRUCT_MEMBER(time_t, mem, offset) = value->v_int64;
|
||||
G_STRUCT_MEMBER (time_t, mem, offset) = value->v_int64;
|
||||
#else
|
||||
# error "Unexpected size for time_t: not 4 or 8"
|
||||
#endif
|
||||
@ -436,31 +487,31 @@ g_field_info_set_field (GIFieldInfo *field_info,
|
||||
{
|
||||
case GI_TYPE_TAG_INT8:
|
||||
case GI_TYPE_TAG_UINT8:
|
||||
G_STRUCT_MEMBER(guint8, mem, offset) = (guint8)value->v_int;
|
||||
G_STRUCT_MEMBER (guint8, mem, offset) = (guint8)value->v_int;
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_INT16:
|
||||
case GI_TYPE_TAG_UINT16:
|
||||
case GI_TYPE_TAG_SHORT:
|
||||
case GI_TYPE_TAG_USHORT:
|
||||
G_STRUCT_MEMBER(guint16, mem, offset) = (guint16)value->v_int;
|
||||
G_STRUCT_MEMBER (guint16, mem, offset) = (guint16)value->v_int;
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_INT32:
|
||||
case GI_TYPE_TAG_UINT32:
|
||||
case GI_TYPE_TAG_INT:
|
||||
case GI_TYPE_TAG_UINT:
|
||||
G_STRUCT_MEMBER(guint32, mem, offset) = (guint32)value->v_int;
|
||||
G_STRUCT_MEMBER (guint32, mem, offset) = (guint32)value->v_int;
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_INT64:
|
||||
case GI_TYPE_TAG_UINT64:
|
||||
G_STRUCT_MEMBER(guint64, mem, offset) = (guint64)value->v_int;
|
||||
G_STRUCT_MEMBER (guint64, mem, offset) = (guint64)value->v_int;
|
||||
result = TRUE;
|
||||
break;
|
||||
case GI_TYPE_TAG_LONG:
|
||||
case GI_TYPE_TAG_ULONG:
|
||||
G_STRUCT_MEMBER(gulong, mem, offset) = (gulong)value->v_int;
|
||||
G_STRUCT_MEMBER (gulong, mem, offset) = (gulong)value->v_int;
|
||||
result = TRUE;
|
||||
break;
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user