mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 07:56:17 +01:00
Bug 557786 - support fixed size arrays
svn path=/trunk/; revision=814
This commit is contained in:
parent
3944a895ce
commit
832328d59a
20
ginfo.c
20
ginfo.c
@ -830,6 +830,26 @@ g_type_info_get_array_length (GITypeInfo *info)
|
||||
return -1;
|
||||
}
|
||||
|
||||
gint
|
||||
g_type_info_get_array_fixed_size (GITypeInfo *info)
|
||||
{
|
||||
GIBaseInfo *base = (GIBaseInfo *)info;
|
||||
SimpleTypeBlob *type = (SimpleTypeBlob *)&base->typelib->data[base->offset];
|
||||
|
||||
if (!(type->reserved == 0 && type->reserved2 == 0))
|
||||
{
|
||||
ArrayTypeBlob *blob = (ArrayTypeBlob *)&base->typelib->data[base->offset];
|
||||
|
||||
if (blob->tag == GI_TYPE_TAG_ARRAY)
|
||||
{
|
||||
if (blob->has_size)
|
||||
return blob->size;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
gboolean
|
||||
g_type_info_is_zero_terminated (GITypeInfo *info)
|
||||
{
|
||||
|
@ -320,6 +320,7 @@ GITypeInfo * g_type_info_get_param_type (GITypeInfo *info,
|
||||
gint n);
|
||||
GIBaseInfo * g_type_info_get_interface (GITypeInfo *info);
|
||||
gint g_type_info_get_array_length (GITypeInfo *info);
|
||||
gint g_type_info_get_array_fixed_size(GITypeInfo *info);
|
||||
gboolean g_type_info_is_zero_terminated (GITypeInfo *info);
|
||||
|
||||
gint g_type_info_get_n_error_domains (GITypeInfo *info);
|
||||
|
10
girnode.c
10
girnode.c
@ -1114,6 +1114,8 @@ serialize_type (GIrModule *module,
|
||||
|
||||
if (node->has_length)
|
||||
g_string_append_printf (str, "length=%d", node->length);
|
||||
else if (node->has_size)
|
||||
g_string_append_printf (str, "fixed-size=%d", node->size);
|
||||
|
||||
if (node->zero_terminated)
|
||||
g_string_append_printf (str, "%szero-terminated=1",
|
||||
@ -1319,8 +1321,14 @@ g_ir_node_build_typelib (GIrNode *node,
|
||||
array->tag = type->tag;
|
||||
array->zero_terminated = type->zero_terminated;
|
||||
array->has_length = type->has_length;
|
||||
array->has_size = type->has_size;
|
||||
array->reserved2 = 0;
|
||||
array->length = type->length;
|
||||
if (array->has_length)
|
||||
array->length = type->length;
|
||||
else if (array->has_size)
|
||||
array->size = type->size;
|
||||
else
|
||||
array->length = -1;
|
||||
|
||||
pos = *offset2 + 4;
|
||||
*offset2 += 8;
|
||||
|
@ -119,6 +119,8 @@ struct _GIrNodeType
|
||||
gboolean zero_terminated;
|
||||
gboolean has_length;
|
||||
gint length;
|
||||
gboolean has_size;
|
||||
gint size;
|
||||
|
||||
GIrNodeType *parameter_type1;
|
||||
GIrNodeType *parameter_type2;
|
||||
|
@ -1514,6 +1514,7 @@ start_type (GMarkupParseContext *context,
|
||||
{
|
||||
const char *zero;
|
||||
const char *len;
|
||||
const char *size;
|
||||
|
||||
typenode = (GIrNodeType *)g_ir_node_new (G_IR_NODE_TYPE);
|
||||
|
||||
@ -1523,10 +1524,14 @@ start_type (GMarkupParseContext *context,
|
||||
|
||||
zero = find_attribute ("zero-terminated", attribute_names, attribute_values);
|
||||
len = find_attribute ("length", attribute_names, attribute_values);
|
||||
|
||||
size = find_attribute ("fixed-size", attribute_names, attribute_values);
|
||||
|
||||
typenode->zero_terminated = !(zero && strcmp (zero, "1") != 0);
|
||||
typenode->has_length = len != NULL;
|
||||
typenode->length = typenode->has_length ? atoi (len) : -1;
|
||||
|
||||
typenode->has_size = size != NULL;
|
||||
typenode->size = typenode->has_size ? atoi (size) : -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -206,9 +206,13 @@ typedef struct
|
||||
|
||||
guint16 zero_terminated :1;
|
||||
guint16 has_length :1;
|
||||
guint16 reserved2 :6;
|
||||
guint16 has_size :1;
|
||||
guint16 reserved2 :5;
|
||||
|
||||
guint16 length;
|
||||
union {
|
||||
guint16 length;
|
||||
guint16 size;
|
||||
};
|
||||
|
||||
SimpleTypeBlob type;
|
||||
} ArrayTypeBlob;
|
||||
|
Loading…
Reference in New Issue
Block a user