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
735
gifieldinfo.c
735
gifieldinfo.c
@ -43,9 +43,13 @@ GIFieldInfoFlags
|
|||||||
g_field_info_get_flags (GIFieldInfo *info)
|
g_field_info_get_flags (GIFieldInfo *info)
|
||||||
{
|
{
|
||||||
GIFieldInfoFlags flags;
|
GIFieldInfoFlags flags;
|
||||||
|
|
||||||
GIRealInfo *rinfo = (GIRealInfo *)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];
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
|
|
||||||
@ -58,32 +62,73 @@ g_field_info_get_flags (GIFieldInfo *info)
|
|||||||
return flags;
|
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
|
gint
|
||||||
g_field_info_get_size (GIFieldInfo *info)
|
g_field_info_get_size (GIFieldInfo *info)
|
||||||
{
|
{
|
||||||
GIRealInfo *rinfo = (GIRealInfo *)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;
|
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
|
gint
|
||||||
g_field_info_get_offset (GIFieldInfo *info)
|
g_field_info_get_offset (GIFieldInfo *info)
|
||||||
{
|
{
|
||||||
GIRealInfo *rinfo = (GIRealInfo *)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;
|
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 *
|
GITypeInfo *
|
||||||
g_field_info_get_type (GIFieldInfo *info)
|
g_field_info_get_type (GIFieldInfo *info)
|
||||||
{
|
{
|
||||||
GIRealInfo *rinfo = (GIRealInfo *)info;
|
GIRealInfo *rinfo = (GIRealInfo *)info;
|
||||||
Header *header = (Header *)rinfo->typelib->data;
|
Header *header = (Header *)rinfo->typelib->data;
|
||||||
FieldBlob *blob = (FieldBlob *)&rinfo->typelib->data[rinfo->offset];
|
FieldBlob *blob;
|
||||||
GIRealInfo *type_info;
|
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)
|
if (blob->has_embedded_type)
|
||||||
{
|
{
|
||||||
type_info = (GIRealInfo *) g_info_new (GI_INFO_TYPE_TYPE,
|
type_info = (GIRealInfo *) g_info_new (GI_INFO_TYPE_TYPE,
|
||||||
@ -115,195 +160,198 @@ g_field_info_get_field (GIFieldInfo *field_info,
|
|||||||
gpointer mem,
|
gpointer mem,
|
||||||
GArgument *value)
|
GArgument *value)
|
||||||
{
|
{
|
||||||
int offset;
|
int offset;
|
||||||
GITypeInfo *type_info;
|
GITypeInfo *type_info;
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
|
|
||||||
if ((g_field_info_get_flags (field_info) & GI_FIELD_IS_READABLE) == 0)
|
g_return_val_if_fail (field_info != NULL, FALSE);
|
||||||
return FALSE;
|
g_return_val_if_fail (GI_IS_FIELD_INFO (field_info), FALSE);
|
||||||
|
|
||||||
offset = g_field_info_get_offset (field_info);
|
if ((g_field_info_get_flags (field_info) & GI_FIELD_IS_READABLE) == 0)
|
||||||
type_info = g_field_info_get_type (field_info);
|
return FALSE;
|
||||||
|
|
||||||
if (g_type_info_is_pointer (type_info))
|
offset = g_field_info_get_offset (field_info);
|
||||||
{
|
type_info = g_field_info_get_type (field_info);
|
||||||
value->v_pointer = G_STRUCT_MEMBER(gpointer, mem, offset);
|
|
||||||
result = TRUE;
|
if (g_type_info_is_pointer (type_info))
|
||||||
}
|
{
|
||||||
else
|
value->v_pointer = G_STRUCT_MEMBER (gpointer, mem, offset);
|
||||||
{
|
result = TRUE;
|
||||||
switch (g_type_info_get_tag (type_info))
|
}
|
||||||
{
|
else
|
||||||
case GI_TYPE_TAG_VOID:
|
{
|
||||||
g_warning("Field %s: should not be have void type",
|
switch (g_type_info_get_tag (type_info))
|
||||||
g_base_info_get_name ((GIBaseInfo *)field_info));
|
{
|
||||||
break;
|
case GI_TYPE_TAG_VOID:
|
||||||
case GI_TYPE_TAG_BOOLEAN:
|
g_warning("Field %s: should not be have void type",
|
||||||
value->v_boolean = G_STRUCT_MEMBER(gboolean, mem, offset) != FALSE;
|
g_base_info_get_name ((GIBaseInfo *)field_info));
|
||||||
result = TRUE;
|
break;
|
||||||
break;
|
case GI_TYPE_TAG_BOOLEAN:
|
||||||
case GI_TYPE_TAG_INT8:
|
value->v_boolean = G_STRUCT_MEMBER (gboolean, mem, offset) != FALSE;
|
||||||
case GI_TYPE_TAG_UINT8:
|
result = TRUE;
|
||||||
value->v_uint8 = G_STRUCT_MEMBER(guint8, mem, offset);
|
break;
|
||||||
result = TRUE;
|
case GI_TYPE_TAG_INT8:
|
||||||
break;
|
case GI_TYPE_TAG_UINT8:
|
||||||
case GI_TYPE_TAG_INT16:
|
value->v_uint8 = G_STRUCT_MEMBER (guint8, mem, offset);
|
||||||
case GI_TYPE_TAG_UINT16:
|
result = TRUE;
|
||||||
case GI_TYPE_TAG_SHORT:
|
break;
|
||||||
case GI_TYPE_TAG_USHORT:
|
case GI_TYPE_TAG_INT16:
|
||||||
value->v_uint16 = G_STRUCT_MEMBER(guint16, mem, offset);
|
case GI_TYPE_TAG_UINT16:
|
||||||
result = TRUE;
|
case GI_TYPE_TAG_SHORT:
|
||||||
break;
|
case GI_TYPE_TAG_USHORT:
|
||||||
case GI_TYPE_TAG_INT32:
|
value->v_uint16 = G_STRUCT_MEMBER (guint16, mem, offset);
|
||||||
case GI_TYPE_TAG_UINT32:
|
result = TRUE;
|
||||||
case GI_TYPE_TAG_INT:
|
break;
|
||||||
case GI_TYPE_TAG_UINT:
|
case GI_TYPE_TAG_INT32:
|
||||||
value->v_uint32 = G_STRUCT_MEMBER(guint32, mem, offset);
|
case GI_TYPE_TAG_UINT32:
|
||||||
result = TRUE;
|
case GI_TYPE_TAG_INT:
|
||||||
break;
|
case GI_TYPE_TAG_UINT:
|
||||||
case GI_TYPE_TAG_INT64:
|
value->v_uint32 = G_STRUCT_MEMBER (guint32, mem, offset);
|
||||||
case GI_TYPE_TAG_UINT64:
|
result = TRUE;
|
||||||
value->v_uint64 = G_STRUCT_MEMBER(guint64, mem, offset);
|
break;
|
||||||
result = TRUE;
|
case GI_TYPE_TAG_INT64:
|
||||||
break;
|
case GI_TYPE_TAG_UINT64:
|
||||||
case GI_TYPE_TAG_LONG:
|
value->v_uint64 = G_STRUCT_MEMBER (guint64, mem, offset);
|
||||||
case GI_TYPE_TAG_ULONG:
|
result = TRUE;
|
||||||
value->v_ulong = G_STRUCT_MEMBER(gulong, mem, offset);
|
break;
|
||||||
result = TRUE;
|
case GI_TYPE_TAG_LONG:
|
||||||
break;
|
case GI_TYPE_TAG_ULONG:
|
||||||
case GI_TYPE_TAG_SSIZE:
|
value->v_ulong = G_STRUCT_MEMBER (gulong, mem, offset);
|
||||||
case GI_TYPE_TAG_SIZE:
|
result = TRUE;
|
||||||
case GI_TYPE_TAG_GTYPE:
|
break;
|
||||||
value->v_size = G_STRUCT_MEMBER(gsize, mem, offset);
|
case GI_TYPE_TAG_SSIZE:
|
||||||
result = TRUE;
|
case GI_TYPE_TAG_SIZE:
|
||||||
break;
|
case GI_TYPE_TAG_GTYPE:
|
||||||
case GI_TYPE_TAG_FLOAT:
|
value->v_size = G_STRUCT_MEMBER (gsize, mem, offset);
|
||||||
value->v_float = G_STRUCT_MEMBER(gfloat, mem, offset);
|
result = TRUE;
|
||||||
result = TRUE;
|
break;
|
||||||
break;
|
case GI_TYPE_TAG_FLOAT:
|
||||||
case GI_TYPE_TAG_DOUBLE:
|
value->v_float = G_STRUCT_MEMBER (gfloat, mem, offset);
|
||||||
value->v_double = G_STRUCT_MEMBER(gdouble, mem, offset);
|
result = TRUE;
|
||||||
result = TRUE;
|
break;
|
||||||
break;
|
case GI_TYPE_TAG_DOUBLE:
|
||||||
case GI_TYPE_TAG_TIME_T:
|
value->v_double = G_STRUCT_MEMBER (gdouble, mem, offset);
|
||||||
|
result = TRUE;
|
||||||
|
break;
|
||||||
|
case GI_TYPE_TAG_TIME_T:
|
||||||
#if SIZEOF_TIME_T == 4
|
#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
|
#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
|
#else
|
||||||
# error "Unexpected size for time_t: not 4 or 8"
|
# error "Unexpected size for time_t: not 4 or 8"
|
||||||
#endif
|
#endif
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
break;
|
break;
|
||||||
case GI_TYPE_TAG_UTF8:
|
case GI_TYPE_TAG_UTF8:
|
||||||
case GI_TYPE_TAG_FILENAME:
|
case GI_TYPE_TAG_FILENAME:
|
||||||
case GI_TYPE_TAG_ARRAY:
|
case GI_TYPE_TAG_ARRAY:
|
||||||
case GI_TYPE_TAG_GLIST:
|
case GI_TYPE_TAG_GLIST:
|
||||||
case GI_TYPE_TAG_GSLIST:
|
case GI_TYPE_TAG_GSLIST:
|
||||||
case GI_TYPE_TAG_GHASH:
|
case GI_TYPE_TAG_GHASH:
|
||||||
g_warning("Field %s: type %s should have is_pointer set",
|
g_warning("Field %s: type %s should have is_pointer set",
|
||||||
g_base_info_get_name ((GIBaseInfo *)field_info),
|
g_base_info_get_name ((GIBaseInfo *)field_info),
|
||||||
g_type_tag_to_string (g_type_info_get_tag (type_info)));
|
g_type_tag_to_string (g_type_info_get_tag (type_info)));
|
||||||
break;
|
break;
|
||||||
case GI_TYPE_TAG_ERROR:
|
case GI_TYPE_TAG_ERROR:
|
||||||
/* Needs to be handled by the language binding directly */
|
/* Needs to be handled by the language binding directly */
|
||||||
break;
|
break;
|
||||||
case GI_TYPE_TAG_INTERFACE:
|
case GI_TYPE_TAG_INTERFACE:
|
||||||
{
|
{
|
||||||
GIBaseInfo *interface = g_type_info_get_interface (type_info);
|
GIBaseInfo *interface = g_type_info_get_interface (type_info);
|
||||||
switch (g_base_info_get_type (interface))
|
switch (g_base_info_get_type (interface))
|
||||||
|
{
|
||||||
|
case GI_INFO_TYPE_STRUCT:
|
||||||
|
case GI_INFO_TYPE_UNION:
|
||||||
|
case GI_INFO_TYPE_BOXED:
|
||||||
|
/* Needs to be handled by the language binding directly */
|
||||||
|
break;
|
||||||
|
case GI_INFO_TYPE_OBJECT:
|
||||||
|
break;
|
||||||
|
case GI_INFO_TYPE_ENUM:
|
||||||
|
case GI_INFO_TYPE_FLAGS:
|
||||||
{
|
{
|
||||||
case GI_INFO_TYPE_STRUCT:
|
/* FIXME: there's a mismatch here between the value->v_int we use
|
||||||
case GI_INFO_TYPE_UNION:
|
* here and the glong result returned from g_value_info_get_value().
|
||||||
case GI_INFO_TYPE_BOXED:
|
* But to switch this to glong, we'd have to make g_function_info_invoke()
|
||||||
/* Needs to be handled by the language binding directly */
|
* translate value->v_long to the proper ABI for an enum function
|
||||||
break;
|
* call parameter, which will usually be int, and then fix up language
|
||||||
case GI_INFO_TYPE_OBJECT:
|
* bindings.
|
||||||
break;
|
*/
|
||||||
case GI_INFO_TYPE_ENUM:
|
GITypeTag storage_type = g_enum_info_get_storage_type ((GIEnumInfo *)interface);
|
||||||
case GI_INFO_TYPE_FLAGS:
|
switch (storage_type)
|
||||||
{
|
{
|
||||||
/* FIXME: there's a mismatch here between the value->v_int we use
|
case GI_TYPE_TAG_INT8:
|
||||||
* here and the glong result returned from g_value_info_get_value().
|
case GI_TYPE_TAG_UINT8:
|
||||||
* But to switch this to glong, we'd have to make g_function_info_invoke()
|
value->v_int = (gint)G_STRUCT_MEMBER (guint8, mem, offset);
|
||||||
* translate value->v_long to the proper ABI for an enum function
|
result = TRUE;
|
||||||
* call parameter, which will usually be int, and then fix up language
|
break;
|
||||||
* bindings.
|
case GI_TYPE_TAG_INT16:
|
||||||
*/
|
case GI_TYPE_TAG_UINT16:
|
||||||
GITypeTag storage_type = g_enum_info_get_storage_type ((GIEnumInfo *)interface);
|
case GI_TYPE_TAG_SHORT:
|
||||||
switch (storage_type)
|
case GI_TYPE_TAG_USHORT:
|
||||||
{
|
value->v_int = (gint)G_STRUCT_MEMBER (guint16, mem, offset);
|
||||||
case GI_TYPE_TAG_INT8:
|
result = TRUE;
|
||||||
case GI_TYPE_TAG_UINT8:
|
break;
|
||||||
value->v_int = (gint)G_STRUCT_MEMBER(guint8, mem, offset);
|
case GI_TYPE_TAG_INT32:
|
||||||
result = TRUE;
|
case GI_TYPE_TAG_UINT32:
|
||||||
break;
|
case GI_TYPE_TAG_INT:
|
||||||
case GI_TYPE_TAG_INT16:
|
case GI_TYPE_TAG_UINT:
|
||||||
case GI_TYPE_TAG_UINT16:
|
value->v_int = (gint)G_STRUCT_MEMBER (guint32, mem, offset);
|
||||||
case GI_TYPE_TAG_SHORT:
|
result = TRUE;
|
||||||
case GI_TYPE_TAG_USHORT:
|
break;
|
||||||
value->v_int = (gint)G_STRUCT_MEMBER(guint16, mem, offset);
|
case GI_TYPE_TAG_INT64:
|
||||||
result = TRUE;
|
case GI_TYPE_TAG_UINT64:
|
||||||
break;
|
value->v_int = (gint)G_STRUCT_MEMBER (guint64, mem, offset);
|
||||||
case GI_TYPE_TAG_INT32:
|
result = TRUE;
|
||||||
case GI_TYPE_TAG_UINT32:
|
break;
|
||||||
case GI_TYPE_TAG_INT:
|
case GI_TYPE_TAG_LONG:
|
||||||
case GI_TYPE_TAG_UINT:
|
case GI_TYPE_TAG_ULONG:
|
||||||
value->v_int = (gint)G_STRUCT_MEMBER(guint32, mem, offset);
|
value->v_int = (gint)G_STRUCT_MEMBER (gulong, mem, offset);
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
break;
|
break;
|
||||||
case GI_TYPE_TAG_INT64:
|
default:
|
||||||
case GI_TYPE_TAG_UINT64:
|
g_warning("Field %s: Unexpected enum storage type %s",
|
||||||
value->v_int = (gint)G_STRUCT_MEMBER(guint64, mem, offset);
|
g_base_info_get_name ((GIBaseInfo *)field_info),
|
||||||
result = TRUE;
|
g_type_tag_to_string (storage_type));
|
||||||
break;
|
break;
|
||||||
case GI_TYPE_TAG_LONG:
|
}
|
||||||
case GI_TYPE_TAG_ULONG:
|
|
||||||
value->v_int = (gint)G_STRUCT_MEMBER(gulong, mem, offset);
|
|
||||||
result = TRUE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
g_warning("Field %s: Unexpected enum storage type %s",
|
|
||||||
g_base_info_get_name ((GIBaseInfo *)field_info),
|
|
||||||
g_type_tag_to_string (storage_type));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case GI_INFO_TYPE_VFUNC:
|
|
||||||
case GI_INFO_TYPE_CALLBACK:
|
|
||||||
g_warning("Field %s: Interface type %d should have is_pointer set",
|
|
||||||
g_base_info_get_name ((GIBaseInfo *)field_info),
|
|
||||||
g_base_info_get_type (interface));
|
|
||||||
break;
|
|
||||||
case GI_INFO_TYPE_INVALID:
|
|
||||||
case GI_INFO_TYPE_INTERFACE:
|
|
||||||
case GI_INFO_TYPE_FUNCTION:
|
|
||||||
case GI_INFO_TYPE_CONSTANT:
|
|
||||||
case GI_INFO_TYPE_ERROR_DOMAIN:
|
|
||||||
case GI_INFO_TYPE_VALUE:
|
|
||||||
case GI_INFO_TYPE_SIGNAL:
|
|
||||||
case GI_INFO_TYPE_PROPERTY:
|
|
||||||
case GI_INFO_TYPE_FIELD:
|
|
||||||
case GI_INFO_TYPE_ARG:
|
|
||||||
case GI_INFO_TYPE_TYPE:
|
|
||||||
case GI_INFO_TYPE_UNRESOLVED:
|
|
||||||
g_warning("Field %s: Interface type %d not expected",
|
|
||||||
g_base_info_get_name ((GIBaseInfo *)field_info),
|
|
||||||
g_base_info_get_type (interface));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case GI_INFO_TYPE_VFUNC:
|
||||||
|
case GI_INFO_TYPE_CALLBACK:
|
||||||
|
g_warning("Field %s: Interface type %d should have is_pointer set",
|
||||||
|
g_base_info_get_name ((GIBaseInfo *)field_info),
|
||||||
|
g_base_info_get_type (interface));
|
||||||
|
break;
|
||||||
|
case GI_INFO_TYPE_INVALID:
|
||||||
|
case GI_INFO_TYPE_INTERFACE:
|
||||||
|
case GI_INFO_TYPE_FUNCTION:
|
||||||
|
case GI_INFO_TYPE_CONSTANT:
|
||||||
|
case GI_INFO_TYPE_ERROR_DOMAIN:
|
||||||
|
case GI_INFO_TYPE_VALUE:
|
||||||
|
case GI_INFO_TYPE_SIGNAL:
|
||||||
|
case GI_INFO_TYPE_PROPERTY:
|
||||||
|
case GI_INFO_TYPE_FIELD:
|
||||||
|
case GI_INFO_TYPE_ARG:
|
||||||
|
case GI_INFO_TYPE_TYPE:
|
||||||
|
case GI_INFO_TYPE_UNRESOLVED:
|
||||||
|
g_warning("Field %s: Interface type %d not expected",
|
||||||
|
g_base_info_get_name ((GIBaseInfo *)field_info),
|
||||||
|
g_base_info_get_type (interface));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
g_base_info_unref ((GIBaseInfo *)interface);
|
g_base_info_unref ((GIBaseInfo *)interface);
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_base_info_unref ((GIBaseInfo *)type_info);
|
g_base_info_unref ((GIBaseInfo *)type_info);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -326,184 +374,187 @@ g_field_info_set_field (GIFieldInfo *field_info,
|
|||||||
gpointer mem,
|
gpointer mem,
|
||||||
const GArgument *value)
|
const GArgument *value)
|
||||||
{
|
{
|
||||||
int offset;
|
int offset;
|
||||||
GITypeInfo *type_info;
|
GITypeInfo *type_info;
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
|
|
||||||
if ((g_field_info_get_flags (field_info) & GI_FIELD_IS_WRITABLE) == 0)
|
g_return_val_if_fail (field_info != NULL, FALSE);
|
||||||
return FALSE;
|
g_return_val_if_fail (GI_IS_FIELD_INFO (field_info), FALSE);
|
||||||
|
|
||||||
offset = g_field_info_get_offset (field_info);
|
if ((g_field_info_get_flags (field_info) & GI_FIELD_IS_WRITABLE) == 0)
|
||||||
type_info = g_field_info_get_type (field_info);
|
return FALSE;
|
||||||
|
|
||||||
if (!g_type_info_is_pointer (type_info))
|
offset = g_field_info_get_offset (field_info);
|
||||||
{
|
type_info = g_field_info_get_type (field_info);
|
||||||
switch (g_type_info_get_tag (type_info))
|
|
||||||
{
|
if (!g_type_info_is_pointer (type_info))
|
||||||
case GI_TYPE_TAG_VOID:
|
{
|
||||||
g_warning("Field %s: should not be have void type",
|
switch (g_type_info_get_tag (type_info))
|
||||||
g_base_info_get_name ((GIBaseInfo *)field_info));
|
{
|
||||||
break;
|
case GI_TYPE_TAG_VOID:
|
||||||
case GI_TYPE_TAG_BOOLEAN:
|
g_warning("Field %s: should not be have void type",
|
||||||
G_STRUCT_MEMBER(gboolean, mem, offset) = value->v_boolean != FALSE;
|
g_base_info_get_name ((GIBaseInfo *)field_info));
|
||||||
result = TRUE;
|
break;
|
||||||
break;
|
case GI_TYPE_TAG_BOOLEAN:
|
||||||
case GI_TYPE_TAG_INT8:
|
G_STRUCT_MEMBER (gboolean, mem, offset) = value->v_boolean != FALSE;
|
||||||
case GI_TYPE_TAG_UINT8:
|
result = TRUE;
|
||||||
G_STRUCT_MEMBER(guint8, mem, offset) = value->v_uint8;
|
break;
|
||||||
result = TRUE;
|
case GI_TYPE_TAG_INT8:
|
||||||
break;
|
case GI_TYPE_TAG_UINT8:
|
||||||
case GI_TYPE_TAG_INT16:
|
G_STRUCT_MEMBER (guint8, mem, offset) = value->v_uint8;
|
||||||
case GI_TYPE_TAG_UINT16:
|
result = TRUE;
|
||||||
case GI_TYPE_TAG_SHORT:
|
break;
|
||||||
case GI_TYPE_TAG_USHORT:
|
case GI_TYPE_TAG_INT16:
|
||||||
G_STRUCT_MEMBER(guint16, mem, offset) = value->v_uint16;
|
case GI_TYPE_TAG_UINT16:
|
||||||
result = TRUE;
|
case GI_TYPE_TAG_SHORT:
|
||||||
break;
|
case GI_TYPE_TAG_USHORT:
|
||||||
case GI_TYPE_TAG_INT32:
|
G_STRUCT_MEMBER (guint16, mem, offset) = value->v_uint16;
|
||||||
case GI_TYPE_TAG_UINT32:
|
result = TRUE;
|
||||||
case GI_TYPE_TAG_INT:
|
break;
|
||||||
case GI_TYPE_TAG_UINT:
|
case GI_TYPE_TAG_INT32:
|
||||||
G_STRUCT_MEMBER(guint32, mem, offset) = value->v_uint32;
|
case GI_TYPE_TAG_UINT32:
|
||||||
result = TRUE;
|
case GI_TYPE_TAG_INT:
|
||||||
break;
|
case GI_TYPE_TAG_UINT:
|
||||||
case GI_TYPE_TAG_INT64:
|
G_STRUCT_MEMBER (guint32, mem, offset) = value->v_uint32;
|
||||||
case GI_TYPE_TAG_UINT64:
|
result = TRUE;
|
||||||
G_STRUCT_MEMBER(guint64, mem, offset) = value->v_uint64;
|
break;
|
||||||
result = TRUE;
|
case GI_TYPE_TAG_INT64:
|
||||||
break;
|
case GI_TYPE_TAG_UINT64:
|
||||||
case GI_TYPE_TAG_LONG:
|
G_STRUCT_MEMBER (guint64, mem, offset) = value->v_uint64;
|
||||||
case GI_TYPE_TAG_ULONG:
|
result = TRUE;
|
||||||
G_STRUCT_MEMBER(gulong, mem, offset)= value->v_ulong;
|
break;
|
||||||
result = TRUE;
|
case GI_TYPE_TAG_LONG:
|
||||||
break;
|
case GI_TYPE_TAG_ULONG:
|
||||||
case GI_TYPE_TAG_SSIZE:
|
G_STRUCT_MEMBER (gulong, mem, offset)= value->v_ulong;
|
||||||
case GI_TYPE_TAG_SIZE:
|
result = TRUE;
|
||||||
case GI_TYPE_TAG_GTYPE:
|
break;
|
||||||
G_STRUCT_MEMBER(gsize, mem, offset) = value->v_size;
|
case GI_TYPE_TAG_SSIZE:
|
||||||
result = TRUE;
|
case GI_TYPE_TAG_SIZE:
|
||||||
break;
|
case GI_TYPE_TAG_GTYPE:
|
||||||
case GI_TYPE_TAG_FLOAT:
|
G_STRUCT_MEMBER (gsize, mem, offset) = value->v_size;
|
||||||
G_STRUCT_MEMBER(gfloat, mem, offset) = value->v_float;
|
result = TRUE;
|
||||||
result = TRUE;
|
break;
|
||||||
break;
|
case GI_TYPE_TAG_FLOAT:
|
||||||
case GI_TYPE_TAG_DOUBLE:
|
G_STRUCT_MEMBER (gfloat, mem, offset) = value->v_float;
|
||||||
G_STRUCT_MEMBER(gdouble, mem, offset)= value->v_double;
|
result = TRUE;
|
||||||
result = TRUE;
|
break;
|
||||||
break;
|
case GI_TYPE_TAG_DOUBLE:
|
||||||
case GI_TYPE_TAG_TIME_T:
|
G_STRUCT_MEMBER (gdouble, mem, offset)= value->v_double;
|
||||||
|
result = TRUE;
|
||||||
|
break;
|
||||||
|
case GI_TYPE_TAG_TIME_T:
|
||||||
#if SIZEOF_TIME_T == 4
|
#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
|
#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
|
#else
|
||||||
# error "Unexpected size for time_t: not 4 or 8"
|
# error "Unexpected size for time_t: not 4 or 8"
|
||||||
#endif
|
#endif
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
break;
|
break;
|
||||||
case GI_TYPE_TAG_UTF8:
|
case GI_TYPE_TAG_UTF8:
|
||||||
case GI_TYPE_TAG_FILENAME:
|
case GI_TYPE_TAG_FILENAME:
|
||||||
case GI_TYPE_TAG_ARRAY:
|
case GI_TYPE_TAG_ARRAY:
|
||||||
case GI_TYPE_TAG_GLIST:
|
case GI_TYPE_TAG_GLIST:
|
||||||
case GI_TYPE_TAG_GSLIST:
|
case GI_TYPE_TAG_GSLIST:
|
||||||
case GI_TYPE_TAG_GHASH:
|
case GI_TYPE_TAG_GHASH:
|
||||||
g_warning("Field %s: type %s should have is_pointer set",
|
g_warning("Field %s: type %s should have is_pointer set",
|
||||||
g_base_info_get_name ((GIBaseInfo *)field_info),
|
g_base_info_get_name ((GIBaseInfo *)field_info),
|
||||||
g_type_tag_to_string (g_type_info_get_tag (type_info)));
|
g_type_tag_to_string (g_type_info_get_tag (type_info)));
|
||||||
break;
|
break;
|
||||||
case GI_TYPE_TAG_ERROR:
|
case GI_TYPE_TAG_ERROR:
|
||||||
/* Needs to be handled by the language binding directly */
|
/* Needs to be handled by the language binding directly */
|
||||||
break;
|
break;
|
||||||
case GI_TYPE_TAG_INTERFACE:
|
case GI_TYPE_TAG_INTERFACE:
|
||||||
{
|
{
|
||||||
GIBaseInfo *interface = g_type_info_get_interface (type_info);
|
GIBaseInfo *interface = g_type_info_get_interface (type_info);
|
||||||
switch (g_base_info_get_type (interface))
|
switch (g_base_info_get_type (interface))
|
||||||
|
{
|
||||||
|
case GI_INFO_TYPE_STRUCT:
|
||||||
|
case GI_INFO_TYPE_UNION:
|
||||||
|
case GI_INFO_TYPE_BOXED:
|
||||||
|
/* Needs to be handled by the language binding directly */
|
||||||
|
break;
|
||||||
|
case GI_INFO_TYPE_OBJECT:
|
||||||
|
break;
|
||||||
|
case GI_INFO_TYPE_ENUM:
|
||||||
|
case GI_INFO_TYPE_FLAGS:
|
||||||
{
|
{
|
||||||
case GI_INFO_TYPE_STRUCT:
|
/* See FIXME above
|
||||||
case GI_INFO_TYPE_UNION:
|
*/
|
||||||
case GI_INFO_TYPE_BOXED:
|
GITypeTag storage_type = g_enum_info_get_storage_type ((GIEnumInfo *)interface);
|
||||||
/* Needs to be handled by the language binding directly */
|
switch (storage_type)
|
||||||
break;
|
{
|
||||||
case GI_INFO_TYPE_OBJECT:
|
case GI_TYPE_TAG_INT8:
|
||||||
break;
|
case GI_TYPE_TAG_UINT8:
|
||||||
case GI_INFO_TYPE_ENUM:
|
G_STRUCT_MEMBER (guint8, mem, offset) = (guint8)value->v_int;
|
||||||
case GI_INFO_TYPE_FLAGS:
|
result = TRUE;
|
||||||
{
|
break;
|
||||||
/* See FIXME above
|
case GI_TYPE_TAG_INT16:
|
||||||
*/
|
case GI_TYPE_TAG_UINT16:
|
||||||
GITypeTag storage_type = g_enum_info_get_storage_type ((GIEnumInfo *)interface);
|
case GI_TYPE_TAG_SHORT:
|
||||||
switch (storage_type)
|
case GI_TYPE_TAG_USHORT:
|
||||||
{
|
G_STRUCT_MEMBER (guint16, mem, offset) = (guint16)value->v_int;
|
||||||
case GI_TYPE_TAG_INT8:
|
result = TRUE;
|
||||||
case GI_TYPE_TAG_UINT8:
|
break;
|
||||||
G_STRUCT_MEMBER(guint8, mem, offset) = (guint8)value->v_int;
|
case GI_TYPE_TAG_INT32:
|
||||||
result = TRUE;
|
case GI_TYPE_TAG_UINT32:
|
||||||
break;
|
case GI_TYPE_TAG_INT:
|
||||||
case GI_TYPE_TAG_INT16:
|
case GI_TYPE_TAG_UINT:
|
||||||
case GI_TYPE_TAG_UINT16:
|
G_STRUCT_MEMBER (guint32, mem, offset) = (guint32)value->v_int;
|
||||||
case GI_TYPE_TAG_SHORT:
|
result = TRUE;
|
||||||
case GI_TYPE_TAG_USHORT:
|
break;
|
||||||
G_STRUCT_MEMBER(guint16, mem, offset) = (guint16)value->v_int;
|
case GI_TYPE_TAG_INT64:
|
||||||
result = TRUE;
|
case GI_TYPE_TAG_UINT64:
|
||||||
break;
|
G_STRUCT_MEMBER (guint64, mem, offset) = (guint64)value->v_int;
|
||||||
case GI_TYPE_TAG_INT32:
|
result = TRUE;
|
||||||
case GI_TYPE_TAG_UINT32:
|
break;
|
||||||
case GI_TYPE_TAG_INT:
|
case GI_TYPE_TAG_LONG:
|
||||||
case GI_TYPE_TAG_UINT:
|
case GI_TYPE_TAG_ULONG:
|
||||||
G_STRUCT_MEMBER(guint32, mem, offset) = (guint32)value->v_int;
|
G_STRUCT_MEMBER (gulong, mem, offset) = (gulong)value->v_int;
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
break;
|
break;
|
||||||
case GI_TYPE_TAG_INT64:
|
default:
|
||||||
case GI_TYPE_TAG_UINT64:
|
g_warning("Field %s: Unexpected enum storage type %s",
|
||||||
G_STRUCT_MEMBER(guint64, mem, offset) = (guint64)value->v_int;
|
g_base_info_get_name ((GIBaseInfo *)field_info),
|
||||||
result = TRUE;
|
g_type_tag_to_string (storage_type));
|
||||||
break;
|
break;
|
||||||
case GI_TYPE_TAG_LONG:
|
}
|
||||||
case GI_TYPE_TAG_ULONG:
|
|
||||||
G_STRUCT_MEMBER(gulong, mem, offset) = (gulong)value->v_int;
|
|
||||||
result = TRUE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
g_warning("Field %s: Unexpected enum storage type %s",
|
|
||||||
g_base_info_get_name ((GIBaseInfo *)field_info),
|
|
||||||
g_type_tag_to_string (storage_type));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GI_INFO_TYPE_VFUNC:
|
|
||||||
case GI_INFO_TYPE_CALLBACK:
|
|
||||||
g_warning("Field%s: Interface type %d should have is_pointer set",
|
|
||||||
g_base_info_get_name ((GIBaseInfo *)field_info),
|
|
||||||
g_base_info_get_type (interface));
|
|
||||||
break;
|
|
||||||
case GI_INFO_TYPE_INVALID:
|
|
||||||
case GI_INFO_TYPE_INTERFACE:
|
|
||||||
case GI_INFO_TYPE_FUNCTION:
|
|
||||||
case GI_INFO_TYPE_CONSTANT:
|
|
||||||
case GI_INFO_TYPE_ERROR_DOMAIN:
|
|
||||||
case GI_INFO_TYPE_VALUE:
|
|
||||||
case GI_INFO_TYPE_SIGNAL:
|
|
||||||
case GI_INFO_TYPE_PROPERTY:
|
|
||||||
case GI_INFO_TYPE_FIELD:
|
|
||||||
case GI_INFO_TYPE_ARG:
|
|
||||||
case GI_INFO_TYPE_TYPE:
|
|
||||||
case GI_INFO_TYPE_UNRESOLVED:
|
|
||||||
g_warning("Field %s: Interface type %d not expected",
|
|
||||||
g_base_info_get_name ((GIBaseInfo *)field_info),
|
|
||||||
g_base_info_get_type (interface));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case GI_INFO_TYPE_VFUNC:
|
||||||
|
case GI_INFO_TYPE_CALLBACK:
|
||||||
|
g_warning("Field%s: Interface type %d should have is_pointer set",
|
||||||
|
g_base_info_get_name ((GIBaseInfo *)field_info),
|
||||||
|
g_base_info_get_type (interface));
|
||||||
|
break;
|
||||||
|
case GI_INFO_TYPE_INVALID:
|
||||||
|
case GI_INFO_TYPE_INTERFACE:
|
||||||
|
case GI_INFO_TYPE_FUNCTION:
|
||||||
|
case GI_INFO_TYPE_CONSTANT:
|
||||||
|
case GI_INFO_TYPE_ERROR_DOMAIN:
|
||||||
|
case GI_INFO_TYPE_VALUE:
|
||||||
|
case GI_INFO_TYPE_SIGNAL:
|
||||||
|
case GI_INFO_TYPE_PROPERTY:
|
||||||
|
case GI_INFO_TYPE_FIELD:
|
||||||
|
case GI_INFO_TYPE_ARG:
|
||||||
|
case GI_INFO_TYPE_TYPE:
|
||||||
|
case GI_INFO_TYPE_UNRESOLVED:
|
||||||
|
g_warning("Field %s: Interface type %d not expected",
|
||||||
|
g_base_info_get_name ((GIBaseInfo *)field_info),
|
||||||
|
g_base_info_get_type (interface));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
g_base_info_unref ((GIBaseInfo *)interface);
|
g_base_info_unref ((GIBaseInfo *)interface);
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_base_info_unref ((GIBaseInfo *)type_info);
|
g_base_info_unref ((GIBaseInfo *)type_info);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user