From 91fc45ea57a98fee7551af90a29c4e17069751ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 17:30:37 +0100 Subject: [PATCH 01/27] girepository: Replace tabs with spaces in indentation We don't use tabs anywhere and the mixed setup just makes many editors to cry. So let's just replace the tabs with 8 spaces. --- girepository/gdump.c | 78 +- girepository/gi-dump-types.c | 10 +- girepository/gibaseinfo.c | 2 +- girepository/gibaseinfo.h | 2 +- girepository/gicallableinfo.h | 2 +- girepository/gicallbackinfo.h | 2 +- girepository/giconstantinfo.c | 82 +- girepository/gifieldinfo.c | 570 ++++---- girepository/ginvoke.c | 8 +- girepository/giobjectinfo.c | 52 +- girepository/giobjectinfo.h | 4 +- girepository/girepository.c | 376 +++--- girepository/girffi.c | 14 +- girepository/girmodule.c | 148 +-- girepository/girnode.c | 2034 ++++++++++++++--------------- girepository/giroffsets.c | 288 ++-- girepository/girparser.c | 1572 +++++++++++----------- girepository/girwriter.c | 306 ++--- girepository/gitypeinfo.c | 18 +- girepository/gitypelib-internal.h | 10 +- girepository/gitypelib.c | 1108 ++++++++-------- girepository/giunioninfo.c | 6 +- girepository/giunioninfo.h | 2 +- girepository/giunresolvedinfo.h | 2 +- 24 files changed, 3348 insertions(+), 3348 deletions(-) diff --git a/girepository/gdump.c b/girepository/gdump.c index 78f4c3cd3..d7ec6b62f 100644 --- a/girepository/gdump.c +++ b/girepository/gdump.c @@ -143,9 +143,9 @@ invoke_get_type (GModule *self, const char *symbol, GError **error) if (!g_module_symbol (self, symbol, (void**)&sym)) { g_set_error (error, - G_FILE_ERROR, - G_FILE_ERROR_FAILED, - "Failed to find symbol '%s'", symbol); + G_FILE_ERROR, + G_FILE_ERROR_FAILED, + "Failed to find symbol '%s'", symbol); return G_TYPE_INVALID; } @@ -153,9 +153,9 @@ invoke_get_type (GModule *self, const char *symbol, GError **error) if (ret == G_TYPE_INVALID) { g_set_error (error, - G_FILE_ERROR, - G_FILE_ERROR_FAILED, - "Function '%s' returned G_TYPE_INVALID", symbol); + G_FILE_ERROR, + G_FILE_ERROR_FAILED, + "Function '%s' returned G_TYPE_INVALID", symbol); } return ret; } @@ -168,9 +168,9 @@ invoke_error_quark (GModule *self, const char *symbol, GError **error) if (!g_module_symbol (self, symbol, (void**)&sym)) { g_set_error (error, - G_FILE_ERROR, - G_FILE_ERROR_FAILED, - "Failed to find symbol '%s'", symbol); + G_FILE_ERROR, + G_FILE_ERROR_FAILED, + "Failed to find symbol '%s'", symbol); return G_TYPE_INVALID; } @@ -273,7 +273,7 @@ dump_properties (GType type, FILE *out) prop = props[i]; if (prop->owner_type != type) - continue; + continue; const GValue *v = g_param_spec_get_default_value (prop); char *default_value = value_to_string (v); @@ -318,7 +318,7 @@ dump_signals (GType type, FILE *out) g_signal_query (sigid, &query); escaped_printf (out, " \n"); for (j = 0; j < query.n_params; j++) - { - escaped_printf (out, " \n", - g_type_name (query.param_types[j])); - } + { + escaped_printf (out, " \n", + g_type_name (query.param_types[j])); + } goutput_write (out, " \n"); } g_free (sig_ids); @@ -360,7 +360,7 @@ dump_object_type (GType type, const char *symbol, FILE *out) GType *interfaces; escaped_printf (out, " \n", - g_type_name (itype)); + g_type_name (itype)); } g_free (interfaces); @@ -414,23 +414,23 @@ dump_interface_type (GType type, const char *symbol, FILE *out) GType *interfaces; escaped_printf (out, " \n", - g_type_name (type), symbol); + g_type_name (type), symbol); interfaces = g_type_interface_prerequisites (type, &n_interfaces); for (i = 0; i < n_interfaces; i++) { GType itype = interfaces[i]; if (itype == G_TYPE_OBJECT) - { - /* Treat this as implicit for now; in theory GInterfaces are - * supported on things like GstMiniObject, but right now - * the introspection system only supports GObject. - * http://bugzilla.gnome.org/show_bug.cgi?id=559706 - */ - continue; - } + { + /* Treat this as implicit for now; in theory GInterfaces are + * supported on things like GstMiniObject, but right now + * the introspection system only supports GObject. + * http://bugzilla.gnome.org/show_bug.cgi?id=559706 + */ + continue; + } escaped_printf (out, " \n", - g_type_name (itype)); + g_type_name (itype)); } g_free (interfaces); @@ -443,7 +443,7 @@ static void dump_boxed_type (GType type, const char *symbol, FILE *out) { escaped_printf (out, " \n", - g_type_name (type), symbol); + g_type_name (type), symbol); } static void @@ -454,14 +454,14 @@ dump_flags_type (GType type, const char *symbol, FILE *out) klass = g_type_class_ref (type); escaped_printf (out, " \n", - g_type_name (type), symbol); + g_type_name (type), symbol); for (i = 0; i < klass->n_values; i++) { GFlagsValue *value = &(klass->values[i]); escaped_printf (out, " \n", - value->value_name, value->value_nick, value->value); + value->value_name, value->value_nick, value->value); } goutput_write (out, " \n"); } @@ -474,14 +474,14 @@ dump_enum_type (GType type, const char *symbol, FILE *out) klass = g_type_class_ref (type); escaped_printf (out, " \n", - g_type_name (type), symbol); + g_type_name (type), symbol); for (i = 0; i < klass->n_values; i++) { GEnumValue *value = &(klass->values[i]); escaped_printf (out, " \n", - value->value_name, value->value_nick, value->value); + value->value_name, value->value_nick, value->value); } goutput_write (out, " "); } @@ -498,7 +498,7 @@ dump_fundamental_type (GType type, const char *symbol, FILE *out) escaped_printf (out, " \n", - g_type_name (itype)); + g_type_name (itype)); } g_free (interfaces); goutput_write (out, " \n"); @@ -573,7 +573,7 @@ static void dump_error_quark (GQuark quark, const char *symbol, FILE *out) { escaped_printf (out, " \n", - symbol, g_quark_to_string (quark)); + symbol, g_quark_to_string (quark)); } /** @@ -622,10 +622,10 @@ gi_repository_dump (const char *input_filename, if (!self) { g_set_error (error, - G_FILE_ERROR, - G_FILE_ERROR_FAILED, - "failed to open self: %s", - g_module_error ()); + G_FILE_ERROR, + G_FILE_ERROR_FAILED, + "failed to open self: %s", + g_module_error ()); return FALSE; } diff --git a/girepository/gi-dump-types.c b/girepository/gi-dump-types.c index 7e8f95e15..791fcf80a 100644 --- a/girepository/gi-dump-types.c +++ b/girepository/gi-dump-types.c @@ -41,12 +41,12 @@ main (int argc, type = invoke_get_type (self, argv[i], &error); if (!type) - { - g_printerr ("%s\n", error->message); - g_clear_error (&error); - } + { + g_printerr ("%s\n", error->message); + g_clear_error (&error); + } else - dump_type (type, argv[i], stdout); + dump_type (type, argv[i], stdout); } return 0; diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c index 575d50035..6a2164f18 100644 --- a/girepository/gibaseinfo.c +++ b/girepository/gibaseinfo.c @@ -428,7 +428,7 @@ gi_info_from_entry (GIRepository *repository, unresolved->namespace = namespace; return (GIBaseInfo *)unresolved; - } + } return (GIBaseInfo *)result; } diff --git a/girepository/gibaseinfo.h b/girepository/gibaseinfo.h index fdbe91ff8..41f568b53 100644 --- a/girepository/gibaseinfo.h +++ b/girepository/gibaseinfo.h @@ -50,7 +50,7 @@ typedef struct { gpointer data4; } GIAttributeIter; -#define GI_TYPE_BASE_INFO (gi_base_info_get_type ()) +#define GI_TYPE_BASE_INFO (gi_base_info_get_type ()) GI_AVAILABLE_IN_ALL diff --git a/girepository/gicallableinfo.h b/girepository/gicallableinfo.h index 64e2a3875..e91aef003 100644 --- a/girepository/gicallableinfo.h +++ b/girepository/gicallableinfo.h @@ -40,7 +40,7 @@ G_BEGIN_DECLS * * Since: 2.80 */ -#define GI_IS_CALLABLE_INFO(info) \ +#define GI_IS_CALLABLE_INFO(info) \ ((gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_FUNCTION) || \ (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_CALLBACK) || \ (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_SIGNAL) || \ diff --git a/girepository/gicallbackinfo.h b/girepository/gicallbackinfo.h index 52fd36882..ee035f525 100644 --- a/girepository/gicallbackinfo.h +++ b/girepository/gicallbackinfo.h @@ -39,7 +39,7 @@ G_BEGIN_DECLS * * Since: 2.80 */ -#define GI_IS_CALLBACK_INFO(info) \ +#define GI_IS_CALLBACK_INFO(info) \ (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_CALLBACK) G_END_DECLS diff --git a/girepository/giconstantinfo.c b/girepository/giconstantinfo.c index 1383e73a5..dd9ed3849 100644 --- a/girepository/giconstantinfo.c +++ b/girepository/giconstantinfo.c @@ -135,49 +135,49 @@ gi_constant_info_get_value (GIConstantInfo *info, { gsize blob_size = blob->size; - value->v_pointer = g_memdup2 (&rinfo->typelib->data[blob->offset], blob_size); + value->v_pointer = g_memdup2 (&rinfo->typelib->data[blob->offset], blob_size); } else - { - switch (blob->type.flags.tag) - { - case GI_TYPE_TAG_BOOLEAN: - value->v_boolean = *(gboolean*)&rinfo->typelib->data[blob->offset]; - break; - case GI_TYPE_TAG_INT8: - value->v_int8 = *(gint8*)&rinfo->typelib->data[blob->offset]; - break; - case GI_TYPE_TAG_UINT8: - value->v_uint8 = *(guint8*)&rinfo->typelib->data[blob->offset]; - break; - case GI_TYPE_TAG_INT16: - value->v_int16 = *(gint16*)&rinfo->typelib->data[blob->offset]; - break; - case GI_TYPE_TAG_UINT16: - value->v_uint16 = *(guint16*)&rinfo->typelib->data[blob->offset]; - break; - case GI_TYPE_TAG_INT32: - value->v_int32 = *(gint32*)&rinfo->typelib->data[blob->offset]; - break; - case GI_TYPE_TAG_UINT32: - value->v_uint32 = *(guint32*)&rinfo->typelib->data[blob->offset]; - break; - case GI_TYPE_TAG_INT64: - DO_ALIGNED_COPY(&value->v_int64, &rinfo->typelib->data[blob->offset], gint64); - break; - case GI_TYPE_TAG_UINT64: - DO_ALIGNED_COPY(&value->v_uint64, &rinfo->typelib->data[blob->offset], guint64); - break; - case GI_TYPE_TAG_FLOAT: - DO_ALIGNED_COPY(&value->v_float, &rinfo->typelib->data[blob->offset], gfloat); - break; - case GI_TYPE_TAG_DOUBLE: - DO_ALIGNED_COPY(&value->v_double, &rinfo->typelib->data[blob->offset], gdouble); - break; - default: - g_assert_not_reached (); - } - } + { + switch (blob->type.flags.tag) + { + case GI_TYPE_TAG_BOOLEAN: + value->v_boolean = *(gboolean*)&rinfo->typelib->data[blob->offset]; + break; + case GI_TYPE_TAG_INT8: + value->v_int8 = *(gint8*)&rinfo->typelib->data[blob->offset]; + break; + case GI_TYPE_TAG_UINT8: + value->v_uint8 = *(guint8*)&rinfo->typelib->data[blob->offset]; + break; + case GI_TYPE_TAG_INT16: + value->v_int16 = *(gint16*)&rinfo->typelib->data[blob->offset]; + break; + case GI_TYPE_TAG_UINT16: + value->v_uint16 = *(guint16*)&rinfo->typelib->data[blob->offset]; + break; + case GI_TYPE_TAG_INT32: + value->v_int32 = *(gint32*)&rinfo->typelib->data[blob->offset]; + break; + case GI_TYPE_TAG_UINT32: + value->v_uint32 = *(guint32*)&rinfo->typelib->data[blob->offset]; + break; + case GI_TYPE_TAG_INT64: + DO_ALIGNED_COPY(&value->v_int64, &rinfo->typelib->data[blob->offset], gint64); + break; + case GI_TYPE_TAG_UINT64: + DO_ALIGNED_COPY(&value->v_uint64, &rinfo->typelib->data[blob->offset], guint64); + break; + case GI_TYPE_TAG_FLOAT: + DO_ALIGNED_COPY(&value->v_float, &rinfo->typelib->data[blob->offset], gfloat); + break; + case GI_TYPE_TAG_DOUBLE: + DO_ALIGNED_COPY(&value->v_double, &rinfo->typelib->data[blob->offset], gdouble); + break; + default: + g_assert_not_reached (); + } + } } return blob->size; diff --git a/girepository/gifieldinfo.c b/girepository/gifieldinfo.c index b7ed9f7a4..eb4d069ed 100644 --- a/girepository/gifieldinfo.c +++ b/girepository/gifieldinfo.c @@ -211,151 +211,151 @@ gi_field_info_get_field (GIFieldInfo *field_info, else { switch (gi_type_info_get_tag (type_info)) - { - case GI_TYPE_TAG_VOID: - g_warning("Field %s: should not be have void type", - gi_base_info_get_name ((GIBaseInfo *)field_info)); - break; - case GI_TYPE_TAG_BOOLEAN: - 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); - result = TRUE; - break; - case GI_TYPE_TAG_INT16: - case GI_TYPE_TAG_UINT16: - 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_UNICHAR: - 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); - result = TRUE; - break; - case GI_TYPE_TAG_GTYPE: - 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); - result = TRUE; - break; - case GI_TYPE_TAG_DOUBLE: - value->v_double = G_STRUCT_MEMBER (gdouble, mem, offset); - result = TRUE; - break; - case GI_TYPE_TAG_ARRAY: - /* We don't check the array type and that it is fixed-size, - we trust g-ir-compiler to do the right thing */ - value->v_pointer = G_STRUCT_MEMBER_P (mem, offset); - result = TRUE; - break; - case GI_TYPE_TAG_UTF8: - case GI_TYPE_TAG_FILENAME: - case GI_TYPE_TAG_GLIST: - case GI_TYPE_TAG_GSLIST: - case GI_TYPE_TAG_GHASH: - g_warning("Field %s: type %s should have is_pointer set", - gi_base_info_get_name ((GIBaseInfo *)field_info), - gi_type_tag_to_string (gi_type_info_get_tag (type_info))); - break; - case GI_TYPE_TAG_ERROR: - /* Needs to be handled by the language binding directly */ - break; - case GI_TYPE_TAG_INTERFACE: - { - GIBaseInfo *interface = gi_type_info_get_interface (type_info); - switch (gi_base_info_get_info_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: - { - /* FIXME: there's a mismatch here between the value->v_int we use - * here and the gint64 result returned from gi_value_info_get_value(). - * But to switch this to gint64, we'd have to make gi_function_info_invoke() - * translate value->v_int64 to the proper ABI for an enum function - * call parameter, which will usually be int, and then fix up language - * bindings. - */ - GITypeTag storage_type = gi_enum_info_get_storage_type ((GIEnumInfo *)interface); - switch (storage_type) - { - case GI_TYPE_TAG_INT8: - case GI_TYPE_TAG_UINT8: - value->v_int = (gint)G_STRUCT_MEMBER (guint8, mem, offset); - result = TRUE; - break; - case GI_TYPE_TAG_INT16: - case GI_TYPE_TAG_UINT16: - value->v_int = (gint)G_STRUCT_MEMBER (guint16, mem, offset); - result = TRUE; - break; - case GI_TYPE_TAG_INT32: - case GI_TYPE_TAG_UINT32: - 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); - result = TRUE; - break; - default: - g_warning("Field %s: Unexpected enum storage type %s", - gi_base_info_get_name ((GIBaseInfo *)field_info), - gi_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", - gi_base_info_get_name ((GIBaseInfo *)field_info), - gi_base_info_get_info_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_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", - gi_base_info_get_name ((GIBaseInfo *)field_info), - gi_base_info_get_info_type (interface)); - break; - default: - break; - } + { + case GI_TYPE_TAG_VOID: + g_warning("Field %s: should not be have void type", + gi_base_info_get_name ((GIBaseInfo *)field_info)); + break; + case GI_TYPE_TAG_BOOLEAN: + 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); + result = TRUE; + break; + case GI_TYPE_TAG_INT16: + case GI_TYPE_TAG_UINT16: + 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_UNICHAR: + 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); + result = TRUE; + break; + case GI_TYPE_TAG_GTYPE: + 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); + result = TRUE; + break; + case GI_TYPE_TAG_DOUBLE: + value->v_double = G_STRUCT_MEMBER (gdouble, mem, offset); + result = TRUE; + break; + case GI_TYPE_TAG_ARRAY: + /* We don't check the array type and that it is fixed-size, + we trust g-ir-compiler to do the right thing */ + value->v_pointer = G_STRUCT_MEMBER_P (mem, offset); + result = TRUE; + break; + case GI_TYPE_TAG_UTF8: + case GI_TYPE_TAG_FILENAME: + case GI_TYPE_TAG_GLIST: + case GI_TYPE_TAG_GSLIST: + case GI_TYPE_TAG_GHASH: + g_warning("Field %s: type %s should have is_pointer set", + gi_base_info_get_name ((GIBaseInfo *)field_info), + gi_type_tag_to_string (gi_type_info_get_tag (type_info))); + break; + case GI_TYPE_TAG_ERROR: + /* Needs to be handled by the language binding directly */ + break; + case GI_TYPE_TAG_INTERFACE: + { + GIBaseInfo *interface = gi_type_info_get_interface (type_info); + switch (gi_base_info_get_info_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: + { + /* FIXME: there's a mismatch here between the value->v_int we use + * here and the gint64 result returned from gi_value_info_get_value(). + * But to switch this to gint64, we'd have to make gi_function_info_invoke() + * translate value->v_int64 to the proper ABI for an enum function + * call parameter, which will usually be int, and then fix up language + * bindings. + */ + GITypeTag storage_type = gi_enum_info_get_storage_type ((GIEnumInfo *)interface); + switch (storage_type) + { + case GI_TYPE_TAG_INT8: + case GI_TYPE_TAG_UINT8: + value->v_int = (gint)G_STRUCT_MEMBER (guint8, mem, offset); + result = TRUE; + break; + case GI_TYPE_TAG_INT16: + case GI_TYPE_TAG_UINT16: + value->v_int = (gint)G_STRUCT_MEMBER (guint16, mem, offset); + result = TRUE; + break; + case GI_TYPE_TAG_INT32: + case GI_TYPE_TAG_UINT32: + 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); + result = TRUE; + break; + default: + g_warning("Field %s: Unexpected enum storage type %s", + gi_base_info_get_name ((GIBaseInfo *)field_info), + gi_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", + gi_base_info_get_name ((GIBaseInfo *)field_info), + gi_base_info_get_info_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_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", + gi_base_info_get_name ((GIBaseInfo *)field_info), + gi_base_info_get_info_type (interface)); + break; + default: + break; + } - gi_base_info_unref ((GIBaseInfo *)interface); - break; - } - break; - default: - break; - } + gi_base_info_unref ((GIBaseInfo *)interface); + break; + } + break; + default: + break; + } } gi_base_info_unref ((GIBaseInfo *)type_info); @@ -402,163 +402,163 @@ gi_field_info_set_field (GIFieldInfo *field_info, if (!gi_type_info_is_pointer (type_info)) { switch (gi_type_info_get_tag (type_info)) - { - case GI_TYPE_TAG_VOID: - g_warning("Field %s: should not be have void type", - gi_base_info_get_name ((GIBaseInfo *)field_info)); - break; - case GI_TYPE_TAG_BOOLEAN: - 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; - result = TRUE; - break; - case GI_TYPE_TAG_INT16: - case GI_TYPE_TAG_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_UNICHAR: - 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; - result = TRUE; - break; - case GI_TYPE_TAG_GTYPE: - 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; - result = TRUE; - break; - case GI_TYPE_TAG_DOUBLE: - G_STRUCT_MEMBER (gdouble, mem, offset)= value->v_double; - result = TRUE; - break; - case GI_TYPE_TAG_UTF8: - case GI_TYPE_TAG_FILENAME: - case GI_TYPE_TAG_ARRAY: - case GI_TYPE_TAG_GLIST: - case GI_TYPE_TAG_GSLIST: - case GI_TYPE_TAG_GHASH: - g_warning("Field %s: type %s should have is_pointer set", - gi_base_info_get_name ((GIBaseInfo *)field_info), - gi_type_tag_to_string (gi_type_info_get_tag (type_info))); - break; - case GI_TYPE_TAG_ERROR: - /* Needs to be handled by the language binding directly */ - break; - case GI_TYPE_TAG_INTERFACE: - { - GIBaseInfo *interface = gi_type_info_get_interface (type_info); - switch (gi_base_info_get_info_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: - { - /* See FIXME above - */ - GITypeTag storage_type = gi_enum_info_get_storage_type ((GIEnumInfo *)interface); - switch (storage_type) - { - case GI_TYPE_TAG_INT8: - case GI_TYPE_TAG_UINT8: - G_STRUCT_MEMBER (guint8, mem, offset) = (guint8)value->v_int; - result = TRUE; - break; - case GI_TYPE_TAG_INT16: - case GI_TYPE_TAG_UINT16: - G_STRUCT_MEMBER (guint16, mem, offset) = (guint16)value->v_int; - result = TRUE; - break; - case GI_TYPE_TAG_INT32: - case GI_TYPE_TAG_UINT32: - 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; - result = TRUE; - break; - default: - g_warning("Field %s: Unexpected enum storage type %s", - gi_base_info_get_name ((GIBaseInfo *)field_info), - gi_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", - gi_base_info_get_name ((GIBaseInfo *)field_info), - gi_base_info_get_info_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_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", - gi_base_info_get_name ((GIBaseInfo *)field_info), - gi_base_info_get_info_type (interface)); - break; - default: - break; - } + { + case GI_TYPE_TAG_VOID: + g_warning("Field %s: should not be have void type", + gi_base_info_get_name ((GIBaseInfo *)field_info)); + break; + case GI_TYPE_TAG_BOOLEAN: + 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; + result = TRUE; + break; + case GI_TYPE_TAG_INT16: + case GI_TYPE_TAG_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_UNICHAR: + 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; + result = TRUE; + break; + case GI_TYPE_TAG_GTYPE: + 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; + result = TRUE; + break; + case GI_TYPE_TAG_DOUBLE: + G_STRUCT_MEMBER (gdouble, mem, offset)= value->v_double; + result = TRUE; + break; + case GI_TYPE_TAG_UTF8: + case GI_TYPE_TAG_FILENAME: + case GI_TYPE_TAG_ARRAY: + case GI_TYPE_TAG_GLIST: + case GI_TYPE_TAG_GSLIST: + case GI_TYPE_TAG_GHASH: + g_warning("Field %s: type %s should have is_pointer set", + gi_base_info_get_name ((GIBaseInfo *)field_info), + gi_type_tag_to_string (gi_type_info_get_tag (type_info))); + break; + case GI_TYPE_TAG_ERROR: + /* Needs to be handled by the language binding directly */ + break; + case GI_TYPE_TAG_INTERFACE: + { + GIBaseInfo *interface = gi_type_info_get_interface (type_info); + switch (gi_base_info_get_info_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: + { + /* See FIXME above + */ + GITypeTag storage_type = gi_enum_info_get_storage_type ((GIEnumInfo *)interface); + switch (storage_type) + { + case GI_TYPE_TAG_INT8: + case GI_TYPE_TAG_UINT8: + G_STRUCT_MEMBER (guint8, mem, offset) = (guint8)value->v_int; + result = TRUE; + break; + case GI_TYPE_TAG_INT16: + case GI_TYPE_TAG_UINT16: + G_STRUCT_MEMBER (guint16, mem, offset) = (guint16)value->v_int; + result = TRUE; + break; + case GI_TYPE_TAG_INT32: + case GI_TYPE_TAG_UINT32: + 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; + result = TRUE; + break; + default: + g_warning("Field %s: Unexpected enum storage type %s", + gi_base_info_get_name ((GIBaseInfo *)field_info), + gi_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", + gi_base_info_get_name ((GIBaseInfo *)field_info), + gi_base_info_get_info_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_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", + gi_base_info_get_name ((GIBaseInfo *)field_info), + gi_base_info_get_info_type (interface)); + break; + default: + break; + } - gi_base_info_unref ((GIBaseInfo *)interface); - break; - } - break; - default: - break; - } + gi_base_info_unref ((GIBaseInfo *)interface); + break; + } + break; + default: + break; + } } else { switch (gi_type_info_get_tag (type_info)) { case GI_TYPE_TAG_INTERFACE: { - GIBaseInfo *interface = gi_type_info_get_interface (type_info); - switch (gi_base_info_get_info_type (interface)) + GIBaseInfo *interface = gi_type_info_get_interface (type_info); + switch (gi_base_info_get_info_type (interface)) { case GI_INFO_TYPE_OBJECT: case GI_INFO_TYPE_INTERFACE: G_STRUCT_MEMBER (gpointer, mem, offset) = (gpointer)value->v_pointer; result = TRUE; break; - default: - break; + default: + break; } gi_base_info_unref ((GIBaseInfo *)interface); } break; - default: - break; + default: + break; } } diff --git a/girepository/ginvoke.c b/girepository/ginvoke.c index 00f29c6b9..f46c5d1b7 100644 --- a/girepository/ginvoke.c +++ b/girepository/ginvoke.c @@ -121,8 +121,8 @@ value_to_ffi_type (const GValue *gvalue, gpointer *value) */ static ffi_type * g_value_to_ffi_return_type (const GValue *gvalue, - const GIArgument *ffi_value, - gpointer *value) + const GIArgument *ffi_value, + gpointer *value) { ffi_type *rettype = NULL; GType type = g_type_fundamental (G_VALUE_TYPE (gvalue)); @@ -246,7 +246,7 @@ g_value_from_ffi_value (GValue *gvalue, break; default: g_warning ("Unsupported fundamental type: %s", - g_type_name (g_type_fundamental (G_VALUE_TYPE (gvalue)))); + g_type_name (g_type_fundamental (G_VALUE_TYPE (gvalue)))); } } @@ -288,7 +288,7 @@ gi_cclosure_marshal_generic (GClosure *closure, if (return_gvalue && G_VALUE_TYPE (return_gvalue)) { rtype = g_value_to_ffi_return_type (return_gvalue, &return_ffi_value, - &rvalue); + &rvalue); } else { diff --git a/girepository/giobjectinfo.c b/girepository/giobjectinfo.c index 67dffb692..8176aff1d 100644 --- a/girepository/giobjectinfo.c +++ b/girepository/giobjectinfo.c @@ -528,20 +528,20 @@ gi_object_info_find_method_using_interfaces (GIObjectInfo *info, n_interfaces = gi_object_info_get_n_interfaces (info); for (i = 0; i < n_interfaces; ++i) - { - GIInterfaceInfo *iface_info; + { + GIInterfaceInfo *iface_info; - iface_info = gi_object_info_get_interface (info, i); + iface_info = gi_object_info_get_interface (info, i); - result = gi_interface_info_find_method (iface_info, name); + result = gi_interface_info_find_method (iface_info, name); - if (result != NULL) - { - implementor_result = (GIObjectInfo *) iface_info; - break; - } - gi_base_info_unref ((GIBaseInfo*) iface_info); - } + if (result != NULL) + { + implementor_result = (GIObjectInfo *) iface_info; + break; + } + gi_base_info_unref ((GIBaseInfo*) iface_info); + } } if (implementor) *implementor = implementor_result; @@ -637,10 +637,10 @@ gi_object_info_find_signal (GIObjectInfo *info, GISignalInfo *siginfo = gi_object_info_get_signal (info, i); if (g_strcmp0 (gi_base_info_get_name ((GIBaseInfo *) siginfo), name) != 0) - { - gi_base_info_unref ((GIBaseInfo*)siginfo); - continue; - } + { + gi_base_info_unref ((GIBaseInfo*)siginfo); + continue; + } return siginfo; } @@ -801,20 +801,20 @@ gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *info, n_interfaces = gi_object_info_get_n_interfaces (info); for (i = 0; i < n_interfaces; ++i) - { - GIInterfaceInfo *iface_info; + { + GIInterfaceInfo *iface_info; - iface_info = gi_object_info_get_interface (info, i); + iface_info = gi_object_info_get_interface (info, i); - result = gi_interface_info_find_vfunc (iface_info, name); + result = gi_interface_info_find_vfunc (iface_info, name); - if (result != NULL) - { - implementor_result = (GIObjectInfo *) iface_info; - break; - } - gi_base_info_unref ((GIBaseInfo*) iface_info); - } + if (result != NULL) + { + implementor_result = (GIObjectInfo *) iface_info; + break; + } + gi_base_info_unref ((GIBaseInfo*) iface_info); + } } if (implementor) *implementor = implementor_result; diff --git a/girepository/giobjectinfo.h b/girepository/giobjectinfo.h index 2259096ff..454965693 100644 --- a/girepository/giobjectinfo.h +++ b/girepository/giobjectinfo.h @@ -88,7 +88,7 @@ typedef void * (*GIObjectInfoGetValueFunction) (const GValue *value); GI_AVAILABLE_IN_ALL -const gchar * gi_object_info_get_type_name (GIObjectInfo *info); +const gchar * gi_object_info_get_type_name (GIObjectInfo *info); GI_AVAILABLE_IN_ALL const gchar * gi_object_info_get_type_init_function_name (GIObjectInfo *info); @@ -135,7 +135,7 @@ GIFunctionInfo * gi_object_info_get_method (GIObjectInfo *info, GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_object_info_find_method (GIObjectInfo *info, - const gchar *name); + const gchar *name); GI_AVAILABLE_IN_ALL diff --git a/girepository/girepository.c b/girepository/girepository.c index 5962efe87..92f991c3c 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -111,8 +111,8 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved); BOOL WINAPI DllMain (HINSTANCE hinstDLL, - DWORD fdwReason, - LPVOID lpvReserved) + DWORD fdwReason, + LPVOID lpvReserved) { if (fdwReason == DLL_PROCESS_ATTACH) girepository_dll = hinstDLL; @@ -129,8 +129,8 @@ DllMain (HINSTANCE hinstDLL, */ #define GOBJECT_INTROSPECTION_LIBDIR \ g_build_filename (g_win32_get_package_installation_directory_of_module (girepository_dll), \ - "lib", \ - NULL) + "lib", \ + NULL) #endif @@ -140,8 +140,8 @@ gi_repository_init (GIRepository *repository) repository->priv = gi_repository_get_instance_private (repository); repository->priv->typelibs = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify) g_free, - (GDestroyNotify) gi_typelib_free); + (GDestroyNotify) g_free, + (GDestroyNotify) gi_typelib_free); repository->priv->lazy_typelibs = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, @@ -324,9 +324,9 @@ get_repository (GIRepository *repository) static GITypelib * check_version_conflict (GITypelib *typelib, - const gchar *namespace, - const gchar *expected_version, - char **version_conflict) + const gchar *namespace, + const gchar *expected_version, + char **version_conflict) { Header *header; const char *loaded_version; @@ -334,7 +334,7 @@ check_version_conflict (GITypelib *typelib, if (expected_version == NULL) { if (version_conflict) - *version_conflict = NULL; + *version_conflict = NULL; return typelib; } @@ -345,7 +345,7 @@ check_version_conflict (GITypelib *typelib, if (strcmp (expected_version, loaded_version) != 0) { if (version_conflict) - *version_conflict = (char*)loaded_version; + *version_conflict = (char*)loaded_version; return NULL; } if (version_conflict) @@ -355,11 +355,11 @@ check_version_conflict (GITypelib *typelib, static GITypelib * get_registered_status (GIRepository *repository, - const char *namespace, - const char *version, - gboolean allow_lazy, - gboolean *lazy_status, - char **version_conflict) + const char *namespace, + const char *version, + gboolean allow_lazy, + gboolean *lazy_status, + char **version_conflict) { GITypelib *typelib; repository = get_repository (repository); @@ -380,16 +380,16 @@ get_registered_status (GIRepository *repository, static GITypelib * get_registered (GIRepository *repository, - const char *namespace, - const char *version) + const char *namespace, + const char *version) { return get_registered_status (repository, namespace, version, TRUE, NULL, NULL); } static gboolean load_dependencies_recurse (GIRepository *repository, - GITypelib *typelib, - GError **error) + GITypelib *typelib, + GError **error) { char **dependencies; @@ -400,25 +400,25 @@ load_dependencies_recurse (GIRepository *repository, int i; for (i = 0; dependencies[i]; i++) - { - char *dependency = dependencies[i]; - const char *last_dash; - char *dependency_namespace; - const char *dependency_version; + { + char *dependency = dependencies[i]; + const char *last_dash; + char *dependency_namespace; + const char *dependency_version; - last_dash = strrchr (dependency, '-'); - dependency_namespace = g_strndup (dependency, last_dash - dependency); - dependency_version = last_dash+1; + last_dash = strrchr (dependency, '-'); + dependency_namespace = g_strndup (dependency, last_dash - dependency); + dependency_version = last_dash+1; - if (!gi_repository_require (repository, dependency_namespace, dependency_version, - 0, error)) - { - g_free (dependency_namespace); - g_strfreev (dependencies); - return FALSE; - } - g_free (dependency_namespace); - } + if (!gi_repository_require (repository, dependency_namespace, dependency_version, + 0, error)) + { + g_free (dependency_namespace); + g_strfreev (dependencies); + return FALSE; + } + g_free (dependency_namespace); + } g_strfreev (dependencies); } return TRUE; @@ -426,10 +426,10 @@ load_dependencies_recurse (GIRepository *repository, static const char * register_internal (GIRepository *repository, - const char *source, - gboolean lazy, - GITypelib *typelib, - GError **error) + const char *source, + gboolean lazy, + GITypelib *typelib, + GError **error) { Header *header; const gchar *namespace; @@ -445,9 +445,9 @@ register_internal (GIRepository *repository, if (lazy) { g_assert (!g_hash_table_lookup (repository->priv->lazy_typelibs, - namespace)); + namespace)); g_hash_table_insert (repository->priv->lazy_typelibs, - build_typelib_key (namespace, source), (void *)typelib); + build_typelib_key (namespace, source), (void *)typelib); } else { @@ -456,15 +456,15 @@ register_internal (GIRepository *repository, /* First, try loading all the dependencies */ if (!load_dependencies_recurse (repository, typelib, error)) - return NULL; + return NULL; /* Check if we are transitioning from lazily loaded state */ if (g_hash_table_lookup_extended (repository->priv->lazy_typelibs, - namespace, - (gpointer)&key, &value)) - g_hash_table_remove (repository->priv->lazy_typelibs, key); + namespace, + (gpointer)&key, &value)) + g_hash_table_remove (repository->priv->lazy_typelibs, key); else - key = build_typelib_key (namespace, source); + key = build_typelib_key (namespace, source); g_hash_table_insert (repository->priv->typelibs, g_steal_pointer (&key), @@ -584,7 +584,7 @@ get_typelib_dependencies_transitive (GIRepository *repository, */ char ** gi_repository_get_dependencies (GIRepository *repository, - const char *namespace) + const char *namespace) { GITypelib *typelib; GHashTable *transitive_dependencies; /* set of owned utf8 */ @@ -636,9 +636,9 @@ gi_repository_get_dependencies (GIRepository *repository, */ const char * gi_repository_load_typelib (GIRepository *repository, - GITypelib *typelib, - GIRepositoryLoadFlags flags, - GError **error) + GITypelib *typelib, + GIRepositoryLoadFlags flags, + GError **error) { Header *header; const char *namespace; @@ -654,20 +654,20 @@ gi_repository_load_typelib (GIRepository *repository, nsversion = gi_typelib_get_string (typelib, header->nsversion); if (get_registered_status (repository, namespace, nsversion, allow_lazy, - &is_lazy, &version_conflict)) + &is_lazy, &version_conflict)) { if (version_conflict != NULL) - { - g_set_error (error, GI_REPOSITORY_ERROR, - GI_REPOSITORY_ERROR_NAMESPACE_VERSION_CONFLICT, - "Attempting to load namespace '%s', version '%s', but '%s' is already loaded", - namespace, nsversion, version_conflict); - return NULL; - } + { + g_set_error (error, GI_REPOSITORY_ERROR, + GI_REPOSITORY_ERROR_NAMESPACE_VERSION_CONFLICT, + "Attempting to load namespace '%s', version '%s', but '%s' is already loaded", + namespace, nsversion, version_conflict); + return NULL; + } return namespace; } return register_internal (repository, "", - allow_lazy, typelib, error); + allow_lazy, typelib, error); } /** @@ -691,8 +691,8 @@ gi_repository_load_typelib (GIRepository *repository, */ gboolean gi_repository_is_registered (GIRepository *repository, - const gchar *namespace, - const gchar *version) + const gchar *namespace, + const gchar *version) { repository = get_repository (repository); return get_registered (repository, namespace, version) != NULL; @@ -755,7 +755,7 @@ gi_repository_new (void) */ guint gi_repository_get_n_infos (GIRepository *repository, - const gchar *namespace) + const gchar *namespace) { GITypelib *typelib; guint n_interfaces = 0; @@ -793,8 +793,8 @@ gi_repository_get_n_infos (GIRepository *repository, */ GIBaseInfo * gi_repository_get_info (GIRepository *repository, - const gchar *namespace, - guint idx) + const gchar *namespace, + guint idx) { GITypelib *typelib; DirEntry *entry; @@ -879,7 +879,7 @@ gi_repository_find_by_gtype (GIRepository *repository, repository = get_repository (repository); cached = g_hash_table_lookup (repository->priv->info_by_gtype, - (gpointer)gtype); + (gpointer)gtype); if (cached != NULL) return gi_base_info_ref (cached); @@ -918,8 +918,8 @@ gi_repository_find_by_gtype (GIRepository *repository, NULL, data.result_typelib, entry->offset); g_hash_table_insert (repository->priv->info_by_gtype, - (gpointer) gtype, - gi_base_info_ref (cached)); + (gpointer) gtype, + gi_base_info_ref (cached)); return cached; } else @@ -948,8 +948,8 @@ gi_repository_find_by_gtype (GIRepository *repository, */ GIBaseInfo * gi_repository_find_by_name (GIRepository *repository, - const gchar *namespace, - const gchar *name) + const gchar *namespace, + const gchar *name) { GITypelib *typelib; DirEntry *entry; @@ -978,8 +978,8 @@ typedef struct { static void find_by_error_domain_foreach (gpointer key, - gpointer value, - gpointer datap) + gpointer value, + gpointer datap) { GITypelib *typelib = (GITypelib*)value; FindByErrorDomainData *data = datap; @@ -1011,7 +1011,7 @@ find_by_error_domain_foreach (gpointer key, */ GIEnumInfo * gi_repository_find_by_error_domain (GIRepository *repository, - GQuark domain) + GQuark domain) { FindByErrorDomainData data; GIEnumInfo *cached; @@ -1019,7 +1019,7 @@ gi_repository_find_by_error_domain (GIRepository *repository, repository = get_repository (repository); cached = g_hash_table_lookup (repository->priv->info_by_error_domain, - GUINT_TO_POINTER (domain)); + GUINT_TO_POINTER (domain)); if (cached != NULL) return (GIEnumInfo *) gi_base_info_ref ((GIBaseInfo *)cached); @@ -1040,8 +1040,8 @@ gi_repository_find_by_error_domain (GIRepository *repository, NULL, data.result_typelib, data.result->offset); g_hash_table_insert (repository->priv->info_by_error_domain, - GUINT_TO_POINTER (domain), - gi_base_info_ref ((GIBaseInfo *) cached)); + GUINT_TO_POINTER (domain), + gi_base_info_ref ((GIBaseInfo *) cached)); return cached; } return NULL; @@ -1130,8 +1130,8 @@ gi_repository_get_object_gtype_interfaces (GIRepository *repository, static void collect_namespaces (gpointer key, - gpointer value, - gpointer data) + gpointer value, + gpointer data) { GList **list = data; @@ -1188,7 +1188,7 @@ gi_repository_get_loaded_namespaces (GIRepository *repository) */ const gchar * gi_repository_get_version (GIRepository *repository, - const gchar *namespace) + const gchar *namespace) { GITypelib *typelib; Header *header; @@ -1331,19 +1331,19 @@ gi_repository_get_c_prefix (GIRepository *repository, */ const gchar * gi_repository_get_typelib_path (GIRepository *repository, - const gchar *namespace) + const gchar *namespace) { gpointer orig_key, value; repository = get_repository (repository); if (!g_hash_table_lookup_extended (repository->priv->typelibs, namespace, - &orig_key, &value)) + &orig_key, &value)) { if (!g_hash_table_lookup_extended (repository->priv->lazy_typelibs, namespace, - &orig_key, &value)) + &orig_key, &value)) - return NULL; + return NULL; } return ((char*)orig_key) + strlen ((char *) orig_key) + 1; } @@ -1379,11 +1379,11 @@ find_namespace_version (const char *namespace, mfile = g_mapped_file_new (path, FALSE, &error); if (error) - { - g_free (path); - g_clear_error (&error); - continue; - } + { + g_free (path); + g_clear_error (&error); + continue; + } *path_ret = path; break; } @@ -1393,8 +1393,8 @@ find_namespace_version (const char *namespace, static gboolean parse_version (const char *version, - int *major, - int *minor) + int *major, + int *minor) { const char *dot; char *end; @@ -1416,7 +1416,7 @@ parse_version (const char *version, static int compare_version (const char *v1, - const char *v2) + const char *v2) { gboolean success; int v1_major, v1_minor; @@ -1452,7 +1452,7 @@ struct NamespaceVersionCandidadate static int compare_candidate_reverse (struct NamespaceVersionCandidadate *c1, - struct NamespaceVersionCandidadate *c2) + struct NamespaceVersionCandidadate *c2) { int result = compare_version (c1->version, c2->version); /* First, check the version */ @@ -1467,11 +1467,11 @@ compare_candidate_reverse (struct NamespaceVersionCandidadate *c1, * pick the earlier one. */ if (c1->path_index == c2->path_index) - return 0; + return 0; else if (c1->path_index > c2->path_index) - return 1; + return 1; else - return -1; + return -1; } } @@ -1509,66 +1509,66 @@ enumerate_namespace_versions (const char *namespace, dirname = search_paths[i]; dir = g_dir_open (dirname, 0, NULL); if (dir == NULL) - continue; + continue; while ((entry = g_dir_read_name (dir)) != NULL) - { - GMappedFile *mfile; - char *path, *version; - struct NamespaceVersionCandidadate *candidate; + { + GMappedFile *mfile; + char *path, *version; + struct NamespaceVersionCandidadate *candidate; - if (!g_str_has_suffix (entry, ".typelib")) - continue; + if (!g_str_has_suffix (entry, ".typelib")) + continue; - if (g_str_has_prefix (entry, namespace_dash)) - { - const char *last_dash; - const char *name_end; - int major, minor; + if (g_str_has_prefix (entry, namespace_dash)) + { + const char *last_dash; + const char *name_end; + int major, minor; - if (g_str_equal (namespace, GIREPOSITORY_TYPELIB_NAME) && - !g_str_equal (entry, GIREPOSITORY_TYPELIB_FILENAME)) - { - g_debug ("Ignoring %s because this libgirepository " - "corresponds to %s", - entry, GIREPOSITORY_TYPELIB_FILENAME); - continue; - } + if (g_str_equal (namespace, GIREPOSITORY_TYPELIB_NAME) && + !g_str_equal (entry, GIREPOSITORY_TYPELIB_FILENAME)) + { + g_debug ("Ignoring %s because this libgirepository " + "corresponds to %s", + entry, GIREPOSITORY_TYPELIB_FILENAME); + continue; + } - name_end = strrchr (entry, '.'); - last_dash = strrchr (entry, '-'); - version = g_strndup (last_dash+1, name_end-(last_dash+1)); - if (!parse_version (version, &major, &minor)) - { - g_free (version); - continue; - } - } - else - continue; + name_end = strrchr (entry, '.'); + last_dash = strrchr (entry, '-'); + version = g_strndup (last_dash+1, name_end-(last_dash+1)); + if (!parse_version (version, &major, &minor)) + { + g_free (version); + continue; + } + } + else + continue; - if (g_hash_table_lookup (found_versions, version) != NULL) - { - g_free (version); - continue; - } + if (g_hash_table_lookup (found_versions, version) != NULL) + { + g_free (version); + continue; + } - path = g_build_filename (dirname, entry, NULL); - mfile = g_mapped_file_new (path, FALSE, &error); - if (mfile == NULL) - { - g_free (path); - g_free (version); - g_clear_error (&error); - continue; - } - candidate = g_slice_new0 (struct NamespaceVersionCandidadate); - candidate->mfile = mfile; - candidate->path_index = index; - candidate->path = path; - candidate->version = version; - candidates = g_slist_prepend (candidates, candidate); - g_hash_table_add (found_versions, version); - } + path = g_build_filename (dirname, entry, NULL); + mfile = g_mapped_file_new (path, FALSE, &error); + if (mfile == NULL) + { + g_free (path); + g_free (version); + g_clear_error (&error); + continue; + } + candidate = g_slice_new0 (struct NamespaceVersionCandidadate); + candidate->mfile = mfile; + candidate->path_index = index; + candidate->path = path; + candidate->version = version; + candidates = g_slist_prepend (candidates, candidate); + g_hash_table_add (found_versions, version); + } g_dir_close (dir); index++; } @@ -1708,9 +1708,9 @@ require_internal (GIRepository *repository, if (version_conflict != NULL) { g_set_error (error, GI_REPOSITORY_ERROR, - GI_REPOSITORY_ERROR_NAMESPACE_VERSION_CONFLICT, - "Requiring namespace '%s' version '%s', but '%s' is already loaded", - namespace, version, version_conflict); + GI_REPOSITORY_ERROR_NAMESPACE_VERSION_CONFLICT, + "Requiring namespace '%s' version '%s', but '%s' is already loaded", + namespace, version, version_conflict); return NULL; } @@ -1729,15 +1729,15 @@ require_internal (GIRepository *repository, if (mfile == NULL) { if (version != NULL) - g_set_error (error, GI_REPOSITORY_ERROR, - GI_REPOSITORY_ERROR_TYPELIB_NOT_FOUND, - "Typelib file for namespace '%s', version '%s' not found", - namespace, version); + g_set_error (error, GI_REPOSITORY_ERROR, + GI_REPOSITORY_ERROR_TYPELIB_NOT_FOUND, + "Typelib file for namespace '%s', version '%s' not found", + namespace, version); else - g_set_error (error, GI_REPOSITORY_ERROR, - GI_REPOSITORY_ERROR_TYPELIB_NOT_FOUND, - "Typelib file for namespace '%s' (any version) not found", - namespace); + g_set_error (error, GI_REPOSITORY_ERROR, + GI_REPOSITORY_ERROR_TYPELIB_NOT_FOUND, + "Typelib file for namespace '%s' (any version) not found", + namespace); goto out; } @@ -1746,12 +1746,12 @@ require_internal (GIRepository *repository, typelib = gi_typelib_new_from_mapped_file (mfile, &temp_error); if (!typelib) { - g_set_error (error, GI_REPOSITORY_ERROR, - GI_REPOSITORY_ERROR_TYPELIB_NOT_FOUND, - "Failed to load typelib file '%s' for namespace '%s': %s", - path, namespace, temp_error->message); - g_clear_error (&temp_error); - goto out; + g_set_error (error, GI_REPOSITORY_ERROR, + GI_REPOSITORY_ERROR_TYPELIB_NOT_FOUND, + "Failed to load typelib file '%s' for namespace '%s': %s", + path, namespace, temp_error->message); + g_clear_error (&temp_error); + goto out; } } header = (Header *) typelib->data; @@ -1761,26 +1761,26 @@ require_internal (GIRepository *repository, if (strcmp (typelib_namespace, namespace) != 0) { g_set_error (error, GI_REPOSITORY_ERROR, - GI_REPOSITORY_ERROR_NAMESPACE_MISMATCH, - "Typelib file %s for namespace '%s' contains " - "namespace '%s' which doesn't match the file name", - path, namespace, typelib_namespace); + GI_REPOSITORY_ERROR_NAMESPACE_MISMATCH, + "Typelib file %s for namespace '%s' contains " + "namespace '%s' which doesn't match the file name", + path, namespace, typelib_namespace); gi_typelib_free (typelib); goto out; } if (version != NULL && strcmp (typelib_version, version) != 0) { g_set_error (error, GI_REPOSITORY_ERROR, - GI_REPOSITORY_ERROR_NAMESPACE_MISMATCH, - "Typelib file %s for namespace '%s' contains " - "version '%s' which doesn't match the expected version '%s'", - path, namespace, typelib_version, version); + GI_REPOSITORY_ERROR_NAMESPACE_MISMATCH, + "Typelib file %s for namespace '%s' contains " + "version '%s' which doesn't match the expected version '%s'", + path, namespace, typelib_version, version); gi_typelib_free (typelib); goto out; } if (!register_internal (repository, path, allow_lazy, - typelib, error)) + typelib, error)) { gi_typelib_free (typelib); goto out; @@ -1814,10 +1814,10 @@ require_internal (GIRepository *repository, */ GITypelib * gi_repository_require (GIRepository *repository, - const gchar *namespace, - const gchar *version, - GIRepositoryLoadFlags flags, - GError **error) + const gchar *namespace, + const gchar *version, + GIRepositoryLoadFlags flags, + GError **error) { GITypelib *typelib; @@ -1853,11 +1853,11 @@ gi_repository_require (GIRepository *repository, */ GITypelib * gi_repository_require_private (GIRepository *repository, - const gchar *typelib_dir, - const gchar *namespace, - const gchar *version, - GIRepositoryLoadFlags flags, - GError **error) + const gchar *typelib_dir, + const gchar *namespace, + const gchar *version, + GIRepositoryLoadFlags flags, + GError **error) { const char * const search_path[] = { typelib_dir, NULL }; @@ -1867,9 +1867,9 @@ gi_repository_require_private (GIRepository *repository, static gboolean gi_repository_introspect_cb (const char *option_name, - const char *value, - gpointer data, - GError **error) + const char *value, + gpointer data, + GError **error) { GError *tmp_error = NULL; char **args; @@ -1879,7 +1879,7 @@ gi_repository_introspect_cb (const char *option_name, if (!gi_repository_dump (args[0], args[1], &tmp_error)) { g_error ("Failed to extract GType data: %s", - tmp_error->message); + tmp_error->message); exit (1); } exit (0); diff --git a/girepository/girffi.c b/girepository/girffi.c index f14ab84c7..d80c50ff7 100644 --- a/girepository/girffi.c +++ b/girepository/girffi.c @@ -38,7 +38,7 @@ static ffi_type * gi_type_tag_get_ffi_type_internal (GITypeTag tag, gboolean is_pointer, - gboolean is_enum) + gboolean is_enum) { switch (tag) { @@ -83,13 +83,13 @@ gi_type_tag_get_ffi_type_internal (GITypeTag tag, return &ffi_type_pointer; case GI_TYPE_TAG_INTERFACE: { - /* We need to handle enums specially: - * https://bugzilla.gnome.org/show_bug.cgi?id=665150 - */ + /* We need to handle enums specially: + * https://bugzilla.gnome.org/show_bug.cgi?id=665150 + */ if (!is_enum) return &ffi_type_pointer; - else - return &ffi_type_sint32; + else + return &ffi_type_sint32; } case GI_TYPE_TAG_VOID: if (is_pointer) @@ -118,7 +118,7 @@ gi_type_tag_get_ffi_type_internal (GITypeTag tag, */ ffi_type * gi_type_tag_get_ffi_type (GITypeTag type_tag, - gboolean is_pointer) + gboolean is_pointer) { return gi_type_tag_get_ffi_type_internal (type_tag, is_pointer, FALSE); } diff --git a/girepository/girmodule.c b/girepository/girmodule.c index d48572165..664915bf3 100644 --- a/girepository/girmodule.c +++ b/girepository/girmodule.c @@ -122,16 +122,16 @@ gi_ir_module_fatal (GIIrTypelibBuild *build, GIIrNode *node = link->data; const char *name = node->name; if (name) - g_string_append (context, name); + g_string_append (context, name); if (link->prev) - g_string_append (context, "."); + g_string_append (context, "."); } if (build->stack) g_string_append (context, ": "); g_printerr ("%s-%s.gir:%serror: %s\n", build->module->name, - build->module->version, - context->str, formatted); + build->module->version, + context->str, formatted); g_string_free (context, TRUE); exit (1); @@ -141,8 +141,8 @@ gi_ir_module_fatal (GIIrTypelibBuild *build, static void add_alias_foreach (gpointer key, - gpointer value, - gpointer data) + gpointer value, + gpointer data) { GIIrModule *module = data; @@ -161,8 +161,8 @@ add_pointer_structure_foreach (gpointer key, static void add_disguised_structure_foreach (gpointer key, - gpointer value, - gpointer data) + gpointer value, + gpointer data) { GIIrModule *module = data; @@ -174,18 +174,18 @@ gi_ir_module_add_include_module (GIIrModule *module, GIIrModule *include_module) { module->include_modules = g_list_prepend (module->include_modules, - include_module); + include_module); g_hash_table_foreach (include_module->aliases, - add_alias_foreach, - module); + add_alias_foreach, + module); g_hash_table_foreach (include_module->pointer_structures, - add_pointer_structure_foreach, - module); + add_pointer_structure_foreach, + module); g_hash_table_foreach (include_module->disguised_structures, - add_disguised_structure_foreach, - module); + add_disguised_structure_foreach, + module); } struct AttributeWriteData @@ -256,11 +256,11 @@ alloc_section (guint8 *data, SectionType section_id, guint32 offset) for (i = 0; i < NUM_SECTIONS; i++) { if (section_data->id == GI_SECTION_END) - { - section_data->id = section_id; - section_data->offset = offset; - return; - } + { + section_data->id = section_id; + section_data->offset = offset; + return; + } section_data++; } g_assert_not_reached (); @@ -346,18 +346,18 @@ gi_ir_module_build_typelib (GIIrModule *module) GList *link; for (link = module->dependencies; link; link = link->next) { - const char *dependency = link->data; - if (!strcmp (dependency, module->name)) - continue; - g_string_append (dependencies_str, dependency); - if (link->next) - g_string_append_c (dependencies_str, '|'); + const char *dependency = link->data; + if (!strcmp (dependency, module->name)) + continue; + g_string_append (dependencies_str, dependency); + if (link->next) + g_string_append_c (dependencies_str, '|'); } dependencies = g_string_free (dependencies_str, FALSE); if (!dependencies[0]) { - g_free (dependencies); - dependencies = NULL; + g_free (dependencies); + dependencies = NULL; } } @@ -369,7 +369,7 @@ gi_ir_module_build_typelib (GIIrModule *module) n_entries = g_list_length (module->entries); g_message ("%d entries (%d local), %d dependencies", n_entries, n_local_entries, - g_list_length (module->dependencies)); + g_list_length (module->dependencies)); dir_size = n_entries * sizeof (DirEntry); size = header_size + dir_size; @@ -398,7 +398,7 @@ gi_ir_module_build_typelib (GIIrModule *module) size += sizeof (Section) * NUM_SECTIONS; g_message ("allocating %d bytes (%d header, %d directory, %d entries)", - size, header_size, dir_size, size - header_size - dir_size); + size, header_size, dir_size, size - header_size - dir_size); data = g_malloc0 (size); @@ -476,67 +476,67 @@ gi_ir_module_build_typelib (GIIrModule *module) if (strchr (node->name, '.')) { - g_error ("Names may not contain '.'"); - } + g_error ("Names may not contain '.'"); + } /* we picked up implicit xref nodes, start over */ if (i == n_entries) - { - GList *link; - g_message ("Found implicit cross references, starting over"); + { + GList *link; + g_message ("Found implicit cross references, starting over"); - g_hash_table_destroy (strings); - g_hash_table_destroy (types); + g_hash_table_destroy (strings); + g_hash_table_destroy (types); - /* Reset the cached offsets */ - for (link = nodes_with_attributes; link; link = link->next) - ((GIIrNode *) link->data)->offset = 0; + /* Reset the cached offsets */ + for (link = nodes_with_attributes; link; link = link->next) + ((GIIrNode *) link->data)->offset = 0; - g_list_free (nodes_with_attributes); - strings = NULL; + g_list_free (nodes_with_attributes); + strings = NULL; - g_free (data); - data = NULL; + g_free (data); + data = NULL; - goto restart; - } + goto restart; + } offset = offset2; if (node->type == GI_IR_NODE_XREF) - { - const char *namespace = ((GIIrNodeXRef*)node)->namespace; + { + const char *namespace = ((GIIrNodeXRef*)node)->namespace; - entry->blob_type = 0; - entry->local = FALSE; - entry->offset = gi_ir_write_string (namespace, strings, data, &offset2); - entry->name = gi_ir_write_string (node->name, strings, data, &offset2); - } + entry->blob_type = 0; + entry->local = FALSE; + entry->offset = gi_ir_write_string (namespace, strings, data, &offset2); + entry->name = gi_ir_write_string (node->name, strings, data, &offset2); + } else - { - old_offset = offset; - offset2 = offset + gi_ir_node_get_size (node); + { + old_offset = offset; + offset2 = offset + gi_ir_node_get_size (node); - entry->blob_type = node->type; - entry->local = TRUE; - entry->offset = offset; - entry->name = gi_ir_write_string (node->name, strings, data, &offset2); + entry->blob_type = node->type; + entry->local = TRUE; + entry->offset = offset; + entry->name = gi_ir_write_string (node->name, strings, data, &offset2); - memset (&build, 0, sizeof (build)); - build.module = module; - build.strings = strings; - build.types = types; - build.nodes_with_attributes = nodes_with_attributes; - build.n_attributes = header->n_attributes; - build.data = data; - gi_ir_node_build_typelib (node, NULL, &build, &offset, &offset2, NULL); + memset (&build, 0, sizeof (build)); + build.module = module; + build.strings = strings; + build.types = types; + build.nodes_with_attributes = nodes_with_attributes; + build.n_attributes = header->n_attributes; + build.data = data; + gi_ir_node_build_typelib (node, NULL, &build, &offset, &offset2, NULL); - nodes_with_attributes = build.nodes_with_attributes; - header->n_attributes = build.n_attributes; + nodes_with_attributes = build.nodes_with_attributes; + header->n_attributes = build.n_attributes; - if (offset2 > old_offset + gi_ir_node_get_full_size (node)) - g_error ("left a hole of %d bytes", offset2 - old_offset - gi_ir_node_get_full_size (node)); - } + if (offset2 > old_offset + gi_ir_node_get_full_size (node)) + g_error ("left a hole of %d bytes", offset2 - old_offset - gi_ir_node_get_full_size (node)); + } entry++; } @@ -572,7 +572,7 @@ gi_ir_module_build_typelib (GIIrModule *module) if (!typelib) { g_error ("error building typelib: %s", - error->message); + error->message); } g_hash_table_destroy (strings); diff --git a/girepository/girnode.c b/girepository/girnode.c index fb02e2425..0fcde3750 100644 --- a/girepository/girnode.c +++ b/girepository/girnode.c @@ -59,15 +59,15 @@ void gi_ir_node_dump_stats (void) { g_message ("%lu strings (%lu before sharing), %lu bytes (%lu before sharing)", - unique_string_count, string_count, unique_string_size, string_size); + unique_string_count, string_count, unique_string_size, string_size); g_message ("%lu types (%lu before sharing)", unique_types_count, types_count); } #define DO_ALIGNED_COPY(dest_addr, value, type) \ do { \ - type tmp_var; \ - tmp_var = value; \ - memcpy(dest_addr, &tmp_var, sizeof(type)); \ + type tmp_var; \ + tmp_var = value; \ + memcpy(dest_addr, &tmp_var, sizeof(type)); \ } while(0) #define ALIGN_VALUE(this, boundary) \ @@ -218,205 +218,205 @@ gi_ir_node_free (GIIrNode *node) case GI_IR_NODE_FUNCTION: case GI_IR_NODE_CALLBACK: { - GIIrNodeFunction *function = (GIIrNodeFunction *)node; + GIIrNodeFunction *function = (GIIrNodeFunction *)node; - g_free (node->name); - g_free (function->symbol); + g_free (node->name); + g_free (function->symbol); g_free (function->property); - gi_ir_node_free ((GIIrNode *)function->result); - for (l = function->parameters; l; l = l->next) - gi_ir_node_free ((GIIrNode *)l->data); - g_list_free (function->parameters); + gi_ir_node_free ((GIIrNode *)function->result); + for (l = function->parameters; l; l = l->next) + gi_ir_node_free ((GIIrNode *)l->data); + g_list_free (function->parameters); } break; case GI_IR_NODE_TYPE: { - GIIrNodeType *type = (GIIrNodeType *)node; + GIIrNodeType *type = (GIIrNodeType *)node; - g_free (node->name); - gi_ir_node_free ((GIIrNode *)type->parameter_type1); - gi_ir_node_free ((GIIrNode *)type->parameter_type2); + g_free (node->name); + gi_ir_node_free ((GIIrNode *)type->parameter_type1); + gi_ir_node_free ((GIIrNode *)type->parameter_type2); - g_free (type->giinterface); - g_strfreev (type->errors); + g_free (type->giinterface); + g_strfreev (type->errors); } break; case GI_IR_NODE_PARAM: { - GIIrNodeParam *param = (GIIrNodeParam *)node; + GIIrNodeParam *param = (GIIrNodeParam *)node; - g_free (node->name); - gi_ir_node_free ((GIIrNode *)param->type); + g_free (node->name); + gi_ir_node_free ((GIIrNode *)param->type); } break; case GI_IR_NODE_PROPERTY: { - GIIrNodeProperty *property = (GIIrNodeProperty *)node; + GIIrNodeProperty *property = (GIIrNodeProperty *)node; - g_free (node->name); + g_free (node->name); g_free (property->setter); g_free (property->getter); - gi_ir_node_free ((GIIrNode *)property->type); + gi_ir_node_free ((GIIrNode *)property->type); } break; case GI_IR_NODE_SIGNAL: { - GIIrNodeSignal *signal = (GIIrNodeSignal *)node; + GIIrNodeSignal *signal = (GIIrNodeSignal *)node; - g_free (node->name); - for (l = signal->parameters; l; l = l->next) - gi_ir_node_free ((GIIrNode *)l->data); - g_list_free (signal->parameters); - gi_ir_node_free ((GIIrNode *)signal->result); + g_free (node->name); + for (l = signal->parameters; l; l = l->next) + gi_ir_node_free ((GIIrNode *)l->data); + g_list_free (signal->parameters); + gi_ir_node_free ((GIIrNode *)signal->result); } break; case GI_IR_NODE_VFUNC: { - GIIrNodeVFunc *vfunc = (GIIrNodeVFunc *)node; + GIIrNodeVFunc *vfunc = (GIIrNodeVFunc *)node; - g_free (node->name); - g_free (vfunc->invoker); - for (l = vfunc->parameters; l; l = l->next) - gi_ir_node_free ((GIIrNode *)l->data); - g_list_free (vfunc->parameters); - gi_ir_node_free ((GIIrNode *)vfunc->result); + g_free (node->name); + g_free (vfunc->invoker); + for (l = vfunc->parameters; l; l = l->next) + gi_ir_node_free ((GIIrNode *)l->data); + g_list_free (vfunc->parameters); + gi_ir_node_free ((GIIrNode *)vfunc->result); } break; case GI_IR_NODE_FIELD: { - GIIrNodeField *field = (GIIrNodeField *)node; + GIIrNodeField *field = (GIIrNodeField *)node; - g_free (node->name); - gi_ir_node_free ((GIIrNode *)field->type); - gi_ir_node_free ((GIIrNode *)field->callback); + g_free (node->name); + gi_ir_node_free ((GIIrNode *)field->type); + gi_ir_node_free ((GIIrNode *)field->callback); } break; case GI_IR_NODE_OBJECT: case GI_IR_NODE_INTERFACE: { - GIIrNodeInterface *iface = (GIIrNodeInterface *)node; + GIIrNodeInterface *iface = (GIIrNodeInterface *)node; - g_free (node->name); - g_free (iface->gtype_name); - g_free (iface->gtype_init); - g_free (iface->ref_func); - g_free (iface->unref_func); - g_free (iface->set_value_func); - g_free (iface->get_value_func); + g_free (node->name); + g_free (iface->gtype_name); + g_free (iface->gtype_init); + g_free (iface->ref_func); + g_free (iface->unref_func); + g_free (iface->set_value_func); + g_free (iface->get_value_func); - g_free (iface->glib_type_struct); - g_free (iface->parent); + g_free (iface->glib_type_struct); + g_free (iface->parent); - for (l = iface->interfaces; l; l = l->next) - g_free ((GIIrNode *)l->data); - g_list_free (iface->interfaces); + for (l = iface->interfaces; l; l = l->next) + g_free ((GIIrNode *)l->data); + g_list_free (iface->interfaces); - for (l = iface->members; l; l = l->next) - gi_ir_node_free ((GIIrNode *)l->data); - g_list_free (iface->members); + for (l = iface->members; l; l = l->next) + gi_ir_node_free ((GIIrNode *)l->data); + g_list_free (iface->members); } break; case GI_IR_NODE_VALUE: { - g_free (node->name); + g_free (node->name); } break; case GI_IR_NODE_ENUM: case GI_IR_NODE_FLAGS: { - GIIrNodeEnum *enum_ = (GIIrNodeEnum *)node; + GIIrNodeEnum *enum_ = (GIIrNodeEnum *)node; - g_free (node->name); - g_free (enum_->gtype_name); - g_free (enum_->gtype_init); - g_free (enum_->error_domain); + g_free (node->name); + g_free (enum_->gtype_name); + g_free (enum_->gtype_init); + g_free (enum_->error_domain); - for (l = enum_->values; l; l = l->next) - gi_ir_node_free ((GIIrNode *)l->data); - g_list_free (enum_->values); + for (l = enum_->values; l; l = l->next) + gi_ir_node_free ((GIIrNode *)l->data); + g_list_free (enum_->values); - for (l = enum_->methods; l; l = l->next) - gi_ir_node_free ((GIIrNode *)l->data); - g_list_free (enum_->methods); + for (l = enum_->methods; l; l = l->next) + gi_ir_node_free ((GIIrNode *)l->data); + g_list_free (enum_->methods); } break; case GI_IR_NODE_BOXED: { - GIIrNodeBoxed *boxed = (GIIrNodeBoxed *)node; + GIIrNodeBoxed *boxed = (GIIrNodeBoxed *)node; - g_free (node->name); - g_free (boxed->gtype_name); - g_free (boxed->gtype_init); + g_free (node->name); + g_free (boxed->gtype_name); + g_free (boxed->gtype_init); - for (l = boxed->members; l; l = l->next) - gi_ir_node_free ((GIIrNode *)l->data); - g_list_free (boxed->members); + for (l = boxed->members; l; l = l->next) + gi_ir_node_free ((GIIrNode *)l->data); + g_list_free (boxed->members); } break; case GI_IR_NODE_STRUCT: { - GIIrNodeStruct *struct_ = (GIIrNodeStruct *)node; + GIIrNodeStruct *struct_ = (GIIrNodeStruct *)node; - g_free (node->name); - g_free (struct_->gtype_name); - g_free (struct_->gtype_init); + g_free (node->name); + g_free (struct_->gtype_name); + g_free (struct_->gtype_init); g_free (struct_->copy_func); g_free (struct_->free_func); - for (l = struct_->members; l; l = l->next) - gi_ir_node_free ((GIIrNode *)l->data); - g_list_free (struct_->members); + for (l = struct_->members; l; l = l->next) + gi_ir_node_free ((GIIrNode *)l->data); + g_list_free (struct_->members); } break; case GI_IR_NODE_CONSTANT: { - GIIrNodeConstant *constant = (GIIrNodeConstant *)node; + GIIrNodeConstant *constant = (GIIrNodeConstant *)node; - g_free (node->name); - g_free (constant->value); - gi_ir_node_free ((GIIrNode *)constant->type); + g_free (node->name); + g_free (constant->value); + gi_ir_node_free ((GIIrNode *)constant->type); } break; case GI_IR_NODE_XREF: { - GIIrNodeXRef *xref = (GIIrNodeXRef *)node; + GIIrNodeXRef *xref = (GIIrNodeXRef *)node; - g_free (node->name); - g_free (xref->namespace); + g_free (node->name); + g_free (xref->namespace); } break; case GI_IR_NODE_UNION: { - GIIrNodeUnion *union_ = (GIIrNodeUnion *)node; + GIIrNodeUnion *union_ = (GIIrNodeUnion *)node; - g_free (node->name); - g_free (union_->gtype_name); - g_free (union_->gtype_init); + g_free (node->name); + g_free (union_->gtype_name); + g_free (union_->gtype_init); g_free (union_->copy_func); g_free (union_->free_func); - gi_ir_node_free ((GIIrNode *)union_->discriminator_type); - for (l = union_->members; l; l = l->next) - gi_ir_node_free ((GIIrNode *)l->data); - for (l = union_->discriminators; l; l = l->next) - gi_ir_node_free ((GIIrNode *)l->data); + gi_ir_node_free ((GIIrNode *)union_->discriminator_type); + for (l = union_->members; l; l = l->next) + gi_ir_node_free ((GIIrNode *)l->data); + for (l = union_->discriminators; l; l = l->next) + gi_ir_node_free ((GIIrNode *)l->data); } break; @@ -458,38 +458,38 @@ gi_ir_node_get_size (GIIrNode *node) case GI_IR_NODE_OBJECT: { - GIIrNodeInterface *iface = (GIIrNodeInterface *)node; + GIIrNodeInterface *iface = (GIIrNodeInterface *)node; - n = g_list_length (iface->interfaces); - size = sizeof (ObjectBlob) + 2 * (n + (n % 2)); + n = g_list_length (iface->interfaces); + size = sizeof (ObjectBlob) + 2 * (n + (n % 2)); - for (l = iface->members; l; l = l->next) - size += gi_ir_node_get_size ((GIIrNode *)l->data); + for (l = iface->members; l; l = l->next) + size += gi_ir_node_get_size ((GIIrNode *)l->data); } break; case GI_IR_NODE_INTERFACE: { - GIIrNodeInterface *iface = (GIIrNodeInterface *)node; + GIIrNodeInterface *iface = (GIIrNodeInterface *)node; - n = g_list_length (iface->prerequisites); - size = sizeof (InterfaceBlob) + 2 * (n + (n % 2)); + n = g_list_length (iface->prerequisites); + size = sizeof (InterfaceBlob) + 2 * (n + (n % 2)); - for (l = iface->members; l; l = l->next) - size += gi_ir_node_get_size ((GIIrNode *)l->data); + for (l = iface->members; l; l = l->next) + size += gi_ir_node_get_size ((GIIrNode *)l->data); } break; case GI_IR_NODE_ENUM: case GI_IR_NODE_FLAGS: { - GIIrNodeEnum *enum_ = (GIIrNodeEnum *)node; + GIIrNodeEnum *enum_ = (GIIrNodeEnum *)node; - size = sizeof (EnumBlob); - for (l = enum_->values; l; l = l->next) - size += gi_ir_node_get_size ((GIIrNode *)l->data); - for (l = enum_->methods; l; l = l->next) - size += gi_ir_node_get_size ((GIIrNode *)l->data); + size = sizeof (EnumBlob); + for (l = enum_->values; l; l = l->next) + size += gi_ir_node_get_size ((GIIrNode *)l->data); + for (l = enum_->methods; l; l = l->next) + size += gi_ir_node_get_size ((GIIrNode *)l->data); } break; @@ -499,21 +499,21 @@ gi_ir_node_get_size (GIIrNode *node) case GI_IR_NODE_STRUCT: { - GIIrNodeStruct *struct_ = (GIIrNodeStruct *)node; + GIIrNodeStruct *struct_ = (GIIrNodeStruct *)node; - size = sizeof (StructBlob); - for (l = struct_->members; l; l = l->next) - size += gi_ir_node_get_size ((GIIrNode *)l->data); + size = sizeof (StructBlob); + for (l = struct_->members; l; l = l->next) + size += gi_ir_node_get_size ((GIIrNode *)l->data); } break; case GI_IR_NODE_BOXED: { - GIIrNodeBoxed *boxed = (GIIrNodeBoxed *)node; + GIIrNodeBoxed *boxed = (GIIrNodeBoxed *)node; - size = sizeof (StructBlob); - for (l = boxed->members; l; l = l->next) - size += gi_ir_node_get_size ((GIIrNode *)l->data); + size = sizeof (StructBlob); + for (l = boxed->members; l; l = l->next) + size += gi_ir_node_get_size ((GIIrNode *)l->data); } break; @@ -531,7 +531,7 @@ gi_ir_node_get_size (GIIrNode *node) case GI_IR_NODE_FIELD: { - GIIrNodeField *field = (GIIrNodeField *)node; + GIIrNodeField *field = (GIIrNodeField *)node; size = sizeof (FieldBlob); if (field->callback) @@ -549,13 +549,13 @@ gi_ir_node_get_size (GIIrNode *node) case GI_IR_NODE_UNION: { - GIIrNodeUnion *union_ = (GIIrNodeUnion *)node; + GIIrNodeUnion *union_ = (GIIrNodeUnion *)node; - size = sizeof (UnionBlob); - for (l = union_->members; l; l = l->next) - size += gi_ir_node_get_size ((GIIrNode *)l->data); - for (l = union_->discriminators; l; l = l->next) - size += gi_ir_node_get_size ((GIIrNode *)l->data); + size = sizeof (UnionBlob); + for (l = union_->members; l; l = l->next) + size += gi_ir_node_get_size ((GIIrNode *)l->data); + for (l = union_->discriminators; l; l = l->next) + size += gi_ir_node_get_size ((GIIrNode *)l->data); } break; @@ -565,7 +565,7 @@ gi_ir_node_get_size (GIIrNode *node) } g_debug ("node %p type '%s' size %d", node, - gi_ir_node_type_to_string (node->type), size); + gi_ir_node_type_to_string (node->type), size); return size; } @@ -594,286 +594,286 @@ gi_ir_node_get_full_size_internal (GIIrNode *parent, g_error ("Caught NULL node, parent=%s", parent->name); g_debug ("node %p type '%s'", node, - gi_ir_node_type_to_string (node->type)); + gi_ir_node_type_to_string (node->type)); switch (node->type) { case GI_IR_NODE_CALLBACK: { - GIIrNodeFunction *function = (GIIrNodeFunction *)node; - size = sizeof (CallbackBlob); - size += ALIGN_VALUE (strlen (node->name) + 1, 4); - for (l = function->parameters; l; l = l->next) - { - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); - } - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)function->result); + GIIrNodeFunction *function = (GIIrNodeFunction *)node; + size = sizeof (CallbackBlob); + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + for (l = function->parameters; l; l = l->next) + { + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); + } + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)function->result); } break; case GI_IR_NODE_FUNCTION: { - GIIrNodeFunction *function = (GIIrNodeFunction *)node; - size = sizeof (FunctionBlob); - size += ALIGN_VALUE (strlen (node->name) + 1, 4); - size += ALIGN_VALUE (strlen (function->symbol) + 1, 4); - for (l = function->parameters; l; l = l->next) - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)function->result); + GIIrNodeFunction *function = (GIIrNodeFunction *)node; + size = sizeof (FunctionBlob); + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + size += ALIGN_VALUE (strlen (function->symbol) + 1, 4); + for (l = function->parameters; l; l = l->next) + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)function->result); } break; case GI_IR_NODE_PARAM: { - GIIrNodeParam *param = (GIIrNodeParam *)node; + GIIrNodeParam *param = (GIIrNodeParam *)node; - /* See the comment in the GI_IR_NODE_PARAM/ArgBlob writing below */ - size = sizeof (ArgBlob) - sizeof (SimpleTypeBlob); - if (node->name) - size += ALIGN_VALUE (strlen (node->name) + 1, 4); - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)param->type); + /* See the comment in the GI_IR_NODE_PARAM/ArgBlob writing below */ + size = sizeof (ArgBlob) - sizeof (SimpleTypeBlob); + if (node->name) + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)param->type); } break; case GI_IR_NODE_TYPE: { - GIIrNodeType *type = (GIIrNodeType *)node; + GIIrNodeType *type = (GIIrNodeType *)node; size = sizeof (SimpleTypeBlob); if (!GI_TYPE_TAG_IS_BASIC (type->tag)) - { - g_debug ("node %p type tag '%s'", node, - gi_type_tag_to_string (type->tag)); + { + g_debug ("node %p type tag '%s'", node, + gi_type_tag_to_string (type->tag)); - switch (type->tag) - { - case GI_TYPE_TAG_ARRAY: - size = sizeof (ArrayTypeBlob); - if (type->parameter_type1) - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)type->parameter_type1); - break; - case GI_TYPE_TAG_INTERFACE: - size += sizeof (InterfaceTypeBlob); - break; - case GI_TYPE_TAG_GLIST: - case GI_TYPE_TAG_GSLIST: - size += sizeof (ParamTypeBlob); - if (type->parameter_type1) - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)type->parameter_type1); - break; - case GI_TYPE_TAG_GHASH: - size += sizeof (ParamTypeBlob) * 2; - if (type->parameter_type1) - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)type->parameter_type1); - if (type->parameter_type2) - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)type->parameter_type2); - break; - case GI_TYPE_TAG_ERROR: - size += sizeof (ErrorTypeBlob); - break; - default: - g_error ("Unknown type tag %d", type->tag); - break; - } - } + switch (type->tag) + { + case GI_TYPE_TAG_ARRAY: + size = sizeof (ArrayTypeBlob); + if (type->parameter_type1) + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)type->parameter_type1); + break; + case GI_TYPE_TAG_INTERFACE: + size += sizeof (InterfaceTypeBlob); + break; + case GI_TYPE_TAG_GLIST: + case GI_TYPE_TAG_GSLIST: + size += sizeof (ParamTypeBlob); + if (type->parameter_type1) + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)type->parameter_type1); + break; + case GI_TYPE_TAG_GHASH: + size += sizeof (ParamTypeBlob) * 2; + if (type->parameter_type1) + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)type->parameter_type1); + if (type->parameter_type2) + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)type->parameter_type2); + break; + case GI_TYPE_TAG_ERROR: + size += sizeof (ErrorTypeBlob); + break; + default: + g_error ("Unknown type tag %d", type->tag); + break; + } + } } break; case GI_IR_NODE_OBJECT: { - GIIrNodeInterface *iface = (GIIrNodeInterface *)node; + GIIrNodeInterface *iface = (GIIrNodeInterface *)node; - n = g_list_length (iface->interfaces); - size = sizeof(ObjectBlob); - if (iface->parent) - size += ALIGN_VALUE (strlen (iface->parent) + 1, 4); + n = g_list_length (iface->interfaces); + size = sizeof(ObjectBlob); + if (iface->parent) + size += ALIGN_VALUE (strlen (iface->parent) + 1, 4); if (iface->glib_type_struct) size += ALIGN_VALUE (strlen (iface->glib_type_struct) + 1, 4); - size += ALIGN_VALUE (strlen (node->name) + 1, 4); - size += ALIGN_VALUE (strlen (iface->gtype_name) + 1, 4); - if (iface->gtype_init) - size += ALIGN_VALUE (strlen (iface->gtype_init) + 1, 4); - if (iface->ref_func) - size += ALIGN_VALUE (strlen (iface->ref_func) + 1, 4); - if (iface->unref_func) - size += ALIGN_VALUE (strlen (iface->unref_func) + 1, 4); - if (iface->set_value_func) - size += ALIGN_VALUE (strlen (iface->set_value_func) + 1, 4); - if (iface->get_value_func) - size += ALIGN_VALUE (strlen (iface->get_value_func) + 1, 4); - size += 2 * (n + (n % 2)); + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + size += ALIGN_VALUE (strlen (iface->gtype_name) + 1, 4); + if (iface->gtype_init) + size += ALIGN_VALUE (strlen (iface->gtype_init) + 1, 4); + if (iface->ref_func) + size += ALIGN_VALUE (strlen (iface->ref_func) + 1, 4); + if (iface->unref_func) + size += ALIGN_VALUE (strlen (iface->unref_func) + 1, 4); + if (iface->set_value_func) + size += ALIGN_VALUE (strlen (iface->set_value_func) + 1, 4); + if (iface->get_value_func) + size += ALIGN_VALUE (strlen (iface->get_value_func) + 1, 4); + size += 2 * (n + (n % 2)); - for (l = iface->members; l; l = l->next) - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); + for (l = iface->members; l; l = l->next) + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); } break; case GI_IR_NODE_INTERFACE: { - GIIrNodeInterface *iface = (GIIrNodeInterface *)node; + GIIrNodeInterface *iface = (GIIrNodeInterface *)node; - n = g_list_length (iface->prerequisites); - size = sizeof (InterfaceBlob); - size += ALIGN_VALUE (strlen (node->name) + 1, 4); - size += ALIGN_VALUE (strlen (iface->gtype_name) + 1, 4); - size += ALIGN_VALUE (strlen (iface->gtype_init) + 1, 4); - size += 2 * (n + (n % 2)); + n = g_list_length (iface->prerequisites); + size = sizeof (InterfaceBlob); + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + size += ALIGN_VALUE (strlen (iface->gtype_name) + 1, 4); + size += ALIGN_VALUE (strlen (iface->gtype_init) + 1, 4); + size += 2 * (n + (n % 2)); - for (l = iface->members; l; l = l->next) - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); + for (l = iface->members; l; l = l->next) + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); } break; case GI_IR_NODE_ENUM: case GI_IR_NODE_FLAGS: { - GIIrNodeEnum *enum_ = (GIIrNodeEnum *)node; + GIIrNodeEnum *enum_ = (GIIrNodeEnum *)node; - size = sizeof (EnumBlob); - size += ALIGN_VALUE (strlen (node->name) + 1, 4); - if (enum_->gtype_name) - { - size += ALIGN_VALUE (strlen (enum_->gtype_name) + 1, 4); - size += ALIGN_VALUE (strlen (enum_->gtype_init) + 1, 4); - } - if (enum_->error_domain) - size += ALIGN_VALUE (strlen (enum_->error_domain) + 1, 4); + size = sizeof (EnumBlob); + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + if (enum_->gtype_name) + { + size += ALIGN_VALUE (strlen (enum_->gtype_name) + 1, 4); + size += ALIGN_VALUE (strlen (enum_->gtype_init) + 1, 4); + } + if (enum_->error_domain) + size += ALIGN_VALUE (strlen (enum_->error_domain) + 1, 4); - for (l = enum_->values; l; l = l->next) - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); - for (l = enum_->methods; l; l = l->next) - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); + for (l = enum_->values; l; l = l->next) + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); + for (l = enum_->methods; l; l = l->next) + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); } break; case GI_IR_NODE_VALUE: { - size = sizeof (ValueBlob); - size += ALIGN_VALUE (strlen (node->name) + 1, 4); + size = sizeof (ValueBlob); + size += ALIGN_VALUE (strlen (node->name) + 1, 4); } break; case GI_IR_NODE_STRUCT: { - GIIrNodeStruct *struct_ = (GIIrNodeStruct *)node; + GIIrNodeStruct *struct_ = (GIIrNodeStruct *)node; - size = sizeof (StructBlob); - size += ALIGN_VALUE (strlen (node->name) + 1, 4); - if (struct_->gtype_name) - size += ALIGN_VALUE (strlen (struct_->gtype_name) + 1, 4); - if (struct_->gtype_init) - size += ALIGN_VALUE (strlen (struct_->gtype_init) + 1, 4); - if (struct_->copy_func) - size += ALIGN_VALUE (strlen (struct_->copy_func) + 1, 4); - if (struct_->free_func) - size += ALIGN_VALUE (strlen (struct_->free_func) + 1, 4); - for (l = struct_->members; l; l = l->next) - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); + size = sizeof (StructBlob); + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + if (struct_->gtype_name) + size += ALIGN_VALUE (strlen (struct_->gtype_name) + 1, 4); + if (struct_->gtype_init) + size += ALIGN_VALUE (strlen (struct_->gtype_init) + 1, 4); + if (struct_->copy_func) + size += ALIGN_VALUE (strlen (struct_->copy_func) + 1, 4); + if (struct_->free_func) + size += ALIGN_VALUE (strlen (struct_->free_func) + 1, 4); + for (l = struct_->members; l; l = l->next) + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); } break; case GI_IR_NODE_BOXED: { - GIIrNodeBoxed *boxed = (GIIrNodeBoxed *)node; + GIIrNodeBoxed *boxed = (GIIrNodeBoxed *)node; - size = sizeof (StructBlob); - size += ALIGN_VALUE (strlen (node->name) + 1, 4); - if (boxed->gtype_name) - { - size += ALIGN_VALUE (strlen (boxed->gtype_name) + 1, 4); - size += ALIGN_VALUE (strlen (boxed->gtype_init) + 1, 4); - } - for (l = boxed->members; l; l = l->next) - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); + size = sizeof (StructBlob); + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + if (boxed->gtype_name) + { + size += ALIGN_VALUE (strlen (boxed->gtype_name) + 1, 4); + size += ALIGN_VALUE (strlen (boxed->gtype_init) + 1, 4); + } + for (l = boxed->members; l; l = l->next) + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); } break; case GI_IR_NODE_PROPERTY: { - GIIrNodeProperty *prop = (GIIrNodeProperty *)node; + GIIrNodeProperty *prop = (GIIrNodeProperty *)node; - size = sizeof (PropertyBlob); - size += ALIGN_VALUE (strlen (node->name) + 1, 4); - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)prop->type); + size = sizeof (PropertyBlob); + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)prop->type); } break; case GI_IR_NODE_SIGNAL: { - GIIrNodeSignal *signal = (GIIrNodeSignal *)node; + GIIrNodeSignal *signal = (GIIrNodeSignal *)node; - size = sizeof (SignalBlob); - size += ALIGN_VALUE (strlen (node->name) + 1, 4); - for (l = signal->parameters; l; l = l->next) - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)signal->result); + size = sizeof (SignalBlob); + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + for (l = signal->parameters; l; l = l->next) + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)signal->result); } break; case GI_IR_NODE_VFUNC: { - GIIrNodeVFunc *vfunc = (GIIrNodeVFunc *)node; + GIIrNodeVFunc *vfunc = (GIIrNodeVFunc *)node; - size = sizeof (VFuncBlob); - size += ALIGN_VALUE (strlen (node->name) + 1, 4); - for (l = vfunc->parameters; l; l = l->next) - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)vfunc->result); + size = sizeof (VFuncBlob); + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + for (l = vfunc->parameters; l; l = l->next) + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)vfunc->result); } break; case GI_IR_NODE_FIELD: { - GIIrNodeField *field = (GIIrNodeField *)node; + GIIrNodeField *field = (GIIrNodeField *)node; - size = sizeof (FieldBlob); - size += ALIGN_VALUE (strlen (node->name) + 1, 4); - if (field->callback) + size = sizeof (FieldBlob); + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + if (field->callback) size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)field->callback); - else + else size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)field->type); } break; case GI_IR_NODE_CONSTANT: { - GIIrNodeConstant *constant = (GIIrNodeConstant *)node; + GIIrNodeConstant *constant = (GIIrNodeConstant *)node; - size = sizeof (ConstantBlob); - size += ALIGN_VALUE (strlen (node->name) + 1, 4); - /* FIXME non-string values */ - size += ALIGN_VALUE (strlen (constant->value) + 1, 4); - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)constant->type); + size = sizeof (ConstantBlob); + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + /* FIXME non-string values */ + size += ALIGN_VALUE (strlen (constant->value) + 1, 4); + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)constant->type); } break; case GI_IR_NODE_XREF: { - GIIrNodeXRef *xref = (GIIrNodeXRef *)node; + GIIrNodeXRef *xref = (GIIrNodeXRef *)node; - size = 0; - size += ALIGN_VALUE (strlen (node->name) + 1, 4); - size += ALIGN_VALUE (strlen (xref->namespace) + 1, 4); + size = 0; + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + size += ALIGN_VALUE (strlen (xref->namespace) + 1, 4); } break; case GI_IR_NODE_UNION: { - GIIrNodeUnion *union_ = (GIIrNodeUnion *)node; + GIIrNodeUnion *union_ = (GIIrNodeUnion *)node; - size = sizeof (UnionBlob); - size += ALIGN_VALUE (strlen (node->name) + 1, 4); - if (union_->gtype_name) - size += ALIGN_VALUE (strlen (union_->gtype_name) + 1, 4); - if (union_->gtype_init) - size += ALIGN_VALUE (strlen (union_->gtype_init) + 1, 4); - if (union_->copy_func) - size += ALIGN_VALUE (strlen (union_->copy_func) + 1, 4); - if (union_->free_func) - size += ALIGN_VALUE (strlen (union_->free_func) + 1, 4); - for (l = union_->members; l; l = l->next) - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); - for (l = union_->discriminators; l; l = l->next) - size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); + size = sizeof (UnionBlob); + size += ALIGN_VALUE (strlen (node->name) + 1, 4); + if (union_->gtype_name) + size += ALIGN_VALUE (strlen (union_->gtype_name) + 1, 4); + if (union_->gtype_init) + size += ALIGN_VALUE (strlen (union_->gtype_init) + 1, 4); + if (union_->copy_func) + size += ALIGN_VALUE (strlen (union_->copy_func) + 1, 4); + if (union_->free_func) + size += ALIGN_VALUE (strlen (union_->free_func) + 1, 4); + for (l = union_->members; l; l = l->next) + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); + for (l = union_->discriminators; l; l = l->next) + size += gi_ir_node_get_full_size_internal (node, (GIIrNode *)l->data); } break; @@ -883,10 +883,10 @@ gi_ir_node_get_full_size_internal (GIIrNode *parent, } g_debug ("node %s%s%s%p type '%s' full size %d", - node->name ? "'" : "", - node->name ? node->name : "", - node->name ? "' " : "", - node, gi_ir_node_type_to_string (node->type), size); + node->name ? "'" : "", + node->name ? node->name : "", + node->name ? "' " : "", + node, gi_ir_node_type_to_string (node->type), size); g_hash_table_foreach (node->attributes, add_attribute_size, &size); @@ -959,39 +959,39 @@ gi_ir_node_add_member (GIIrNode *node, case GI_IR_NODE_OBJECT: case GI_IR_NODE_INTERFACE: { - GIIrNodeInterface *iface = (GIIrNodeInterface *)node; - iface->members = - g_list_insert_sorted (iface->members, member, - (GCompareFunc) gi_ir_node_cmp); - break; + GIIrNodeInterface *iface = (GIIrNodeInterface *)node; + iface->members = + g_list_insert_sorted (iface->members, member, + (GCompareFunc) gi_ir_node_cmp); + break; } case GI_IR_NODE_BOXED: { - GIIrNodeBoxed *boxed = (GIIrNodeBoxed *)node; - boxed->members = - g_list_insert_sorted (boxed->members, member, - (GCompareFunc) gi_ir_node_cmp); - break; + GIIrNodeBoxed *boxed = (GIIrNodeBoxed *)node; + boxed->members = + g_list_insert_sorted (boxed->members, member, + (GCompareFunc) gi_ir_node_cmp); + break; } case GI_IR_NODE_STRUCT: { - GIIrNodeStruct *struct_ = (GIIrNodeStruct *)node; - struct_->members = - g_list_insert_sorted (struct_->members, member, - (GCompareFunc) gi_ir_node_cmp); - break; + GIIrNodeStruct *struct_ = (GIIrNodeStruct *)node; + struct_->members = + g_list_insert_sorted (struct_->members, member, + (GCompareFunc) gi_ir_node_cmp); + break; } case GI_IR_NODE_UNION: { - GIIrNodeUnion *union_ = (GIIrNodeUnion *)node; - union_->members = - g_list_insert_sorted (union_->members, member, - (GCompareFunc) gi_ir_node_cmp); - break; + GIIrNodeUnion *union_ = (GIIrNodeUnion *)node; + union_->members = + g_list_insert_sorted (union_->members, member, + (GCompareFunc) gi_ir_node_cmp); + break; } default: g_error ("Cannot add a member to unknown type tag type %d", - node->type); + node->type); break; } } @@ -1002,9 +1002,9 @@ gi_ir_node_param_direction_string (GIIrNodeParam * node) if (node->out) { if (node->in) - return "in-out"; + return "in-out"; else - return "out"; + return "out"; } return "in"; } @@ -1065,23 +1065,23 @@ find_entry_node (GIIrTypelibBuild *build, GIIrNode *node = (GIIrNode *)l->data; if (n_names > 1) - { - if (node->type != GI_IR_NODE_XREF) - continue; + { + if (node->type != GI_IR_NODE_XREF) + continue; - if (((GIIrNodeXRef *)node)->namespace == NULL || - strcmp (((GIIrNodeXRef *)node)->namespace, names[0]) != 0) - continue; - } + if (((GIIrNodeXRef *)node)->namespace == NULL || + strcmp (((GIIrNodeXRef *)node)->namespace, names[0]) != 0) + continue; + } if (strcmp (node->name, names[n_names - 1]) == 0) - { - if (idx) - *idx = i; + { + if (idx) + *idx = i; - result = node; - goto out; - } + result = node; + goto out; + } } if (n_names > 1) @@ -1094,7 +1094,7 @@ find_entry_node (GIIrTypelibBuild *build, module->entries = g_list_append (module->entries, node); if (idx) - *idx = g_list_length (module->entries); + *idx = g_list_length (module->entries); result = node; @@ -1179,10 +1179,10 @@ gi_ir_find_node (GIIrTypelibBuild *build, GIIrNode *node = (GIIrNode *)l->data; if (strcmp (node->name, target_name) == 0) - { - return_node = node; - break; - } + { + return_node = node; + break; + } } done: @@ -1225,48 +1225,48 @@ serialize_type (GIIrTypelibBuild *build, if (GI_TYPE_TAG_IS_BASIC (node->tag)) { g_string_append_printf (str, "%s%s", gi_type_tag_to_string (node->tag), - node->is_pointer ? "*" : ""); + node->is_pointer ? "*" : ""); } else if (node->tag == GI_TYPE_TAG_ARRAY) { if (node->array_type == GI_ARRAY_TYPE_C) - { - serialize_type (build, node->parameter_type1, str); - g_string_append (str, "["); + { + serialize_type (build, node->parameter_type1, str); + g_string_append (str, "["); - 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->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", - node->has_length ? "," : ""); + if (node->zero_terminated) + g_string_append_printf (str, "%szero-terminated=1", + node->has_length ? "," : ""); - g_string_append (str, "]"); - if (node->is_pointer) - g_string_append (str, "*"); - } + g_string_append (str, "]"); + if (node->is_pointer) + g_string_append (str, "*"); + } else if (node->array_type == GI_ARRAY_TYPE_BYTE_ARRAY) - { - /* We on purpose skip serializing parameter_type1, which should - always be void* - */ - g_string_append (str, "GByteArray"); - } + { + /* We on purpose skip serializing parameter_type1, which should + always be void* + */ + g_string_append (str, "GByteArray"); + } else - { - if (node->array_type == GI_ARRAY_TYPE_ARRAY) - g_string_append (str, "GArray"); - else - g_string_append (str, "GPtrArray"); - if (node->parameter_type1) - { - g_string_append (str, "<"); - serialize_type (build, node->parameter_type1, str); - g_string_append (str, ">"); - } - } + { + if (node->array_type == GI_ARRAY_TYPE_ARRAY) + g_string_append (str, "GArray"); + else + g_string_append (str, "GPtrArray"); + if (node->parameter_type1) + { + g_string_append (str, "<"); + serialize_type (build, node->parameter_type1, str); + g_string_append (str, ">"); + } + } } else if (node->tag == GI_TYPE_TAG_INTERFACE) { @@ -1281,60 +1281,60 @@ serialize_type (GIIrTypelibBuild *build, name = iface->name; } else - { - g_warning ("Interface for type reference %s not found", node->giinterface); - name = node->giinterface; - } + { + g_warning ("Interface for type reference %s not found", node->giinterface); + name = node->giinterface; + } g_string_append_printf (str, "%s%s", name, - node->is_pointer ? "*" : ""); + node->is_pointer ? "*" : ""); } else if (node->tag == GI_TYPE_TAG_GLIST) { g_string_append (str, "GList"); if (node->parameter_type1) - { - g_string_append (str, "<"); - serialize_type (build, node->parameter_type1, str); - g_string_append (str, ">"); - } + { + g_string_append (str, "<"); + serialize_type (build, node->parameter_type1, str); + g_string_append (str, ">"); + } } else if (node->tag == GI_TYPE_TAG_GSLIST) { g_string_append (str, "GSList"); if (node->parameter_type1) - { - g_string_append (str, "<"); - serialize_type (build, node->parameter_type1, str); - g_string_append (str, ">"); - } + { + g_string_append (str, "<"); + serialize_type (build, node->parameter_type1, str); + g_string_append (str, ">"); + } } else if (node->tag == GI_TYPE_TAG_GHASH) { g_string_append (str, "GHashTable"); if (node->parameter_type1) - { - g_string_append (str, "<"); - serialize_type (build, node->parameter_type1, str); - g_string_append (str, ","); - serialize_type (build, node->parameter_type2, str); - g_string_append (str, ">"); - } + { + g_string_append (str, "<"); + serialize_type (build, node->parameter_type1, str); + g_string_append (str, ","); + serialize_type (build, node->parameter_type2, str); + g_string_append (str, ">"); + } } else if (node->tag == GI_TYPE_TAG_ERROR) { g_string_append (str, "GError"); if (node->errors) - { - g_string_append (str, "<"); - for (i = 0; node->errors[i]; i++) - { - if (i > 0) - g_string_append (str, ","); - g_string_append (str, node->errors[i]); - } - g_string_append (str, ">"); - } + { + g_string_append (str, "<"); + for (i = 0; node->errors[i]; i++) + { + if (i > 0) + g_string_append (str, ","); + g_string_append (str, node->errors[i]); + } + g_string_append (str, ">"); + } } } @@ -1356,11 +1356,11 @@ gi_ir_node_build_members (GList **members, GList *next = l->next; if (member->type == type) - { - (*count)++; - gi_ir_node_build_typelib (member, parent, build, offset, offset2, count2); - *members = g_list_delete_link (*members, l); - } + { + (*count)++; + gi_ir_node_build_typelib (member, parent, build, offset, offset2, count2); + *members = g_list_delete_link (*members, l); + } l = next; } } @@ -1375,13 +1375,13 @@ gi_ir_node_check_unhandled_members (GList **members, GList *l; for (l = *members; l; l = l->next) - { - GIIrNode *member = (GIIrNode *)l->data; - g_printerr ("Unhandled '%s' member '%s' type '%s'\n", - gi_ir_node_type_to_string (container_type), - member->name, - gi_ir_node_type_to_string (member->type)); - } + { + GIIrNode *member = (GIIrNode *)l->data; + g_printerr ("Unhandled '%s' member '%s' type '%s'\n", + gi_ir_node_type_to_string (container_type), + member->name, + gi_ir_node_type_to_string (member->type)); + } g_list_free (*members); *members = NULL; @@ -1413,9 +1413,9 @@ gi_ir_node_build_typelib (GIIrNode *node, g_assert (node != NULL); g_debug ("build_typelib: %s%s(%s)", - node->name ? node->name : "", - node->name ? " " : "", - gi_ir_node_type_to_string (node->type)); + node->name ? node->name : "", + node->name ? " " : "", + gi_ir_node_type_to_string (node->type)); if (build->stack) appended_stack = node != (GIIrNode*)build->stack->data; @@ -1439,57 +1439,57 @@ gi_ir_node_build_typelib (GIIrNode *node, { case GI_IR_NODE_TYPE: { - GIIrNodeType *type = (GIIrNodeType *)node; - SimpleTypeBlob *blob = (SimpleTypeBlob *)&data[*offset]; + GIIrNodeType *type = (GIIrNodeType *)node; + SimpleTypeBlob *blob = (SimpleTypeBlob *)&data[*offset]; - *offset += sizeof (SimpleTypeBlob); + *offset += sizeof (SimpleTypeBlob); - if (GI_TYPE_TAG_IS_BASIC (type->tag)) - { - blob->flags.reserved = 0; - blob->flags.reserved2 = 0; - blob->flags.pointer = type->is_pointer; - blob->flags.reserved3 = 0; - blob->flags.tag = type->tag; - } - else - { - GString *str; - gchar *s; - gpointer value; + if (GI_TYPE_TAG_IS_BASIC (type->tag)) + { + blob->flags.reserved = 0; + blob->flags.reserved2 = 0; + blob->flags.pointer = type->is_pointer; + blob->flags.reserved3 = 0; + blob->flags.tag = type->tag; + } + else + { + GString *str; + gchar *s; + gpointer value; - str = g_string_new (0); - serialize_type (build, type, str); - s = g_string_free (str, FALSE); + str = g_string_new (0); + serialize_type (build, type, str); + s = g_string_free (str, FALSE); - types_count += 1; - value = g_hash_table_lookup (types, s); - if (value) - { - blob->offset = GPOINTER_TO_UINT (value); - g_free (s); - } - else - { - unique_types_count += 1; - g_hash_table_insert (types, s, GUINT_TO_POINTER(*offset2)); + types_count += 1; + value = g_hash_table_lookup (types, s); + if (value) + { + blob->offset = GPOINTER_TO_UINT (value); + g_free (s); + } + else + { + unique_types_count += 1; + g_hash_table_insert (types, s, GUINT_TO_POINTER(*offset2)); - blob->offset = *offset2; - switch (type->tag) - { - case GI_TYPE_TAG_ARRAY: - { - ArrayTypeBlob *array = (ArrayTypeBlob *)&data[*offset2]; - guint32 pos; + blob->offset = *offset2; + switch (type->tag) + { + case GI_TYPE_TAG_ARRAY: + { + ArrayTypeBlob *array = (ArrayTypeBlob *)&data[*offset2]; + guint32 pos; - array->pointer = type->is_pointer; - array->reserved = 0; - array->tag = type->tag; - array->zero_terminated = type->zero_terminated; - array->has_length = type->has_length; + array->pointer = type->is_pointer; + array->reserved = 0; + array->tag = type->tag; + array->zero_terminated = type->zero_terminated; + array->has_length = type->has_length; array->has_size = type->has_size; array->array_type = type->array_type; - array->reserved2 = 0; + array->reserved2 = 0; if (array->has_length) array->dimensions.length = type->length; else if (array->has_size) @@ -1497,114 +1497,114 @@ gi_ir_node_build_typelib (GIIrNode *node, else array->dimensions.length = -1; - pos = *offset2 + G_STRUCT_OFFSET (ArrayTypeBlob, type); - *offset2 += sizeof (ArrayTypeBlob); + pos = *offset2 + G_STRUCT_OFFSET (ArrayTypeBlob, type); + *offset2 += sizeof (ArrayTypeBlob); - gi_ir_node_build_typelib ((GIIrNode *)type->parameter_type1, + gi_ir_node_build_typelib ((GIIrNode *)type->parameter_type1, node, build, &pos, offset2, NULL); - } - break; + } + break; - case GI_TYPE_TAG_INTERFACE: - { - InterfaceTypeBlob *iface = (InterfaceTypeBlob *)&data[*offset2]; - *offset2 += sizeof (InterfaceTypeBlob); + case GI_TYPE_TAG_INTERFACE: + { + InterfaceTypeBlob *iface = (InterfaceTypeBlob *)&data[*offset2]; + *offset2 += sizeof (InterfaceTypeBlob); - iface->pointer = type->is_pointer; - iface->reserved = 0; - iface->tag = type->tag; - iface->reserved2 = 0; - iface->interface = find_entry (build, type->giinterface); + iface->pointer = type->is_pointer; + iface->reserved = 0; + iface->tag = type->tag; + iface->reserved2 = 0; + iface->interface = find_entry (build, type->giinterface); - } - break; + } + break; - case GI_TYPE_TAG_GLIST: - case GI_TYPE_TAG_GSLIST: - { - ParamTypeBlob *param = (ParamTypeBlob *)&data[*offset2]; - guint32 pos; + case GI_TYPE_TAG_GLIST: + case GI_TYPE_TAG_GSLIST: + { + ParamTypeBlob *param = (ParamTypeBlob *)&data[*offset2]; + guint32 pos; - param->pointer = 1; - param->reserved = 0; - param->tag = type->tag; - param->reserved2 = 0; - param->n_types = 1; + param->pointer = 1; + param->reserved = 0; + param->tag = type->tag; + param->reserved2 = 0; + param->n_types = 1; - pos = *offset2 + G_STRUCT_OFFSET (ParamTypeBlob, type); - *offset2 += sizeof (ParamTypeBlob) + sizeof (SimpleTypeBlob); + pos = *offset2 + G_STRUCT_OFFSET (ParamTypeBlob, type); + *offset2 += sizeof (ParamTypeBlob) + sizeof (SimpleTypeBlob); - gi_ir_node_build_typelib ((GIIrNode *)type->parameter_type1, + gi_ir_node_build_typelib ((GIIrNode *)type->parameter_type1, node, build, &pos, offset2, NULL); - } - break; + } + break; - case GI_TYPE_TAG_GHASH: - { - ParamTypeBlob *param = (ParamTypeBlob *)&data[*offset2]; - guint32 pos; + case GI_TYPE_TAG_GHASH: + { + ParamTypeBlob *param = (ParamTypeBlob *)&data[*offset2]; + guint32 pos; - param->pointer = 1; - param->reserved = 0; - param->tag = type->tag; - param->reserved2 = 0; - param->n_types = 2; + param->pointer = 1; + param->reserved = 0; + param->tag = type->tag; + param->reserved2 = 0; + param->n_types = 2; - pos = *offset2 + G_STRUCT_OFFSET (ParamTypeBlob, type); - *offset2 += sizeof (ParamTypeBlob) + sizeof (SimpleTypeBlob)*2; + pos = *offset2 + G_STRUCT_OFFSET (ParamTypeBlob, type); + *offset2 += sizeof (ParamTypeBlob) + sizeof (SimpleTypeBlob)*2; - gi_ir_node_build_typelib ((GIIrNode *)type->parameter_type1, + gi_ir_node_build_typelib ((GIIrNode *)type->parameter_type1, node, build, &pos, offset2, NULL); - gi_ir_node_build_typelib ((GIIrNode *)type->parameter_type2, + gi_ir_node_build_typelib ((GIIrNode *)type->parameter_type2, node, build, &pos, offset2, NULL); - } - break; + } + break; - case GI_TYPE_TAG_ERROR: - { - ErrorTypeBlob *error_blob = (ErrorTypeBlob *)&data[*offset2]; + case GI_TYPE_TAG_ERROR: + { + ErrorTypeBlob *error_blob = (ErrorTypeBlob *)&data[*offset2]; - error_blob->pointer = 1; - error_blob->reserved = 0; - error_blob->tag = type->tag; - error_blob->reserved2 = 0; - error_blob->n_domains = 0; + error_blob->pointer = 1; + error_blob->reserved = 0; + error_blob->tag = type->tag; + error_blob->reserved2 = 0; + error_blob->n_domains = 0; - *offset2 += sizeof (ErrorTypeBlob); - } - break; + *offset2 += sizeof (ErrorTypeBlob); + } + break; - default: - g_error ("Unknown type tag %d", type->tag); - break; - } - } - } + default: + g_error ("Unknown type tag %d", type->tag); + break; + } + } + } } break; case GI_IR_NODE_FIELD: { - GIIrNodeField *field = (GIIrNodeField *)node; - FieldBlob *blob; + GIIrNodeField *field = (GIIrNodeField *)node; + FieldBlob *blob; - blob = (FieldBlob *)&data[*offset]; + blob = (FieldBlob *)&data[*offset]; - blob->name = gi_ir_write_string (node->name, strings, data, offset2); - blob->readable = field->readable; - blob->writable = field->writable; - blob->reserved = 0; - blob->bits = 0; - if (field->offset >= 0) - blob->struct_offset = field->offset; - else - blob->struct_offset = 0xFFFF; /* mark as unknown */ + blob->name = gi_ir_write_string (node->name, strings, data, offset2); + blob->readable = field->readable; + blob->writable = field->writable; + blob->reserved = 0; + blob->bits = 0; + if (field->offset >= 0) + blob->struct_offset = field->offset; + else + blob->struct_offset = 0xFFFF; /* mark as unknown */ if (field->callback) { blob->has_embedded_type = TRUE; blob->type.offset = GI_INFO_TYPE_CALLBACK; - *offset += sizeof (FieldBlob); + *offset += sizeof (FieldBlob); gi_ir_node_build_typelib ((GIIrNode *)field->callback, node, build, offset, offset2, NULL); /* Fields with callbacks are bigger than normal, update count2 @@ -1619,7 +1619,7 @@ gi_ir_node_build_typelib (GIIrNode *node, { blob->has_embedded_type = FALSE; /* We handle the size member specially below, so subtract it */ - *offset += sizeof (FieldBlob) - sizeof (SimpleTypeBlob); + *offset += sizeof (FieldBlob) - sizeof (SimpleTypeBlob); gi_ir_node_build_typelib ((GIIrNode *)field->type, node, build, offset, offset2, NULL); } @@ -1628,20 +1628,20 @@ gi_ir_node_build_typelib (GIIrNode *node, case GI_IR_NODE_PROPERTY: { - GIIrNodeProperty *prop = (GIIrNodeProperty *)node; - PropertyBlob *blob = (PropertyBlob *)&data[*offset]; + GIIrNodeProperty *prop = (GIIrNodeProperty *)node; + PropertyBlob *blob = (PropertyBlob *)&data[*offset]; /* We handle the size member specially below, so subtract it */ - *offset += sizeof (PropertyBlob) - sizeof (SimpleTypeBlob); + *offset += sizeof (PropertyBlob) - sizeof (SimpleTypeBlob); - blob->name = gi_ir_write_string (node->name, strings, data, offset2); - blob->deprecated = prop->deprecated; - blob->readable = prop->readable; - blob->writable = prop->writable; - blob->construct = prop->construct; - blob->construct_only = prop->construct_only; - blob->transfer_ownership = prop->transfer; - blob->transfer_container_ownership = prop->shallow_transfer; - blob->reserved = 0; + blob->name = gi_ir_write_string (node->name, strings, data, offset2); + blob->deprecated = prop->deprecated; + blob->readable = prop->readable; + blob->writable = prop->writable; + blob->construct = prop->construct; + blob->construct_only = prop->construct_only; + blob->transfer_ownership = prop->transfer; + blob->transfer_container_ownership = prop->shallow_transfer; + blob->reserved = 0; if (prop->setter != NULL) { @@ -1680,30 +1680,30 @@ gi_ir_node_build_typelib (GIIrNode *node, case GI_IR_NODE_FUNCTION: { - FunctionBlob *blob = (FunctionBlob *)&data[*offset]; - SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2]; - GIIrNodeFunction *function = (GIIrNodeFunction *)node; - guint32 signature; - gint n; + FunctionBlob *blob = (FunctionBlob *)&data[*offset]; + SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2]; + GIIrNodeFunction *function = (GIIrNodeFunction *)node; + guint32 signature; + gint n; - signature = *offset2; - n = g_list_length (function->parameters); + signature = *offset2; + n = g_list_length (function->parameters); - *offset += sizeof (FunctionBlob); - *offset2 += sizeof (SignatureBlob) + n * sizeof (ArgBlob); + *offset += sizeof (FunctionBlob); + *offset2 += sizeof (SignatureBlob) + n * sizeof (ArgBlob); - blob->blob_type = BLOB_TYPE_FUNCTION; - blob->deprecated = function->deprecated; + blob->blob_type = BLOB_TYPE_FUNCTION; + blob->deprecated = function->deprecated; blob->is_static = !function->is_method; - blob->setter = FALSE; - blob->getter = FALSE; - blob->constructor = function->is_constructor; - blob->wraps_vfunc = function->wraps_vfunc; - blob->throws = function->throws; /* Deprecated. Also stored in SignatureBlob. */ - blob->index = 0; - blob->name = gi_ir_write_string (node->name, strings, data, offset2); - blob->symbol = gi_ir_write_string (function->symbol, strings, data, offset2); - blob->signature = signature; + blob->setter = FALSE; + blob->getter = FALSE; + blob->constructor = function->is_constructor; + blob->wraps_vfunc = function->wraps_vfunc; + blob->throws = function->throws; /* Deprecated. Also stored in SignatureBlob. */ + blob->index = 0; + blob->name = gi_ir_write_string (node->name, strings, data, offset2); + blob->symbol = gi_ir_write_string (function->symbol, strings, data, offset2); + blob->signature = signature; if (function->is_setter || function->is_getter) { @@ -1728,101 +1728,101 @@ gi_ir_node_build_typelib (GIIrNode *node, g_assert (((GIIrNode *) function->result)->offset == 0); ((GIIrNode *) function->result)->offset = signature; - g_debug ("building function '%s'", function->symbol); + g_debug ("building function '%s'", function->symbol); gi_ir_node_build_typelib ((GIIrNode *)function->result->type, node, build, &signature, offset2, NULL); - blob2->may_return_null = function->result->nullable; - blob2->caller_owns_return_value = function->result->transfer; - blob2->caller_owns_return_container = function->result->shallow_transfer; - blob2->skip_return = function->result->skip; + blob2->may_return_null = function->result->nullable; + blob2->caller_owns_return_value = function->result->transfer; + blob2->caller_owns_return_container = function->result->shallow_transfer; + blob2->skip_return = function->result->skip; blob2->instance_transfer_ownership = function->instance_transfer_full; - blob2->reserved = 0; - blob2->n_arguments = n; - blob2->throws = function->throws; + blob2->reserved = 0; + blob2->n_arguments = n; + blob2->throws = function->throws; - signature += 4; + signature += 4; - for (l = function->parameters; l; l = l->next) - { - GIIrNode *param = (GIIrNode *)l->data; + for (l = function->parameters; l; l = l->next) + { + GIIrNode *param = (GIIrNode *)l->data; - gi_ir_node_build_typelib (param, node, build, &signature, offset2, NULL); - } + gi_ir_node_build_typelib (param, node, build, &signature, offset2, NULL); + } } break; case GI_IR_NODE_CALLBACK: { - CallbackBlob *blob = (CallbackBlob *)&data[*offset]; - SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2]; - GIIrNodeFunction *function = (GIIrNodeFunction *)node; - guint32 signature; - gint n; + CallbackBlob *blob = (CallbackBlob *)&data[*offset]; + SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2]; + GIIrNodeFunction *function = (GIIrNodeFunction *)node; + guint32 signature; + gint n; - signature = *offset2; - n = g_list_length (function->parameters); + signature = *offset2; + n = g_list_length (function->parameters); - *offset += sizeof (CallbackBlob); - *offset2 += sizeof (SignatureBlob) + n * sizeof (ArgBlob); + *offset += sizeof (CallbackBlob); + *offset2 += sizeof (SignatureBlob) + n * sizeof (ArgBlob); - blob->blob_type = BLOB_TYPE_CALLBACK; - blob->deprecated = function->deprecated; - blob->reserved = 0; - blob->name = gi_ir_write_string (node->name, strings, data, offset2); - blob->signature = signature; + blob->blob_type = BLOB_TYPE_CALLBACK; + blob->deprecated = function->deprecated; + blob->reserved = 0; + blob->name = gi_ir_write_string (node->name, strings, data, offset2); + blob->signature = signature; gi_ir_node_build_typelib ((GIIrNode *)function->result->type, node, build, &signature, offset2, NULL); - blob2->may_return_null = function->result->nullable; - blob2->caller_owns_return_value = function->result->transfer; - blob2->caller_owns_return_container = function->result->shallow_transfer; - blob2->reserved = 0; - blob2->n_arguments = n; - blob2->throws = function->throws; + blob2->may_return_null = function->result->nullable; + blob2->caller_owns_return_value = function->result->transfer; + blob2->caller_owns_return_container = function->result->shallow_transfer; + blob2->reserved = 0; + blob2->n_arguments = n; + blob2->throws = function->throws; - signature += 4; + signature += 4; - for (l = function->parameters; l; l = l->next) - { - GIIrNode *param = (GIIrNode *)l->data; + for (l = function->parameters; l; l = l->next) + { + GIIrNode *param = (GIIrNode *)l->data; - gi_ir_node_build_typelib (param, node, build, &signature, offset2, NULL); - } + gi_ir_node_build_typelib (param, node, build, &signature, offset2, NULL); + } } break; case GI_IR_NODE_SIGNAL: { - SignalBlob *blob = (SignalBlob *)&data[*offset]; - SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2]; - GIIrNodeSignal *signal = (GIIrNodeSignal *)node; - guint32 signature; - gint n; + SignalBlob *blob = (SignalBlob *)&data[*offset]; + SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2]; + GIIrNodeSignal *signal = (GIIrNodeSignal *)node; + guint32 signature; + gint n; - signature = *offset2; - n = g_list_length (signal->parameters); + signature = *offset2; + n = g_list_length (signal->parameters); - *offset += sizeof (SignalBlob); - *offset2 += sizeof (SignatureBlob) + n * sizeof (ArgBlob); + *offset += sizeof (SignalBlob); + *offset2 += sizeof (SignatureBlob) + n * sizeof (ArgBlob); - blob->deprecated = signal->deprecated; - blob->run_first = signal->run_first; - blob->run_last = signal->run_last; - blob->run_cleanup = signal->run_cleanup; - blob->no_recurse = signal->no_recurse; - blob->detailed = signal->detailed; - blob->action = signal->action; - blob->no_hooks = signal->no_hooks; - blob->has_class_closure = 0; /* FIXME */ - blob->true_stops_emit = 0; /* FIXME */ - blob->reserved = 0; - blob->class_closure = 0; /* FIXME */ - blob->name = gi_ir_write_string (node->name, strings, data, offset2); - blob->signature = signature; + blob->deprecated = signal->deprecated; + blob->run_first = signal->run_first; + blob->run_last = signal->run_last; + blob->run_cleanup = signal->run_cleanup; + blob->no_recurse = signal->no_recurse; + blob->detailed = signal->detailed; + blob->action = signal->action; + blob->no_hooks = signal->no_hooks; + blob->has_class_closure = 0; /* FIXME */ + blob->true_stops_emit = 0; /* FIXME */ + blob->reserved = 0; + blob->class_closure = 0; /* FIXME */ + blob->name = gi_ir_write_string (node->name, strings, data, offset2); + blob->signature = signature; /* signal->result is special since it doesn't appear in the serialized format but * we do want the attributes for it to appear @@ -1835,106 +1835,106 @@ gi_ir_node_build_typelib (GIIrNode *node, gi_ir_node_build_typelib ((GIIrNode *)signal->result->type, node, build, &signature, offset2, NULL); - blob2->may_return_null = signal->result->nullable; - blob2->caller_owns_return_value = signal->result->transfer; - blob2->caller_owns_return_container = signal->result->shallow_transfer; + blob2->may_return_null = signal->result->nullable; + blob2->caller_owns_return_value = signal->result->transfer; + blob2->caller_owns_return_container = signal->result->shallow_transfer; blob2->instance_transfer_ownership = signal->instance_transfer_full; - blob2->reserved = 0; - blob2->n_arguments = n; + blob2->reserved = 0; + blob2->n_arguments = n; - signature += 4; + signature += 4; - for (l = signal->parameters; l; l = l->next) - { - GIIrNode *param = (GIIrNode *)l->data; + for (l = signal->parameters; l; l = l->next) + { + GIIrNode *param = (GIIrNode *)l->data; - gi_ir_node_build_typelib (param, node, build, &signature, offset2, NULL); - } + gi_ir_node_build_typelib (param, node, build, &signature, offset2, NULL); + } } break; case GI_IR_NODE_VFUNC: { - VFuncBlob *blob = (VFuncBlob *)&data[*offset]; - SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2]; - GIIrNodeVFunc *vfunc = (GIIrNodeVFunc *)node; - guint32 signature; - gint n; + VFuncBlob *blob = (VFuncBlob *)&data[*offset]; + SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2]; + GIIrNodeVFunc *vfunc = (GIIrNodeVFunc *)node; + guint32 signature; + gint n; - signature = *offset2; - n = g_list_length (vfunc->parameters); + signature = *offset2; + n = g_list_length (vfunc->parameters); - *offset += sizeof (VFuncBlob); - *offset2 += sizeof (SignatureBlob) + n * sizeof (ArgBlob); + *offset += sizeof (VFuncBlob); + *offset2 += sizeof (SignatureBlob) + n * sizeof (ArgBlob); - blob->name = gi_ir_write_string (node->name, strings, data, offset2); - blob->must_chain_up = 0; /* FIXME */ - blob->must_be_implemented = 0; /* FIXME */ - blob->must_not_be_implemented = 0; /* FIXME */ - blob->class_closure = 0; /* FIXME */ - blob->throws = vfunc->throws; /* Deprecated. Also stored in SignatureBlob. */ - blob->reserved = 0; + blob->name = gi_ir_write_string (node->name, strings, data, offset2); + blob->must_chain_up = 0; /* FIXME */ + blob->must_be_implemented = 0; /* FIXME */ + blob->must_not_be_implemented = 0; /* FIXME */ + blob->class_closure = 0; /* FIXME */ + blob->throws = vfunc->throws; /* Deprecated. Also stored in SignatureBlob. */ + blob->reserved = 0; - if (vfunc->invoker) - { - int index = get_index_of_member_type ((GIIrNodeInterface*)parent, GI_IR_NODE_FUNCTION, vfunc->invoker); - if (index == -1) - { - g_error ("Unknown member function %s for vfunc %s", vfunc->invoker, node->name); - } + if (vfunc->invoker) + { + int index = get_index_of_member_type ((GIIrNodeInterface*)parent, GI_IR_NODE_FUNCTION, vfunc->invoker); + if (index == -1) + { + g_error ("Unknown member function %s for vfunc %s", vfunc->invoker, node->name); + } blob->invoker = (guint) index; - } - else - blob->invoker = 0x3ff; /* max of 10 bits */ + } + else + blob->invoker = 0x3ff; /* max of 10 bits */ - blob->struct_offset = vfunc->offset; - blob->reserved2 = 0; - blob->signature = signature; + blob->struct_offset = vfunc->offset; + blob->reserved2 = 0; + blob->signature = signature; gi_ir_node_build_typelib ((GIIrNode *)vfunc->result->type, node, build, &signature, offset2, NULL); - blob2->may_return_null = vfunc->result->nullable; - blob2->caller_owns_return_value = vfunc->result->transfer; - blob2->caller_owns_return_container = vfunc->result->shallow_transfer; + blob2->may_return_null = vfunc->result->nullable; + blob2->caller_owns_return_value = vfunc->result->transfer; + blob2->caller_owns_return_container = vfunc->result->shallow_transfer; blob2->instance_transfer_ownership = vfunc->instance_transfer_full; - blob2->reserved = 0; - blob2->n_arguments = n; - blob2->throws = vfunc->throws; + blob2->reserved = 0; + blob2->n_arguments = n; + blob2->throws = vfunc->throws; - signature += 4; + signature += 4; - for (l = vfunc->parameters; l; l = l->next) - { - GIIrNode *param = (GIIrNode *)l->data; + for (l = vfunc->parameters; l; l = l->next) + { + GIIrNode *param = (GIIrNode *)l->data; - gi_ir_node_build_typelib (param, node, build, &signature, offset2, NULL); - } + gi_ir_node_build_typelib (param, node, build, &signature, offset2, NULL); + } } break; case GI_IR_NODE_PARAM: { - ArgBlob *blob = (ArgBlob *)&data[*offset]; - GIIrNodeParam *param = (GIIrNodeParam *)node; + ArgBlob *blob = (ArgBlob *)&data[*offset]; + GIIrNodeParam *param = (GIIrNodeParam *)node; - /* The offset for this one is smaller than the struct because - * we recursively build the simple type inline here below. - */ - *offset += sizeof (ArgBlob) - sizeof (SimpleTypeBlob); + /* The offset for this one is smaller than the struct because + * we recursively build the simple type inline here below. + */ + *offset += sizeof (ArgBlob) - sizeof (SimpleTypeBlob); - blob->name = gi_ir_write_string (node->name, strings, data, offset2); - blob->in = param->in; - blob->out = param->out; - blob->caller_allocates = param->caller_allocates; - blob->nullable = param->nullable; - blob->skip = param->skip; - blob->optional = param->optional; - blob->transfer_ownership = param->transfer; - blob->transfer_container_ownership = param->shallow_transfer; - blob->return_value = param->retval; + blob->name = gi_ir_write_string (node->name, strings, data, offset2); + blob->in = param->in; + blob->out = param->out; + blob->caller_allocates = param->caller_allocates; + blob->nullable = param->nullable; + blob->skip = param->skip; + blob->optional = param->optional; + blob->transfer_ownership = param->transfer; + blob->transfer_container_ownership = param->shallow_transfer; + blob->return_value = param->retval; blob->scope = param->scope; - blob->reserved = 0; + blob->reserved = 0; blob->closure = param->closure; blob->destroy = param->destroy; @@ -1944,236 +1944,236 @@ gi_ir_node_build_typelib (GIIrNode *node, case GI_IR_NODE_STRUCT: { - StructBlob *blob = (StructBlob *)&data[*offset]; - GIIrNodeStruct *struct_ = (GIIrNodeStruct *)node; - GList *members; + StructBlob *blob = (StructBlob *)&data[*offset]; + GIIrNodeStruct *struct_ = (GIIrNodeStruct *)node; + GList *members; - blob->blob_type = BLOB_TYPE_STRUCT; + blob->blob_type = BLOB_TYPE_STRUCT; blob->foreign = struct_->foreign; - blob->deprecated = struct_->deprecated; - blob->is_gtype_struct = struct_->is_gtype_struct; - blob->reserved = 0; - blob->name = gi_ir_write_string (node->name, strings, data, offset2); - blob->alignment = struct_->alignment; - blob->size = struct_->size; + blob->deprecated = struct_->deprecated; + blob->is_gtype_struct = struct_->is_gtype_struct; + blob->reserved = 0; + blob->name = gi_ir_write_string (node->name, strings, data, offset2); + blob->alignment = struct_->alignment; + blob->size = struct_->size; - if (struct_->gtype_name) - { - blob->unregistered = FALSE; - blob->gtype_name = gi_ir_write_string (struct_->gtype_name, strings, data, offset2); - blob->gtype_init = gi_ir_write_string (struct_->gtype_init, strings, data, offset2); - } - else - { - blob->unregistered = TRUE; - blob->gtype_name = 0; - blob->gtype_init = 0; - } + if (struct_->gtype_name) + { + blob->unregistered = FALSE; + blob->gtype_name = gi_ir_write_string (struct_->gtype_name, strings, data, offset2); + blob->gtype_init = gi_ir_write_string (struct_->gtype_init, strings, data, offset2); + } + else + { + blob->unregistered = TRUE; + blob->gtype_name = 0; + blob->gtype_init = 0; + } if (struct_->copy_func) blob->copy_func = gi_ir_write_string (struct_->copy_func, strings, data, offset2); if (struct_->free_func) blob->free_func = gi_ir_write_string (struct_->free_func, strings, data, offset2); - blob->n_fields = 0; - blob->n_methods = 0; + blob->n_fields = 0; + blob->n_methods = 0; - *offset += sizeof (StructBlob); + *offset += sizeof (StructBlob); - members = g_list_copy (struct_->members); + members = g_list_copy (struct_->members); - gi_ir_node_build_members (&members, GI_IR_NODE_FIELD, &blob->n_fields, + gi_ir_node_build_members (&members, GI_IR_NODE_FIELD, &blob->n_fields, node, build, offset, offset2, NULL); - gi_ir_node_build_members (&members, GI_IR_NODE_FUNCTION, &blob->n_methods, + gi_ir_node_build_members (&members, GI_IR_NODE_FUNCTION, &blob->n_methods, node, build, offset, offset2, NULL); - gi_ir_node_check_unhandled_members (&members, node->type); + gi_ir_node_check_unhandled_members (&members, node->type); - g_assert (members == NULL); + g_assert (members == NULL); } break; case GI_IR_NODE_BOXED: { - StructBlob *blob = (StructBlob *)&data[*offset]; - GIIrNodeBoxed *boxed = (GIIrNodeBoxed *)node; - GList *members; + StructBlob *blob = (StructBlob *)&data[*offset]; + GIIrNodeBoxed *boxed = (GIIrNodeBoxed *)node; + GList *members; - blob->blob_type = BLOB_TYPE_BOXED; - blob->deprecated = boxed->deprecated; - blob->unregistered = FALSE; - blob->reserved = 0; - blob->name = gi_ir_write_string (node->name, strings, data, offset2); - blob->gtype_name = gi_ir_write_string (boxed->gtype_name, strings, data, offset2); - blob->gtype_init = gi_ir_write_string (boxed->gtype_init, strings, data, offset2); - blob->alignment = boxed->alignment; - blob->size = boxed->size; + blob->blob_type = BLOB_TYPE_BOXED; + blob->deprecated = boxed->deprecated; + blob->unregistered = FALSE; + blob->reserved = 0; + blob->name = gi_ir_write_string (node->name, strings, data, offset2); + blob->gtype_name = gi_ir_write_string (boxed->gtype_name, strings, data, offset2); + blob->gtype_init = gi_ir_write_string (boxed->gtype_init, strings, data, offset2); + blob->alignment = boxed->alignment; + blob->size = boxed->size; - blob->n_fields = 0; - blob->n_methods = 0; + blob->n_fields = 0; + blob->n_methods = 0; - *offset += sizeof (StructBlob); + *offset += sizeof (StructBlob); - members = g_list_copy (boxed->members); + members = g_list_copy (boxed->members); - gi_ir_node_build_members (&members, GI_IR_NODE_FIELD, &blob->n_fields, + gi_ir_node_build_members (&members, GI_IR_NODE_FIELD, &blob->n_fields, node, build, offset, offset2, NULL); - gi_ir_node_build_members (&members, GI_IR_NODE_FUNCTION, &blob->n_methods, + gi_ir_node_build_members (&members, GI_IR_NODE_FUNCTION, &blob->n_methods, node, build, offset, offset2, NULL); - gi_ir_node_check_unhandled_members (&members, node->type); + gi_ir_node_check_unhandled_members (&members, node->type); - g_assert (members == NULL); + g_assert (members == NULL); } break; case GI_IR_NODE_UNION: { - UnionBlob *blob = (UnionBlob *)&data[*offset]; - GIIrNodeUnion *union_ = (GIIrNodeUnion *)node; - GList *members; + UnionBlob *blob = (UnionBlob *)&data[*offset]; + GIIrNodeUnion *union_ = (GIIrNodeUnion *)node; + GList *members; - blob->blob_type = BLOB_TYPE_UNION; - blob->deprecated = union_->deprecated; - blob->reserved = 0; - blob->name = gi_ir_write_string (node->name, strings, data, offset2); - blob->alignment = union_->alignment; - blob->size = union_->size; - if (union_->gtype_name) - { - blob->unregistered = FALSE; - blob->gtype_name = gi_ir_write_string (union_->gtype_name, strings, data, offset2); - blob->gtype_init = gi_ir_write_string (union_->gtype_init, strings, data, offset2); - } - else - { - blob->unregistered = TRUE; - blob->gtype_name = 0; - blob->gtype_init = 0; - } + blob->blob_type = BLOB_TYPE_UNION; + blob->deprecated = union_->deprecated; + blob->reserved = 0; + blob->name = gi_ir_write_string (node->name, strings, data, offset2); + blob->alignment = union_->alignment; + blob->size = union_->size; + if (union_->gtype_name) + { + blob->unregistered = FALSE; + blob->gtype_name = gi_ir_write_string (union_->gtype_name, strings, data, offset2); + blob->gtype_init = gi_ir_write_string (union_->gtype_init, strings, data, offset2); + } + else + { + blob->unregistered = TRUE; + blob->gtype_name = 0; + blob->gtype_init = 0; + } - blob->n_fields = 0; - blob->n_functions = 0; + blob->n_fields = 0; + blob->n_functions = 0; - blob->discriminator_offset = union_->discriminator_offset; + blob->discriminator_offset = union_->discriminator_offset; if (union_->copy_func) blob->copy_func = gi_ir_write_string (union_->copy_func, strings, data, offset2); if (union_->free_func) blob->free_func = gi_ir_write_string (union_->free_func, strings, data, offset2); - /* We don't support Union discriminators right now. */ - /* - if (union_->discriminator_type) - { - *offset += 28; - blob->discriminated = TRUE; - gi_ir_node_build_typelib ((GIIrNode *)union_->discriminator_type, + /* We don't support Union discriminators right now. */ + /* + if (union_->discriminator_type) + { + *offset += 28; + blob->discriminated = TRUE; + gi_ir_node_build_typelib ((GIIrNode *)union_->discriminator_type, build, offset, offset2, NULL); - } - else - { + } + else + { */ - *offset += sizeof (UnionBlob); - blob->discriminated = FALSE; - blob->discriminator_type.offset = 0; + *offset += sizeof (UnionBlob); + blob->discriminated = FALSE; + blob->discriminator_type.offset = 0; - members = g_list_copy (union_->members); + members = g_list_copy (union_->members); - gi_ir_node_build_members (&members, GI_IR_NODE_FIELD, &blob->n_fields, + gi_ir_node_build_members (&members, GI_IR_NODE_FIELD, &blob->n_fields, node, build, offset, offset2, NULL); - gi_ir_node_build_members (&members, GI_IR_NODE_FUNCTION, &blob->n_functions, + gi_ir_node_build_members (&members, GI_IR_NODE_FUNCTION, &blob->n_functions, node, build, offset, offset2, NULL); - gi_ir_node_check_unhandled_members (&members, node->type); + gi_ir_node_check_unhandled_members (&members, node->type); - g_assert (members == NULL); + g_assert (members == NULL); - if (union_->discriminator_type) - { - for (l = union_->discriminators; l; l = l->next) - { - GIIrNode *member = (GIIrNode *)l->data; + if (union_->discriminator_type) + { + for (l = union_->discriminators; l; l = l->next) + { + GIIrNode *member = (GIIrNode *)l->data; - gi_ir_node_build_typelib (member, node, build, offset, offset2, NULL); - } - } + gi_ir_node_build_typelib (member, node, build, offset, offset2, NULL); + } + } } break; case GI_IR_NODE_ENUM: case GI_IR_NODE_FLAGS: { - EnumBlob *blob = (EnumBlob *)&data[*offset]; - GIIrNodeEnum *enum_ = (GIIrNodeEnum *)node; + EnumBlob *blob = (EnumBlob *)&data[*offset]; + GIIrNodeEnum *enum_ = (GIIrNodeEnum *)node; - *offset += sizeof (EnumBlob); + *offset += sizeof (EnumBlob); - if (node->type == GI_IR_NODE_ENUM) - blob->blob_type = BLOB_TYPE_ENUM; - else - blob->blob_type = BLOB_TYPE_FLAGS; + if (node->type == GI_IR_NODE_ENUM) + blob->blob_type = BLOB_TYPE_ENUM; + else + blob->blob_type = BLOB_TYPE_FLAGS; - blob->deprecated = enum_->deprecated; - blob->reserved = 0; - blob->storage_type = enum_->storage_type; - blob->name = gi_ir_write_string (node->name, strings, data, offset2); - if (enum_->gtype_name) - { - blob->unregistered = FALSE; - blob->gtype_name = gi_ir_write_string (enum_->gtype_name, strings, data, offset2); - blob->gtype_init = gi_ir_write_string (enum_->gtype_init, strings, data, offset2); - } - else - { - blob->unregistered = TRUE; - blob->gtype_name = 0; - blob->gtype_init = 0; - } - if (enum_->error_domain) - blob->error_domain = gi_ir_write_string (enum_->error_domain, strings, data, offset2); - else - blob->error_domain = 0; + blob->deprecated = enum_->deprecated; + blob->reserved = 0; + blob->storage_type = enum_->storage_type; + blob->name = gi_ir_write_string (node->name, strings, data, offset2); + if (enum_->gtype_name) + { + blob->unregistered = FALSE; + blob->gtype_name = gi_ir_write_string (enum_->gtype_name, strings, data, offset2); + blob->gtype_init = gi_ir_write_string (enum_->gtype_init, strings, data, offset2); + } + else + { + blob->unregistered = TRUE; + blob->gtype_name = 0; + blob->gtype_init = 0; + } + if (enum_->error_domain) + blob->error_domain = gi_ir_write_string (enum_->error_domain, strings, data, offset2); + else + blob->error_domain = 0; - blob->n_values = 0; - blob->n_methods = 0; + blob->n_values = 0; + blob->n_methods = 0; - for (l = enum_->values; l; l = l->next) - { - GIIrNode *value = (GIIrNode *)l->data; + for (l = enum_->values; l; l = l->next) + { + GIIrNode *value = (GIIrNode *)l->data; - blob->n_values++; - gi_ir_node_build_typelib (value, node, build, offset, offset2, NULL); - } + blob->n_values++; + gi_ir_node_build_typelib (value, node, build, offset, offset2, NULL); + } - for (l = enum_->methods; l; l = l->next) - { - GIIrNode *method = (GIIrNode *)l->data; + for (l = enum_->methods; l; l = l->next) + { + GIIrNode *method = (GIIrNode *)l->data; - blob->n_methods++; - gi_ir_node_build_typelib (method, node, build, offset, offset2, NULL); - } + blob->n_methods++; + gi_ir_node_build_typelib (method, node, build, offset, offset2, NULL); + } } break; case GI_IR_NODE_OBJECT: { - ObjectBlob *blob = (ObjectBlob *)&data[*offset]; - GIIrNodeInterface *object = (GIIrNodeInterface *)node; - GList *members; + ObjectBlob *blob = (ObjectBlob *)&data[*offset]; + GIIrNodeInterface *object = (GIIrNodeInterface *)node; + GList *members; - blob->blob_type = BLOB_TYPE_OBJECT; - blob->abstract = object->abstract; + blob->blob_type = BLOB_TYPE_OBJECT; + blob->abstract = object->abstract; blob->fundamental = object->fundamental; blob->final_ = object->final_; - blob->deprecated = object->deprecated; - blob->reserved = 0; - blob->name = gi_ir_write_string (node->name, strings, data, offset2); - blob->gtype_name = gi_ir_write_string (object->gtype_name, strings, data, offset2); - blob->gtype_init = gi_ir_write_string (object->gtype_init, strings, data, offset2); + blob->deprecated = object->deprecated; + blob->reserved = 0; + blob->name = gi_ir_write_string (node->name, strings, data, offset2); + blob->gtype_name = gi_ir_write_string (object->gtype_name, strings, data, offset2); + blob->gtype_init = gi_ir_write_string (object->gtype_init, strings, data, offset2); if (object->ref_func) blob->ref_func = gi_ir_write_string (object->ref_func, strings, data, offset2); if (object->unref_func) @@ -2182,210 +2182,210 @@ gi_ir_node_build_typelib (GIIrNode *node, blob->set_value_func = gi_ir_write_string (object->set_value_func, strings, data, offset2); if (object->get_value_func) blob->get_value_func = gi_ir_write_string (object->get_value_func, strings, data, offset2); - if (object->parent) - blob->parent = find_entry (build, object->parent); - else - blob->parent = 0; - if (object->glib_type_struct) - blob->gtype_struct = find_entry (build, object->glib_type_struct); - else - blob->gtype_struct = 0; + if (object->parent) + blob->parent = find_entry (build, object->parent); + else + blob->parent = 0; + if (object->glib_type_struct) + blob->gtype_struct = find_entry (build, object->glib_type_struct); + else + blob->gtype_struct = 0; - blob->n_interfaces = 0; - blob->n_fields = 0; - blob->n_properties = 0; - blob->n_methods = 0; - blob->n_signals = 0; - blob->n_vfuncs = 0; - blob->n_constants = 0; - blob->n_field_callbacks = 0; + blob->n_interfaces = 0; + blob->n_fields = 0; + blob->n_properties = 0; + blob->n_methods = 0; + blob->n_signals = 0; + blob->n_vfuncs = 0; + blob->n_constants = 0; + blob->n_field_callbacks = 0; - *offset += sizeof(ObjectBlob); - for (l = object->interfaces; l; l = l->next) - { - blob->n_interfaces++; - *(guint16*)&data[*offset] = find_entry (build, (gchar *)l->data); - *offset += 2; - } + *offset += sizeof(ObjectBlob); + for (l = object->interfaces; l; l = l->next) + { + blob->n_interfaces++; + *(guint16*)&data[*offset] = find_entry (build, (gchar *)l->data); + *offset += 2; + } - members = g_list_copy (object->members); + members = g_list_copy (object->members); - *offset = ALIGN_VALUE (*offset, 4); - gi_ir_node_build_members (&members, GI_IR_NODE_FIELD, &blob->n_fields, + *offset = ALIGN_VALUE (*offset, 4); + gi_ir_node_build_members (&members, GI_IR_NODE_FIELD, &blob->n_fields, node, build, offset, offset2, &blob->n_field_callbacks); - *offset = ALIGN_VALUE (*offset, 4); - gi_ir_node_build_members (&members, GI_IR_NODE_PROPERTY, &blob->n_properties, + *offset = ALIGN_VALUE (*offset, 4); + gi_ir_node_build_members (&members, GI_IR_NODE_PROPERTY, &blob->n_properties, node, build, offset, offset2, NULL); - *offset = ALIGN_VALUE (*offset, 4); - gi_ir_node_build_members (&members, GI_IR_NODE_FUNCTION, &blob->n_methods, + *offset = ALIGN_VALUE (*offset, 4); + gi_ir_node_build_members (&members, GI_IR_NODE_FUNCTION, &blob->n_methods, node, build, offset, offset2, NULL); - *offset = ALIGN_VALUE (*offset, 4); - gi_ir_node_build_members (&members, GI_IR_NODE_SIGNAL, &blob->n_signals, + *offset = ALIGN_VALUE (*offset, 4); + gi_ir_node_build_members (&members, GI_IR_NODE_SIGNAL, &blob->n_signals, node, build, offset, offset2, NULL); - *offset = ALIGN_VALUE (*offset, 4); - gi_ir_node_build_members (&members, GI_IR_NODE_VFUNC, &blob->n_vfuncs, + *offset = ALIGN_VALUE (*offset, 4); + gi_ir_node_build_members (&members, GI_IR_NODE_VFUNC, &blob->n_vfuncs, node, build, offset, offset2, NULL); - *offset = ALIGN_VALUE (*offset, 4); - gi_ir_node_build_members (&members, GI_IR_NODE_CONSTANT, &blob->n_constants, + *offset = ALIGN_VALUE (*offset, 4); + gi_ir_node_build_members (&members, GI_IR_NODE_CONSTANT, &blob->n_constants, node, build, offset, offset2, NULL); - gi_ir_node_check_unhandled_members (&members, node->type); + gi_ir_node_check_unhandled_members (&members, node->type); - g_assert (members == NULL); + g_assert (members == NULL); } break; case GI_IR_NODE_INTERFACE: { - InterfaceBlob *blob = (InterfaceBlob *)&data[*offset]; - GIIrNodeInterface *iface = (GIIrNodeInterface *)node; - GList *members; + InterfaceBlob *blob = (InterfaceBlob *)&data[*offset]; + GIIrNodeInterface *iface = (GIIrNodeInterface *)node; + GList *members; - blob->blob_type = BLOB_TYPE_INTERFACE; - blob->deprecated = iface->deprecated; - blob->reserved = 0; - blob->name = gi_ir_write_string (node->name, strings, data, offset2); - blob->gtype_name = gi_ir_write_string (iface->gtype_name, strings, data, offset2); - blob->gtype_init = gi_ir_write_string (iface->gtype_init, strings, data, offset2); - if (iface->glib_type_struct) - blob->gtype_struct = find_entry (build, iface->glib_type_struct); - else - blob->gtype_struct = 0; - blob->n_prerequisites = 0; - blob->n_properties = 0; - blob->n_methods = 0; - blob->n_signals = 0; - blob->n_vfuncs = 0; - blob->n_constants = 0; + blob->blob_type = BLOB_TYPE_INTERFACE; + blob->deprecated = iface->deprecated; + blob->reserved = 0; + blob->name = gi_ir_write_string (node->name, strings, data, offset2); + blob->gtype_name = gi_ir_write_string (iface->gtype_name, strings, data, offset2); + blob->gtype_init = gi_ir_write_string (iface->gtype_init, strings, data, offset2); + if (iface->glib_type_struct) + blob->gtype_struct = find_entry (build, iface->glib_type_struct); + else + blob->gtype_struct = 0; + blob->n_prerequisites = 0; + blob->n_properties = 0; + blob->n_methods = 0; + blob->n_signals = 0; + blob->n_vfuncs = 0; + blob->n_constants = 0; - *offset += sizeof (InterfaceBlob); - for (l = iface->prerequisites; l; l = l->next) - { - blob->n_prerequisites++; - *(guint16*)&data[*offset] = find_entry (build, (gchar *)l->data); - *offset += 2; - } + *offset += sizeof (InterfaceBlob); + for (l = iface->prerequisites; l; l = l->next) + { + blob->n_prerequisites++; + *(guint16*)&data[*offset] = find_entry (build, (gchar *)l->data); + *offset += 2; + } - members = g_list_copy (iface->members); + members = g_list_copy (iface->members); - *offset = ALIGN_VALUE (*offset, 4); - gi_ir_node_build_members (&members, GI_IR_NODE_PROPERTY, &blob->n_properties, + *offset = ALIGN_VALUE (*offset, 4); + gi_ir_node_build_members (&members, GI_IR_NODE_PROPERTY, &blob->n_properties, node, build, offset, offset2, NULL); - *offset = ALIGN_VALUE (*offset, 4); - gi_ir_node_build_members (&members, GI_IR_NODE_FUNCTION, &blob->n_methods, + *offset = ALIGN_VALUE (*offset, 4); + gi_ir_node_build_members (&members, GI_IR_NODE_FUNCTION, &blob->n_methods, node, build, offset, offset2, NULL); - *offset = ALIGN_VALUE (*offset, 4); - gi_ir_node_build_members (&members, GI_IR_NODE_SIGNAL, &blob->n_signals, + *offset = ALIGN_VALUE (*offset, 4); + gi_ir_node_build_members (&members, GI_IR_NODE_SIGNAL, &blob->n_signals, node, build, offset, offset2, NULL); - *offset = ALIGN_VALUE (*offset, 4); - gi_ir_node_build_members (&members, GI_IR_NODE_VFUNC, &blob->n_vfuncs, + *offset = ALIGN_VALUE (*offset, 4); + gi_ir_node_build_members (&members, GI_IR_NODE_VFUNC, &blob->n_vfuncs, node, build, offset, offset2, NULL); - *offset = ALIGN_VALUE (*offset, 4); - gi_ir_node_build_members (&members, GI_IR_NODE_CONSTANT, &blob->n_constants, + *offset = ALIGN_VALUE (*offset, 4); + gi_ir_node_build_members (&members, GI_IR_NODE_CONSTANT, &blob->n_constants, node, build, offset, offset2, NULL); - gi_ir_node_check_unhandled_members (&members, node->type); + gi_ir_node_check_unhandled_members (&members, node->type); - g_assert (members == NULL); + g_assert (members == NULL); } break; case GI_IR_NODE_VALUE: { - GIIrNodeValue *value = (GIIrNodeValue *)node; - ValueBlob *blob = (ValueBlob *)&data[*offset]; - *offset += sizeof (ValueBlob); + GIIrNodeValue *value = (GIIrNodeValue *)node; + ValueBlob *blob = (ValueBlob *)&data[*offset]; + *offset += sizeof (ValueBlob); - blob->deprecated = value->deprecated; - blob->reserved = 0; - blob->unsigned_value = value->value >= 0 ? 1 : 0; - blob->name = gi_ir_write_string (node->name, strings, data, offset2); - blob->value = (gint32)value->value; + blob->deprecated = value->deprecated; + blob->reserved = 0; + blob->unsigned_value = value->value >= 0 ? 1 : 0; + blob->name = gi_ir_write_string (node->name, strings, data, offset2); + blob->value = (gint32)value->value; } break; case GI_IR_NODE_CONSTANT: { - GIIrNodeConstant *constant = (GIIrNodeConstant *)node; - ConstantBlob *blob = (ConstantBlob *)&data[*offset]; - guint32 pos; + GIIrNodeConstant *constant = (GIIrNodeConstant *)node; + ConstantBlob *blob = (ConstantBlob *)&data[*offset]; + guint32 pos; - pos = *offset + G_STRUCT_OFFSET (ConstantBlob, type); - *offset += sizeof (ConstantBlob); + pos = *offset + G_STRUCT_OFFSET (ConstantBlob, type); + *offset += sizeof (ConstantBlob); - blob->blob_type = BLOB_TYPE_CONSTANT; - blob->deprecated = constant->deprecated; - blob->reserved = 0; - blob->name = gi_ir_write_string (node->name, strings, data, offset2); + blob->blob_type = BLOB_TYPE_CONSTANT; + blob->deprecated = constant->deprecated; + blob->reserved = 0; + blob->name = gi_ir_write_string (node->name, strings, data, offset2); - blob->offset = *offset2; - switch (constant->type->tag) - { - case GI_TYPE_TAG_BOOLEAN: - blob->size = 4; - *(gboolean*)&data[blob->offset] = parse_boolean_value (constant->value); - break; - case GI_TYPE_TAG_INT8: - blob->size = 1; - *(gint8*)&data[blob->offset] = (gint8) parse_int_value (constant->value); - break; - case GI_TYPE_TAG_UINT8: - blob->size = 1; - *(guint8*)&data[blob->offset] = (guint8) parse_uint_value (constant->value); - break; - case GI_TYPE_TAG_INT16: - blob->size = 2; - *(gint16*)&data[blob->offset] = (gint16) parse_int_value (constant->value); - break; - case GI_TYPE_TAG_UINT16: - blob->size = 2; - *(guint16*)&data[blob->offset] = (guint16) parse_uint_value (constant->value); - break; - case GI_TYPE_TAG_INT32: - blob->size = 4; - *(gint32*)&data[blob->offset] = (gint32) parse_int_value (constant->value); - break; - case GI_TYPE_TAG_UINT32: - blob->size = 4; - *(guint32*)&data[blob->offset] = (guint32) parse_uint_value (constant->value); - break; - case GI_TYPE_TAG_INT64: - blob->size = 8; - DO_ALIGNED_COPY(&data[blob->offset], parse_int_value (constant->value), gint64); - break; - case GI_TYPE_TAG_UINT64: - blob->size = 8; - DO_ALIGNED_COPY(&data[blob->offset], parse_uint_value (constant->value), guint64); - break; - case GI_TYPE_TAG_FLOAT: - blob->size = sizeof (gfloat); - DO_ALIGNED_COPY(&data[blob->offset], parse_float_value (constant->value), gfloat); - break; - case GI_TYPE_TAG_DOUBLE: - blob->size = sizeof (gdouble); - DO_ALIGNED_COPY(&data[blob->offset], parse_float_value (constant->value), gdouble); - break; - case GI_TYPE_TAG_UTF8: - case GI_TYPE_TAG_FILENAME: - blob->size = strlen (constant->value) + 1; - memcpy (&data[blob->offset], constant->value, blob->size); - break; - default: - break; - } - *offset2 += ALIGN_VALUE (blob->size, 4); + blob->offset = *offset2; + switch (constant->type->tag) + { + case GI_TYPE_TAG_BOOLEAN: + blob->size = 4; + *(gboolean*)&data[blob->offset] = parse_boolean_value (constant->value); + break; + case GI_TYPE_TAG_INT8: + blob->size = 1; + *(gint8*)&data[blob->offset] = (gint8) parse_int_value (constant->value); + break; + case GI_TYPE_TAG_UINT8: + blob->size = 1; + *(guint8*)&data[blob->offset] = (guint8) parse_uint_value (constant->value); + break; + case GI_TYPE_TAG_INT16: + blob->size = 2; + *(gint16*)&data[blob->offset] = (gint16) parse_int_value (constant->value); + break; + case GI_TYPE_TAG_UINT16: + blob->size = 2; + *(guint16*)&data[blob->offset] = (guint16) parse_uint_value (constant->value); + break; + case GI_TYPE_TAG_INT32: + blob->size = 4; + *(gint32*)&data[blob->offset] = (gint32) parse_int_value (constant->value); + break; + case GI_TYPE_TAG_UINT32: + blob->size = 4; + *(guint32*)&data[blob->offset] = (guint32) parse_uint_value (constant->value); + break; + case GI_TYPE_TAG_INT64: + blob->size = 8; + DO_ALIGNED_COPY(&data[blob->offset], parse_int_value (constant->value), gint64); + break; + case GI_TYPE_TAG_UINT64: + blob->size = 8; + DO_ALIGNED_COPY(&data[blob->offset], parse_uint_value (constant->value), guint64); + break; + case GI_TYPE_TAG_FLOAT: + blob->size = sizeof (gfloat); + DO_ALIGNED_COPY(&data[blob->offset], parse_float_value (constant->value), gfloat); + break; + case GI_TYPE_TAG_DOUBLE: + blob->size = sizeof (gdouble); + DO_ALIGNED_COPY(&data[blob->offset], parse_float_value (constant->value), gdouble); + break; + case GI_TYPE_TAG_UTF8: + case GI_TYPE_TAG_FILENAME: + blob->size = strlen (constant->value) + 1; + memcpy (&data[blob->offset], constant->value, blob->size); + break; + default: + break; + } + *offset2 += ALIGN_VALUE (blob->size, 4); - gi_ir_node_build_typelib ((GIIrNode *)constant->type, node, build, &pos, offset2, NULL); + gi_ir_node_build_typelib ((GIIrNode *)constant->type, node, build, &pos, offset2, NULL); } break; default: @@ -2393,11 +2393,11 @@ gi_ir_node_build_typelib (GIIrNode *node, } g_debug ("node %s%s%s%p type '%s', offset %d -> %d, offset2 %d -> %d", - node->name ? "'" : "", - node->name ? node->name : "", - node->name ? "' " : "", - node, gi_ir_node_type_to_string (node->type), - old_offset, *offset, old_offset2, *offset2); + node->name ? "'" : "", + node->name ? node->name : "", + node->name ? "' " : "", + node, gi_ir_node_type_to_string (node->type), + old_offset, *offset, old_offset2, *offset2); if (*offset2 - old_offset2 + *offset - old_offset > gi_ir_node_get_full_size (node)) g_error ("exceeding space reservation; offset: %d (prev %d) offset2: %d (prev %d) nodesize: %d", diff --git a/girepository/giroffsets.c b/girepository/giroffsets.c index 32bf684df..3a443c6b6 100644 --- a/girepository/giroffsets.c +++ b/girepository/giroffsets.c @@ -95,44 +95,44 @@ compute_enum_storage_type (GIIrNodeEnum *enum_node) signed_type = TRUE; if (min_value > -128 && max_value <= 127) - width = sizeof(Enum7); + width = sizeof(Enum7); else if (min_value >= G_MINSHORT && max_value <= G_MAXSHORT) - width = sizeof(Enum8); + width = sizeof(Enum8); else - width = sizeof(Enum9); + width = sizeof(Enum9); } else { if (max_value <= 127) - { - width = sizeof (Enum1); - signed_type = (gint64)(Enum1)(-1) < 0; - } + { + width = sizeof (Enum1); + signed_type = (gint64)(Enum1)(-1) < 0; + } else if (max_value <= 255) - { - width = sizeof (Enum2); - signed_type = (gint64)(Enum2)(-1) < 0; - } + { + width = sizeof (Enum2); + signed_type = (gint64)(Enum2)(-1) < 0; + } else if (max_value <= G_MAXSHORT) - { - width = sizeof (Enum3); - signed_type = (gint64)(Enum3)(-1) < 0; - } + { + width = sizeof (Enum3); + signed_type = (gint64)(Enum3)(-1) < 0; + } else if (max_value <= G_MAXUSHORT) - { - width = sizeof (Enum4); - signed_type = (gint64)(Enum4)(-1) < 0; - } + { + width = sizeof (Enum4); + signed_type = (gint64)(Enum4)(-1) < 0; + } else if (max_value <= G_MAXINT) - { - width = sizeof (Enum5); - signed_type = (gint64)(Enum5)(-1) < 0; - } + { + width = sizeof (Enum5); + signed_type = (gint64)(Enum5)(-1) < 0; + } else - { - width = sizeof (Enum6); - signed_type = (gint64)(Enum6)(-1) < 0; - } + { + width = sizeof (Enum6); + signed_type = (gint64)(Enum6)(-1) < 0; + } } if (width == 1) @@ -176,7 +176,7 @@ get_enum_size_alignment (GIIrNodeEnum *enum_node, break; default: g_error ("Unexpected enum storage type %s", - gi_type_tag_to_string (enum_node->storage_type)); + gi_type_tag_to_string (enum_node->storage_type)); } *size = type_ffi->size; @@ -209,53 +209,53 @@ get_interface_size_alignment (GIIrTypelibBuild *build, { case GI_IR_NODE_BOXED: { - GIIrNodeBoxed *boxed = (GIIrNodeBoxed *)iface; - *size = boxed->size; - *alignment = boxed->alignment; - break; + GIIrNodeBoxed *boxed = (GIIrNodeBoxed *)iface; + *size = boxed->size; + *alignment = boxed->alignment; + break; } case GI_IR_NODE_STRUCT: { - GIIrNodeStruct *struct_ = (GIIrNodeStruct *)iface; - *size = struct_->size; - *alignment = struct_->alignment; - break; + GIIrNodeStruct *struct_ = (GIIrNodeStruct *)iface; + *size = struct_->size; + *alignment = struct_->alignment; + break; } case GI_IR_NODE_OBJECT: case GI_IR_NODE_INTERFACE: { - GIIrNodeInterface *interface = (GIIrNodeInterface *)iface; - *size = interface->size; - *alignment = interface->alignment; - break; + GIIrNodeInterface *interface = (GIIrNodeInterface *)iface; + *size = interface->size; + *alignment = interface->alignment; + break; } case GI_IR_NODE_UNION: { - GIIrNodeUnion *union_ = (GIIrNodeUnion *)iface; - *size = union_->size; - *alignment = union_->alignment; - break; + GIIrNodeUnion *union_ = (GIIrNodeUnion *)iface; + *size = union_->size; + *alignment = union_->alignment; + break; } case GI_IR_NODE_ENUM: case GI_IR_NODE_FLAGS: { - return get_enum_size_alignment ((GIIrNodeEnum *)iface, - size, alignment); + return get_enum_size_alignment ((GIIrNodeEnum *)iface, + size, alignment); } case GI_IR_NODE_CALLBACK: { - *size = ffi_type_pointer.size; - *alignment = ffi_type_pointer.alignment; - break; + *size = ffi_type_pointer.size; + *alignment = ffi_type_pointer.alignment; + break; } default: { - g_warning ("%s has is not a pointer and is of type %s", + g_warning ("%s has is not a pointer and is of type %s", who, - gi_ir_node_type_to_string (iface->type)); - *size = -1; - *alignment = -1; - break; + gi_ir_node_type_to_string (iface->type)); + *size = -1; + *alignment = -1; + break; } } @@ -296,30 +296,30 @@ get_type_size_alignment (GIIrTypelibBuild *build, else { if (type->tag == GI_TYPE_TAG_INTERFACE) - { - return get_interface_size_alignment (build, type, size, alignment, who); - } + { + return get_interface_size_alignment (build, type, size, alignment, who); + } else - { - type_ffi = gi_type_tag_get_ffi_type (type->tag, type->is_pointer); + { + type_ffi = gi_type_tag_get_ffi_type (type->tag, type->is_pointer); - if (type_ffi == &ffi_type_void) - { - g_warning ("%s has void type", who); - *size = -1; - *alignment = -1; - return FALSE; - } - else if (type_ffi == &ffi_type_pointer) - { - g_warning ("%s has is not a pointer and is of type %s", + if (type_ffi == &ffi_type_void) + { + g_warning ("%s has void type", who); + *size = -1; + *alignment = -1; + return FALSE; + } + else if (type_ffi == &ffi_type_pointer) + { + g_warning ("%s has is not a pointer and is of type %s", who, - gi_type_tag_to_string (type->tag)); - *size = -1; - *alignment = -1; - return FALSE; - } - } + gi_type_tag_to_string (type->tag)); + *size = -1; + *alignment = -1; + return FALSE; + } + } } g_assert (type_ffi); @@ -376,35 +376,35 @@ compute_struct_field_offsets (GIIrTypelibBuild *build, GIIrNode *member = (GIIrNode *)l->data; if (member->type == GI_IR_NODE_FIELD) - { - GIIrNodeField *field = (GIIrNodeField *)member; + { + GIIrNodeField *field = (GIIrNodeField *)member; - if (!have_error) - { - int member_size; - int member_alignment; + if (!have_error) + { + int member_size; + int member_alignment; - if (get_field_size_alignment (build, field, node, - &member_size, &member_alignment)) - { - size = GI_ALIGN (size, member_alignment); - alignment = MAX (alignment, member_alignment); - field->offset = size; - size += member_size; - } - else - have_error = TRUE; - } + if (get_field_size_alignment (build, field, node, + &member_size, &member_alignment)) + { + size = GI_ALIGN (size, member_alignment); + alignment = MAX (alignment, member_alignment); + field->offset = size; + size += member_size; + } + else + have_error = TRUE; + } - if (have_error) - field->offset = -1; - } + if (have_error) + field->offset = -1; + } else if (member->type == GI_IR_NODE_CALLBACK) - { + { size = GI_ALIGN (size, ffi_type_pointer.alignment); alignment = MAX (alignment, ffi_type_pointer.alignment); - size += ffi_type_pointer.size; - } + size += ffi_type_pointer.size; + } } /* Structs are tail-padded out to a multiple of their alignment */ @@ -443,24 +443,24 @@ compute_union_field_offsets (GIIrTypelibBuild *build, GIIrNode *member = (GIIrNode *)l->data; if (member->type == GI_IR_NODE_FIELD) - { - GIIrNodeField *field = (GIIrNodeField *)member; + { + GIIrNodeField *field = (GIIrNodeField *)member; - if (!have_error) - { - int member_size; - int member_alignment; + if (!have_error) + { + int member_size; + int member_alignment; - if (get_field_size_alignment (build,field, node, - &member_size, &member_alignment)) - { - size = MAX (size, member_size); - alignment = MAX (alignment, member_alignment); - } - else - have_error = TRUE; - } - } + if (get_field_size_alignment (build,field, node, + &member_size, &member_alignment)) + { + size = MAX (size, member_size); + alignment = MAX (alignment, member_alignment); + } + else + have_error = TRUE; + } + } } /* Unions are tail-padded out to a multiple of their alignment */ @@ -495,7 +495,7 @@ check_needs_computation (GIIrTypelibBuild *build, if (alignment == -2) { g_warning ("Recursion encountered when computing the size of %s.%s", - module->name, node->name); + module->name, node->name); } return alignment == 0; @@ -529,60 +529,60 @@ gi_ir_node_compute_offsets (GIIrTypelibBuild *build, { case GI_IR_NODE_BOXED: { - GIIrNodeBoxed *boxed = (GIIrNodeBoxed *)node; + GIIrNodeBoxed *boxed = (GIIrNodeBoxed *)node; - if (!check_needs_computation (build, node, boxed->alignment)) - return; + if (!check_needs_computation (build, node, boxed->alignment)) + return; - compute_struct_field_offsets (build, node, boxed->members, - &boxed->size, &boxed->alignment); - break; + compute_struct_field_offsets (build, node, boxed->members, + &boxed->size, &boxed->alignment); + break; } case GI_IR_NODE_STRUCT: { - GIIrNodeStruct *struct_ = (GIIrNodeStruct *)node; + GIIrNodeStruct *struct_ = (GIIrNodeStruct *)node; - if (!check_needs_computation (build, node, struct_->alignment)) - return; + if (!check_needs_computation (build, node, struct_->alignment)) + return; - compute_struct_field_offsets (build, node, struct_->members, - &struct_->size, &struct_->alignment); - break; + compute_struct_field_offsets (build, node, struct_->members, + &struct_->size, &struct_->alignment); + break; } case GI_IR_NODE_OBJECT: case GI_IR_NODE_INTERFACE: { - GIIrNodeInterface *iface = (GIIrNodeInterface *)node; + GIIrNodeInterface *iface = (GIIrNodeInterface *)node; - if (!check_needs_computation (build, node, iface->alignment)) - return; + if (!check_needs_computation (build, node, iface->alignment)) + return; - compute_struct_field_offsets (build, node, iface->members, - &iface->size, &iface->alignment); - break; + compute_struct_field_offsets (build, node, iface->members, + &iface->size, &iface->alignment); + break; } case GI_IR_NODE_UNION: { - GIIrNodeUnion *union_ = (GIIrNodeUnion *)node; + GIIrNodeUnion *union_ = (GIIrNodeUnion *)node; - if (!check_needs_computation (build, node, union_->alignment)) - return; + if (!check_needs_computation (build, node, union_->alignment)) + return; - compute_union_field_offsets (build, (GIIrNode*)union_, union_->members, - &union_->size, &union_->alignment); - break; + compute_union_field_offsets (build, (GIIrNode*)union_, union_->members, + &union_->size, &union_->alignment); + break; } case GI_IR_NODE_ENUM: case GI_IR_NODE_FLAGS: { - GIIrNodeEnum *enum_ = (GIIrNodeEnum *)node; + GIIrNodeEnum *enum_ = (GIIrNodeEnum *)node; - if (enum_->storage_type != GI_TYPE_TAG_VOID) /* already done */ - return; + if (enum_->storage_type != GI_TYPE_TAG_VOID) /* already done */ + return; - compute_enum_storage_type (enum_); + compute_enum_storage_type (enum_); - break; + break; } default: break; diff --git a/girepository/girparser.c b/girepository/girparser.c index 04008a1a7..7667c53bf 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -133,23 +133,23 @@ struct _ParseContext #define CURRENT_NODE(ctx) ((GIIrNode *)((ctx)->node_stack->data)) static void start_element_handler (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - gpointer user_data, - GError **error); + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + gpointer user_data, + GError **error); static void end_element_handler (GMarkupParseContext *context, - const gchar *element_name, - gpointer user_data, - GError **error); + const gchar *element_name, + gpointer user_data, + GError **error); static void text_handler (GMarkupParseContext *context, - const gchar *text, - gsize text_len, - gpointer user_data, - GError **error); + const gchar *text, + gsize text_len, + gpointer user_data, + GError **error); static void cleanup (GMarkupParseContext *context, - GError *error, - gpointer user_data); + GError *error, + gpointer user_data); static void state_switch (ParseContext *ctx, ParseState newstate); @@ -164,22 +164,22 @@ static GMarkupParser markup_parser = static gboolean start_alias (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error); + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error); static gboolean start_type (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error); + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error); static const gchar *find_attribute (const gchar *name, - const gchar **attribute_names, - const gchar **attribute_values); + const gchar **attribute_names, + const gchar **attribute_values); GIIrParser * @@ -219,23 +219,23 @@ gi_ir_parser_set_includes (GIIrParser *parser, static void firstpass_start_element_handler (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - gpointer user_data, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + gpointer user_data, + GError **error) { ParseContext *ctx = user_data; if (strcmp (element_name, "alias") == 0) { start_alias (context, element_name, attribute_names, attribute_values, - ctx, error); + ctx, error); } else if (ctx->state == STATE_ALIAS && strcmp (element_name, "type") == 0) { start_type (context, element_name, attribute_names, attribute_values, - ctx, error); + ctx, error); } else if (strcmp (element_name, "record") == 0) { @@ -252,23 +252,23 @@ firstpass_start_element_handler (GMarkupParseContext *context, char *key; key = g_strdup_printf ("%s.%s", ctx->namespace, name); - g_hash_table_replace (ctx->pointer_structures, key, GINT_TO_POINTER (1)); + g_hash_table_replace (ctx->pointer_structures, key, GINT_TO_POINTER (1)); } else if (g_strcmp0 (disguised, "1") == 0) - { - char *key; + { + char *key; - key = g_strdup_printf ("%s.%s", ctx->namespace, name); - g_hash_table_replace (ctx->disguised_structures, key, GINT_TO_POINTER (1)); - } + key = g_strdup_printf ("%s.%s", ctx->namespace, name); + g_hash_table_replace (ctx->disguised_structures, key, GINT_TO_POINTER (1)); + } } } static void firstpass_end_element_handler (GMarkupParseContext *context, - const gchar *element_name, - gpointer user_data, - GError **error) + const gchar *element_name, + gpointer user_data, + GError **error) { ParseContext *ctx = user_data; if (strcmp (element_name, "alias") == 0) @@ -304,13 +304,13 @@ locate_gir (GIIrParser *parser, if (parser->includes != NULL) { for (dir = (const gchar *const *)parser->includes; *dir; dir++) - { - path = g_build_filename (*dir, girname, NULL); - g_debug ("Trying %s from includes", path); - if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) - return g_steal_pointer (&path); - g_clear_pointer (&path, g_free); - } + { + path = g_build_filename (*dir, girname, NULL); + g_debug ("Trying %s from includes", path); + if (g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) + return g_steal_pointer (&path); + g_clear_pointer (&path, g_free); + } } if (parser->gi_gir_path != NULL) @@ -367,21 +367,21 @@ locate_gir (GIIrParser *parser, return NULL; } -#define MISSING_ATTRIBUTE(context,error,element,attribute) \ +#define MISSING_ATTRIBUTE(context,error,element,attribute) \ do { \ int line_number, char_number; \ g_markup_parse_context_get_position (context, &line_number, &char_number); \ g_set_error (error, \ - G_MARKUP_ERROR, \ - G_MARKUP_ERROR_INVALID_CONTENT, \ - "Line %d, character %d: The attribute '%s' on the element '%s' must be specified", \ - line_number, char_number, attribute, element); \ + G_MARKUP_ERROR, \ + G_MARKUP_ERROR_INVALID_CONTENT, \ + "Line %d, character %d: The attribute '%s' on the element '%s' must be specified", \ + line_number, char_number, attribute, element); \ } while (0) static const gchar * find_attribute (const gchar *name, - const gchar **attribute_names, - const gchar **attribute_values) + const gchar **attribute_names, + const gchar **attribute_values) { gint i; @@ -490,42 +490,42 @@ parse_basic (const char *str) for (i = 0; i < n_basic; i++) { if (strcmp (str, basic_types[i].str) == 0) - return &(basic_types[i]); + return &(basic_types[i]); } for (i = 0; i < G_N_ELEMENTS (integer_aliases); i++) { if (strcmp (str, integer_aliases[i].str) == 0) - { - switch (integer_aliases[i].size) - { - case sizeof(guint8): - if (integer_aliases[i].is_signed) - return &basic_types[BASIC_TYPE_FIXED_OFFSET]; - else - return &basic_types[BASIC_TYPE_FIXED_OFFSET+1]; - break; - case sizeof(guint16): - if (integer_aliases[i].is_signed) - return &basic_types[BASIC_TYPE_FIXED_OFFSET+2]; - else - return &basic_types[BASIC_TYPE_FIXED_OFFSET+3]; - break; - case sizeof(guint32): - if (integer_aliases[i].is_signed) - return &basic_types[BASIC_TYPE_FIXED_OFFSET+4]; - else - return &basic_types[BASIC_TYPE_FIXED_OFFSET+5]; - break; - case sizeof(guint64): - if (integer_aliases[i].is_signed) - return &basic_types[BASIC_TYPE_FIXED_OFFSET+6]; - else - return &basic_types[BASIC_TYPE_FIXED_OFFSET+7]; - break; - default: - g_assert_not_reached (); - } - } + { + switch (integer_aliases[i].size) + { + case sizeof(guint8): + if (integer_aliases[i].is_signed) + return &basic_types[BASIC_TYPE_FIXED_OFFSET]; + else + return &basic_types[BASIC_TYPE_FIXED_OFFSET+1]; + break; + case sizeof(guint16): + if (integer_aliases[i].is_signed) + return &basic_types[BASIC_TYPE_FIXED_OFFSET+2]; + else + return &basic_types[BASIC_TYPE_FIXED_OFFSET+3]; + break; + case sizeof(guint32): + if (integer_aliases[i].is_signed) + return &basic_types[BASIC_TYPE_FIXED_OFFSET+4]; + else + return &basic_types[BASIC_TYPE_FIXED_OFFSET+5]; + break; + case sizeof(guint64): + if (integer_aliases[i].is_signed) + return &basic_types[BASIC_TYPE_FIXED_OFFSET+6]; + else + return &basic_types[BASIC_TYPE_FIXED_OFFSET+7]; + break; + default: + g_assert_not_reached (); + } + } } return NULL; } @@ -568,51 +568,51 @@ parse_type_internal (GIIrModule *module, * special. */ if (g_str_has_prefix (str, "List<") || - strcmp (str, "List") == 0) - { - temporary_type = g_strdup_printf ("GLib.List%s", str + 4); - str = temporary_type; - } + strcmp (str, "List") == 0) + { + temporary_type = g_strdup_printf ("GLib.List%s", str + 4); + str = temporary_type; + } else if (g_str_has_prefix (str, "SList<") || - strcmp (str, "SList") == 0) - { - temporary_type = g_strdup_printf ("GLib.SList%s", str + 5); - str = temporary_type; - } + strcmp (str, "SList") == 0) + { + temporary_type = g_strdup_printf ("GLib.SList%s", str + 5); + str = temporary_type; + } else if (g_str_has_prefix (str, "HashTable<") || - strcmp (str, "HashTable") == 0) - { - temporary_type = g_strdup_printf ("GLib.HashTable%s", str + 9); - str = temporary_type; - } + strcmp (str, "HashTable") == 0) + { + temporary_type = g_strdup_printf ("GLib.HashTable%s", str + 9); + str = temporary_type; + } else if (g_str_has_prefix (str, "Error<") || - strcmp (str, "Error") == 0) - { - temporary_type = g_strdup_printf ("GLib.Error%s", str + 5); - str = temporary_type; - } + strcmp (str, "Error") == 0) + { + temporary_type = g_strdup_printf ("GLib.Error%s", str + 5); + str = temporary_type; + } } if (basic != NULL) /* found a basic type */; else if (g_str_has_prefix (str, "GLib.List") || - g_str_has_prefix (str, "GLib.SList")) + g_str_has_prefix (str, "GLib.SList")) { str += strlen ("GLib."); if (g_str_has_prefix (str, "List")) - { - type->tag = GI_TYPE_TAG_GLIST; - type->is_glist = TRUE; - type->is_pointer = TRUE; - str += strlen ("List"); - } + { + type->tag = GI_TYPE_TAG_GLIST; + type->is_glist = TRUE; + type->is_pointer = TRUE; + str += strlen ("List"); + } else - { - type->tag = GI_TYPE_TAG_GSLIST; - type->is_gslist = TRUE; - type->is_pointer = TRUE; - str += strlen ("SList"); - } + { + type->tag = GI_TYPE_TAG_GSLIST; + type->is_gslist = TRUE; + type->is_pointer = TRUE; + str += strlen ("SList"); + } } else if (g_str_has_prefix (str, "GLib.HashTable")) { @@ -633,17 +633,17 @@ parse_type_internal (GIIrModule *module, str += strlen ("Error"); if (*str == '<') - { - char *tmp, *end; - (str)++; + { + char *tmp, *end; + (str)++; - end = strchr (str, '>'); - tmp = g_strndup (str, end - str); - type->errors = g_strsplit (tmp, ",", 0); - g_free (tmp); + end = strchr (str, '>'); + tmp = g_strndup (str, end - str); + type->errors = g_strsplit (tmp, ",", 0); + g_free (tmp); - str = end; - } + str = end; + } } else { @@ -654,11 +654,11 @@ parse_type_internal (GIIrModule *module, /* must be an interface type */ while (g_ascii_isalnum (*str) || - *str == '.' || - *str == '-' || - *str == '_' || - *str == ':') - (str)++; + *str == '.' || + *str == '-' || + *str == '_' || + *str == ':') + (str)++; type->giinterface = g_strndup (start, str - start); } @@ -701,8 +701,8 @@ resolve_aliases (ParseContext *ctx, const gchar *type) g_debug ("Resolved: %s => %s", lookup, (char*)value); lookup = value; if (g_slist_find_custom (seen_values, lookup, - (GCompareFunc)strcmp) != NULL) - break; + (GCompareFunc)strcmp) != NULL) + break; seen_values = g_slist_prepend (seen_values, (gchar*)lookup); } g_slist_free (seen_values); @@ -769,10 +769,10 @@ parse_type (ParseContext *ctx, const gchar *type) static gboolean introspectable_prelude (GMarkupParseContext *context, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - ParseState new_state) + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + ParseState new_state) { const gchar *introspectable_arg; const gchar *shadowed_by; @@ -795,11 +795,11 @@ introspectable_prelude (GMarkupParseContext *context, static gboolean start_glib_boxed (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { const gchar *name; const gchar *typename; @@ -808,7 +808,7 @@ start_glib_boxed (GMarkupParseContext *context, GIIrNodeBoxed *boxed; if (!(strcmp (element_name, "glib:boxed") == 0 && - ctx->state == STATE_NAMESPACE)) + ctx->state == STATE_NAMESPACE)) return FALSE; if (!introspectable_prelude (context, attribute_names, attribute_values, ctx, STATE_BOXED)) @@ -855,11 +855,11 @@ start_glib_boxed (GMarkupParseContext *context, static gboolean start_function (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { const gchar *name; const gchar *shadows; @@ -876,7 +876,7 @@ start_function (GMarkupParseContext *context, { case STATE_NAMESPACE: found = (strcmp (element_name, "function") == 0 || - strcmp (element_name, "callback") == 0); + strcmp (element_name, "callback") == 0); break; case STATE_CLASS: case STATE_BOXED: @@ -887,9 +887,9 @@ start_function (GMarkupParseContext *context, G_GNUC_FALLTHROUGH; case STATE_INTERFACE: found = (found || - strcmp (element_name, "function") == 0 || - strcmp (element_name, "method") == 0 || - strcmp (element_name, "callback") == 0); + strcmp (element_name, "function") == 0 || + strcmp (element_name, "method") == 0 || + strcmp (element_name, "callback") == 0); break; case STATE_ENUM: found = strcmp (element_name, "function") == 0; @@ -950,9 +950,9 @@ start_function (GMarkupParseContext *context, function->is_method = TRUE; if (strcmp (element_name, "constructor") == 0) - function->is_constructor = TRUE; + function->is_constructor = TRUE; else - function->is_constructor = FALSE; + function->is_constructor = FALSE; if (set_property != NULL) { @@ -991,7 +991,7 @@ start_function (GMarkupParseContext *context, if (ctx->node_stack == NULL) { ctx->current_module->entries = - g_list_append (ctx->current_module->entries, function); + g_list_append (ctx->current_module->entries, function); } else if (ctx->current_typed) { @@ -1005,47 +1005,47 @@ start_function (GMarkupParseContext *context, { case GI_IR_NODE_INTERFACE: case GI_IR_NODE_OBJECT: - { - GIIrNodeInterface *iface; + { + GIIrNodeInterface *iface; - iface = (GIIrNodeInterface *)CURRENT_NODE (ctx); - iface->members = g_list_append (iface->members, function); - } - break; + iface = (GIIrNodeInterface *)CURRENT_NODE (ctx); + iface->members = g_list_append (iface->members, function); + } + break; case GI_IR_NODE_BOXED: - { - GIIrNodeBoxed *boxed; + { + GIIrNodeBoxed *boxed; - boxed = (GIIrNodeBoxed *)CURRENT_NODE (ctx); - boxed->members = g_list_append (boxed->members, function); - } - break; + boxed = (GIIrNodeBoxed *)CURRENT_NODE (ctx); + boxed->members = g_list_append (boxed->members, function); + } + break; case GI_IR_NODE_STRUCT: - { - GIIrNodeStruct *struct_; + { + GIIrNodeStruct *struct_; - struct_ = (GIIrNodeStruct *)CURRENT_NODE (ctx); - struct_->members = g_list_append (struct_->members, function); } - break; + struct_ = (GIIrNodeStruct *)CURRENT_NODE (ctx); + struct_->members = g_list_append (struct_->members, function); } + break; case GI_IR_NODE_UNION: - { - GIIrNodeUnion *union_; + { + GIIrNodeUnion *union_; - union_ = (GIIrNodeUnion *)CURRENT_NODE (ctx); - union_->members = g_list_append (union_->members, function); - } - break; + union_ = (GIIrNodeUnion *)CURRENT_NODE (ctx); + union_->members = g_list_append (union_->members, function); + } + break; case GI_IR_NODE_ENUM: case GI_IR_NODE_FLAGS: - { - GIIrNodeEnum *enum_; + { + GIIrNodeEnum *enum_; - enum_ = (GIIrNodeEnum *)CURRENT_NODE (ctx); - enum_->methods = g_list_append (enum_->methods, function); - } - break; + enum_ = (GIIrNodeEnum *)CURRENT_NODE (ctx); + enum_->methods = g_list_append (enum_->methods, function); + } + break; default: - g_assert_not_reached (); + g_assert_not_reached (); } push_node(ctx, (GIIrNode *)function); @@ -1096,13 +1096,13 @@ parse_property_transfer (GIIrNodeProperty *property, static gboolean parse_param_transfer (GIIrNodeParam *param, const gchar *transfer, const gchar *name, - GError **error) + GError **error) { if (transfer == NULL) { g_set_error (error, G_MARKUP_ERROR, - G_MARKUP_ERROR_INVALID_CONTENT, - "required attribute 'transfer-ownership' missing"); + G_MARKUP_ERROR_INVALID_CONTENT, + "required attribute 'transfer-ownership' missing"); return FALSE; } else if (strcmp (transfer, "none") == 0) @@ -1123,8 +1123,8 @@ parse_param_transfer (GIIrNodeParam *param, const gchar *transfer, const gchar * else { g_set_error (error, G_MARKUP_ERROR, - G_MARKUP_ERROR_INVALID_CONTENT, - "invalid value for 'transfer-ownership': %s", transfer); + G_MARKUP_ERROR_INVALID_CONTENT, + "invalid value for 'transfer-ownership': %s", transfer); return FALSE; } return TRUE; @@ -1142,7 +1142,7 @@ start_instance_parameter (GMarkupParseContext *context, gboolean transfer_full; if (!(strcmp (element_name, "instance-parameter") == 0 && - ctx->state == STATE_FUNCTION_PARAMETERS)) + ctx->state == STATE_FUNCTION_PARAMETERS)) return FALSE; transfer = find_attribute ("transfer-ownership", attribute_names, attribute_values); @@ -1156,8 +1156,8 @@ start_instance_parameter (GMarkupParseContext *context, else { g_set_error (error, G_MARKUP_ERROR, - G_MARKUP_ERROR_INVALID_CONTENT, - "invalid value for 'transfer-ownership' for instance parameter: %s", transfer); + G_MARKUP_ERROR_INVALID_CONTENT, + "invalid value for 'transfer-ownership' for instance parameter: %s", transfer); return FALSE; } @@ -1166,25 +1166,25 @@ start_instance_parameter (GMarkupParseContext *context, case GI_IR_NODE_FUNCTION: case GI_IR_NODE_CALLBACK: { - GIIrNodeFunction *func; + GIIrNodeFunction *func; - func = (GIIrNodeFunction *)CURRENT_NODE (ctx); + func = (GIIrNodeFunction *)CURRENT_NODE (ctx); func->instance_transfer_full = transfer_full; } break; case GI_IR_NODE_SIGNAL: { - GIIrNodeSignal *signal; + GIIrNodeSignal *signal; - signal = (GIIrNodeSignal *)CURRENT_NODE (ctx); + signal = (GIIrNodeSignal *)CURRENT_NODE (ctx); signal->instance_transfer_full = transfer_full; } break; case GI_IR_NODE_VFUNC: { - GIIrNodeVFunc *vfunc; + GIIrNodeVFunc *vfunc; - vfunc = (GIIrNodeVFunc *)CURRENT_NODE (ctx); + vfunc = (GIIrNodeVFunc *)CURRENT_NODE (ctx); vfunc->instance_transfer_full = transfer_full; } break; @@ -1197,11 +1197,11 @@ start_instance_parameter (GMarkupParseContext *context, static gboolean start_parameter (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { const gchar *name; const gchar *direction; @@ -1218,7 +1218,7 @@ start_parameter (GMarkupParseContext *context, GIIrNodeParam *param; if (!(strcmp (element_name, "parameter") == 0 && - ctx->state == STATE_FUNCTION_PARAMETERS)) + ctx->state == STATE_FUNCTION_PARAMETERS)) return FALSE; name = find_attribute ("name", attribute_names, attribute_values); @@ -1250,9 +1250,9 @@ start_parameter (GMarkupParseContext *context, param->in = FALSE; param->out = TRUE; if (caller_allocates == NULL) - param->caller_allocates = FALSE; + param->caller_allocates = FALSE; else - param->caller_allocates = strcmp (caller_allocates, "1") == 0; + param->caller_allocates = strcmp (caller_allocates, "1") == 0; } else if (direction && strcmp (direction, "inout") == 0) { @@ -1319,26 +1319,26 @@ start_parameter (GMarkupParseContext *context, case GI_IR_NODE_FUNCTION: case GI_IR_NODE_CALLBACK: { - GIIrNodeFunction *func; + GIIrNodeFunction *func; - func = (GIIrNodeFunction *)CURRENT_NODE (ctx); - func->parameters = g_list_append (func->parameters, param); + func = (GIIrNodeFunction *)CURRENT_NODE (ctx); + func->parameters = g_list_append (func->parameters, param); } break; case GI_IR_NODE_SIGNAL: { - GIIrNodeSignal *signal; + GIIrNodeSignal *signal; - signal = (GIIrNodeSignal *)CURRENT_NODE (ctx); - signal->parameters = g_list_append (signal->parameters, param); + signal = (GIIrNodeSignal *)CURRENT_NODE (ctx); + signal->parameters = g_list_append (signal->parameters, param); } break; case GI_IR_NODE_VFUNC: { - GIIrNodeVFunc *vfunc; + GIIrNodeVFunc *vfunc; - vfunc = (GIIrNodeVFunc *)CURRENT_NODE (ctx); - vfunc->parameters = g_list_append (vfunc->parameters, param); + vfunc = (GIIrNodeVFunc *)CURRENT_NODE (ctx); + vfunc->parameters = g_list_append (vfunc->parameters, param); } break; default: @@ -1350,11 +1350,11 @@ start_parameter (GMarkupParseContext *context, static gboolean start_field (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { const gchar *name; const gchar *readable; @@ -1435,55 +1435,55 @@ start_field (GMarkupParseContext *context, { case GI_IR_NODE_OBJECT: { - GIIrNodeInterface *iface; + GIIrNodeInterface *iface; - iface = (GIIrNodeInterface *)CURRENT_NODE (ctx); - iface->members = g_list_append (iface->members, field); + iface = (GIIrNodeInterface *)CURRENT_NODE (ctx); + iface->members = g_list_append (iface->members, field); } break; case GI_IR_NODE_INTERFACE: { - GIIrNodeInterface *iface; + GIIrNodeInterface *iface; - iface = (GIIrNodeInterface *)CURRENT_NODE (ctx); - iface->members = g_list_append (iface->members, field); + iface = (GIIrNodeInterface *)CURRENT_NODE (ctx); + iface->members = g_list_append (iface->members, field); } break; case GI_IR_NODE_BOXED: { - GIIrNodeBoxed *boxed; + GIIrNodeBoxed *boxed; - boxed = (GIIrNodeBoxed *)CURRENT_NODE (ctx); - boxed->members = g_list_append (boxed->members, field); + boxed = (GIIrNodeBoxed *)CURRENT_NODE (ctx); + boxed->members = g_list_append (boxed->members, field); } break; case GI_IR_NODE_STRUCT: { - GIIrNodeStruct *struct_; + GIIrNodeStruct *struct_; - struct_ = (GIIrNodeStruct *)CURRENT_NODE (ctx); - struct_->members = g_list_append (struct_->members, field); + struct_ = (GIIrNodeStruct *)CURRENT_NODE (ctx); + struct_->members = g_list_append (struct_->members, field); } break; case GI_IR_NODE_UNION: { - GIIrNodeUnion *union_; + GIIrNodeUnion *union_; - union_ = (GIIrNodeUnion *)CURRENT_NODE (ctx); - union_->members = g_list_append (union_->members, field); - if (branch) - { - GIIrNodeConstant *constant; + union_ = (GIIrNodeUnion *)CURRENT_NODE (ctx); + union_->members = g_list_append (union_->members, field); + if (branch) + { + GIIrNodeConstant *constant; - constant = (GIIrNodeConstant *) gi_ir_node_new (GI_IR_NODE_CONSTANT, + constant = (GIIrNodeConstant *) gi_ir_node_new (GI_IR_NODE_CONSTANT, ctx->current_module); - ((GIIrNode *)constant)->name = g_strdup (name); - constant->value = g_strdup (branch); - constant->type = union_->discriminator_type; - constant->deprecated = FALSE; + ((GIIrNode *)constant)->name = g_strdup (name); + constant->value = g_strdup (branch); + constant->type = union_->discriminator_type; + constant->deprecated = FALSE; - union_->discriminators = g_list_append (union_->discriminators, constant); - } + union_->discriminators = g_list_append (union_->discriminators, constant); + } } break; default: @@ -1495,11 +1495,11 @@ start_field (GMarkupParseContext *context, static gboolean start_alias (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { const gchar *name; @@ -1518,11 +1518,11 @@ start_alias (GMarkupParseContext *context, static gboolean start_enum (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { const gchar *name; const gchar *typename; @@ -1532,7 +1532,7 @@ start_enum (GMarkupParseContext *context, GIIrNodeEnum *enum_; if (!((strcmp (element_name, "enumeration") == 0 && ctx->state == STATE_NAMESPACE) || - (strcmp (element_name, "bitfield") == 0 && ctx->state == STATE_NAMESPACE))) + (strcmp (element_name, "bitfield") == 0 && ctx->state == STATE_NAMESPACE))) return FALSE; if (!introspectable_prelude (context, attribute_names, attribute_values, ctx, STATE_ENUM)) @@ -1575,11 +1575,11 @@ start_enum (GMarkupParseContext *context, static gboolean start_property (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { ParseState target_state; const gchar *name; @@ -1594,8 +1594,8 @@ start_property (GMarkupParseContext *context, GIIrNodeInterface *iface; if (!(strcmp (element_name, "property") == 0 && - (ctx->state == STATE_CLASS || - ctx->state == STATE_INTERFACE))) + (ctx->state == STATE_CLASS || + ctx->state == STATE_INTERFACE))) return FALSE; if (ctx->state == STATE_CLASS) @@ -1684,11 +1684,11 @@ parse_value (const gchar *str) static gboolean start_member (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { const gchar *name; const gchar *value; @@ -1698,7 +1698,7 @@ start_member (GMarkupParseContext *context, GIIrNodeValue *value_; if (!(strcmp (element_name, "member") == 0 && - ctx->state == STATE_ENUM)) + ctx->state == STATE_ENUM)) return FALSE; name = find_attribute ("name", attribute_names, attribute_values); @@ -1736,11 +1736,11 @@ start_member (GMarkupParseContext *context, static gboolean start_constant (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { ParseState prev_state; ParseState target_state; @@ -1750,9 +1750,9 @@ start_constant (GMarkupParseContext *context, GIIrNodeConstant *constant; if (!(strcmp (element_name, "constant") == 0 && - (ctx->state == STATE_NAMESPACE || - ctx->state == STATE_CLASS || - ctx->state == STATE_INTERFACE))) + (ctx->state == STATE_NAMESPACE || + ctx->state == STATE_CLASS || + ctx->state == STATE_INTERFACE))) return FALSE; switch (ctx->state) @@ -1807,7 +1807,7 @@ start_constant (GMarkupParseContext *context, { push_node (ctx, (GIIrNode *) constant); ctx->current_module->entries = - g_list_append (ctx->current_module->entries, constant); + g_list_append (ctx->current_module->entries, constant); } else { @@ -1822,11 +1822,11 @@ start_constant (GMarkupParseContext *context, static gboolean start_interface (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { const gchar *name; const gchar *typename; @@ -1836,7 +1836,7 @@ start_interface (GMarkupParseContext *context, GIIrNodeInterface *iface; if (!(strcmp (element_name, "interface") == 0 && - ctx->state == STATE_NAMESPACE)) + ctx->state == STATE_NAMESPACE)) return FALSE; if (!introspectable_prelude (context, attribute_names, attribute_values, ctx, STATE_INTERFACE)) @@ -1884,11 +1884,11 @@ start_interface (GMarkupParseContext *context, static gboolean start_class (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { const gchar *name; const gchar *parent; @@ -1906,7 +1906,7 @@ start_class (GMarkupParseContext *context, GIIrNodeInterface *iface; if (!(strcmp (element_name, "class") == 0 && - ctx->state == STATE_NAMESPACE)) + ctx->state == STATE_NAMESPACE)) return FALSE; if (!introspectable_prelude (context, attribute_names, attribute_values, ctx, STATE_CLASS)) @@ -1977,11 +1977,11 @@ start_class (GMarkupParseContext *context, static gboolean start_type (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { const gchar *name; const gchar *ctype; @@ -2003,22 +2003,22 @@ start_type (GMarkupParseContext *context, ctx->type_parameters = NULL; } else if (ctx->state == STATE_FUNCTION_PARAMETER || - ctx->state == STATE_FUNCTION_RETURN || - ctx->state == STATE_STRUCT_FIELD || - ctx->state == STATE_UNION_FIELD || - ctx->state == STATE_CLASS_PROPERTY || - ctx->state == STATE_CLASS_FIELD || - ctx->state == STATE_INTERFACE_FIELD || - ctx->state == STATE_INTERFACE_PROPERTY || - ctx->state == STATE_BOXED_FIELD || - ctx->state == STATE_NAMESPACE_CONSTANT || - ctx->state == STATE_CLASS_CONSTANT || - ctx->state == STATE_INTERFACE_CONSTANT || - ctx->state == STATE_ALIAS - ) + ctx->state == STATE_FUNCTION_RETURN || + ctx->state == STATE_STRUCT_FIELD || + ctx->state == STATE_UNION_FIELD || + ctx->state == STATE_CLASS_PROPERTY || + ctx->state == STATE_CLASS_FIELD || + ctx->state == STATE_INTERFACE_FIELD || + ctx->state == STATE_INTERFACE_PROPERTY || + ctx->state == STATE_BOXED_FIELD || + ctx->state == STATE_NAMESPACE_CONSTANT || + ctx->state == STATE_CLASS_CONSTANT || + ctx->state == STATE_INTERFACE_CONSTANT || + ctx->state == STATE_ALIAS + ) { if (ctx->state == STATE_ALIAS) - in_alias = TRUE; + in_alias = TRUE; state_switch (ctx, STATE_TYPE); ctx->type_depth = 1; ctx->type_stack = NULL; @@ -2033,27 +2033,27 @@ start_type (GMarkupParseContext *context, char *value; if (name == NULL) - { - MISSING_ATTRIBUTE (context, error, element_name, "name"); - return FALSE; - } + { + MISSING_ATTRIBUTE (context, error, element_name, "name"); + return FALSE; + } key = g_strdup_printf ("%s.%s", ctx->namespace, ctx->current_alias); if (!strchr (name, '.')) - { - const BasicTypeInfo *basic = parse_basic (name); - if (!basic) - { - /* For non-basic types, re-qualify the interface */ - value = g_strdup_printf ("%s.%s", ctx->namespace, name); - } - else - { - value = g_strdup (name); - } - } + { + const BasicTypeInfo *basic = parse_basic (name); + if (!basic) + { + /* For non-basic types, re-qualify the interface */ + value = g_strdup_printf ("%s.%s", ctx->namespace, name); + } + else + { + value = g_strdup (name); + } + } else - value = g_strdup (name); + value = g_strdup (name); g_hash_table_replace (ctx->aliases, key, value); @@ -2065,9 +2065,9 @@ start_type (GMarkupParseContext *context, if (!ctx->current_typed) { g_set_error (error, - G_MARKUP_ERROR, - G_MARKUP_ERROR_INVALID_CONTENT, - "The element is invalid here"); + G_MARKUP_ERROR, + G_MARKUP_ERROR_INVALID_CONTENT, + "The element is invalid here"); return FALSE; } @@ -2129,10 +2129,10 @@ start_type (GMarkupParseContext *context, int pointer_depth; if (name == NULL) - { - MISSING_ATTRIBUTE (context, error, element_name, "name"); - return FALSE; - } + { + MISSING_ATTRIBUTE (context, error, element_name, "name"); + return FALSE; + } pointer_depth = 0; ctype = find_attribute ("c:type", attribute_names, attribute_values); @@ -2142,9 +2142,9 @@ start_type (GMarkupParseContext *context, while (cp > ctype && *cp-- == '*') pointer_depth++; - if (g_str_has_prefix (ctype, "gpointer") - || g_str_has_prefix (ctype, "gconstpointer")) - pointer_depth++; + if (g_str_has_prefix (ctype, "gpointer") + || g_str_has_prefix (ctype, "gconstpointer")) + pointer_depth++; } if (ctx->current_typed->type == GI_IR_NODE_PARAM && @@ -2168,11 +2168,11 @@ start_type (GMarkupParseContext *context, &is_disguised); if (is_pointer || is_disguised) - pointer_depth++; + pointer_depth++; } if (pointer_depth > 0) - typenode->is_pointer = TRUE; + typenode->is_pointer = TRUE; } ctx->type_parameters = g_list_append (ctx->type_parameters, typenode); @@ -2196,41 +2196,41 @@ end_type_top (ParseContext *ctx) typenode->tag == GI_TYPE_TAG_GSLIST) { if (typenode->parameter_type1 == NULL) - typenode->parameter_type1 = parse_type (ctx, "gpointer"); + typenode->parameter_type1 = parse_type (ctx, "gpointer"); } else if (typenode->tag == GI_TYPE_TAG_GHASH) { if (typenode->parameter_type1 == NULL) - { - typenode->parameter_type1 = parse_type (ctx, "gpointer"); - typenode->parameter_type2 = parse_type (ctx, "gpointer"); - } + { + typenode->parameter_type1 = parse_type (ctx, "gpointer"); + typenode->parameter_type2 = parse_type (ctx, "gpointer"); + } } switch (ctx->current_typed->type) { case GI_IR_NODE_PARAM: { - GIIrNodeParam *param = (GIIrNodeParam *)ctx->current_typed; - param->type = typenode; + GIIrNodeParam *param = (GIIrNodeParam *)ctx->current_typed; + param->type = typenode; } break; case GI_IR_NODE_FIELD: { - GIIrNodeField *field = (GIIrNodeField *)ctx->current_typed; - field->type = typenode; + GIIrNodeField *field = (GIIrNodeField *)ctx->current_typed; + field->type = typenode; } break; case GI_IR_NODE_PROPERTY: { - GIIrNodeProperty *property = (GIIrNodeProperty *) ctx->current_typed; - property->type = typenode; + GIIrNodeProperty *property = (GIIrNodeProperty *) ctx->current_typed; + property->type = typenode; } break; case GI_IR_NODE_CONSTANT: { - GIIrNodeConstant *constant = (GIIrNodeConstant *)ctx->current_typed; - constant->type = typenode; + GIIrNodeConstant *constant = (GIIrNodeConstant *)ctx->current_typed; + constant->type = typenode; } break; default: @@ -2344,11 +2344,11 @@ start_attribute (GMarkupParseContext *context, static gboolean start_return_value (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { GIIrNodeParam *param; const gchar *transfer; @@ -2356,7 +2356,7 @@ start_return_value (GMarkupParseContext *context, const gchar *nullable; if (!(strcmp (element_name, "return-value") == 0 && - ctx->state == STATE_FUNCTION)) + ctx->state == STATE_FUNCTION)) return FALSE; param = (GIIrNodeParam *)gi_ir_node_new (GI_IR_NODE_PARAM, @@ -2388,20 +2388,20 @@ start_return_value (GMarkupParseContext *context, case GI_IR_NODE_FUNCTION: case GI_IR_NODE_CALLBACK: { - GIIrNodeFunction *func = (GIIrNodeFunction *)CURRENT_NODE (ctx); - func->result = param; + GIIrNodeFunction *func = (GIIrNodeFunction *)CURRENT_NODE (ctx); + func->result = param; } break; case GI_IR_NODE_SIGNAL: { - GIIrNodeSignal *signal = (GIIrNodeSignal *)CURRENT_NODE (ctx); - signal->result = param; + GIIrNodeSignal *signal = (GIIrNodeSignal *)CURRENT_NODE (ctx); + signal->result = param; } break; case GI_IR_NODE_VFUNC: { - GIIrNodeVFunc *vfunc = (GIIrNodeVFunc *)CURRENT_NODE (ctx); - vfunc->result = param; + GIIrNodeVFunc *vfunc = (GIIrNodeVFunc *)CURRENT_NODE (ctx); + vfunc->result = param; } break; default: @@ -2413,11 +2413,11 @@ start_return_value (GMarkupParseContext *context, static gboolean start_implements (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { GIIrNodeInterface *iface; const char *name; @@ -2443,11 +2443,11 @@ start_implements (GMarkupParseContext *context, static gboolean start_glib_signal (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { const gchar *name; const gchar *when; @@ -2460,8 +2460,8 @@ start_glib_signal (GMarkupParseContext *context, GIIrNodeSignal *signal; if (!(strcmp (element_name, "glib:signal") == 0 && - (ctx->state == STATE_CLASS || - ctx->state == STATE_INTERFACE))) + (ctx->state == STATE_CLASS || + ctx->state == STATE_INTERFACE))) return FALSE; if (!introspectable_prelude (context, attribute_names, attribute_values, ctx, STATE_FUNCTION)) @@ -2526,11 +2526,11 @@ start_glib_signal (GMarkupParseContext *context, static gboolean start_vfunc (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { const gchar *name; const gchar *must_chain_up; @@ -2543,8 +2543,8 @@ start_vfunc (GMarkupParseContext *context, GIIrNodeVFunc *vfunc; if (!(strcmp (element_name, "virtual-method") == 0 && - (ctx->state == STATE_CLASS || - ctx->state == STATE_INTERFACE))) + (ctx->state == STATE_CLASS || + ctx->state == STATE_INTERFACE))) return FALSE; if (!introspectable_prelude (context, attribute_names, attribute_values, ctx, STATE_FUNCTION)) @@ -2617,11 +2617,11 @@ start_vfunc (GMarkupParseContext *context, static gboolean start_struct (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { const gchar *name; const gchar *deprecated; @@ -2637,10 +2637,10 @@ start_struct (GMarkupParseContext *context, GIIrNodeStruct *struct_; if (!(strcmp (element_name, "record") == 0 && - (ctx->state == STATE_NAMESPACE || - ctx->state == STATE_UNION || - ctx->state == STATE_STRUCT || - ctx->state == STATE_CLASS))) + (ctx->state == STATE_NAMESPACE || + ctx->state == STATE_UNION || + ctx->state == STATE_STRUCT || + ctx->state == STATE_CLASS))) return FALSE; if (!introspectable_prelude (context, attribute_names, attribute_values, ctx, STATE_STRUCT)) @@ -2711,11 +2711,11 @@ start_struct (GMarkupParseContext *context, static gboolean start_union (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { const gchar *name; const gchar *deprecated; @@ -2726,10 +2726,10 @@ start_union (GMarkupParseContext *context, GIIrNodeUnion *union_; if (!(strcmp (element_name, "union") == 0 && - (ctx->state == STATE_NAMESPACE || - ctx->state == STATE_UNION || - ctx->state == STATE_STRUCT || - ctx->state == STATE_CLASS))) + (ctx->state == STATE_NAMESPACE || + ctx->state == STATE_UNION || + ctx->state == STATE_STRUCT || + ctx->state == STATE_CLASS))) return FALSE; if (!introspectable_prelude (context, attribute_names, attribute_values, ctx, STATE_UNION)) @@ -2770,16 +2770,16 @@ start_union (GMarkupParseContext *context, static gboolean start_discriminator (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - ParseContext *ctx, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + ParseContext *ctx, + GError **error) { const gchar *type; const gchar *offset; if (!(strcmp (element_name, "discriminator") == 0 && - ctx->state == STATE_UNION)) + ctx->state == STATE_UNION)) return FALSE; type = find_attribute ("type", attribute_names, attribute_values); @@ -2805,9 +2805,9 @@ start_discriminator (GMarkupParseContext *context, static gboolean parse_include (GMarkupParseContext *context, - ParseContext *ctx, - const char *name, - const char *version) + ParseContext *ctx, + const char *name, + const char *version) { GError *error = NULL; gchar *buffer; @@ -2821,20 +2821,20 @@ parse_include (GMarkupParseContext *context, GIIrModule *m = l->data; if (strcmp (m->name, name) == 0) - { - if (strcmp (m->version, version) == 0) - { - ctx->include_modules = g_list_prepend (ctx->include_modules, m); + { + if (strcmp (m->version, version) == 0) + { + ctx->include_modules = g_list_prepend (ctx->include_modules, m); - return TRUE; - } - else - { - g_printerr ("Module '%s' imported with conflicting versions '%s' and '%s'\n", - name, m->version, version); - return FALSE; - } - } + return TRUE; + } + else + { + g_printerr ("Module '%s' imported with conflicting versions '%s' and '%s'\n", + name, m->version, version); + return FALSE; + } + } } girname = g_strdup_printf ("%s-%s.gir", name, version); @@ -2843,7 +2843,7 @@ parse_include (GMarkupParseContext *context, if (girpath == NULL) { g_printerr ("Could not find GIR file '%s'; check XDG_DATA_DIRS or use --includedir\n", - girname); + girname); g_free (girname); return FALSE; } @@ -2873,7 +2873,7 @@ parse_include (GMarkupParseContext *context, g_free (girpath); ctx->include_modules = g_list_append (ctx->include_modules, - module); + module); return TRUE; } @@ -2882,11 +2882,11 @@ extern GLogLevelFlags logged_levels; static void start_element_handler (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - gpointer user_data, - GError **error) + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + gpointer user_data, + GError **error) { ParseContext *ctx = user_data; @@ -2896,8 +2896,8 @@ start_element_handler (GMarkupParseContext *context, int i; for (i = 0; attribute_names[i]; i++) g_string_append_printf (tags, "%s=\"%s\" ", - attribute_names[i], - attribute_values[i]); + attribute_names[i], + attribute_values[i]); if (i) { @@ -2918,14 +2918,14 @@ start_element_handler (GMarkupParseContext *context, { case 'a': if (ctx->state == STATE_NAMESPACE && strcmp (element_name, "alias") == 0) - { - state_switch (ctx, STATE_ALIAS); - goto out; - } + { + state_switch (ctx, STATE_ALIAS); + goto out; + } if (start_type (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; else if (start_attribute (context, element_name, attribute_names, attribute_values, ctx, error)) @@ -2933,29 +2933,29 @@ start_element_handler (GMarkupParseContext *context, break; case 'b': if (start_enum (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; break; case 'c': if (start_function (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; else if (start_constant (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; else if (start_class (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; break; case 'd': if (start_discriminator (context, element_name, - attribute_names, attribute_values, - ctx, error)) + attribute_names, attribute_values, + ctx, error)) goto out; if (strcmp ("doc", element_name) == 0 || strcmp ("doc-deprecated", element_name) == 0 || strcmp ("doc-stability", element_name) == 0 || strcmp ("doc-version", element_name) == 0 || @@ -2968,9 +2968,9 @@ start_element_handler (GMarkupParseContext *context, case 'e': if (start_enum (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; break; case 'f': @@ -2980,192 +2980,192 @@ start_element_handler (GMarkupParseContext *context, goto out; } else if (start_function (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; else if (start_field (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; break; case 'g': if (start_glib_boxed (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; else if (start_glib_signal (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; break; case 'i': if (strcmp (element_name, "include") == 0 && - ctx->state == STATE_REPOSITORY) - { - const gchar *name; - const gchar *version; + ctx->state == STATE_REPOSITORY) + { + const gchar *name; + const gchar *version; - name = find_attribute ("name", attribute_names, attribute_values); - version = find_attribute ("version", attribute_names, attribute_values); + name = find_attribute ("name", attribute_names, attribute_values); + version = find_attribute ("version", attribute_names, attribute_values); - if (name == NULL) - { - MISSING_ATTRIBUTE (context, error, element_name, "name"); - break; - } - if (version == NULL) - { - MISSING_ATTRIBUTE (context, error, element_name, "version"); - break; - } + if (name == NULL) + { + MISSING_ATTRIBUTE (context, error, element_name, "name"); + break; + } + if (version == NULL) + { + MISSING_ATTRIBUTE (context, error, element_name, "version"); + break; + } - if (!parse_include (context, ctx, name, version)) - { - g_set_error (error, - G_MARKUP_ERROR, - G_MARKUP_ERROR_INVALID_CONTENT, - "Failed to parse included gir %s-%s", - name, - version); - return; - } + if (!parse_include (context, ctx, name, version)) + { + g_set_error (error, + G_MARKUP_ERROR, + G_MARKUP_ERROR_INVALID_CONTENT, + "Failed to parse included gir %s-%s", + name, + version); + return; + } - ctx->dependencies = g_list_prepend (ctx->dependencies, - g_strdup_printf ("%s-%s", name, version)); + ctx->dependencies = g_list_prepend (ctx->dependencies, + g_strdup_printf ("%s-%s", name, version)); - state_switch (ctx, STATE_INCLUDE); - goto out; - } + state_switch (ctx, STATE_INCLUDE); + goto out; + } if (start_interface (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; else if (start_implements (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; else if (start_instance_parameter (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; else if (strcmp (element_name, "c:include") == 0) - { - state_switch (ctx, STATE_C_INCLUDE); - goto out; - } + { + state_switch (ctx, STATE_C_INCLUDE); + goto out; + } break; case 'm': if (start_function (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; else if (start_member (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; break; case 'n': if (strcmp (element_name, "namespace") == 0 && ctx->state == STATE_REPOSITORY) - { - const gchar *name, *version, *shared_library, *cprefix; + { + const gchar *name, *version, *shared_library, *cprefix; - if (ctx->current_module != NULL) - { - g_set_error (error, - G_MARKUP_ERROR, - G_MARKUP_ERROR_INVALID_CONTENT, - "Only one element is currently allowed per "); - goto out; - } + if (ctx->current_module != NULL) + { + g_set_error (error, + G_MARKUP_ERROR, + G_MARKUP_ERROR_INVALID_CONTENT, + "Only one element is currently allowed per "); + goto out; + } - name = find_attribute ("name", attribute_names, attribute_values); - version = find_attribute ("version", attribute_names, attribute_values); - shared_library = find_attribute ("shared-library", attribute_names, attribute_values); - cprefix = find_attribute ("c:identifier-prefixes", attribute_names, attribute_values); + name = find_attribute ("name", attribute_names, attribute_values); + version = find_attribute ("version", attribute_names, attribute_values); + shared_library = find_attribute ("shared-library", attribute_names, attribute_values); + cprefix = find_attribute ("c:identifier-prefixes", attribute_names, attribute_values); /* Backwards compatibility; vala currently still generates this */ if (cprefix == NULL) cprefix = find_attribute ("c:prefix", attribute_names, attribute_values); - if (name == NULL) - MISSING_ATTRIBUTE (context, error, element_name, "name"); - else if (version == NULL) - MISSING_ATTRIBUTE (context, error, element_name, "version"); - else - { - GList *l; + if (name == NULL) + MISSING_ATTRIBUTE (context, error, element_name, "name"); + else if (version == NULL) + MISSING_ATTRIBUTE (context, error, element_name, "version"); + else + { + GList *l; - if (strcmp (name, ctx->namespace) != 0) - g_set_error (error, - G_MARKUP_ERROR, - G_MARKUP_ERROR_INVALID_CONTENT, - " name element '%s' doesn't match file name '%s'", - name, ctx->namespace); + if (strcmp (name, ctx->namespace) != 0) + g_set_error (error, + G_MARKUP_ERROR, + G_MARKUP_ERROR_INVALID_CONTENT, + " name element '%s' doesn't match file name '%s'", + name, ctx->namespace); - ctx->current_module = gi_ir_module_new (name, version, shared_library, cprefix); + ctx->current_module = gi_ir_module_new (name, version, shared_library, cprefix); - ctx->current_module->aliases = ctx->aliases; - ctx->aliases = NULL; - ctx->current_module->disguised_structures = ctx->disguised_structures; - ctx->current_module->pointer_structures = ctx->pointer_structures; - ctx->disguised_structures = NULL; - ctx->pointer_structures = NULL; + ctx->current_module->aliases = ctx->aliases; + ctx->aliases = NULL; + ctx->current_module->disguised_structures = ctx->disguised_structures; + ctx->current_module->pointer_structures = ctx->pointer_structures; + ctx->disguised_structures = NULL; + ctx->pointer_structures = NULL; - for (l = ctx->include_modules; l; l = l->next) - gi_ir_module_add_include_module (ctx->current_module, l->data); + for (l = ctx->include_modules; l; l = l->next) + gi_ir_module_add_include_module (ctx->current_module, l->data); - g_list_free (ctx->include_modules); - ctx->include_modules = NULL; + g_list_free (ctx->include_modules); + ctx->include_modules = NULL; - ctx->modules = g_list_append (ctx->modules, ctx->current_module); - ctx->current_module->dependencies = ctx->dependencies; + ctx->modules = g_list_append (ctx->modules, ctx->current_module); + ctx->current_module->dependencies = ctx->dependencies; - state_switch (ctx, STATE_NAMESPACE); - goto out; - } - } + state_switch (ctx, STATE_NAMESPACE); + goto out; + } + } break; case 'p': if (start_property (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; else if (strcmp (element_name, "parameters") == 0 && - ctx->state == STATE_FUNCTION) - { - state_switch (ctx, STATE_FUNCTION_PARAMETERS); + ctx->state == STATE_FUNCTION) + { + state_switch (ctx, STATE_FUNCTION_PARAMETERS); - goto out; - } + goto out; + } else if (start_parameter (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; else if (strcmp (element_name, "prerequisite") == 0 && - ctx->state == STATE_INTERFACE) - { - const gchar *name; + ctx->state == STATE_INTERFACE) + { + const gchar *name; - name = find_attribute ("name", attribute_names, attribute_values); + name = find_attribute ("name", attribute_names, attribute_values); - state_switch (ctx, STATE_PREREQUISITE); + state_switch (ctx, STATE_PREREQUISITE); - if (name == NULL) - MISSING_ATTRIBUTE (context, error, element_name, "name"); - else - { - GIIrNodeInterface *iface; + if (name == NULL) + MISSING_ATTRIBUTE (context, error, element_name, "name"); + else + { + GIIrNodeInterface *iface; - iface = (GIIrNodeInterface *)CURRENT_NODE(ctx); - iface->prerequisites = g_list_append (iface->prerequisites, g_strdup (name)); - } - goto out; - } + iface = (GIIrNodeInterface *)CURRENT_NODE(ctx); + iface->prerequisites = g_list_append (iface->prerequisites, g_strdup (name)); + } + goto out; + } else if (strcmp (element_name, "package") == 0 && ctx->state == STATE_REPOSITORY) { @@ -3176,32 +3176,32 @@ start_element_handler (GMarkupParseContext *context, case 'r': if (strcmp (element_name, "repository") == 0 && ctx->state == STATE_START) - { - const gchar *version; + { + const gchar *version; - version = find_attribute ("version", attribute_names, attribute_values); + version = find_attribute ("version", attribute_names, attribute_values); - if (version == NULL) - MISSING_ATTRIBUTE (context, error, element_name, "version"); - else if (strcmp (version, SUPPORTED_GIR_VERSION) != 0) - g_set_error (error, - G_MARKUP_ERROR, - G_MARKUP_ERROR_INVALID_CONTENT, - "Unsupported version '%s'", - version); - else - state_switch (ctx, STATE_REPOSITORY); + if (version == NULL) + MISSING_ATTRIBUTE (context, error, element_name, "version"); + else if (strcmp (version, SUPPORTED_GIR_VERSION) != 0) + g_set_error (error, + G_MARKUP_ERROR, + G_MARKUP_ERROR_INVALID_CONTENT, + "Unsupported version '%s'", + version); + else + state_switch (ctx, STATE_REPOSITORY); - goto out; - } + goto out; + } else if (start_return_value (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; else if (start_struct (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; break; case 's': @@ -3213,27 +3213,27 @@ start_element_handler (GMarkupParseContext *context, break; case 'u': if (start_union (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; break; case 't': if (start_type (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; break; case 'v': if (start_vfunc (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; if (start_type (context, element_name, - attribute_names, attribute_values, - ctx, error)) - goto out; + attribute_names, attribute_values, + ctx, error)) + goto out; break; default: break; @@ -3244,9 +3244,9 @@ start_element_handler (GMarkupParseContext *context, gint line_number, char_number; g_markup_parse_context_get_position (context, &line_number, &char_number); if (!g_str_has_prefix (element_name, "c:")) - g_printerr ("%s:%d:%d: warning: element %s from state %d is unknown, ignoring\n", - ctx->file_path, line_number, char_number, element_name, - ctx->state); + g_printerr ("%s:%d:%d: warning: element %s from state %d is unknown, ignoring\n", + ctx->file_path, line_number, char_number, element_name, + ctx->state); state_switch (ctx, STATE_PASSTHROUGH); } @@ -3262,10 +3262,10 @@ start_element_handler (GMarkupParseContext *context, static gboolean require_one_of_end_elements (GMarkupParseContext *context, - ParseContext *ctx, - const char *actual_name, - GError **error, - ...) + ParseContext *ctx, + const char *actual_name, + GError **error, + ...) { va_list args; int line_number, char_number; @@ -3277,10 +3277,10 @@ require_one_of_end_elements (GMarkupParseContext *context, while ((expected = va_arg (args, const char*)) != NULL) { if (strcmp (expected, actual_name) == 0) - { - matched = TRUE; - break; - } + { + matched = TRUE; + break; + } } va_end (args); @@ -3290,11 +3290,11 @@ require_one_of_end_elements (GMarkupParseContext *context, g_markup_parse_context_get_position (context, &line_number, &char_number); g_set_error (error, - G_MARKUP_ERROR, - G_MARKUP_ERROR_INVALID_CONTENT, - "Unexpected end tag '%s' on line %d char %d; current state=%d (prev=%d)", - actual_name, - line_number, char_number, ctx->state, ctx->prev_state); + G_MARKUP_ERROR, + G_MARKUP_ERROR_INVALID_CONTENT, + "Unexpected end tag '%s' on line %d char %d; current state=%d (prev=%d)", + actual_name, + line_number, char_number, ctx->state, ctx->prev_state); return FALSE; } @@ -3335,19 +3335,19 @@ state_switch_end_struct_or_union (GMarkupParseContext *context, static gboolean require_end_element (GMarkupParseContext *context, - ParseContext *ctx, - const char *expected_name, - const char *actual_name, - GError **error) + ParseContext *ctx, + const char *expected_name, + const char *actual_name, + GError **error) { return require_one_of_end_elements (context, ctx, actual_name, error, expected_name, NULL); } static void end_element_handler (GMarkupParseContext *context, - const gchar *element_name, - gpointer user_data, - GError **error) + const gchar *element_name, + gpointer user_data, + GError **error) { ParseContext *ctx = user_data; @@ -3366,14 +3366,14 @@ end_element_handler (GMarkupParseContext *context, case STATE_INCLUDE: if (require_end_element (context, ctx, "include", element_name, error)) - { + { state_switch (ctx, STATE_REPOSITORY); } break; case STATE_C_INCLUDE: if (require_end_element (context, ctx, "c:include", element_name, error)) - { + { state_switch (ctx, STATE_REPOSITORY); } break; @@ -3387,7 +3387,7 @@ end_element_handler (GMarkupParseContext *context, case STATE_NAMESPACE: if (require_end_element (context, ctx, "namespace", element_name, error)) - { + { ctx->current_module = NULL; state_switch (ctx, STATE_REPOSITORY); } @@ -3395,198 +3395,198 @@ end_element_handler (GMarkupParseContext *context, case STATE_ALIAS: if (require_end_element (context, ctx, "alias", element_name, error)) - { - g_free (ctx->current_alias); - ctx->current_alias = NULL; - state_switch (ctx, STATE_NAMESPACE); - } + { + g_free (ctx->current_alias); + ctx->current_alias = NULL; + state_switch (ctx, STATE_NAMESPACE); + } break; case STATE_FUNCTION_RETURN: if (strcmp ("type", element_name) == 0) - break; + break; if (require_end_element (context, ctx, "return-value", element_name, error)) - { - state_switch (ctx, STATE_FUNCTION); - } + { + state_switch (ctx, STATE_FUNCTION); + } break; case STATE_FUNCTION_PARAMETERS: if (require_end_element (context, ctx, "parameters", element_name, error)) - { - state_switch (ctx, STATE_FUNCTION); - } + { + state_switch (ctx, STATE_FUNCTION); + } break; case STATE_FUNCTION_PARAMETER: if (strcmp ("type", element_name) == 0) - break; + break; if (require_end_element (context, ctx, "parameter", element_name, error)) - { - state_switch (ctx, STATE_FUNCTION_PARAMETERS); - } + { + state_switch (ctx, STATE_FUNCTION_PARAMETERS); + } break; case STATE_FUNCTION: { pop_node (ctx); - if (ctx->node_stack == NULL) - { - state_switch (ctx, STATE_NAMESPACE); - } - else - { + if (ctx->node_stack == NULL) + { + state_switch (ctx, STATE_NAMESPACE); + } + else + { g_debug("case STATE_FUNCTION %d", CURRENT_NODE (ctx)->type); if (ctx->in_embedded_state != STATE_NONE) { state_switch (ctx, ctx->in_embedded_state); ctx->in_embedded_state = STATE_NONE; } - else if (CURRENT_NODE (ctx)->type == GI_IR_NODE_INTERFACE) - state_switch (ctx, STATE_INTERFACE); - else if (CURRENT_NODE (ctx)->type == GI_IR_NODE_OBJECT) - state_switch (ctx, STATE_CLASS); - else if (CURRENT_NODE (ctx)->type == GI_IR_NODE_BOXED) - state_switch (ctx, STATE_BOXED); - else if (CURRENT_NODE (ctx)->type == GI_IR_NODE_STRUCT) - state_switch (ctx, STATE_STRUCT); - else if (CURRENT_NODE (ctx)->type == GI_IR_NODE_UNION) - state_switch (ctx, STATE_UNION); - else if (CURRENT_NODE (ctx)->type == GI_IR_NODE_ENUM || - CURRENT_NODE (ctx)->type == GI_IR_NODE_FLAGS) - state_switch (ctx, STATE_ENUM); - else - { - int line_number, char_number; - g_markup_parse_context_get_position (context, &line_number, &char_number); - g_set_error (error, - G_MARKUP_ERROR, - G_MARKUP_ERROR_INVALID_CONTENT, - "Unexpected end tag '%s' on line %d char %d", - element_name, - line_number, char_number); - } - } + else if (CURRENT_NODE (ctx)->type == GI_IR_NODE_INTERFACE) + state_switch (ctx, STATE_INTERFACE); + else if (CURRENT_NODE (ctx)->type == GI_IR_NODE_OBJECT) + state_switch (ctx, STATE_CLASS); + else if (CURRENT_NODE (ctx)->type == GI_IR_NODE_BOXED) + state_switch (ctx, STATE_BOXED); + else if (CURRENT_NODE (ctx)->type == GI_IR_NODE_STRUCT) + state_switch (ctx, STATE_STRUCT); + else if (CURRENT_NODE (ctx)->type == GI_IR_NODE_UNION) + state_switch (ctx, STATE_UNION); + else if (CURRENT_NODE (ctx)->type == GI_IR_NODE_ENUM || + CURRENT_NODE (ctx)->type == GI_IR_NODE_FLAGS) + state_switch (ctx, STATE_ENUM); + else + { + int line_number, char_number; + g_markup_parse_context_get_position (context, &line_number, &char_number); + g_set_error (error, + G_MARKUP_ERROR, + G_MARKUP_ERROR_INVALID_CONTENT, + "Unexpected end tag '%s' on line %d char %d", + element_name, + line_number, char_number); + } + } } break; case STATE_CLASS_FIELD: if (strcmp ("type", element_name) == 0) - break; + break; if (require_end_element (context, ctx, "field", element_name, error)) - { - state_switch (ctx, STATE_CLASS); - } + { + state_switch (ctx, STATE_CLASS); + } break; case STATE_CLASS_PROPERTY: if (strcmp ("type", element_name) == 0) - break; + break; if (require_end_element (context, ctx, "property", element_name, error)) - { - state_switch (ctx, STATE_CLASS); - } + { + state_switch (ctx, STATE_CLASS); + } break; case STATE_CLASS: if (require_end_element (context, ctx, "class", element_name, error)) - { - pop_node (ctx); - state_switch (ctx, STATE_NAMESPACE); - } + { + pop_node (ctx); + state_switch (ctx, STATE_NAMESPACE); + } break; case STATE_INTERFACE_PROPERTY: if (strcmp ("type", element_name) == 0) - break; + break; if (require_end_element (context, ctx, "property", element_name, error)) - { - state_switch (ctx, STATE_INTERFACE); - } + { + state_switch (ctx, STATE_INTERFACE); + } break; case STATE_INTERFACE_FIELD: if (strcmp ("type", element_name) == 0) - break; + break; if (require_end_element (context, ctx, "field", element_name, error)) - { - state_switch (ctx, STATE_INTERFACE); - } + { + state_switch (ctx, STATE_INTERFACE); + } break; case STATE_INTERFACE: if (require_end_element (context, ctx, "interface", element_name, error)) - { - pop_node (ctx); - state_switch (ctx, STATE_NAMESPACE); - } + { + pop_node (ctx); + state_switch (ctx, STATE_NAMESPACE); + } break; case STATE_ENUM: if (strcmp ("member", element_name) == 0) - break; + break; else if (strcmp ("function", element_name) == 0) - break; + break; else if (require_one_of_end_elements (context, ctx, - element_name, error, "enumeration", - "bitfield", NULL)) - { - pop_node (ctx); - state_switch (ctx, STATE_NAMESPACE); - } + element_name, error, "enumeration", + "bitfield", NULL)) + { + pop_node (ctx); + state_switch (ctx, STATE_NAMESPACE); + } break; case STATE_BOXED: if (require_end_element (context, ctx, "glib:boxed", element_name, error)) - { - pop_node (ctx); - state_switch (ctx, STATE_NAMESPACE); - } + { + pop_node (ctx); + state_switch (ctx, STATE_NAMESPACE); + } break; case STATE_BOXED_FIELD: if (strcmp ("type", element_name) == 0) - break; + break; if (require_end_element (context, ctx, "field", element_name, error)) - { - state_switch (ctx, STATE_BOXED); - } + { + state_switch (ctx, STATE_BOXED); + } break; case STATE_STRUCT_FIELD: if (strcmp ("type", element_name) == 0) - break; + break; if (require_end_element (context, ctx, "field", element_name, error)) - { - state_switch (ctx, STATE_STRUCT); - } + { + state_switch (ctx, STATE_STRUCT); + } break; case STATE_STRUCT: if (require_end_element (context, ctx, "record", element_name, error)) - { - state_switch_end_struct_or_union (context, ctx, element_name, error); - } + { + state_switch_end_struct_or_union (context, ctx, element_name, error); + } break; case STATE_UNION_FIELD: if (strcmp ("type", element_name) == 0) - break; + break; if (require_end_element (context, ctx, "field", element_name, error)) - { - state_switch (ctx, STATE_UNION); - } + { + state_switch (ctx, STATE_UNION); + } break; case STATE_UNION: if (require_end_element (context, ctx, "union", element_name, error)) - { - state_switch_end_struct_or_union (context, ctx, element_name, error); - } + { + state_switch_end_struct_or_union (context, ctx, element_name, error); + } break; case STATE_IMPLEMENTS: if (strcmp ("interface", element_name) == 0) - break; + break; if (require_end_element (context, ctx, "implements", element_name, error)) state_switch (ctx, STATE_CLASS); break; @@ -3598,33 +3598,33 @@ end_element_handler (GMarkupParseContext *context, case STATE_CLASS_CONSTANT: case STATE_INTERFACE_CONSTANT: if (strcmp ("type", element_name) == 0) - break; + break; if (require_end_element (context, ctx, "constant", element_name, error)) - { - switch (ctx->state) - { - case STATE_NAMESPACE_CONSTANT: - pop_node (ctx); - state_switch (ctx, STATE_NAMESPACE); - break; - case STATE_CLASS_CONSTANT: - state_switch (ctx, STATE_CLASS); - break; - case STATE_INTERFACE_CONSTANT: - state_switch (ctx, STATE_INTERFACE); - break; - default: - g_assert_not_reached (); - break; - } - } + { + switch (ctx->state) + { + case STATE_NAMESPACE_CONSTANT: + pop_node (ctx); + state_switch (ctx, STATE_NAMESPACE); + break; + case STATE_CLASS_CONSTANT: + state_switch (ctx, STATE_CLASS); + break; + case STATE_INTERFACE_CONSTANT: + state_switch (ctx, STATE_INTERFACE); + break; + default: + g_assert_not_reached (); + break; + } + } break; case STATE_TYPE: if ((strcmp ("type", element_name) == 0) || (strcmp ("array", element_name) == 0) || - (strcmp ("varargs", element_name) == 0)) - { - end_type (ctx); - } + (strcmp ("varargs", element_name) == 0)) + { + end_type (ctx); + } break; case STATE_ATTRIBUTE: if (strcmp ("attribute", element_name) == 0) @@ -3646,18 +3646,18 @@ end_element_handler (GMarkupParseContext *context, static void text_handler (GMarkupParseContext *context, - const gchar *text, - gsize text_len, - gpointer user_data, - GError **error) + const gchar *text, + gsize text_len, + gpointer user_data, + GError **error) { /* FIXME warn about non-whitespace text */ } static void cleanup (GMarkupParseContext *context, - GError *error, - gpointer user_data) + GError *error, + gpointer user_data) { ParseContext *ctx = user_data; GList *m; @@ -3728,7 +3728,7 @@ gi_ir_parser_parse_string (GIIrParser *parser, goto out; parser->parsed_modules = g_list_concat (g_list_copy (ctx.modules), - parser->parsed_modules); + parser->parsed_modules); out: @@ -3785,9 +3785,9 @@ gi_ir_parser_parse_file (GIIrParser *parser, if (!g_str_has_suffix (filename, ".gir")) { g_set_error (error, - G_MARKUP_ERROR, - G_MARKUP_ERROR_INVALID_CONTENT, - "Expected filename to end with '.gir'"); + G_MARKUP_ERROR, + G_MARKUP_ERROR_INVALID_CONTENT, + "Expected filename to end with '.gir'"); return NULL; } diff --git a/girepository/girwriter.c b/girepository/girwriter.c index c01aef27c..fc109deca 100644 --- a/girepository/girwriter.c +++ b/girepository/girwriter.c @@ -169,13 +169,13 @@ check_unresolved (GIBaseInfo *info) return; g_critical ("Found unresolved type '%s' '%s'", - gi_base_info_get_name (info), gi_base_info_get_namespace (info)); + gi_base_info_get_name (info), gi_base_info_get_namespace (info)); } static void write_type_name (const gchar *ns, - GIBaseInfo *info, - Xml *file) + GIBaseInfo *info, + Xml *file) { if (strcmp (ns, gi_base_info_get_namespace (info)) != 0) xml_printf (file, "%s.", gi_base_info_get_namespace (info)); @@ -185,9 +185,9 @@ write_type_name (const gchar *ns, static void write_type_name_attribute (const gchar *ns, - GIBaseInfo *info, - const char *attr_name, - Xml *file) + GIBaseInfo *info, + const char *attr_name, + Xml *file) { xml_printf (file, " %s=\"", attr_name); write_type_name (ns, info, file); @@ -216,8 +216,8 @@ write_ownership_transfer (GITransfer transfer, static void write_type_info (const gchar *ns, - GITypeInfo *info, - Xml *file) + GITypeInfo *info, + Xml *file) { gint tag; GITypeInfo *type; @@ -280,7 +280,7 @@ write_type_info (const gchar *ns, xml_printf (file, " fixed-size=\"%" G_GSSIZE_FORMAT "\"", size); if (gi_type_info_is_zero_terminated (info)) - xml_printf (file, " zero-terminated=\"1\""); + xml_printf (file, " zero-terminated=\"1\""); write_type_info (ns, type, file); @@ -302,10 +302,10 @@ write_type_info (const gchar *ns, xml_printf (file, " name=\"GLib.List\""); type = gi_type_info_get_param_type (info, 0); if (type) - { - write_type_info (ns, type, file); - gi_base_info_unref ((GIBaseInfo *)type); - } + { + write_type_info (ns, type, file); + gi_base_info_unref ((GIBaseInfo *)type); + } xml_end_element (file, "type"); } else if (tag == GI_TYPE_TAG_GSLIST) @@ -314,10 +314,10 @@ write_type_info (const gchar *ns, xml_printf (file, " name=\"GLib.SList\""); type = gi_type_info_get_param_type (info, 0); if (type) - { - write_type_info (ns, type, file); - gi_base_info_unref ((GIBaseInfo *)type); - } + { + write_type_info (ns, type, file); + gi_base_info_unref ((GIBaseInfo *)type); + } xml_end_element (file, "type"); } else if (tag == GI_TYPE_TAG_GHASH) @@ -326,13 +326,13 @@ write_type_info (const gchar *ns, xml_printf (file, " name=\"GLib.HashTable\""); type = gi_type_info_get_param_type (info, 0); if (type) - { - write_type_info (ns, type, file); - gi_base_info_unref ((GIBaseInfo *)type); - type = gi_type_info_get_param_type (info, 1); - write_type_info (ns, type, file); - gi_base_info_unref ((GIBaseInfo *)type); - } + { + write_type_info (ns, type, file); + gi_base_info_unref ((GIBaseInfo *)type); + type = gi_type_info_get_param_type (info, 1); + write_type_info (ns, type, file); + gi_base_info_unref ((GIBaseInfo *)type); + } xml_end_element (file, "type"); } else if (tag == GI_TYPE_TAG_ERROR) @@ -380,20 +380,20 @@ write_return_value_attributes (Xml *file, static void write_constant_value (const gchar *ns, - GITypeInfo *info, - GIArgument *argument, - Xml *file); + GITypeInfo *info, + GIArgument *argument, + Xml *file); static void write_callback_info (const gchar *ns, - GICallbackInfo *info, - Xml *file); + GICallbackInfo *info, + Xml *file); static void write_field_info (const gchar *ns, - GIFieldInfo *info, - GIConstantInfo *branch, - Xml *file) + GIFieldInfo *info, + GIConstantInfo *branch, + Xml *file) { const gchar *name; GIFieldInfoFlags flags; @@ -458,8 +458,8 @@ write_field_info (const gchar *ns, static void write_callable_info (const gchar *ns, - GICallableInfo *info, - Xml *file) + GICallableInfo *info, + Xml *file) { GITypeInfo *type; @@ -501,28 +501,28 @@ write_callable_info (const gchar *ns, write_ownership_transfer (gi_arg_info_get_ownership_transfer (arg), file); switch (gi_arg_info_get_direction (arg)) - { - case GI_DIRECTION_IN: - break; - case GI_DIRECTION_OUT: - xml_printf (file, " direction=\"out\" caller-allocates=\"%s\"", - gi_arg_info_is_caller_allocates (arg) ? "1" : "0"); - break; - case GI_DIRECTION_INOUT: - xml_printf (file, " direction=\"inout\""); - break; - default: - g_assert_not_reached (); - } + { + case GI_DIRECTION_IN: + break; + case GI_DIRECTION_OUT: + xml_printf (file, " direction=\"out\" caller-allocates=\"%s\"", + gi_arg_info_is_caller_allocates (arg) ? "1" : "0"); + break; + case GI_DIRECTION_INOUT: + xml_printf (file, " direction=\"inout\""); + break; + default: + g_assert_not_reached (); + } if (gi_arg_info_may_be_null (arg)) - xml_printf (file, " allow-none=\"1\""); + xml_printf (file, " allow-none=\"1\""); if (gi_arg_info_is_return_value (arg)) - xml_printf (file, " retval=\"1\""); + xml_printf (file, " retval=\"1\""); if (gi_arg_info_is_optional (arg)) - xml_printf (file, " optional=\"1\""); + xml_printf (file, " optional=\"1\""); switch (gi_arg_info_get_scope (arg)) { @@ -569,8 +569,8 @@ write_callable_info (const gchar *ns, static void write_function_info (const gchar *ns, - GIFunctionInfo *info, - Xml *file) + GIFunctionInfo *info, + Xml *file) { GIFunctionInfoFlags flags; const gchar *tag; @@ -620,8 +620,8 @@ write_function_info (const gchar *ns, static void write_callback_info (const gchar *ns, - GICallbackInfo *info, - Xml *file) + GICallbackInfo *info, + Xml *file) { const gchar *name; gboolean deprecated; @@ -641,8 +641,8 @@ write_callback_info (const gchar *ns, static void write_struct_info (const gchar *ns, - GIStructInfo *info, - Xml *file) + GIStructInfo *info, + Xml *file) { const gchar *name; const gchar *type_name; @@ -703,18 +703,18 @@ write_struct_info (const gchar *ns, if (n_elts > 0) { for (guint i = 0; i < gi_struct_info_get_n_fields (info); i++) - { - GIFieldInfo *field = gi_struct_info_get_field (info, i); - write_field_info (ns, field, NULL, file); - gi_base_info_unref ((GIBaseInfo *)field); - } + { + GIFieldInfo *field = gi_struct_info_get_field (info, i); + write_field_info (ns, field, NULL, file); + gi_base_info_unref ((GIBaseInfo *)field); + } for (guint i = 0; i < gi_struct_info_get_n_methods (info); i++) - { - GIFunctionInfo *function = gi_struct_info_get_method (info, i); - write_function_info (ns, function, file); - gi_base_info_unref ((GIBaseInfo *)function); - } + { + GIFunctionInfo *function = gi_struct_info_get_method (info, i); + write_function_info (ns, function, file); + gi_base_info_unref ((GIBaseInfo *)function); + } } @@ -723,8 +723,8 @@ write_struct_info (const gchar *ns, static void write_value_info (const gchar *ns, - GIValueInfo *info, - Xml *file) + GIValueInfo *info, + Xml *file) { const gchar *name; gint64 value; @@ -750,9 +750,9 @@ write_value_info (const gchar *ns, static void write_constant_value (const gchar *ns, - GITypeInfo *type, - GIArgument *value, - Xml *file) + GITypeInfo *type, + GIArgument *value, + Xml *file) { switch (gi_type_info_get_tag (type)) { @@ -800,8 +800,8 @@ write_constant_value (const gchar *ns, static void write_constant_info (const gchar *ns, - GIConstantInfo *info, - Xml *file) + GIConstantInfo *info, + Xml *file) { GITypeInfo *type; const gchar *name; @@ -831,8 +831,8 @@ write_constant_info (const gchar *ns, static void write_enum_info (const gchar *ns, - GIEnumInfo *info, - Xml *file) + GIEnumInfo *info, + Xml *file) { const gchar *name; const gchar *type_name; @@ -875,8 +875,8 @@ write_enum_info (const gchar *ns, static void write_signal_info (const gchar *ns, - GISignalInfo *info, - Xml *file) + GISignalInfo *info, + Xml *file) { GSignalFlags flags; const gchar *name; @@ -918,8 +918,8 @@ write_signal_info (const gchar *ns, static void write_vfunc_info (const gchar *ns, - GIVFuncInfo *info, - Xml *file) + GIVFuncInfo *info, + Xml *file) { GIVFuncInfoFlags flags; const gchar *name; @@ -962,8 +962,8 @@ write_vfunc_info (const gchar *ns, static void write_property_info (const gchar *ns, - GIPropertyInfo *info, - Xml *file) + GIPropertyInfo *info, + Xml *file) { GParamFlags flags; const gchar *name; @@ -1027,8 +1027,8 @@ write_property_info (const gchar *ns, static void write_object_info (const gchar *ns, - GIObjectInfo *info, - Xml *file) + GIObjectInfo *info, + Xml *file) { const gchar *name; const gchar *type_name; @@ -1101,13 +1101,13 @@ write_object_info (const gchar *ns, if (gi_object_info_get_n_interfaces (info) > 0) { for (guint i = 0; i < gi_object_info_get_n_interfaces (info); i++) - { - GIInterfaceInfo *imp = gi_object_info_get_interface (info, i); + { + GIInterfaceInfo *imp = gi_object_info_get_interface (info, i); xml_start_element (file, "implements"); - write_type_name_attribute (ns, (GIBaseInfo *)imp, "name", file); + write_type_name_attribute (ns, (GIBaseInfo *)imp, "name", file); xml_end_element (file, "implements"); - gi_base_info_unref ((GIBaseInfo*)imp); - } + gi_base_info_unref ((GIBaseInfo*)imp); + } } for (guint i = 0; i < gi_object_info_get_n_fields (info); i++) @@ -1157,8 +1157,8 @@ write_object_info (const gchar *ns, static void write_interface_info (const gchar *ns, - GIInterfaceInfo *info, - Xml *file) + GIInterfaceInfo *info, + Xml *file) { const gchar *name; const gchar *type_name; @@ -1173,7 +1173,7 @@ write_interface_info (const gchar *ns, type_init = gi_registered_type_info_get_type_init_function_name ((GIRegisteredTypeInfo*)info); xml_start_element (file, "interface"); xml_printf (file, " name=\"%s\" glib:type-name=\"%s\" glib:get-type=\"%s\"", - name, type_name, type_init); + name, type_name, type_init); class_struct = gi_interface_info_get_iface_struct (info); if (class_struct) @@ -1190,15 +1190,15 @@ write_interface_info (const gchar *ns, if (gi_interface_info_get_n_prerequisites (info) > 0) { for (guint i = 0; i < gi_interface_info_get_n_prerequisites (info); i++) - { - GIBaseInfo *req = gi_interface_info_get_prerequisite (info, i); + { + GIBaseInfo *req = gi_interface_info_get_prerequisite (info, i); - xml_start_element (file, "prerequisite"); - write_type_name_attribute (ns, req, "name", file); + xml_start_element (file, "prerequisite"); + write_type_name_attribute (ns, req, "name", file); xml_end_element_unchecked (file); - gi_base_info_unref (req); - } + gi_base_info_unref (req); + } } for (guint i = 0; i < gi_interface_info_get_n_methods (info); i++) @@ -1241,8 +1241,8 @@ write_interface_info (const gchar *ns, static void write_union_info (const gchar *ns, - GIUnionInfo *info, - Xml *file) + GIUnionInfo *info, + Xml *file) { const gchar *name; const gchar *type_name; @@ -1302,7 +1302,7 @@ write_union_info (const gchar *ns, write_field_info (ns, field, constant, file); gi_base_info_unref ((GIBaseInfo *)field); if (constant) - gi_base_info_unref ((GIBaseInfo *)constant); + gi_base_info_unref ((GIBaseInfo *)constant); } for (guint i = 0; i < gi_union_info_get_n_methods (info); i++) @@ -1349,19 +1349,19 @@ gi_ir_writer_write (const char *filename, gchar *full_filename; if (needs_prefix) - full_filename = g_strdup_printf ("%s-%s", ns, filename); + full_filename = g_strdup_printf ("%s-%s", ns, filename); else - full_filename = g_strdup (filename); + full_filename = g_strdup (filename); ofile = g_fopen (filename, "w"); if (ofile == NULL) - { - g_fprintf (stderr, "failed to open '%s': %s\n", - full_filename, g_strerror (errno)); - g_free (full_filename); + { + g_fprintf (stderr, "failed to open '%s': %s\n", + full_filename, g_strerror (errno)); + g_free (full_filename); - return; - } + return; + } g_free (full_filename); } @@ -1371,21 +1371,21 @@ gi_ir_writer_write (const char *filename, xml_printf (xml, "\n"); xml_start_element (xml, "repository"); xml_printf (xml, " version=\"1.0\"\n" - " xmlns=\"http://www.gtk.org/introspection/core/1.0\"\n" - " xmlns:c=\"http://www.gtk.org/introspection/c/1.0\"\n" - " xmlns:glib=\"http://www.gtk.org/introspection/glib/1.0\""); + " xmlns=\"http://www.gtk.org/introspection/core/1.0\"\n" + " xmlns:c=\"http://www.gtk.org/introspection/c/1.0\"\n" + " xmlns:glib=\"http://www.gtk.org/introspection/glib/1.0\""); dependencies = gi_repository_get_immediate_dependencies (repository, ns); if (dependencies != NULL) { for (i = 0; dependencies[i]; i++) - { - char **parts = g_strsplit (dependencies[i], "-", 2); - xml_start_element (xml, "include"); - xml_printf (xml, " name=\"%s\" version=\"%s\"", parts[0], parts[1]); - xml_end_element (xml, "include"); - g_strfreev (parts); - } + { + char **parts = g_strsplit (dependencies[i], "-", 2); + xml_start_element (xml, "include"); + xml_printf (xml, " name=\"%s\" version=\"%s\"", parts[0], parts[1]); + xml_end_element (xml, "include"); + g_strfreev (parts); + } } if (TRUE) @@ -1413,50 +1413,50 @@ gi_ir_writer_write (const char *filename, n_infos = gi_repository_get_n_infos (repository, cur_ns); for (j = 0; j < n_infos; j++) - { - GIBaseInfo *info = gi_repository_get_info (repository, cur_ns, j); - switch (gi_base_info_get_info_type (info)) - { - case GI_INFO_TYPE_FUNCTION: - write_function_info (ns, (GIFunctionInfo *)info, xml); - break; + { + GIBaseInfo *info = gi_repository_get_info (repository, cur_ns, j); + switch (gi_base_info_get_info_type (info)) + { + case GI_INFO_TYPE_FUNCTION: + write_function_info (ns, (GIFunctionInfo *)info, xml); + break; - case GI_INFO_TYPE_CALLBACK: - write_callback_info (ns, (GICallbackInfo *)info, xml); - break; + case GI_INFO_TYPE_CALLBACK: + write_callback_info (ns, (GICallbackInfo *)info, xml); + break; - case GI_INFO_TYPE_STRUCT: - case GI_INFO_TYPE_BOXED: - write_struct_info (ns, (GIStructInfo *)info, xml); - break; + case GI_INFO_TYPE_STRUCT: + case GI_INFO_TYPE_BOXED: + write_struct_info (ns, (GIStructInfo *)info, xml); + break; - case GI_INFO_TYPE_UNION: - write_union_info (ns, (GIUnionInfo *)info, xml); - break; + case GI_INFO_TYPE_UNION: + write_union_info (ns, (GIUnionInfo *)info, xml); + break; - case GI_INFO_TYPE_ENUM: - case GI_INFO_TYPE_FLAGS: - write_enum_info (ns, (GIEnumInfo *)info, xml); - break; + case GI_INFO_TYPE_ENUM: + case GI_INFO_TYPE_FLAGS: + write_enum_info (ns, (GIEnumInfo *)info, xml); + break; - case GI_INFO_TYPE_CONSTANT: - write_constant_info (ns, (GIConstantInfo *)info, xml); - break; + case GI_INFO_TYPE_CONSTANT: + write_constant_info (ns, (GIConstantInfo *)info, xml); + break; - case GI_INFO_TYPE_OBJECT: - write_object_info (ns, (GIObjectInfo *)info, xml); - break; + case GI_INFO_TYPE_OBJECT: + write_object_info (ns, (GIObjectInfo *)info, xml); + break; - case GI_INFO_TYPE_INTERFACE: - write_interface_info (ns, (GIInterfaceInfo *)info, xml); - break; + case GI_INFO_TYPE_INTERFACE: + write_interface_info (ns, (GIInterfaceInfo *)info, xml); + break; - default: - g_error ("unknown info type %d", gi_base_info_get_info_type (info)); - } + default: + g_error ("unknown info type %d", gi_base_info_get_info_type (info)); + } - gi_base_info_unref (info); - } + gi_base_info_unref (info); + } xml_end_element (xml, "namespace"); } diff --git a/girepository/gitypeinfo.c b/girepository/gitypeinfo.c index 9ecdfa28a..b292b0aef 100644 --- a/girepository/gitypeinfo.c +++ b/girepository/gitypeinfo.c @@ -257,10 +257,10 @@ gi_type_info_get_array_length_index (GITypeInfo *info) ArrayTypeBlob *blob = (ArrayTypeBlob *)&rinfo->typelib->data[rinfo->offset]; if (blob->tag == GI_TYPE_TAG_ARRAY) - { - if (blob->has_length) - return blob->dimensions.length; - } + { + if (blob->has_length) + return blob->dimensions.length; + } } return -1; @@ -293,10 +293,10 @@ gi_type_info_get_array_fixed_size (GITypeInfo *info) ArrayTypeBlob *blob = (ArrayTypeBlob *)&rinfo->typelib->data[rinfo->offset]; if (blob->tag == GI_TYPE_TAG_ARRAY) - { - if (blob->has_size) - return blob->dimensions.size; - } + { + if (blob->has_size) + return blob->dimensions.size; + } } return -1; @@ -329,7 +329,7 @@ gi_type_info_is_zero_terminated (GITypeInfo *info) ArrayTypeBlob *blob = (ArrayTypeBlob *)&rinfo->typelib->data[rinfo->offset]; if (blob->tag == GI_TYPE_TAG_ARRAY) - return blob->zero_terminated; + return blob->zero_terminated; } return FALSE; diff --git a/girepository/gitypelib-internal.h b/girepository/gitypelib-internal.h index f3de423b3..dc66eb100 100644 --- a/girepository/gitypelib-internal.h +++ b/girepository/gitypelib-internal.h @@ -735,12 +735,12 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint8 pointer :1; - guint8 reserved :2; - guint8 tag :5; + guint8 pointer :1; + guint8 reserved :2; + guint8 tag :5; - guint8 reserved2; - guint16 n_types; + guint8 reserved2; + guint16 n_types; SimpleTypeBlob type[]; } ParamTypeBlob; diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index b23de4330..79191afb5 100644 --- a/girepository/gitypelib.c +++ b/girepository/gitypelib.c @@ -60,18 +60,18 @@ pop_context (ValidateContext *ctx) { g_assert (ctx->context_stack != NULL); ctx->context_stack = g_slist_delete_link (ctx->context_stack, - ctx->context_stack); + ctx->context_stack); } static gboolean validate_interface_blob (ValidateContext *ctx, - guint32 offset, - GError **error); + guint32 offset, + GError **error); static DirEntry * get_dir_entry_checked (GITypelib *typelib, - guint16 index, - GError **error) + guint16 index, + GError **error) { Header *header = (Header *)typelib->data; guint32 offset; @@ -79,9 +79,9 @@ get_dir_entry_checked (GITypelib *typelib, if (index == 0 || index > header->n_entries) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Invalid directory index %d", index); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Invalid directory index %d", index); return FALSE; } @@ -90,9 +90,9 @@ get_dir_entry_checked (GITypelib *typelib, if (typelib->len < offset + sizeof (DirEntry)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -102,15 +102,15 @@ get_dir_entry_checked (GITypelib *typelib, static CommonBlob * get_blob (GITypelib *typelib, - guint32 offset, - GError **error) + guint32 offset, + GError **error) { if (typelib->len < offset + sizeof (CommonBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } return (CommonBlob *)&typelib->data[offset]; @@ -118,25 +118,25 @@ get_blob (GITypelib *typelib, static InterfaceTypeBlob * get_type_blob (GITypelib *typelib, - SimpleTypeBlob *simple, - GError **error) + SimpleTypeBlob *simple, + GError **error) { if (simple->offset == 0) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "Expected blob for type"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "Expected blob for type"); return FALSE; } if (simple->flags.reserved == 0 && simple->flags.reserved2 == 0) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "Expected non-basic type but got %d", - simple->flags.tag); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "Expected non-basic type but got %d", + simple->flags.tag); return FALSE; } @@ -164,7 +164,7 @@ gi_typelib_get_dir_entry (GITypelib *typelib, static Section * get_section_by_id (GITypelib *typelib, - SectionType section_type) + SectionType section_type) { Header *header = (Header *)typelib->data; Section *section; @@ -177,7 +177,7 @@ get_section_by_id (GITypelib *typelib, section++) { if (section->id == section_type) - return section; + return section; } return NULL; } @@ -208,12 +208,12 @@ gi_typelib_get_dir_entry_by_name (GITypelib *typelib, if (dirindex == NULL) { for (i = 1; i <= n_entries; i++) - { - entry = gi_typelib_get_dir_entry (typelib, i); - entry_name = gi_typelib_get_string (typelib, entry->name); - if (strcmp (name, entry_name) == 0) - return entry; - } + { + entry = gi_typelib_get_dir_entry (typelib, i); + entry_name = gi_typelib_get_string (typelib, entry->name); + if (strcmp (name, entry_name) == 0) + return entry; + } return NULL; } else @@ -225,7 +225,7 @@ gi_typelib_get_dir_entry_by_name (GITypelib *typelib, entry = gi_typelib_get_dir_entry (typelib, index + 1); entry_name = gi_typelib_get_string (typelib, entry->name); if (strcmp (name, entry_name) == 0) - return entry; + return entry; return NULL; } } @@ -255,15 +255,15 @@ gi_typelib_get_dir_entry_by_gtype_name (GITypelib *typelib, const char *type; DirEntry *entry = gi_typelib_get_dir_entry (typelib, i); if (!BLOB_IS_REGISTERED_TYPE (entry)) - continue; + continue; blob = (RegisteredTypeBlob *)(&typelib->data[entry->offset]); if (!blob->gtype_name) - continue; + continue; type = gi_typelib_get_string (typelib, blob->gtype_name); if (strcmp (type, gtype_name) == 0) - return entry; + return entry; } return NULL; } @@ -412,15 +412,15 @@ gi_typelib_get_dir_entry_by_error_domain (GITypelib *typelib, entry = gi_typelib_get_dir_entry (typelib, i); if (entry->blob_type != BLOB_TYPE_ENUM) - continue; + continue; blob = (EnumBlob *)(&typelib->data[entry->offset]); if (!blob->error_domain) - continue; + continue; enum_domain_string = gi_typelib_get_string (typelib, blob->error_domain); if (strcmp (domain_string, enum_domain_string) == 0) - return entry; + return entry; } return NULL; } @@ -445,7 +445,7 @@ gi_typelib_check_format (void) if (sizeof(s) != n) \ { \ g_printerr ("sizeof("#s") is expected to be %d but is %"G_GSIZE_FORMAT".\n", \ - n, sizeof (s)); \ + n, sizeof (s)); \ size_check_ok = FALSE; \ } @@ -503,9 +503,9 @@ get_string (GITypelib *typelib, guint32 offset, GError **error) if (typelib->len < offset) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "Buffer is too short while looking up name"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "Buffer is too short while looking up name"); return NULL; } @@ -522,9 +522,9 @@ get_string_nofail (GITypelib *typelib, guint32 offset) static gboolean validate_name (GITypelib *typelib, - const char *msg, - const guchar *data, guint32 offset, - GError **error) + const char *msg, + const guchar *data, guint32 offset, + GError **error) { const char *name; @@ -535,20 +535,20 @@ validate_name (GITypelib *typelib, if (!memchr (name, '\0', MAX_NAME_LEN)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The %s is too long: %s", - msg, name); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The %s is too long: %s", + msg, name); return FALSE; } if (strspn (name, G_CSET_a_2_z G_CSET_A_2_Z G_CSET_DIGITS "-_") < strlen (name)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The %s contains invalid characters: '%s'", - msg, name); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The %s contains invalid characters: '%s'", + msg, name); return FALSE; } @@ -558,27 +558,27 @@ validate_name (GITypelib *typelib, /* Fast path sanity check, operates on a memory blob */ static gboolean validate_header_basic (const guint8 *memory, - gsize len, - GError **error) + gsize len, + GError **error) { Header *header = (Header *)memory; if (len < sizeof (Header)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The specified typelib length %" G_GSIZE_FORMAT " is too short", - len); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The specified typelib length %" G_GSIZE_FORMAT " is too short", + len); return FALSE; } if (strncmp (header->magic, GI_IR_MAGIC, 16) != 0) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_HEADER, - "Invalid magic header"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_HEADER, + "Invalid magic header"); return FALSE; } @@ -586,10 +586,10 @@ validate_header_basic (const guint8 *memory, if (header->major_version != 4) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_HEADER, - "Typelib version mismatch; expected 4, found %d", - header->major_version); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_HEADER, + "Typelib version mismatch; expected 4, found %d", + header->major_version); return FALSE; } @@ -597,19 +597,19 @@ validate_header_basic (const guint8 *memory, if (header->n_entries < header->n_local_entries) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_HEADER, - "Inconsistent entry counts"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_HEADER, + "Inconsistent entry counts"); return FALSE; } if (header->size != len) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_HEADER, - "Typelib size %" G_GSIZE_FORMAT " does not match %" G_GSIZE_FORMAT, - (gsize) header->size, len); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_HEADER, + "Typelib size %" G_GSIZE_FORMAT " does not match %" G_GSIZE_FORMAT, + (gsize) header->size, len); return FALSE; } @@ -640,36 +640,36 @@ validate_header_basic (const guint8 *memory, header->union_blob_size != sizeof (UnionBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_HEADER, - "Blob size mismatch"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_HEADER, + "Blob size mismatch"); return FALSE; } if (!is_aligned (header->directory)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_HEADER, - "Misaligned directory"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_HEADER, + "Misaligned directory"); return FALSE; } if (!is_aligned (header->attributes)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_HEADER, - "Misaligned attributes"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_HEADER, + "Misaligned attributes"); return FALSE; } if (header->attributes == 0 && header->n_attributes > 0) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_HEADER, - "Wrong number of attributes"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_HEADER, + "Wrong number of attributes"); return FALSE; } @@ -678,7 +678,7 @@ validate_header_basic (const guint8 *memory, static gboolean validate_header (ValidateContext *ctx, - GError **error) + GError **error) { GITypelib *typelib = ctx->typelib; @@ -695,23 +695,23 @@ validate_header (ValidateContext *ctx, } static gboolean validate_type_blob (GITypelib *typelib, - guint32 offset, - guint32 signature_offset, - gboolean return_type, - GError **error); + guint32 offset, + guint32 signature_offset, + gboolean return_type, + GError **error); static gboolean validate_array_type_blob (GITypelib *typelib, - guint32 offset, - guint32 signature_offset, - gboolean return_type, - GError **error) + guint32 offset, + guint32 signature_offset, + gboolean return_type, + GError **error) { /* FIXME validate length */ if (!validate_type_blob (typelib, - offset + G_STRUCT_OFFSET (ArrayTypeBlob, type), - 0, FALSE, error)) + offset + G_STRUCT_OFFSET (ArrayTypeBlob, type), + 0, FALSE, error)) return FALSE; return TRUE; @@ -719,10 +719,10 @@ validate_array_type_blob (GITypelib *typelib, static gboolean validate_iface_type_blob (GITypelib *typelib, - guint32 offset, - guint32 signature_offset, - gboolean return_type, - GError **error) + guint32 offset, + guint32 signature_offset, + gboolean return_type, + GError **error) { InterfaceTypeBlob *blob; InterfaceBlob *target; @@ -741,11 +741,11 @@ validate_iface_type_blob (GITypelib *typelib, static gboolean validate_param_type_blob (GITypelib *typelib, - guint32 offset, - guint32 signature_offset, - gboolean return_type, - gint n_params, - GError **error) + guint32 offset, + guint32 signature_offset, + gboolean return_type, + gint n_params, + GError **error) { ParamTypeBlob *blob; gint i; @@ -755,28 +755,28 @@ validate_param_type_blob (GITypelib *typelib, if (!blob->pointer) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Pointer type exected for tag %d", blob->tag); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Pointer type exected for tag %d", blob->tag); return FALSE; } if (blob->n_types != n_params) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Parameter type number mismatch"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Parameter type number mismatch"); return FALSE; } for (i = 0; i < n_params; i++) { if (!validate_type_blob (typelib, - offset + sizeof (ParamTypeBlob) + - i * sizeof (SimpleTypeBlob), - 0, FALSE, error)) - return FALSE; + offset + sizeof (ParamTypeBlob) + + i * sizeof (SimpleTypeBlob), + 0, FALSE, error)) + return FALSE; } return TRUE; @@ -784,10 +784,10 @@ validate_param_type_blob (GITypelib *typelib, static gboolean validate_error_type_blob (GITypelib *typelib, - guint32 offset, - guint32 signature_offset, - gboolean return_type, - GError **error) + guint32 offset, + guint32 signature_offset, + gboolean return_type, + GError **error) { ErrorTypeBlob *blob; @@ -796,9 +796,9 @@ validate_error_type_blob (GITypelib *typelib, if (!blob->pointer) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Pointer type exected for tag %d", blob->tag); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Pointer type exected for tag %d", blob->tag); return FALSE; } @@ -807,10 +807,10 @@ validate_error_type_blob (GITypelib *typelib, static gboolean validate_type_blob (GITypelib *typelib, - guint32 offset, - guint32 signature_offset, - gboolean return_type, - GError **error) + guint32 offset, + guint32 signature_offset, + gboolean return_type, + GError **error) { SimpleTypeBlob *simple; InterfaceTypeBlob *iface; @@ -821,24 +821,24 @@ validate_type_blob (GITypelib *typelib, simple->flags.reserved2 == 0) { if (!GI_TYPE_TAG_IS_BASIC(simple->flags.tag)) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Invalid non-basic tag %d in simple type", simple->flags.tag); - return FALSE; - } + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Invalid non-basic tag %d in simple type", simple->flags.tag); + return FALSE; + } if (simple->flags.tag >= GI_TYPE_TAG_UTF8 && - simple->flags.tag != GI_TYPE_TAG_UNICHAR && - !simple->flags.pointer) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Pointer type exected for tag %d", simple->flags.tag); - return FALSE; - } + simple->flags.tag != GI_TYPE_TAG_UNICHAR && + !simple->flags.pointer) + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Pointer type exected for tag %d", simple->flags.tag); + return FALSE; + } return TRUE; } @@ -849,35 +849,35 @@ validate_type_blob (GITypelib *typelib, { case GI_TYPE_TAG_ARRAY: if (!validate_array_type_blob (typelib, simple->offset, - signature_offset, return_type, error)) - return FALSE; + signature_offset, return_type, error)) + return FALSE; break; case GI_TYPE_TAG_INTERFACE: if (!validate_iface_type_blob (typelib, simple->offset, - signature_offset, return_type, error)) - return FALSE; + signature_offset, return_type, error)) + return FALSE; break; case GI_TYPE_TAG_GLIST: case GI_TYPE_TAG_GSLIST: if (!validate_param_type_blob (typelib, simple->offset, - signature_offset, return_type, 1, error)) - return FALSE; + signature_offset, return_type, 1, error)) + return FALSE; break; case GI_TYPE_TAG_GHASH: if (!validate_param_type_blob (typelib, simple->offset, - signature_offset, return_type, 2, error)) - return FALSE; + signature_offset, return_type, 2, error)) + return FALSE; break; case GI_TYPE_TAG_ERROR: if (!validate_error_type_blob (typelib, simple->offset, - signature_offset, return_type, error)) - return FALSE; + signature_offset, return_type, error)) + return FALSE; break; default: g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Wrong tag in complex type"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Wrong tag in complex type"); return FALSE; } @@ -886,18 +886,18 @@ validate_type_blob (GITypelib *typelib, static gboolean validate_arg_blob (GITypelib *typelib, - guint32 offset, - guint32 signature_offset, - GError **error) + guint32 offset, + guint32 signature_offset, + GError **error) { ArgBlob *blob; if (typelib->len < offset + sizeof (ArgBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -907,8 +907,8 @@ validate_arg_blob (GITypelib *typelib, return FALSE; if (!validate_type_blob (typelib, - offset + G_STRUCT_OFFSET (ArgBlob, arg_type), - signature_offset, FALSE, error)) + offset + G_STRUCT_OFFSET (ArgBlob, arg_type), + signature_offset, FALSE, error)) return FALSE; return TRUE; @@ -916,16 +916,16 @@ validate_arg_blob (GITypelib *typelib, static SimpleTypeBlob * return_type_from_signature (GITypelib *typelib, - guint32 offset, - GError **error) + guint32 offset, + GError **error) { SignatureBlob *blob; if (typelib->len < offset + sizeof (SignatureBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return NULL; } @@ -933,9 +933,9 @@ return_type_from_signature (GITypelib *typelib, if (blob->return_type.offset == 0) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "No return type found in signature"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "No return type found in signature"); return NULL; } @@ -944,8 +944,8 @@ return_type_from_signature (GITypelib *typelib, static gboolean validate_signature_blob (GITypelib *typelib, - guint32 offset, - GError **error) + guint32 offset, + GError **error) { SignatureBlob *blob; gint i; @@ -953,9 +953,9 @@ validate_signature_blob (GITypelib *typelib, if (typelib->len < offset + sizeof (SignatureBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -964,19 +964,19 @@ validate_signature_blob (GITypelib *typelib, if (blob->return_type.offset != 0) { if (!validate_type_blob (typelib, - offset + G_STRUCT_OFFSET (SignatureBlob, return_type), - offset, TRUE, error)) - return FALSE; + offset + G_STRUCT_OFFSET (SignatureBlob, return_type), + offset, TRUE, error)) + return FALSE; } for (i = 0; i < blob->n_arguments; i++) { if (!validate_arg_blob (typelib, - offset + sizeof (SignatureBlob) + - i * sizeof (ArgBlob), - offset, - error)) - return FALSE; + offset + sizeof (SignatureBlob) + + i * sizeof (ArgBlob), + offset, + error)) + return FALSE; } /* FIXME check constraints on return_value */ @@ -986,9 +986,9 @@ validate_signature_blob (GITypelib *typelib, static gboolean validate_function_blob (ValidateContext *ctx, - guint32 offset, - guint16 container_type, - GError **error) + guint32 offset, + guint16 container_type, + GError **error) { GITypelib *typelib = ctx->typelib; FunctionBlob *blob; @@ -996,9 +996,9 @@ validate_function_blob (ValidateContext *ctx, if (typelib->len < offset + sizeof (FunctionBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -1007,9 +1007,9 @@ validate_function_blob (ValidateContext *ctx, if (blob->blob_type != BLOB_TYPE_FUNCTION) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Wrong blob type %d, expected function", blob->blob_type); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Wrong blob type %d, expected function", blob->blob_type); return FALSE; } @@ -1024,48 +1024,48 @@ validate_function_blob (ValidateContext *ctx, if (blob->constructor) { switch (container_type) - { - case BLOB_TYPE_BOXED: - case BLOB_TYPE_STRUCT: - case BLOB_TYPE_UNION: - case BLOB_TYPE_OBJECT: - case BLOB_TYPE_INTERFACE: - break; - default: - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Constructor not allowed"); - return FALSE; - } + { + case BLOB_TYPE_BOXED: + case BLOB_TYPE_STRUCT: + case BLOB_TYPE_UNION: + case BLOB_TYPE_OBJECT: + case BLOB_TYPE_INTERFACE: + break; + default: + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Constructor not allowed"); + return FALSE; + } } if (blob->setter || blob->getter || blob->wraps_vfunc) { switch (container_type) - { - case BLOB_TYPE_OBJECT: - case BLOB_TYPE_INTERFACE: - break; - default: - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Setter, getter or wrapper not allowed"); - return FALSE; - } + { + case BLOB_TYPE_OBJECT: + case BLOB_TYPE_INTERFACE: + break; + default: + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Setter, getter or wrapper not allowed"); + return FALSE; + } } if (blob->index) { if (!(blob->setter || blob->getter || blob->wraps_vfunc)) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Must be setter, getter or wrapper"); - return FALSE; - } + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Must be setter, getter or wrapper"); + return FALSE; + } } /* FIXME: validate index range */ @@ -1076,27 +1076,27 @@ validate_function_blob (ValidateContext *ctx, if (blob->constructor) { SimpleTypeBlob *simple = return_type_from_signature (typelib, - blob->signature, - error); + blob->signature, + error); InterfaceTypeBlob *iface_type; if (!simple) - return FALSE; + return FALSE; iface_type = get_type_blob (typelib, simple, error); if (!iface_type) - return FALSE; + return FALSE; if (iface_type->tag != GI_TYPE_TAG_INTERFACE && (container_type == BLOB_TYPE_OBJECT || container_type == BLOB_TYPE_INTERFACE)) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "Invalid return type '%s' for constructor '%s'", - gi_type_tag_to_string (iface_type->tag), - get_string_nofail (typelib, blob->symbol)); - return FALSE; - } + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "Invalid return type '%s' for constructor '%s'", + gi_type_tag_to_string (iface_type->tag), + get_string_nofail (typelib, blob->symbol)); + return FALSE; + } } pop_context (ctx); @@ -1106,8 +1106,8 @@ validate_function_blob (ValidateContext *ctx, static gboolean validate_callback_blob (ValidateContext *ctx, - guint32 offset, - GError **error) + guint32 offset, + GError **error) { GITypelib *typelib = ctx->typelib; CallbackBlob *blob; @@ -1115,9 +1115,9 @@ validate_callback_blob (ValidateContext *ctx, if (typelib->len < offset + sizeof (CallbackBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -1126,9 +1126,9 @@ validate_callback_blob (ValidateContext *ctx, if (blob->blob_type != BLOB_TYPE_CALLBACK) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Wrong blob type"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Wrong blob type"); return FALSE; } @@ -1147,8 +1147,8 @@ validate_callback_blob (ValidateContext *ctx, static gboolean validate_constant_blob (GITypelib *typelib, - guint32 offset, - GError **error) + guint32 offset, + GError **error) { guint value_size[] = { 0, /* VOID */ @@ -1182,9 +1182,9 @@ validate_constant_blob (GITypelib *typelib, if (typelib->len < offset + sizeof (ConstantBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -1193,9 +1193,9 @@ validate_constant_blob (GITypelib *typelib, if (blob->blob_type != BLOB_TYPE_CONSTANT) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Wrong blob type"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Wrong blob type"); return FALSE; } @@ -1203,15 +1203,15 @@ validate_constant_blob (GITypelib *typelib, return FALSE; if (!validate_type_blob (typelib, offset + G_STRUCT_OFFSET (ConstantBlob, type), - 0, FALSE, error)) + 0, FALSE, error)) return FALSE; if (!is_aligned (blob->offset)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Misaligned constant value"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Misaligned constant value"); return FALSE; } @@ -1219,23 +1219,23 @@ validate_constant_blob (GITypelib *typelib, if (type->flags.reserved == 0 && type->flags.reserved2 == 0) { if (type->flags.tag == 0) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Constant value type void"); - return FALSE; - } + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Constant value type void"); + return FALSE; + } if (value_size[type->flags.tag] != 0 && - blob->size != value_size[type->flags.tag]) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Constant value size mismatch"); - return FALSE; - } + blob->size != value_size[type->flags.tag]) + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Constant value size mismatch"); + return FALSE; + } /* FIXME check string values */ } @@ -1244,17 +1244,17 @@ validate_constant_blob (GITypelib *typelib, static gboolean validate_value_blob (GITypelib *typelib, - guint32 offset, - GError **error) + guint32 offset, + GError **error) { ValueBlob *blob; if (typelib->len < offset + sizeof (ValueBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -1268,8 +1268,8 @@ validate_value_blob (GITypelib *typelib, static gboolean validate_field_blob (ValidateContext *ctx, - guint32 offset, - GError **error) + guint32 offset, + GError **error) { GITypelib *typelib = ctx->typelib; Header *header = (Header *)typelib->data; @@ -1278,9 +1278,9 @@ validate_field_blob (ValidateContext *ctx, if (typelib->len < offset + sizeof (FieldBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -1295,8 +1295,8 @@ validate_field_blob (ValidateContext *ctx, return FALSE; } else if (!validate_type_blob (typelib, - offset + G_STRUCT_OFFSET (FieldBlob, type), - 0, FALSE, error)) + offset + G_STRUCT_OFFSET (FieldBlob, type), + 0, FALSE, error)) return FALSE; return TRUE; @@ -1304,17 +1304,17 @@ validate_field_blob (ValidateContext *ctx, static gboolean validate_property_blob (GITypelib *typelib, - guint32 offset, - GError **error) + guint32 offset, + GError **error) { PropertyBlob *blob; if (typelib->len < offset + sizeof (PropertyBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -1324,8 +1324,8 @@ validate_property_blob (GITypelib *typelib, return FALSE; if (!validate_type_blob (typelib, - offset + G_STRUCT_OFFSET (PropertyBlob, type), - 0, FALSE, error)) + offset + G_STRUCT_OFFSET (PropertyBlob, type), + 0, FALSE, error)) return FALSE; return TRUE; @@ -1333,9 +1333,9 @@ validate_property_blob (GITypelib *typelib, static gboolean validate_signal_blob (GITypelib *typelib, - guint32 offset, - guint32 container_offset, - GError **error) + guint32 offset, + guint32 container_offset, + GError **error) { SignalBlob *blob; gint n_signals; @@ -1343,9 +1343,9 @@ validate_signal_blob (GITypelib *typelib, if (typelib->len < offset + sizeof (SignalBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -1359,39 +1359,39 @@ validate_signal_blob (GITypelib *typelib, (blob->run_cleanup != 0) != 1) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Invalid signal run flags"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Invalid signal run flags"); return FALSE; } if (blob->has_class_closure) { if (((CommonBlob*)&typelib->data[container_offset])->blob_type == BLOB_TYPE_OBJECT) - { - ObjectBlob *object; + { + ObjectBlob *object; - object = (ObjectBlob*)&typelib->data[container_offset]; + object = (ObjectBlob*)&typelib->data[container_offset]; - n_signals = object->n_signals; - } + n_signals = object->n_signals; + } else - { - InterfaceBlob *iface; + { + InterfaceBlob *iface; - iface = (InterfaceBlob*)&typelib->data[container_offset]; + iface = (InterfaceBlob*)&typelib->data[container_offset]; - n_signals = iface->n_signals; - } + n_signals = iface->n_signals; + } if (blob->class_closure >= n_signals) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Invalid class closure index"); - return FALSE; - } + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Invalid class closure index"); + return FALSE; + } } if (!validate_signature_blob (typelib, blob->signature, error)) @@ -1402,9 +1402,9 @@ validate_signal_blob (GITypelib *typelib, static gboolean validate_vfunc_blob (GITypelib *typelib, - guint32 offset, - guint32 container_offset, - GError **error) + guint32 offset, + guint32 container_offset, + GError **error) { VFuncBlob *blob; gint n_vfuncs; @@ -1412,9 +1412,9 @@ validate_vfunc_blob (GITypelib *typelib, if (typelib->len < offset + sizeof (VFuncBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -1426,30 +1426,30 @@ validate_vfunc_blob (GITypelib *typelib, if (blob->class_closure) { if (((CommonBlob*)&typelib->data[container_offset])->blob_type == BLOB_TYPE_OBJECT) - { - ObjectBlob *object; + { + ObjectBlob *object; - object = (ObjectBlob*)&typelib->data[container_offset]; + object = (ObjectBlob*)&typelib->data[container_offset]; - n_vfuncs = object->n_vfuncs; - } + n_vfuncs = object->n_vfuncs; + } else - { - InterfaceBlob *iface; + { + InterfaceBlob *iface; - iface = (InterfaceBlob*)&typelib->data[container_offset]; + iface = (InterfaceBlob*)&typelib->data[container_offset]; - n_vfuncs = iface->n_vfuncs; - } + n_vfuncs = iface->n_vfuncs; + } if (blob->class_closure >= n_vfuncs) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Invalid class closure index"); - return FALSE; - } + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Invalid class closure index"); + return FALSE; + } } if (!validate_signature_blob (typelib, blob->signature, error)) @@ -1460,9 +1460,9 @@ validate_vfunc_blob (GITypelib *typelib, static gboolean validate_struct_blob (ValidateContext *ctx, - guint32 offset, - guint16 blob_type, - GError **error) + guint32 offset, + guint16 blob_type, + GError **error) { GITypelib *typelib = ctx->typelib; StructBlob *blob; @@ -1472,9 +1472,9 @@ validate_struct_blob (ValidateContext *ctx, if (typelib->len < offset + sizeof (StructBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -1483,9 +1483,9 @@ validate_struct_blob (ValidateContext *ctx, if (blob->blob_type != blob_type) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Wrong blob type"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Wrong blob type"); return FALSE; } @@ -1497,21 +1497,21 @@ validate_struct_blob (ValidateContext *ctx, if (!blob->unregistered) { if (!validate_name (typelib, "boxed", typelib->data, blob->gtype_name, error)) - return FALSE; + return FALSE; if (!validate_name (typelib, "boxed", typelib->data, blob->gtype_init, error)) - return FALSE; + return FALSE; } else { if (blob->gtype_name || blob->gtype_init) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Gtype data in struct"); - return FALSE; - } + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Gtype data in struct"); + return FALSE; + } } if (typelib->len < offset + sizeof (StructBlob) + @@ -1519,9 +1519,9 @@ validate_struct_blob (ValidateContext *ctx, blob->n_methods * sizeof (FunctionBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -1531,9 +1531,9 @@ validate_struct_blob (ValidateContext *ctx, FieldBlob *field_blob = (FieldBlob*) &typelib->data[field_offset]; if (!validate_field_blob (ctx, - field_offset, - error)) - return FALSE; + field_offset, + error)) + return FALSE; field_offset += sizeof (FieldBlob); if (field_blob->has_embedded_type) @@ -1543,11 +1543,11 @@ validate_struct_blob (ValidateContext *ctx, for (i = 0; i < blob->n_methods; i++) { if (!validate_function_blob (ctx, - field_offset + - i * sizeof (FunctionBlob), - blob_type, - error)) - return FALSE; + field_offset + + i * sizeof (FunctionBlob), + blob_type, + error)) + return FALSE; } pop_context (ctx); @@ -1557,9 +1557,9 @@ validate_struct_blob (ValidateContext *ctx, static gboolean validate_enum_blob (ValidateContext *ctx, - guint32 offset, - guint16 blob_type, - GError **error) + guint32 offset, + guint16 blob_type, + GError **error) { GITypelib *typelib = ctx->typelib; EnumBlob *blob; @@ -1569,9 +1569,9 @@ validate_enum_blob (ValidateContext *ctx, if (typelib->len < offset + sizeof (EnumBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -1580,30 +1580,30 @@ validate_enum_blob (ValidateContext *ctx, if (blob->blob_type != blob_type) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Wrong blob type"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Wrong blob type"); return FALSE; } if (!blob->unregistered) { if (!validate_name (typelib, "enum", typelib->data, blob->gtype_name, error)) - return FALSE; + return FALSE; if (!validate_name (typelib, "enum", typelib->data, blob->gtype_init, error)) - return FALSE; + return FALSE; } else { if (blob->gtype_name || blob->gtype_init) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Gtype data in unregistered enum"); - return FALSE; - } + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Gtype data in unregistered enum"); + return FALSE; + } } if (!validate_name (typelib, "enum", typelib->data, blob->name, error)) @@ -1614,9 +1614,9 @@ validate_enum_blob (ValidateContext *ctx, blob->n_methods * sizeof (FunctionBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -1627,35 +1627,35 @@ validate_enum_blob (ValidateContext *ctx, for (i = 0; i < blob->n_values; i++, offset2 += sizeof (ValueBlob)) { if (!validate_value_blob (typelib, - offset2, - error)) - return FALSE; + offset2, + error)) + return FALSE; #if 0 v1 = (ValueBlob *)&typelib->data[offset2]; for (j = 0; j < i; j++) - { - v2 = (ValueBlob *)&typelib->data[offset2 + + { + v2 = (ValueBlob *)&typelib->data[offset2 + j * sizeof (ValueBlob)]; - if (v1->value == v2->value) - { + if (v1->value == v2->value) + { - /* FIXME should this be an error ? */ - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Duplicate enum value"); - return FALSE; - } - } + /* FIXME should this be an error ? */ + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Duplicate enum value"); + return FALSE; + } + } #endif } for (i = 0; i < blob->n_methods; i++, offset2 += sizeof (FunctionBlob)) { if (!validate_function_blob (ctx, offset2, BLOB_TYPE_ENUM, error)) - return FALSE; + return FALSE; } pop_context (ctx); @@ -1665,8 +1665,8 @@ validate_enum_blob (ValidateContext *ctx, static gboolean validate_object_blob (ValidateContext *ctx, - guint32 offset, - GError **error) + guint32 offset, + GError **error) { GITypelib *typelib = ctx->typelib; Header *header; @@ -1680,9 +1680,9 @@ validate_object_blob (ValidateContext *ctx, if (typelib->len < offset + sizeof (ObjectBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -1691,9 +1691,9 @@ validate_object_blob (ValidateContext *ctx, if (blob->blob_type != BLOB_TYPE_OBJECT) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Wrong blob type"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Wrong blob type"); return FALSE; } @@ -1709,9 +1709,9 @@ validate_object_blob (ValidateContext *ctx, if (blob->parent > header->n_entries) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Invalid parent index"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Invalid parent index"); return FALSE; } @@ -1723,14 +1723,14 @@ validate_object_blob (ValidateContext *ctx, if (!entry) return FALSE; if (entry->blob_type != BLOB_TYPE_OBJECT && - (entry->local || entry->blob_type != 0)) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Parent not object"); - return FALSE; - } + (entry->local || entry->blob_type != 0)) + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Parent not object"); + return FALSE; + } } if (blob->gtype_struct != 0) @@ -1761,9 +1761,9 @@ validate_object_blob (ValidateContext *ctx, { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -1776,27 +1776,27 @@ validate_object_blob (ValidateContext *ctx, iface = *(guint16*)&typelib->data[offset2]; if (iface == 0 || iface > header->n_entries) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Invalid interface index"); - return FALSE; - } + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Invalid interface index"); + return FALSE; + } entry = get_dir_entry_checked (typelib, iface, error); if (!entry) return FALSE; if (entry->blob_type != BLOB_TYPE_INTERFACE && - (entry->local || entry->blob_type != 0)) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Not an interface"); - return FALSE; - } + (entry->local || entry->blob_type != 0)) + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Not an interface"); + return FALSE; + } } offset2 += 2 * (blob->n_interfaces %2); @@ -1809,7 +1809,7 @@ validate_object_blob (ValidateContext *ctx, FieldBlob *field_blob = (FieldBlob*) &typelib->data[offset2]; if (!validate_field_blob (ctx, offset2, error)) - return FALSE; + return FALSE; offset2 += sizeof (FieldBlob); /* Special case fields which are callbacks. */ @@ -1833,31 +1833,31 @@ validate_object_blob (ValidateContext *ctx, for (i = 0; i < blob->n_properties; i++, offset2 += sizeof (PropertyBlob)) { if (!validate_property_blob (typelib, offset2, error)) - return FALSE; + return FALSE; } for (i = 0; i < blob->n_methods; i++, offset2 += sizeof (FunctionBlob)) { if (!validate_function_blob (ctx, offset2, BLOB_TYPE_OBJECT, error)) - return FALSE; + return FALSE; } for (i = 0; i < blob->n_signals; i++, offset2 += sizeof (SignalBlob)) { if (!validate_signal_blob (typelib, offset2, offset, error)) - return FALSE; + return FALSE; } for (i = 0; i < blob->n_vfuncs; i++, offset2 += sizeof (VFuncBlob)) { if (!validate_vfunc_blob (typelib, offset2, offset, error)) - return FALSE; + return FALSE; } for (i = 0; i < blob->n_constants; i++, offset2 += sizeof (ConstantBlob)) { if (!validate_constant_blob (typelib, offset2, error)) - return FALSE; + return FALSE; } pop_context (ctx); @@ -1867,8 +1867,8 @@ validate_object_blob (ValidateContext *ctx, static gboolean validate_interface_blob (ValidateContext *ctx, - guint32 offset, - GError **error) + guint32 offset, + GError **error) { GITypelib *typelib = ctx->typelib; Header *header; @@ -1881,9 +1881,9 @@ validate_interface_blob (ValidateContext *ctx, if (typelib->len < offset + sizeof (InterfaceBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -1892,9 +1892,9 @@ validate_interface_blob (ValidateContext *ctx, if (blob->blob_type != BLOB_TYPE_INTERFACE) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Wrong blob type; expected interface, got %d", blob->blob_type); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Wrong blob type; expected interface, got %d", blob->blob_type); return FALSE; } @@ -1917,9 +1917,9 @@ validate_interface_blob (ValidateContext *ctx, { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -1932,25 +1932,25 @@ validate_interface_blob (ValidateContext *ctx, req = *(guint16*)&typelib->data[offset2]; if (req == 0 || req > header->n_entries) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Invalid prerequisite index"); - return FALSE; - } + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Invalid prerequisite index"); + return FALSE; + } entry = gi_typelib_get_dir_entry (typelib, req); if (entry->blob_type != BLOB_TYPE_INTERFACE && - entry->blob_type != BLOB_TYPE_OBJECT && - (entry->local || entry->blob_type != 0)) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_BLOB, - "Not an interface or object"); - return FALSE; - } + entry->blob_type != BLOB_TYPE_OBJECT && + (entry->local || entry->blob_type != 0)) + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_BLOB, + "Not an interface or object"); + return FALSE; + } } offset2 += 2 * (blob->n_prerequisites % 2); @@ -1960,31 +1960,31 @@ validate_interface_blob (ValidateContext *ctx, for (i = 0; i < blob->n_properties; i++, offset2 += sizeof (PropertyBlob)) { if (!validate_property_blob (typelib, offset2, error)) - return FALSE; + return FALSE; } for (i = 0; i < blob->n_methods; i++, offset2 += sizeof (FunctionBlob)) { if (!validate_function_blob (ctx, offset2, BLOB_TYPE_INTERFACE, error)) - return FALSE; + return FALSE; } for (i = 0; i < blob->n_signals; i++, offset2 += sizeof (SignalBlob)) { if (!validate_signal_blob (typelib, offset2, offset, error)) - return FALSE; + return FALSE; } for (i = 0; i < blob->n_vfuncs; i++, offset2 += sizeof (VFuncBlob)) { if (!validate_vfunc_blob (typelib, offset2, offset, error)) - return FALSE; + return FALSE; } for (i = 0; i < blob->n_constants; i++, offset2 += sizeof (ConstantBlob)) { if (!validate_constant_blob (typelib, offset2, error)) - return FALSE; + return FALSE; } pop_context (ctx); @@ -1994,16 +1994,16 @@ validate_interface_blob (ValidateContext *ctx, static gboolean validate_union_blob (GITypelib *typelib, - guint32 offset, - GError **error) + guint32 offset, + GError **error) { return TRUE; } static gboolean validate_blob (ValidateContext *ctx, - guint32 offset, - GError **error) + guint32 offset, + GError **error) { GITypelib *typelib = ctx->typelib; CommonBlob *common; @@ -2011,9 +2011,9 @@ validate_blob (ValidateContext *ctx, if (typelib->len < offset + sizeof (CommonBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -2023,43 +2023,43 @@ validate_blob (ValidateContext *ctx, { case BLOB_TYPE_FUNCTION: if (!validate_function_blob (ctx, offset, 0, error)) - return FALSE; + return FALSE; break; case BLOB_TYPE_CALLBACK: if (!validate_callback_blob (ctx, offset, error)) - return FALSE; + return FALSE; break; case BLOB_TYPE_STRUCT: case BLOB_TYPE_BOXED: if (!validate_struct_blob (ctx, offset, common->blob_type, error)) - return FALSE; + return FALSE; break; case BLOB_TYPE_ENUM: case BLOB_TYPE_FLAGS: if (!validate_enum_blob (ctx, offset, common->blob_type, error)) - return FALSE; + return FALSE; break; case BLOB_TYPE_OBJECT: if (!validate_object_blob (ctx, offset, error)) - return FALSE; + return FALSE; break; case BLOB_TYPE_INTERFACE: if (!validate_interface_blob (ctx, offset, error)) - return FALSE; + return FALSE; break; case BLOB_TYPE_CONSTANT: if (!validate_constant_blob (typelib, offset, error)) - return FALSE; + return FALSE; break; case BLOB_TYPE_UNION: if (!validate_union_blob (typelib, offset, error)) - return FALSE; + return FALSE; break; default: g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_ENTRY, - "Invalid blob type"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_ENTRY, + "Invalid blob type"); return FALSE; } @@ -2068,7 +2068,7 @@ validate_blob (ValidateContext *ctx, static gboolean validate_directory (ValidateContext *ctx, - GError **error) + GError **error) { GITypelib *typelib = ctx->typelib; Header *header = (Header *)typelib->data; @@ -2078,9 +2078,9 @@ validate_directory (ValidateContext *ctx, if (typelib->len < header->directory + header->n_entries * sizeof (DirEntry)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -2089,55 +2089,55 @@ validate_directory (ValidateContext *ctx, entry = gi_typelib_get_dir_entry (typelib, i + 1); if (!validate_name (typelib, "entry", typelib->data, entry->name, error)) - return FALSE; + return FALSE; if ((entry->local && entry->blob_type == BLOB_TYPE_INVALID) || - entry->blob_type > BLOB_TYPE_UNION) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_DIRECTORY, - "Invalid entry type"); - return FALSE; - } + entry->blob_type > BLOB_TYPE_UNION) + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_DIRECTORY, + "Invalid entry type"); + return FALSE; + } if (i < header->n_local_entries) - { - if (!entry->local) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_DIRECTORY, - "Too few local directory entries"); - return FALSE; - } + { + if (!entry->local) + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_DIRECTORY, + "Too few local directory entries"); + return FALSE; + } - if (!is_aligned (entry->offset)) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_DIRECTORY, - "Misaligned entry"); - return FALSE; - } + if (!is_aligned (entry->offset)) + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_DIRECTORY, + "Misaligned entry"); + return FALSE; + } - if (!validate_blob (ctx, entry->offset, error)) - return FALSE; - } + if (!validate_blob (ctx, entry->offset, error)) + return FALSE; + } else - { - if (entry->local) - { - g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID_DIRECTORY, - "Too many local directory entries"); - return FALSE; - } + { + if (entry->local) + { + g_set_error (error, + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID_DIRECTORY, + "Too many local directory entries"); + return FALSE; + } - if (!validate_name (typelib, "namespace", typelib->data, entry->offset, error)) - return FALSE; - } + if (!validate_name (typelib, "namespace", typelib->data, entry->offset, error)) + return FALSE; + } } return TRUE; @@ -2145,7 +2145,7 @@ validate_directory (ValidateContext *ctx, static gboolean validate_attributes (ValidateContext *ctx, - GError **error) + GError **error) { GITypelib *typelib = ctx->typelib; Header *header = (Header *)typelib->data; @@ -2153,9 +2153,9 @@ validate_attributes (ValidateContext *ctx, if (header->size < header->attributes + header->n_attributes * sizeof (AttributeBlob)) { g_set_error (error, - GI_TYPELIB_ERROR, - GI_TYPELIB_ERROR_INVALID, - "The buffer is too short"); + GI_TYPELIB_ERROR, + GI_TYPELIB_ERROR_INVALID, + "The buffer is too short"); return FALSE; } @@ -2164,8 +2164,8 @@ validate_attributes (ValidateContext *ctx, static void prefix_with_context (GError **error, - const char *section, - ValidateContext *ctx) + const char *section, + ValidateContext *ctx) { GString *str; GSList *link; @@ -2184,7 +2184,7 @@ prefix_with_context (GError **error, { g_string_append (str, link->data); if (link->next) - g_string_append_c (str, '/'); + g_string_append_c (str, '/'); } g_string_append_c (str, ')'); buf = g_string_free (str, FALSE); diff --git a/girepository/giunioninfo.c b/girepository/giunioninfo.c index 890145232..6e9434fb4 100644 --- a/girepository/giunioninfo.c +++ b/girepository/giunioninfo.c @@ -213,9 +213,9 @@ gi_union_info_get_discriminator (GIUnionInfo *info, gint offset; offset = rinfo->offset + header->union_blob_size - + blob->n_fields * header->field_blob_size - + blob->n_functions * header->function_blob_size - + n * header->constant_blob_size; + + blob->n_fields * header->field_blob_size + + blob->n_functions * header->function_blob_size + + n * header->constant_blob_size; return (GIConstantInfo *) gi_info_new (GI_INFO_TYPE_CONSTANT, (GIBaseInfo*)info, rinfo->typelib, offset); diff --git a/girepository/giunioninfo.h b/girepository/giunioninfo.h index f0e0bbdd9..fb50ed9a5 100644 --- a/girepository/giunioninfo.h +++ b/girepository/giunioninfo.h @@ -72,7 +72,7 @@ GIConstantInfo * gi_union_info_get_discriminator (GIUnionInfo *info, GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_union_info_find_method (GIUnionInfo *info, - const gchar *name); + const gchar *name); GI_AVAILABLE_IN_ALL gsize gi_union_info_get_size (GIUnionInfo *info); diff --git a/girepository/giunresolvedinfo.h b/girepository/giunresolvedinfo.h index 5ca487941..e2f68e2d6 100644 --- a/girepository/giunresolvedinfo.h +++ b/girepository/giunresolvedinfo.h @@ -39,7 +39,7 @@ G_BEGIN_DECLS * * Since: 2.80 */ -#define GI_IS_UNRESOLVED_INFO(info) \ +#define GI_IS_UNRESOLVED_INFO(info) \ (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_UNRESOLVED) G_END_DECLS From 44e45557650d35a1aadeaa315536c4cc4007d188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 15 Jan 2024 19:52:17 +0100 Subject: [PATCH 02/27] girepository/cmph-bdz-test: Avoid using unused temporary variable --- girepository/tests/cmph-bdz.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/girepository/tests/cmph-bdz.c b/girepository/tests/cmph-bdz.c index aec4f79fd..56aac0979 100644 --- a/girepository/tests/cmph-bdz.c +++ b/girepository/tests/cmph-bdz.c @@ -142,15 +142,11 @@ test_search_packed (void) int main(int argc, char **argv) { - gint ret; - g_test_init (&argc, &argv, NULL); g_test_add_func ("/cmph-bdz/search", test_search); g_test_add_func ("/cmph-bdz/search-packed", test_search_packed); - ret = g_test_run (); - - return ret; + return g_test_run (); } From eda4bfcf95afa099f365c3d5d9166394e0592758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 15 Jan 2024 20:16:00 +0100 Subject: [PATCH 03/27] girrepository: Use void* instead of gpointer --- girepository/gibaseinfo.c | 2 +- girepository/gibaseinfo.h | 6 ++---- girepository/gicallableinfo.c | 22 ++++++++++---------- girepository/gicallableinfo.h | 2 +- girepository/gifieldinfo.c | 8 ++++---- girepository/gifieldinfo.h | 4 ++-- girepository/gifunctioninfo.c | 2 +- girepository/ginvoke.c | 38 +++++++++++++++++------------------ girepository/giobjectinfo.c | 2 +- girepository/girepository.c | 2 +- girepository/girepository.h | 4 ++-- girepository/girffi.c | 14 ++++++------- girepository/girffi.h | 10 ++++----- girepository/girmodule.c | 6 +++--- girepository/girnode.c | 4 ++-- girepository/girparser.c | 24 +++++++++++----------- girepository/gitypeinfo.c | 8 ++++---- girepository/gitypeinfo.h | 8 ++++---- girepository/gitypelib.c | 2 +- girepository/gitypelib.h | 4 ++-- girepository/gitypes.h | 2 +- girepository/givfuncinfo.c | 10 ++++----- girepository/givfuncinfo.h | 2 +- girepository/gthash.c | 4 ++-- 24 files changed, 94 insertions(+), 96 deletions(-) diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c index 6a2164f18..d8876a6ad 100644 --- a/girepository/gibaseinfo.c +++ b/girepository/gibaseinfo.c @@ -64,7 +64,7 @@ value_base_info_copy_value (const GValue *src, dst->data[0].v_pointer = NULL; } -static gpointer +static void * value_base_info_peek_pointer (const GValue *value) { return value->data[0].v_pointer; diff --git a/girepository/gibaseinfo.h b/girepository/gibaseinfo.h index 41f568b53..6c0fb7e5c 100644 --- a/girepository/gibaseinfo.h +++ b/girepository/gibaseinfo.h @@ -44,10 +44,8 @@ G_BEGIN_DECLS */ typedef struct { /*< private >*/ - gpointer data; - gpointer data2; - gpointer data3; - gpointer data4; + void *data; + void *_dummy[4]; } GIAttributeIter; #define GI_TYPE_BASE_INFO (gi_base_info_get_type ()) diff --git a/girepository/gicallableinfo.c b/girepository/gicallableinfo.c index 618ae2774..70ce5706a 100644 --- a/girepository/gicallableinfo.c +++ b/girepository/gicallableinfo.c @@ -556,12 +556,12 @@ gi_type_tag_extract_ffi_return_value (GITypeTag return_tag, arg->v_int32 = (gint32) ffi_value->v_long; break; default: - arg->v_pointer = (gpointer) ffi_value->v_pointer; + arg->v_pointer = (void *) ffi_value->v_pointer; break; } break; default: - arg->v_pointer = (gpointer) ffi_value->v_pointer; + arg->v_pointer = (void *) ffi_value->v_pointer; break; } } @@ -629,7 +629,7 @@ gi_type_info_extract_ffi_return_value (GITypeInfo *return_info, */ gboolean gi_callable_info_invoke (GICallableInfo *info, - gpointer function, + void *function, const GIArgument *in_args, gsize n_in_args, GIArgument *out_args, @@ -645,12 +645,12 @@ gi_callable_info_invoke (GICallableInfo *info, GITypeTag rtag; GIArgInfo *ainfo; gsize n_args, n_invoke_args, in_pos, out_pos, i; - gpointer *args; + void **args; gboolean success = FALSE; GError *local_error = NULL; - gpointer error_address = &local_error; + void *error_address = &local_error; GIFFIReturnValue ffi_return_value; - gpointer return_value_p; /* Will point inside the union return_value */ + void *return_value_p; /* Will point inside the union return_value */ gboolean is_method, throws; rinfo = gi_callable_info_get_return_type ((GICallableInfo *)info); @@ -684,12 +684,12 @@ gi_callable_info_invoke (GICallableInfo *info, n_invoke_args ++; atypes = g_alloca (sizeof (ffi_type*) * n_invoke_args); - args = g_alloca (sizeof (gpointer) * n_invoke_args); + args = g_alloca (sizeof (void *) * n_invoke_args); if (is_method) { atypes[0] = &ffi_type_pointer; - args[0] = (gpointer) &in_args[0]; + args[0] = (void *) &in_args[0]; } for (i = 0; i < n_args; i++) { @@ -712,7 +712,7 @@ gi_callable_info_invoke (GICallableInfo *info, goto out; } - args[i+offset] = (gpointer)&in_args[in_pos]; + args[i+offset] = (void *)&in_args[in_pos]; in_pos++; break; @@ -729,7 +729,7 @@ gi_callable_info_invoke (GICallableInfo *info, goto out; } - args[i+offset] = (gpointer)&out_args[out_pos]; + args[i+offset] = (void *)&out_args[out_pos]; out_pos++; break; case GI_DIRECTION_INOUT: @@ -754,7 +754,7 @@ gi_callable_info_invoke (GICallableInfo *info, goto out; } - args[i+offset] = (gpointer)&in_args[in_pos]; + args[i+offset] = (void *)&in_args[in_pos]; in_pos++; out_pos++; break; diff --git a/girepository/gicallableinfo.h b/girepository/gicallableinfo.h index e91aef003..5d6f6d7f6 100644 --- a/girepository/gicallableinfo.h +++ b/girepository/gicallableinfo.h @@ -93,7 +93,7 @@ void gi_callable_info_load_arg (GICallableInfo *info, GI_AVAILABLE_IN_ALL gboolean gi_callable_info_invoke (GICallableInfo *info, - gpointer function, + void *function, const GIArgument *in_args, gsize n_in_args, GIArgument *out_args, diff --git a/girepository/gifieldinfo.c b/girepository/gifieldinfo.c index eb4d069ed..533c2d243 100644 --- a/girepository/gifieldinfo.c +++ b/girepository/gifieldinfo.c @@ -187,7 +187,7 @@ gi_field_info_get_type_info (GIFieldInfo *info) */ gboolean gi_field_info_get_field (GIFieldInfo *field_info, - gpointer mem, + void *mem, GIArgument *value) { int offset; @@ -205,7 +205,7 @@ gi_field_info_get_field (GIFieldInfo *field_info, if (gi_type_info_is_pointer (type_info)) { - value->v_pointer = G_STRUCT_MEMBER (gpointer, mem, offset); + value->v_pointer = G_STRUCT_MEMBER (void *, mem, offset); result = TRUE; } else @@ -383,7 +383,7 @@ gi_field_info_get_field (GIFieldInfo *field_info, */ gboolean gi_field_info_set_field (GIFieldInfo *field_info, - gpointer mem, + void *mem, const GIArgument *value) { int offset; @@ -548,7 +548,7 @@ gi_field_info_set_field (GIFieldInfo *field_info, { case GI_INFO_TYPE_OBJECT: case GI_INFO_TYPE_INTERFACE: - G_STRUCT_MEMBER (gpointer, mem, offset) = (gpointer)value->v_pointer; + G_STRUCT_MEMBER (void *, mem, offset) = (void *)value->v_pointer; result = TRUE; break; default: diff --git a/girepository/gifieldinfo.h b/girepository/gifieldinfo.h index 222751222..c7df49e54 100644 --- a/girepository/gifieldinfo.h +++ b/girepository/gifieldinfo.h @@ -58,12 +58,12 @@ GITypeInfo * gi_field_info_get_type_info (GIFieldInfo *info); GI_AVAILABLE_IN_ALL gboolean gi_field_info_get_field (GIFieldInfo *field_info, - gpointer mem, + void *mem, GIArgument *value); GI_AVAILABLE_IN_ALL gboolean gi_field_info_set_field (GIFieldInfo *field_info, - gpointer mem, + void *mem, const GIArgument *value); G_END_DECLS diff --git a/girepository/gifunctioninfo.c b/girepository/gifunctioninfo.c index d4fe5cf8a..6a0c2043b 100644 --- a/girepository/gifunctioninfo.c +++ b/girepository/gifunctioninfo.c @@ -273,7 +273,7 @@ gi_function_info_invoke (GIFunctionInfo *info, GError **error) { const gchar *symbol; - gpointer func; + void *func; symbol = gi_function_info_get_symbol (info); diff --git a/girepository/ginvoke.c b/girepository/ginvoke.c index f46c5d1b7..ec4dd4244 100644 --- a/girepository/ginvoke.c +++ b/girepository/ginvoke.c @@ -44,7 +44,7 @@ * Since: 2.80 */ static ffi_type * -value_to_ffi_type (const GValue *gvalue, gpointer *value) +value_to_ffi_type (const GValue *gvalue, void **value) { ffi_type *rettype = NULL; GType type = g_type_fundamental (G_VALUE_TYPE (gvalue)); @@ -56,12 +56,12 @@ value_to_ffi_type (const GValue *gvalue, gpointer *value) case G_TYPE_CHAR: case G_TYPE_INT: rettype = &ffi_type_sint; - *value = (gpointer)&(gvalue->data[0].v_int); + *value = (void *) &(gvalue->data[0].v_int); break; case G_TYPE_UCHAR: case G_TYPE_UINT: rettype = &ffi_type_uint; - *value = (gpointer)&(gvalue->data[0].v_uint); + *value = (void *) &(gvalue->data[0].v_uint); break; case G_TYPE_STRING: case G_TYPE_OBJECT: @@ -69,31 +69,31 @@ value_to_ffi_type (const GValue *gvalue, gpointer *value) case G_TYPE_POINTER: case G_TYPE_PARAM: rettype = &ffi_type_pointer; - *value = (gpointer)&(gvalue->data[0].v_pointer); + *value = (void *) &(gvalue->data[0].v_pointer); break; case G_TYPE_FLOAT: rettype = &ffi_type_float; - *value = (gpointer)&(gvalue->data[0].v_float); + *value = (void *) &(gvalue->data[0].v_float); break; case G_TYPE_DOUBLE: rettype = &ffi_type_double; - *value = (gpointer)&(gvalue->data[0].v_double); + *value = (void *) &(gvalue->data[0].v_double); break; case G_TYPE_LONG: rettype = &ffi_type_slong; - *value = (gpointer)&(gvalue->data[0].v_long); + *value = (void *) &(gvalue->data[0].v_long); break; case G_TYPE_ULONG: rettype = &ffi_type_ulong; - *value = (gpointer)&(gvalue->data[0].v_ulong); + *value = (void *) &(gvalue->data[0].v_ulong); break; case G_TYPE_INT64: rettype = &ffi_type_sint64; - *value = (gpointer)&(gvalue->data[0].v_int64); + *value = (void *) &(gvalue->data[0].v_int64); break; case G_TYPE_UINT64: rettype = &ffi_type_uint64; - *value = (gpointer)&(gvalue->data[0].v_uint64); + *value = (void *) &(gvalue->data[0].v_uint64); break; default: rettype = &ffi_type_pointer; @@ -122,13 +122,13 @@ value_to_ffi_type (const GValue *gvalue, gpointer *value) static ffi_type * g_value_to_ffi_return_type (const GValue *gvalue, const GIArgument *ffi_value, - gpointer *value) + void **value) { ffi_type *rettype = NULL; GType type = g_type_fundamental (G_VALUE_TYPE (gvalue)); g_assert (type != G_TYPE_INVALID); - *value = (gpointer)&(ffi_value->v_long); + *value = (void *) &(ffi_value->v_long); switch (type) { case G_TYPE_CHAR: @@ -153,11 +153,11 @@ g_value_to_ffi_return_type (const GValue *gvalue, break; case G_TYPE_FLOAT: rettype = &ffi_type_float; - *value = (gpointer)&(ffi_value->v_float); + *value = (void *) &(ffi_value->v_float); break; case G_TYPE_DOUBLE: rettype = &ffi_type_double; - *value = (gpointer)&(ffi_value->v_double); + *value = (void *) &(ffi_value->v_double); break; case G_TYPE_LONG: rettype = &ffi_type_slong; @@ -167,11 +167,11 @@ g_value_to_ffi_return_type (const GValue *gvalue, break; case G_TYPE_INT64: rettype = &ffi_type_sint64; - *value = (gpointer)&(ffi_value->v_int64); + *value = (void *) &(ffi_value->v_int64); break; case G_TYPE_UINT64: rettype = &ffi_type_uint64; - *value = (gpointer)&(ffi_value->v_uint64); + *value = (void *) &(ffi_value->v_uint64); break; default: rettype = &ffi_type_pointer; @@ -272,8 +272,8 @@ gi_cclosure_marshal_generic (GClosure *closure, GValue *return_gvalue, guint n_param_values, const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data) + void *invocation_hint, + void *marshal_data) { GIArgument return_ffi_value = { 0, }; ffi_type *rtype; @@ -298,7 +298,7 @@ gi_cclosure_marshal_generic (GClosure *closure, n_args = n_param_values + 1; atypes = g_alloca (sizeof (ffi_type *) * n_args); - args = g_alloca (sizeof (gpointer) * n_args); + args = g_alloca (sizeof (void *) * n_args); if (n_param_values > 0) { diff --git a/girepository/giobjectinfo.c b/girepository/giobjectinfo.c index 8176aff1d..e21ce4b36 100644 --- a/girepository/giobjectinfo.c +++ b/girepository/giobjectinfo.c @@ -925,7 +925,7 @@ _get_func(GIObjectInfo *info, const char* symbol; GSList *parents = NULL, *l; GIObjectInfo *parent_info; - gpointer func = NULL; + void *func = NULL; parent_info = (GIObjectInfo *) gi_base_info_ref ((GIBaseInfo *) info); while (parent_info != NULL) diff --git a/girepository/girepository.c b/girepository/girepository.c index 92f991c3c..e68eaeb5b 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -1083,7 +1083,7 @@ gi_repository_get_object_gtype_interfaces (GIRepository *repository, repository = get_repository (repository); cache = g_hash_table_lookup (repository->priv->interfaces_for_gtype, - (gpointer) gtype); + (void *) gtype); if (cache == NULL) { GType *interfaces; diff --git a/girepository/girepository.h b/girepository/girepository.h index 667ef9779..27a9a42a8 100644 --- a/girepository/girepository.h +++ b/girepository/girepository.h @@ -251,7 +251,7 @@ void gi_cclosure_marshal_generic (GClosure *closure, GValue *return_gvalue, guint n_param_values, const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); + void *invocation_hint, + void *marshal_data); G_END_DECLS diff --git a/girepository/girffi.c b/girepository/girffi.c index d80c50ff7..1629cfa16 100644 --- a/girepository/girffi.c +++ b/girepository/girffi.c @@ -276,7 +276,7 @@ gi_function_info_prep_invoker (GIFunctionInfo *info, GError **error) { const char *symbol; - gpointer addr; + void *addr; g_return_val_if_fail (info != NULL, FALSE); g_return_val_if_fail (invoker != NULL, FALSE); @@ -316,7 +316,7 @@ gi_function_info_prep_invoker (GIFunctionInfo *info, * Since: 2.80 */ gboolean -gi_function_invoker_new_for_address (gpointer addr, +gi_function_invoker_new_for_address (void *addr, GICallableInfo *info, GIFunctionInvoker *invoker, GError **error) @@ -355,8 +355,8 @@ gi_function_invoker_destroy (GIFunctionInvoker *invoker) typedef struct { ffi_closure ffi_closure; - gpointer writable_self; - gpointer native_address; + void *writable_self; + void *native_address; } GIClosureWrapper; /** @@ -377,9 +377,9 @@ ffi_closure * gi_callable_info_create_closure (GICallableInfo *callable_info, ffi_cif *cif, GIFFIClosureCallback callback, - gpointer user_data) + void *user_data) { - gpointer exec_ptr; + void *exec_ptr; size_t n_args; ffi_type **atypes; GIClosureWrapper *closure; @@ -432,7 +432,7 @@ gi_callable_info_create_closure (GICallableInfo *callable_info, * Returns: (transfer none): native address * Since: 2.80 */ -gpointer * +void ** gi_callable_info_get_closure_native_address (GICallableInfo *callable_info, ffi_closure *closure) { diff --git a/girepository/girffi.h b/girepository/girffi.h index 4125011f1..ed8c701ad 100644 --- a/girepository/girffi.h +++ b/girepository/girffi.h @@ -65,9 +65,9 @@ typedef void (*GIFFIClosureCallback) (ffi_cif *cif, */ typedef struct { ffi_cif cif; - gpointer native_address; + void *native_address; /*< private >*/ - gpointer padding[3]; + void *padding[3]; } GIFunctionInvoker; /** @@ -102,7 +102,7 @@ gboolean gi_function_info_prep_invoker (GIFunctionInfo *info, GError **error); GI_AVAILABLE_IN_ALL -gboolean gi_function_invoker_new_for_address (gpointer addr, +gboolean gi_function_invoker_new_for_address (void *addr, GICallableInfo *info, GIFunctionInvoker *invoker, GError **error); @@ -115,10 +115,10 @@ GI_AVAILABLE_IN_ALL ffi_closure * gi_callable_info_create_closure (GICallableInfo *callable_info, ffi_cif *cif, GIFFIClosureCallback callback, - gpointer user_data); + void *user_data); GI_AVAILABLE_IN_ALL -gpointer * gi_callable_info_get_closure_native_address (GICallableInfo *callable_info, +void ** gi_callable_info_get_closure_native_address (GICallableInfo *callable_info, ffi_closure *closure); GI_AVAILABLE_IN_ALL diff --git a/girepository/girmodule.c b/girepository/girmodule.c index 664915bf3..c73aaacf1 100644 --- a/girepository/girmodule.c +++ b/girepository/girmodule.c @@ -235,9 +235,9 @@ write_attributes (GIIrModule *module, return wdata.count; } -static gint -node_cmp_offset_func (gconstpointer a, - gconstpointer b) +static int +node_cmp_offset_func (const void *a, + const void *b) { const GIIrNode *na = a; const GIIrNode *nb = b; diff --git a/girepository/girnode.c b/girepository/girnode.c index 0fcde3750..5f3188adf 100644 --- a/girepository/girnode.c +++ b/girepository/girnode.c @@ -2417,8 +2417,8 @@ gi_ir_write_string (const gchar *str, guchar *data, guint32 *offset) { - gpointer value; guint32 start; + void *value; string_count += 1; string_size += strlen (str); @@ -2431,7 +2431,7 @@ gi_ir_write_string (const gchar *str, unique_string_count += 1; unique_string_size += strlen (str); - g_hash_table_insert (strings, (gpointer)str, GUINT_TO_POINTER (*offset)); + g_hash_table_insert (strings, (void *)str, GUINT_TO_POINTER (*offset)); start = *offset; *offset = ALIGN_VALUE (start + strlen (str) + 1, 4); diff --git a/girepository/girparser.c b/girepository/girparser.c index 7667c53bf..9d49798c2 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -136,20 +136,20 @@ static void start_element_handler (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, - gpointer user_data, + void *user_data, GError **error); static void end_element_handler (GMarkupParseContext *context, const gchar *element_name, - gpointer user_data, + void *user_data, GError **error); static void text_handler (GMarkupParseContext *context, const gchar *text, gsize text_len, - gpointer user_data, + void *user_data, GError **error); static void cleanup (GMarkupParseContext *context, GError *error, - gpointer user_data); + void *user_data); static void state_switch (ParseContext *ctx, ParseState newstate); @@ -222,7 +222,7 @@ firstpass_start_element_handler (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, - gpointer user_data, + void *user_data, GError **error) { ParseContext *ctx = user_data; @@ -267,7 +267,7 @@ firstpass_start_element_handler (GMarkupParseContext *context, static void firstpass_end_element_handler (GMarkupParseContext *context, const gchar *element_name, - gpointer user_data, + void *user_data, GError **error) { ParseContext *ctx = user_data; @@ -678,8 +678,8 @@ parse_type_internal (GIIrModule *module, static const char * resolve_aliases (ParseContext *ctx, const gchar *type) { - gpointer orig; - gpointer value; + void *orig; + void *value; GSList *seen_values = NULL; const gchar *lookup; gchar *prefixed; @@ -2885,7 +2885,7 @@ start_element_handler (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, - gpointer user_data, + void *user_data, GError **error) { ParseContext *ctx = user_data; @@ -3346,7 +3346,7 @@ require_end_element (GMarkupParseContext *context, static void end_element_handler (GMarkupParseContext *context, const gchar *element_name, - gpointer user_data, + void *user_data, GError **error) { ParseContext *ctx = user_data; @@ -3648,7 +3648,7 @@ static void text_handler (GMarkupParseContext *context, const gchar *text, gsize text_len, - gpointer user_data, + void *user_data, GError **error) { /* FIXME warn about non-whitespace text */ @@ -3657,7 +3657,7 @@ text_handler (GMarkupParseContext *context, static void cleanup (GMarkupParseContext *context, GError *error, - gpointer user_data) + void *user_data) { ParseContext *ctx = user_data; GList *m; diff --git a/girepository/gitypeinfo.c b/girepository/gitypeinfo.c index b292b0aef..13957f772 100644 --- a/girepository/gitypeinfo.c +++ b/girepository/gitypeinfo.c @@ -426,7 +426,7 @@ gi_type_info_get_storage_type (GITypeInfo *info) */ void gi_type_tag_argument_from_hash_pointer (GITypeTag storage_type, - gpointer hash_pointer, + void *hash_pointer, GIArgument *arg) { switch (storage_type) @@ -503,7 +503,7 @@ gi_type_tag_argument_from_hash_pointer (GITypeTag storage_type, */ void gi_type_info_argument_from_hash_pointer (GITypeInfo *info, - gpointer hash_pointer, + void *hash_pointer, GIArgument *arg) { GITypeTag storage_type = gi_type_info_get_storage_type (info); @@ -537,7 +537,7 @@ gi_type_info_argument_from_hash_pointer (GITypeInfo *info, * for example * Since: 2.80 */ -gpointer +void * gi_type_tag_hash_pointer_from_argument (GITypeTag storage_type, GIArgument *arg) { @@ -605,7 +605,7 @@ gi_type_tag_hash_pointer_from_argument (GITypeTag storage_type, * for example * Since: 2.80 */ -gpointer +void * gi_type_info_hash_pointer_from_argument (GITypeInfo *info, GIArgument *arg) { diff --git a/girepository/gitypeinfo.h b/girepository/gitypeinfo.h index 7076fdf46..dbc46ce7f 100644 --- a/girepository/gitypeinfo.h +++ b/girepository/gitypeinfo.h @@ -112,20 +112,20 @@ GITypeTag gi_type_info_get_storage_type (GITypeInfo *info); GI_AVAILABLE_IN_ALL void gi_type_info_argument_from_hash_pointer (GITypeInfo *info, - gpointer hash_pointer, + void *hash_pointer, GIArgument *arg); GI_AVAILABLE_IN_ALL -gpointer gi_type_info_hash_pointer_from_argument (GITypeInfo *info, +void * gi_type_info_hash_pointer_from_argument (GITypeInfo *info, GIArgument *arg); GI_AVAILABLE_IN_ALL void gi_type_tag_argument_from_hash_pointer (GITypeTag storage_type, - gpointer hash_pointer, + void *hash_pointer, GIArgument *arg); GI_AVAILABLE_IN_ALL -gpointer gi_type_tag_hash_pointer_from_argument (GITypeTag storage_type, +void * gi_type_tag_hash_pointer_from_argument (GITypeTag storage_type, GIArgument *arg); G_END_DECLS diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index 79191afb5..703553d05 100644 --- a/girepository/gitypelib.c +++ b/girepository/gitypelib.c @@ -2541,7 +2541,7 @@ gi_typelib_get_namespace (GITypelib *typelib) * Since: 2.80 */ gboolean -gi_typelib_symbol (GITypelib *typelib, const char *symbol_name, gpointer *symbol) +gi_typelib_symbol (GITypelib *typelib, const char *symbol_name, void **symbol) { GList *l; diff --git a/girepository/gitypelib.h b/girepository/gitypelib.h index 0f965a062..66f01ddfe 100644 --- a/girepository/gitypelib.h +++ b/girepository/gitypelib.h @@ -55,8 +55,8 @@ void gi_typelib_free (GITypelib *typelib); GI_AVAILABLE_IN_ALL gboolean gi_typelib_symbol (GITypelib *typelib, - const gchar *symbol_name, - gpointer *symbol); + const gchar *symbol_name, + void **symbol); GI_AVAILABLE_IN_ALL const gchar * gi_typelib_get_namespace (GITypelib *typelib); diff --git a/girepository/gitypes.h b/girepository/gitypes.h index eaf57b07f..5957881ca 100644 --- a/girepository/gitypes.h +++ b/girepository/gitypes.h @@ -133,7 +133,7 @@ union _GIArgument gssize v_ssize; gsize v_size; gchar * v_string; - gpointer v_pointer; + void *v_pointer; }; /** diff --git a/girepository/givfuncinfo.c b/girepository/givfuncinfo.c index 11d6c452e..ab447a4d3 100644 --- a/girepository/givfuncinfo.c +++ b/girepository/givfuncinfo.c @@ -217,7 +217,7 @@ gi_vfunc_info_get_invoker (GIVFuncInfo *info) * Returns: address to a function * Since: 2.80 */ -gpointer +void * gi_vfunc_info_get_address (GIVFuncInfo *vfunc_info, GType implementor_gtype, GError **error) @@ -228,8 +228,8 @@ gi_vfunc_info_get_address (GIVFuncInfo *vfunc_info, GIStructInfo *struct_info; GIFieldInfo *field_info = NULL; int length, i, offset; - gpointer implementor_class, implementor_vtable; - gpointer func = NULL; + void *implementor_class, *implementor_vtable; + void *func = NULL; g_return_val_if_fail (vfunc_info != NULL, NULL); g_return_val_if_fail (GI_IS_VFUNC_INFO (vfunc_info), NULL); @@ -288,7 +288,7 @@ gi_vfunc_info_get_address (GIVFuncInfo *vfunc_info, } offset = gi_field_info_get_offset (field_info); - func = *(gpointer*) G_STRUCT_MEMBER_P (implementor_vtable, offset); + func = *(void**) G_STRUCT_MEMBER_P (implementor_vtable, offset); g_type_class_unref (implementor_class); gi_base_info_unref ((GIBaseInfo *) field_info); @@ -347,7 +347,7 @@ gi_vfunc_info_invoke (GIVFuncInfo *info, GIArgument *return_value, GError **error) { - gpointer func; + void *func; GError *local_error = NULL; g_return_val_if_fail (info != NULL, FALSE); diff --git a/girepository/givfuncinfo.h b/girepository/givfuncinfo.h index cd0ed8ff1..2e0cded3b 100644 --- a/girepository/givfuncinfo.h +++ b/girepository/givfuncinfo.h @@ -56,7 +56,7 @@ GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_vfunc_info_get_invoker (GIVFuncInfo *info); GI_AVAILABLE_IN_ALL -gpointer gi_vfunc_info_get_address (GIVFuncInfo *info, +void * gi_vfunc_info_get_address (GIVFuncInfo *info, GType implementor_gtype, GError **error); diff --git a/girepository/gthash.c b/girepository/gthash.c index bc1c22a53..cdb0d8ce1 100644 --- a/girepository/gthash.c +++ b/girepository/gthash.c @@ -86,7 +86,7 @@ gi_typelib_hash_builder_prepare (GITypelibHashBuilder *builder) { char **strs; GHashTableIter hashiter; - gpointer key, value; + void *key, *value; cmph_io_adapter_t *io; cmph_config_t *config; guint32 num_elts; @@ -152,7 +152,7 @@ gi_typelib_hash_builder_pack (GITypelibHashBuilder *builder, guint8* mem, guint3 { guint16 *table; GHashTableIter hashiter; - gpointer key, value; + void *key, *value; #ifndef G_DISABLE_ASSERT guint32 num_elts; #endif From 8891429a5bda9c958e06f668b1feabea0f616e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 15 Jan 2024 20:20:47 +0100 Subject: [PATCH 04/27] girepository: Use char instead of glib-specific gchar --- girepository/gibaseinfo.c | 20 +- girepository/gibaseinfo.h | 8 +- girepository/gicallableinfo.c | 6 +- girepository/gicallableinfo.h | 4 +- girepository/gienuminfo.c | 2 +- girepository/gienuminfo.h | 2 +- girepository/gifunctioninfo.c | 8 +- girepository/gifunctioninfo.h | 2 +- girepository/giinterfaceinfo.c | 6 +- girepository/giinterfaceinfo.h | 6 +- girepository/ginvoke.c | 4 +- girepository/giobjectinfo.c | 14 +- girepository/giobjectinfo.h | 14 +- girepository/giregisteredtypeinfo.c | 4 +- girepository/giregisteredtypeinfo.h | 4 +- girepository/girepository-private.h | 8 +- girepository/girepository.c | 78 ++--- girepository/girepository.h | 52 +-- girepository/girmodule-private.h | 16 +- girepository/girmodule.c | 8 +- girepository/girnode-private.h | 64 ++-- girepository/girnode.c | 34 +- girepository/giroffsets.c | 2 +- girepository/girparser-private.h | 10 +- girepository/girparser.c | 482 ++++++++++++++-------------- girepository/girwriter.c | 104 +++--- girepository/gistructinfo.c | 6 +- girepository/gistructinfo.h | 4 +- girepository/gitypeinfo.h | 4 +- girepository/gitypelib-internal.h | 8 +- girepository/gitypelib.c | 10 +- girepository/gitypelib.h | 4 +- girepository/gitypes.h | 2 +- girepository/giunioninfo.c | 2 +- girepository/giunioninfo.h | 2 +- girepository/givfuncinfo.c | 4 +- 36 files changed, 505 insertions(+), 503 deletions(-) diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c index d8876a6ad..14b3903e5 100644 --- a/girepository/gibaseinfo.c +++ b/girepository/gibaseinfo.c @@ -96,7 +96,7 @@ value_base_info_collect_value (GValue *value, return NULL; } -static gchar * +static char * value_base_info_lcopy_value (const GValue *value, guint n_collect_values, GTypeCValue *collect_values, @@ -410,8 +410,8 @@ gi_info_from_entry (GIRepository *repository, result = gi_info_new_full (entry->blob_type, repository, NULL, typelib, entry->offset); else { - const gchar *namespace = gi_typelib_get_string (typelib, entry->offset); - const gchar *name = gi_typelib_get_string (typelib, entry->name); + const char *namespace = gi_typelib_get_string (typelib, entry->offset); + const char *name = gi_typelib_get_string (typelib, entry->name); result = gi_repository_find_by_name (repository, namespace, name); if (result == NULL) @@ -564,7 +564,7 @@ gi_base_info_get_info_type (GIBaseInfo *info) * Returns: (nullable): the name of @info or `NULL` if it lacks a name. * Since: 2.80 */ -const gchar * +const char * gi_base_info_get_name (GIBaseInfo *info) { GIRealInfo *rinfo = (GIRealInfo*)info; @@ -661,7 +661,7 @@ gi_base_info_get_name (GIBaseInfo *info) * Returns: the namespace * Since: 2.80 */ -const gchar * +const char * gi_base_info_get_namespace (GIBaseInfo *info) { GIRealInfo *rinfo = (GIRealInfo*) info; @@ -757,16 +757,16 @@ gi_base_info_is_deprecated (GIBaseInfo *info) * attribute exists * Since: 2.80 */ -const gchar * +const char * gi_base_info_get_attribute (GIBaseInfo *info, - const gchar *name) + const char *name) { GIAttributeIter iter = { 0, }; const char *curname, *curvalue; while (gi_base_info_iterate_attributes (info, &iter, &curname, &curvalue)) { if (strcmp (name, curname) == 0) - return (const gchar*) curvalue; + return (const char *) curvalue; } return NULL; @@ -865,8 +865,8 @@ _attribute_blob_find_first (GIBaseInfo *info, gboolean gi_base_info_iterate_attributes (GIBaseInfo *info, GIAttributeIter *iterator, - const gchar **name, - const gchar **value) + const char **name, + const char **value) { GIRealInfo *rinfo = (GIRealInfo *)info; Header *header = (Header *)rinfo->typelib->data; diff --git a/girepository/gibaseinfo.h b/girepository/gibaseinfo.h index 6c0fb7e5c..08feb3223 100644 --- a/girepository/gibaseinfo.h +++ b/girepository/gibaseinfo.h @@ -64,17 +64,17 @@ GI_AVAILABLE_IN_ALL GIInfoType gi_base_info_get_info_type (GIBaseInfo *info); GI_AVAILABLE_IN_ALL -const gchar * gi_base_info_get_name (GIBaseInfo *info); +const char * gi_base_info_get_name (GIBaseInfo *info); GI_AVAILABLE_IN_ALL -const gchar * gi_base_info_get_namespace (GIBaseInfo *info); +const char * gi_base_info_get_namespace (GIBaseInfo *info); GI_AVAILABLE_IN_ALL gboolean gi_base_info_is_deprecated (GIBaseInfo *info); GI_AVAILABLE_IN_ALL -const gchar * gi_base_info_get_attribute (GIBaseInfo *info, - const gchar *name); +const char * gi_base_info_get_attribute (GIBaseInfo *info, + const char *name); GI_AVAILABLE_IN_ALL gboolean gi_base_info_iterate_attributes (GIBaseInfo *info, diff --git a/girepository/gicallableinfo.c b/girepository/gicallableinfo.c index 70ce5706a..3d7e7020f 100644 --- a/girepository/gicallableinfo.c +++ b/girepository/gicallableinfo.c @@ -420,16 +420,16 @@ gi_callable_info_load_arg (GICallableInfo *info, * attribute exists * Since: 2.80 */ -const gchar * +const char * gi_callable_info_get_return_attribute (GICallableInfo *info, - const gchar *name) + const char *name) { GIAttributeIter iter = { 0, }; const char *curname, *curvalue; while (gi_callable_info_iterate_return_attributes (info, &iter, &curname, &curvalue)) { if (g_strcmp0 (name, curname) == 0) - return (const gchar*) curvalue; + return (const char*) curvalue; } return NULL; diff --git a/girepository/gicallableinfo.h b/girepository/gicallableinfo.h index 5d6f6d7f6..9a76457bc 100644 --- a/girepository/gicallableinfo.h +++ b/girepository/gicallableinfo.h @@ -61,8 +61,8 @@ void gi_callable_info_load_return_type (GICallableInfo *info, GITypeInfo *type); GI_AVAILABLE_IN_ALL -const gchar * gi_callable_info_get_return_attribute (GICallableInfo *info, - const gchar *name); +const char * gi_callable_info_get_return_attribute (GICallableInfo *info, + const char *name); GI_AVAILABLE_IN_ALL gboolean gi_callable_info_iterate_return_attributes (GICallableInfo *info, diff --git a/girepository/gienuminfo.c b/girepository/gienuminfo.c index 24e4a4cde..d0bf5105e 100644 --- a/girepository/gienuminfo.c +++ b/girepository/gienuminfo.c @@ -80,7 +80,7 @@ gi_enum_info_get_n_values (GIEnumInfo *info) * associated with this enum, or `NULL`. * Since: 2.80 */ -const gchar * +const char * gi_enum_info_get_error_domain (GIEnumInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; diff --git a/girepository/gienuminfo.h b/girepository/gienuminfo.h index c1427b566..344058aa9 100644 --- a/girepository/gienuminfo.h +++ b/girepository/gienuminfo.h @@ -74,7 +74,7 @@ GI_AVAILABLE_IN_ALL GITypeTag gi_enum_info_get_storage_type (GIEnumInfo *info); GI_AVAILABLE_IN_ALL -const gchar * gi_enum_info_get_error_domain (GIEnumInfo *info); +const char * gi_enum_info_get_error_domain (GIEnumInfo *info); GI_AVAILABLE_IN_ALL diff --git a/girepository/gifunctioninfo.c b/girepository/gifunctioninfo.c index 6a0c2043b..a79e874fe 100644 --- a/girepository/gifunctioninfo.c +++ b/girepository/gifunctioninfo.c @@ -52,7 +52,7 @@ GIFunctionInfo * gi_base_info_find_method (GIBaseInfo *base, guint32 offset, guint n_methods, - const gchar *name) + const char *name) { /* FIXME hash */ GIRealInfo *rinfo = (GIRealInfo*)base; @@ -61,7 +61,7 @@ gi_base_info_find_method (GIBaseInfo *base, for (guint i = 0; i < n_methods; i++) { FunctionBlob *fblob = (FunctionBlob *)&rinfo->typelib->data[offset]; - const gchar *fname = (const gchar *)&rinfo->typelib->data[fblob->name]; + const char *fname = (const char *)&rinfo->typelib->data[fblob->name]; if (strcmp (name, fname) == 0) return (GIFunctionInfo *) gi_info_new (GI_INFO_TYPE_FUNCTION, base, @@ -85,7 +85,7 @@ gi_base_info_find_method (GIBaseInfo *base, * Returns: the symbol * Since: 2.80 */ -const gchar * +const char * gi_function_info_get_symbol (GIFunctionInfo *info) { GIRealInfo *rinfo; @@ -272,7 +272,7 @@ gi_function_info_invoke (GIFunctionInfo *info, GIArgument *return_value, GError **error) { - const gchar *symbol; + const char *symbol; void *func; symbol = gi_function_info_get_symbol (info); diff --git a/girepository/gifunctioninfo.h b/girepository/gifunctioninfo.h index a6399df73..aa799dc90 100644 --- a/girepository/gifunctioninfo.h +++ b/girepository/gifunctioninfo.h @@ -45,7 +45,7 @@ G_BEGIN_DECLS GI_AVAILABLE_IN_ALL -const gchar * gi_function_info_get_symbol (GIFunctionInfo *info); +const char * gi_function_info_get_symbol (GIFunctionInfo *info); GI_AVAILABLE_IN_ALL GIFunctionInfoFlags gi_function_info_get_flags (GIFunctionInfo *info); diff --git a/girepository/giinterfaceinfo.c b/girepository/giinterfaceinfo.c index 61a1a8404..aad79cbad 100644 --- a/girepository/giinterfaceinfo.c +++ b/girepository/giinterfaceinfo.c @@ -228,7 +228,7 @@ gi_interface_info_get_method (GIInterfaceInfo *info, */ GIFunctionInfo * gi_interface_info_find_method (GIInterfaceInfo *info, - const gchar *name) + const char *name) { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; @@ -317,7 +317,7 @@ gi_interface_info_get_signal (GIInterfaceInfo *info, */ GISignalInfo * gi_interface_info_find_signal (GIInterfaceInfo *info, - const gchar *name) + const char *name) { guint n_signals; @@ -414,7 +414,7 @@ gi_interface_info_get_vfunc (GIInterfaceInfo *info, */ GIVFuncInfo * gi_interface_info_find_vfunc (GIInterfaceInfo *info, - const gchar *name) + const char *name) { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; diff --git a/girepository/giinterfaceinfo.h b/girepository/giinterfaceinfo.h index 80cd018ef..638f56bd4 100644 --- a/girepository/giinterfaceinfo.h +++ b/girepository/giinterfaceinfo.h @@ -67,7 +67,7 @@ GIFunctionInfo * gi_interface_info_get_method (GIInterfaceInfo *info, GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_interface_info_find_method (GIInterfaceInfo *info, - const gchar *name); + const char *name); GI_AVAILABLE_IN_ALL guint gi_interface_info_get_n_signals (GIInterfaceInfo *info); @@ -78,7 +78,7 @@ GISignalInfo * gi_interface_info_get_signal (GIInterfaceInfo *info, GI_AVAILABLE_IN_ALL GISignalInfo * gi_interface_info_find_signal (GIInterfaceInfo *info, - const gchar *name); + const char *name); GI_AVAILABLE_IN_ALL guint gi_interface_info_get_n_vfuncs (GIInterfaceInfo *info); @@ -89,7 +89,7 @@ GIVFuncInfo * gi_interface_info_get_vfunc (GIInterfaceInfo *info, GI_AVAILABLE_IN_ALL GIVFuncInfo * gi_interface_info_find_vfunc (GIInterfaceInfo *info, - const gchar *name); + const char *name); GI_AVAILABLE_IN_ALL guint gi_interface_info_get_n_constants (GIInterfaceInfo *info); diff --git a/girepository/ginvoke.c b/girepository/ginvoke.c index ec4dd4244..5b9399a20 100644 --- a/girepository/ginvoke.c +++ b/girepository/ginvoke.c @@ -212,10 +212,10 @@ g_value_from_ffi_value (GValue *gvalue, g_value_set_boolean (gvalue, (gboolean)value->v_long); break; case G_TYPE_STRING: - g_value_set_string (gvalue, (gchar*)value->v_pointer); + g_value_set_string (gvalue, (char*)value->v_pointer); break; case G_TYPE_CHAR: - g_value_set_schar (gvalue, (gchar)value->v_long); + g_value_set_schar (gvalue, (char)value->v_long); break; case G_TYPE_UCHAR: g_value_set_uchar (gvalue, (guchar)value->v_ulong); diff --git a/girepository/giobjectinfo.c b/girepository/giobjectinfo.c index e21ce4b36..097ad5f37 100644 --- a/girepository/giobjectinfo.c +++ b/girepository/giobjectinfo.c @@ -194,7 +194,7 @@ gi_object_info_get_fundamental (GIObjectInfo *info) * Returns: name of the object’s type * Since: 2.80 */ -const gchar * +const char * gi_object_info_get_type_name (GIObjectInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -218,7 +218,7 @@ gi_object_info_get_type_name (GIObjectInfo *info) * Returns: the type init function name * Since: 2.80 */ -const gchar * +const char * gi_object_info_get_type_init_function_name (GIObjectInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -466,7 +466,7 @@ gi_object_info_get_method (GIObjectInfo *info, */ GIFunctionInfo * gi_object_info_find_method (GIObjectInfo *info, - const gchar *name) + const char *name) { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; @@ -511,7 +511,7 @@ gi_object_info_find_method (GIObjectInfo *info, */ GIFunctionInfo * gi_object_info_find_method_using_interfaces (GIObjectInfo *info, - const gchar *name, + const char *name, GIObjectInfo **implementor) { GIFunctionInfo *result = NULL; @@ -627,7 +627,7 @@ gi_object_info_get_signal (GIObjectInfo *info, */ GISignalInfo * gi_object_info_find_signal (GIObjectInfo *info, - const gchar *name) + const char *name) { guint n_signals; @@ -732,7 +732,7 @@ gi_object_info_get_vfunc (GIObjectInfo *info, */ GIVFuncInfo * gi_object_info_find_vfunc (GIObjectInfo *info, - const gchar *name) + const char *name) { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; @@ -784,7 +784,7 @@ gi_object_info_find_vfunc (GIObjectInfo *info, */ GIVFuncInfo * gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *info, - const gchar *name, + const char *name, GIObjectInfo **implementor) { GIVFuncInfo *result = NULL; diff --git a/girepository/giobjectinfo.h b/girepository/giobjectinfo.h index 454965693..d0e950403 100644 --- a/girepository/giobjectinfo.h +++ b/girepository/giobjectinfo.h @@ -88,10 +88,10 @@ typedef void * (*GIObjectInfoGetValueFunction) (const GValue *value); GI_AVAILABLE_IN_ALL -const gchar * gi_object_info_get_type_name (GIObjectInfo *info); +const char * gi_object_info_get_type_name (GIObjectInfo *info); GI_AVAILABLE_IN_ALL -const gchar * gi_object_info_get_type_init_function_name (GIObjectInfo *info); +const char * gi_object_info_get_type_init_function_name (GIObjectInfo *info); GI_AVAILABLE_IN_ALL gboolean gi_object_info_get_abstract (GIObjectInfo *info); @@ -135,12 +135,12 @@ GIFunctionInfo * gi_object_info_get_method (GIObjectInfo *info, GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_object_info_find_method (GIObjectInfo *info, - const gchar *name); + const char *name); GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_object_info_find_method_using_interfaces (GIObjectInfo *info, - const gchar *name, + const char *name, GIObjectInfo **implementor); @@ -154,7 +154,7 @@ GISignalInfo * gi_object_info_get_signal (GIObjectInfo *info, GI_AVAILABLE_IN_ALL GISignalInfo * gi_object_info_find_signal (GIObjectInfo *info, - const gchar *name); + const char *name); GI_AVAILABLE_IN_ALL @@ -166,11 +166,11 @@ GIVFuncInfo * gi_object_info_get_vfunc (GIObjectInfo *info, GI_AVAILABLE_IN_ALL GIVFuncInfo * gi_object_info_find_vfunc (GIObjectInfo *info, - const gchar *name); + const char *name); GI_AVAILABLE_IN_ALL GIVFuncInfo * gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *info, - const gchar *name, + const char *name, GIObjectInfo **implementor); GI_AVAILABLE_IN_ALL diff --git a/girepository/giregisteredtypeinfo.c b/girepository/giregisteredtypeinfo.c index a937736e9..cb20a31b0 100644 --- a/girepository/giregisteredtypeinfo.c +++ b/girepository/giregisteredtypeinfo.c @@ -65,7 +65,7 @@ * Returns: (nullable): the type name, or `NULL` if unknown * Since: 2.80 */ -const gchar * +const char * gi_registered_type_info_get_type_name (GIRegisteredTypeInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -97,7 +97,7 @@ gi_registered_type_info_get_type_name (GIRegisteredTypeInfo *info) * passing into [method@GModule.Module.symbol], or `NULL` if unknown * Since: 2.80 */ -const gchar * +const char * gi_registered_type_info_get_type_init_function_name (GIRegisteredTypeInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; diff --git a/girepository/giregisteredtypeinfo.h b/girepository/giregisteredtypeinfo.h index 45a910073..4bdc9dbef 100644 --- a/girepository/giregisteredtypeinfo.h +++ b/girepository/giregisteredtypeinfo.h @@ -53,10 +53,10 @@ G_BEGIN_DECLS (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_BOXED)) GI_AVAILABLE_IN_ALL -const gchar * gi_registered_type_info_get_type_name (GIRegisteredTypeInfo *info); +const char * gi_registered_type_info_get_type_name (GIRegisteredTypeInfo *info); GI_AVAILABLE_IN_ALL -const gchar * gi_registered_type_info_get_type_init_function_name (GIRegisteredTypeInfo *info); +const char * gi_registered_type_info_get_type_init_function_name (GIRegisteredTypeInfo *info); GI_AVAILABLE_IN_ALL GType gi_registered_type_info_get_g_type (GIRegisteredTypeInfo *info); diff --git a/girepository/girepository-private.h b/girepository/girepository-private.h index 0146fcdf0..a9fb655ef 100644 --- a/girepository/girepository-private.h +++ b/girepository/girepository-private.h @@ -203,8 +203,8 @@ struct _GIUnresolvedInfo { GIBaseInfo parent; - const gchar *name; - const gchar *namespace; + const char *name; + const char *namespace; }; void gi_unresolved_info_class_init (gpointer g_class, @@ -239,9 +239,9 @@ void gi_type_info_init (GIBaseInfo *info, GIFunctionInfo * gi_base_info_find_method (GIBaseInfo *base, guint32 offset, guint n_methods, - const gchar *name); + const char *name); GIVFuncInfo * gi_base_info_find_vfunc (GIRealInfo *rinfo, guint32 offset, guint n_vfuncs, - const gchar *name); + const char *name); diff --git a/girepository/girepository.c b/girepository/girepository.c index e68eaeb5b..cd8512448 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -203,7 +203,7 @@ init_globals (void) { const char *libdir; char *typelib_dir; - const gchar *type_lib_path_env; + const char *type_lib_path_env; /* This variable is intended to take precedence over both: * - the default search path; @@ -213,7 +213,7 @@ init_globals (void) if (type_lib_path_env) { - gchar **custom_dirs; + char **custom_dirs; custom_dirs = g_strsplit (type_lib_path_env, G_SEARCHPATH_SEPARATOR_S, 0); typelib_search_path = @@ -324,8 +324,8 @@ get_repository (GIRepository *repository) static GITypelib * check_version_conflict (GITypelib *typelib, - const gchar *namespace, - const gchar *expected_version, + const char *namespace, + const char *expected_version, char **version_conflict) { Header *header; @@ -432,7 +432,7 @@ register_internal (GIRepository *repository, GError **error) { Header *header; - const gchar *namespace; + const char *namespace; g_return_val_if_fail (typelib != NULL, FALSE); @@ -502,7 +502,7 @@ gi_repository_get_immediate_dependencies (GIRepository *repository, const char *namespace) { GITypelib *typelib; - gchar **deps; + char **deps; g_return_val_if_fail (namespace != NULL, NULL); @@ -528,16 +528,16 @@ get_typelib_dependencies_transitive (GIRepository *repository, GITypelib *typelib, GHashTable *transitive_dependencies) { - gchar **immediate_dependencies; guint i; + char **immediate_dependencies; immediate_dependencies = get_typelib_dependencies (typelib); for (i = 0; immediate_dependencies != NULL && immediate_dependencies[i]; i++) { - gchar *dependency; - const gchar *last_dash; - gchar *dependency_namespace; + char *dependency; + const char *last_dash; + char *dependency_namespace; dependency = immediate_dependencies[i]; @@ -589,7 +589,7 @@ gi_repository_get_dependencies (GIRepository *repository, GITypelib *typelib; GHashTable *transitive_dependencies; /* set of owned utf8 */ GHashTableIter iter; - gchar *dependency; + char *dependency; GPtrArray *out; /* owned utf8 elements */ g_return_val_if_fail (namespace != NULL, NULL); @@ -618,7 +618,7 @@ gi_repository_get_dependencies (GIRepository *repository, g_hash_table_unref (transitive_dependencies); - return (gchar **) g_ptr_array_free (out, FALSE); + return (char **) g_ptr_array_free (out, FALSE); } /** @@ -691,8 +691,8 @@ gi_repository_load_typelib (GIRepository *repository, */ gboolean gi_repository_is_registered (GIRepository *repository, - const gchar *namespace, - const gchar *version) + const char *namespace, + const char *version) { repository = get_repository (repository); return get_registered (repository, namespace, version) != NULL; @@ -755,7 +755,7 @@ gi_repository_new (void) */ guint gi_repository_get_n_infos (GIRepository *repository, - const gchar *namespace) + const char *namespace) { GITypelib *typelib; guint n_interfaces = 0; @@ -793,7 +793,7 @@ gi_repository_get_n_infos (GIRepository *repository, */ GIBaseInfo * gi_repository_get_info (GIRepository *repository, - const gchar *namespace, + const char *namespace, guint idx) { GITypelib *typelib; @@ -816,7 +816,7 @@ gi_repository_get_info (GIRepository *repository, } typedef struct { - const gchar *gtype_name; + const char *gtype_name; GITypelib *result_typelib; } FindByGTypeData; @@ -948,8 +948,8 @@ gi_repository_find_by_gtype (GIRepository *repository, */ GIBaseInfo * gi_repository_find_by_name (GIRepository *repository, - const gchar *namespace, - const gchar *name) + const char *namespace, + const char *name) { GITypelib *typelib; DirEntry *entry; @@ -1149,11 +1149,11 @@ collect_namespaces (gpointer key, * list of namespaces * Since: 2.80 */ -gchar ** +char ** gi_repository_get_loaded_namespaces (GIRepository *repository) { GList *l, *list = NULL; - gchar **names; + char **names; gint i; repository = get_repository (repository); @@ -1161,7 +1161,7 @@ gi_repository_get_loaded_namespaces (GIRepository *repository) g_hash_table_foreach (repository->priv->typelibs, collect_namespaces, &list); g_hash_table_foreach (repository->priv->lazy_typelibs, collect_namespaces, &list); - names = g_malloc0 (sizeof (gchar *) * (g_list_length (list) + 1)); + names = g_malloc0 (sizeof (char *) * (g_list_length (list) + 1)); i = 0; for (l = list; l; l = l->next) names[i++] = g_strdup (l->data); @@ -1186,9 +1186,9 @@ gi_repository_get_loaded_namespaces (GIRepository *repository) * Returns: Loaded version * Since: 2.80 */ -const gchar * +const char * gi_repository_get_version (GIRepository *repository, - const gchar *namespace) + const char *namespace) { GITypelib *typelib; Header *header; @@ -1232,7 +1232,7 @@ gi_repository_get_version (GIRepository *repository, */ const char * const * gi_repository_get_shared_libraries (GIRepository *repository, - const gchar *namespace, + const char *namespace, size_t *out_n_elements) { GITypelib *typelib; @@ -1291,9 +1291,9 @@ gi_repository_get_shared_libraries (GIRepository *repository, * Returns: (nullable): C namespace prefix, or `NULL` if none associated * Since: 2.80 */ -const gchar * +const char * gi_repository_get_c_prefix (GIRepository *repository, - const gchar *namespace_) + const char *namespace_) { GITypelib *typelib; Header *header; @@ -1329,9 +1329,9 @@ gi_repository_get_c_prefix (GIRepository *repository, * successful, `NULL` if namespace is not loaded * Since: 2.80 */ -const gchar * +const char * gi_repository_get_typelib_path (GIRepository *repository, - const gchar *namespace) + const char *namespace) { gpointer orig_key, value; @@ -1629,12 +1629,12 @@ find_namespace_latest (const char *namespace, */ char ** gi_repository_enumerate_versions (GIRepository *repository, - const gchar *namespace_, + const char *namespace_, size_t *n_versions_out) { GPtrArray *versions; GSList *candidates, *link; - const gchar *loaded_version; + const char *loaded_version; char **ret; init_globals (); @@ -1689,7 +1689,7 @@ require_internal (GIRepository *repository, GITypelib *ret = NULL; Header *header; GITypelib *typelib = NULL; - const gchar *typelib_namespace, *typelib_version; + const char *typelib_namespace, *typelib_version; gboolean allow_lazy = (flags & GI_REPOSITORY_LOAD_FLAG_LAZY) > 0; gboolean is_lazy; char *version_conflict = NULL; @@ -1814,8 +1814,8 @@ require_internal (GIRepository *repository, */ GITypelib * gi_repository_require (GIRepository *repository, - const gchar *namespace, - const gchar *version, + const char *namespace, + const char *version, GIRepositoryLoadFlags flags, GError **error) { @@ -1853,9 +1853,9 @@ gi_repository_require (GIRepository *repository, */ GITypelib * gi_repository_require_private (GIRepository *repository, - const gchar *typelib_dir, - const gchar *namespace, - const gchar *version, + const char *typelib_dir, + const char *namespace, + const char *version, GIRepositoryLoadFlags flags, GError **error) { @@ -1931,7 +1931,7 @@ gi_repository_error_quark (void) * Returns: the string * Since: 2.80 */ -const gchar* +const char * gi_type_tag_to_string (GITypeTag type) { switch (type) @@ -1994,7 +1994,7 @@ gi_type_tag_to_string (GITypeTag type) * Returns: the string * Since: 2.80 */ -const gchar* +const char * gi_info_type_to_string (GIInfoType type) { switch (type) diff --git a/girepository/girepository.h b/girepository/girepository.h index 27a9a42a8..6f8883d99 100644 --- a/girepository/girepository.h +++ b/girepository/girepository.h @@ -119,44 +119,44 @@ const char * gi_repository_load_typelib (GIRepository *repository, GI_AVAILABLE_IN_ALL gboolean gi_repository_is_registered (GIRepository *repository, - const gchar *namespace_, - const gchar *version); + const char *namespace_, + const char *version); GI_AVAILABLE_IN_ALL GIBaseInfo * gi_repository_find_by_name (GIRepository *repository, - const gchar *namespace_, - const gchar *name); + const char *namespace_, + const char *name); GI_AVAILABLE_IN_ALL char ** gi_repository_enumerate_versions (GIRepository *repository, - const gchar *namespace_, + const char *namespace_, size_t *n_versions_out); GI_AVAILABLE_IN_ALL GITypelib * gi_repository_require (GIRepository *repository, - const gchar *namespace_, - const gchar *version, + const char *namespace_, + const char *version, GIRepositoryLoadFlags flags, GError **error); GI_AVAILABLE_IN_ALL GITypelib * gi_repository_require_private (GIRepository *repository, - const gchar *typelib_dir, - const gchar *namespace_, - const gchar *version, + const char *typelib_dir, + const char *namespace_, + const char *version, GIRepositoryLoadFlags flags, GError **error); GI_AVAILABLE_IN_ALL -gchar ** gi_repository_get_immediate_dependencies (GIRepository *repository, - const gchar *namespace_); +char ** gi_repository_get_immediate_dependencies (GIRepository *repository, + const char *namespace_); GI_AVAILABLE_IN_ALL -gchar ** gi_repository_get_dependencies (GIRepository *repository, - const gchar *namespace_); +char ** gi_repository_get_dependencies (GIRepository *repository, + const char *namespace_); GI_AVAILABLE_IN_ALL -gchar ** gi_repository_get_loaded_namespaces (GIRepository *repository); +char ** gi_repository_get_loaded_namespaces (GIRepository *repository); GI_AVAILABLE_IN_ALL GIBaseInfo * gi_repository_find_by_gtype (GIRepository *repository, @@ -170,11 +170,11 @@ void gi_repository_get_object_gtype_interfaces (GIRepository *repo GI_AVAILABLE_IN_ALL guint gi_repository_get_n_infos (GIRepository *repository, - const gchar *namespace_); + const char *namespace_); GI_AVAILABLE_IN_ALL GIBaseInfo * gi_repository_get_info (GIRepository *repository, - const gchar *namespace_, + const char *namespace_, guint idx); GI_AVAILABLE_IN_ALL @@ -182,18 +182,18 @@ GIEnumInfo * gi_repository_find_by_error_domain (GIRepository *repository, GQuark domain); GI_AVAILABLE_IN_ALL -const gchar * gi_repository_get_typelib_path (GIRepository *repository, - const gchar *namespace_); +const char * gi_repository_get_typelib_path (GIRepository *repository, + const char *namespace_); GI_AVAILABLE_IN_ALL -const gchar * const *gi_repository_get_shared_libraries (GIRepository *repository, - const gchar *namespace_, - size_t *out_n_elements); +const char * const *gi_repository_get_shared_libraries (GIRepository *repository, + const char *namespace_, + size_t *out_n_elements); GI_AVAILABLE_IN_ALL -const gchar * gi_repository_get_c_prefix (GIRepository *repository, - const gchar *namespace_); +const char * gi_repository_get_c_prefix (GIRepository *repository, + const char *namespace_); GI_AVAILABLE_IN_ALL -const gchar * gi_repository_get_version (GIRepository *repository, - const gchar *namespace_); +const char * gi_repository_get_version (GIRepository *repository, + const char *namespace_); GI_AVAILABLE_IN_ALL diff --git a/girepository/girmodule-private.h b/girepository/girmodule-private.h index ef386638d..d99a5d3b4 100644 --- a/girepository/girmodule-private.h +++ b/girepository/girmodule-private.h @@ -43,10 +43,10 @@ struct _GIIrTypelibBuild { struct _GIIrModule { - gchar *name; - gchar *version; - gchar *shared_library; - gchar *c_prefix; + char *name; + char *version; + char *shared_library; + char *c_prefix; GList *dependencies; GList *entries; @@ -66,10 +66,10 @@ struct _GIIrModule GHashTable *disguised_structures; }; -GIIrModule *gi_ir_module_new (const gchar *name, - const gchar *nsversion, - const gchar *module_filename, - const gchar *c_prefix); +GIIrModule *gi_ir_module_new (const char *name, + const char *nsversion, + const char *module_filename, + const char *c_prefix); void gi_ir_module_free (GIIrModule *module); void gi_ir_module_add_include_module (GIIrModule *module, diff --git a/girepository/girmodule.c b/girepository/girmodule.c index c73aaacf1..f7850632c 100644 --- a/girepository/girmodule.c +++ b/girepository/girmodule.c @@ -38,10 +38,10 @@ #define NUM_SECTIONS 2 GIIrModule * -gi_ir_module_new (const gchar *name, - const gchar *version, - const gchar *shared_library, - const gchar *c_prefix) +gi_ir_module_new (const char *name, + const char *version, + const char *shared_library, + const char *c_prefix) { GIIrModule *module; diff --git a/girepository/girnode-private.h b/girepository/girnode-private.h index 61a3794f1..21f034423 100644 --- a/girepository/girnode-private.h +++ b/girepository/girnode-private.h @@ -73,7 +73,7 @@ typedef enum struct _GIIrNode { GIIrNodeTypeId type; - gchar *name; + char *name; GIIrModule *module; guint32 offset; /* Assigned as we build the typelib */ @@ -85,7 +85,7 @@ struct _GIIrNodeXRef { GIIrNode node; - gchar *namespace; + char *namespace; }; struct _GIIrNodeFunction @@ -103,7 +103,7 @@ struct _GIIrNodeFunction gboolean throws; gboolean instance_transfer_full; - gchar *symbol; + char *symbol; char *property; GIIrNodeParam *result; @@ -124,7 +124,7 @@ struct _GIIrNodeType gboolean is_error; gint tag; - gchar *unparsed; + char *unparsed; gboolean zero_terminated; gboolean has_length; @@ -136,8 +136,8 @@ struct _GIIrNodeType GIIrNodeType *parameter_type1; GIIrNodeType *parameter_type2; - gchar *giinterface; - gchar **errors; + char *giinterface; + char **errors; }; struct _GIIrNodeParam @@ -167,7 +167,7 @@ struct _GIIrNodeProperty gboolean deprecated; - gchar *name; + char *name; gboolean readable; gboolean writable; gboolean construct; @@ -247,16 +247,16 @@ struct _GIIrNodeInterface gboolean fundamental; gboolean final_; - gchar *gtype_name; - gchar *gtype_init; + char *gtype_name; + char *gtype_init; - gchar *ref_func; - gchar *unref_func; - gchar *set_value_func; - gchar *get_value_func; + char *ref_func; + char *unref_func; + char *set_value_func; + char *get_value_func; - gchar *parent; - gchar *glib_type_struct; + char *parent; + char *glib_type_struct; GList *interfaces; GList *prerequisites; @@ -284,7 +284,7 @@ struct _GIIrNodeConstant GIIrNodeType *type; - gchar *value; + char *value; }; struct _GIIrNodeEnum @@ -294,9 +294,9 @@ struct _GIIrNodeEnum gboolean deprecated; gint storage_type; - gchar *gtype_name; - gchar *gtype_init; - gchar *error_domain; + char *gtype_name; + char *gtype_init; + char *error_domain; GList *values; GList *methods; @@ -308,8 +308,8 @@ struct _GIIrNodeBoxed gboolean deprecated; - gchar *gtype_name; - gchar *gtype_init; + char *gtype_name; + char *gtype_init; gint alignment; gint size; @@ -328,11 +328,11 @@ struct _GIIrNodeStruct gboolean is_gtype_struct; gboolean foreign; - gchar *gtype_name; - gchar *gtype_init; + char *gtype_name; + char *gtype_init; - gchar *copy_func; - gchar *free_func; + char *copy_func; + char *free_func; gint alignment; gint size; @@ -349,11 +349,11 @@ struct _GIIrNodeUnion GList *members; GList *discriminators; - gchar *gtype_name; - gchar *gtype_init; + char *gtype_name; + char *gtype_init; - gchar *copy_func; - gchar *free_func; + char *copy_func; + char *free_func; gint alignment; gint size; @@ -379,13 +379,13 @@ int gi_ir_node_cmp (GIIrNode *node, gboolean gi_ir_node_can_have_member (GIIrNode *node); void gi_ir_node_add_member (GIIrNode *node, GIIrNodeFunction *member); -guint32 gi_ir_write_string (const gchar *str, +guint32 gi_ir_write_string (const char *str, GHashTable *strings, guchar *data, guint32 *offset); -const gchar * gi_ir_node_param_direction_string (GIIrNodeParam * node); -const gchar * gi_ir_node_type_to_string (GIIrNodeTypeId type); +const char * gi_ir_node_param_direction_string (GIIrNodeParam * node); +const char * gi_ir_node_type_to_string (GIIrNodeTypeId type); GIIrNode *gi_ir_find_node (GIIrTypelibBuild *build, GIIrModule *module, diff --git a/girepository/girnode.c b/girepository/girnode.c index 5f3188adf..6da186e86 100644 --- a/girepository/girnode.c +++ b/girepository/girnode.c @@ -74,7 +74,7 @@ do { \ (( ((unsigned long)(this)) + (((unsigned long)(boundary)) -1)) & (~(((unsigned long)(boundary))-1))) -const gchar * +const char * gi_ir_node_type_to_string (GIIrNodeTypeId type) { switch (type) @@ -573,8 +573,8 @@ gi_ir_node_get_size (GIIrNode *node) static void add_attribute_size (gpointer key, gpointer value, gpointer data) { - const gchar *key_str = key; - const gchar *value_str = value; + const char *key_str = key; + const char *value_str = value; gint *size_p = data; *size_p += sizeof (AttributeBlob); @@ -996,7 +996,7 @@ gi_ir_node_add_member (GIIrNode *node, } } -const gchar * +const char * gi_ir_node_param_direction_string (GIIrNodeParam * node) { if (node->out) @@ -1010,25 +1010,25 @@ gi_ir_node_param_direction_string (GIIrNodeParam * node) } static gint64 -parse_int_value (const gchar *str) +parse_int_value (const char *str) { return g_ascii_strtoll (str, NULL, 0); } static guint64 -parse_uint_value (const gchar *str) +parse_uint_value (const char *str) { return g_ascii_strtoull (str, NULL, 0); } static gdouble -parse_float_value (const gchar *str) +parse_float_value (const char *str) { return g_ascii_strtod (str, NULL); } static gboolean -parse_boolean_value (const gchar *str) +parse_boolean_value (const char *str) { if (g_ascii_strcasecmp (str, "TRUE") == 0) return TRUE; @@ -1041,15 +1041,15 @@ parse_boolean_value (const gchar *str) static GIIrNode * find_entry_node (GIIrTypelibBuild *build, - const gchar *name, + const char *name, guint16 *idx) { GIIrModule *module = build->module; GList *l; gint i; - gchar **names; gint n_names; + char **names; GIIrNode *result = NULL; g_assert (name != NULL); @@ -1114,7 +1114,7 @@ find_entry_node (GIIrTypelibBuild *build, static guint16 find_entry (GIIrTypelibBuild *build, - const gchar *name) + const char *name) { guint16 idx = 0; @@ -1271,7 +1271,7 @@ serialize_type (GIIrTypelibBuild *build, else if (node->tag == GI_TYPE_TAG_INTERFACE) { GIIrNode *iface; - gchar *name; + char *name; iface = find_entry_node (build, node->giinterface, NULL); if (iface) @@ -1455,7 +1455,7 @@ gi_ir_node_build_typelib (GIIrNode *node, else { GString *str; - gchar *s; + char *s; gpointer value; str = g_string_new (0); @@ -2204,7 +2204,7 @@ gi_ir_node_build_typelib (GIIrNode *node, for (l = object->interfaces; l; l = l->next) { blob->n_interfaces++; - *(guint16*)&data[*offset] = find_entry (build, (gchar *)l->data); + *(guint16*)&data[*offset] = find_entry (build, (char *)l->data); *offset += 2; } @@ -2267,7 +2267,7 @@ gi_ir_node_build_typelib (GIIrNode *node, for (l = iface->prerequisites; l; l = l->next) { blob->n_prerequisites++; - *(guint16*)&data[*offset] = find_entry (build, (gchar *)l->data); + *(guint16*)&data[*offset] = find_entry (build, (char *)l->data); *offset += 2; } @@ -2412,7 +2412,7 @@ gi_ir_node_build_typelib (GIIrNode *node, * typelib is not large enough to hold the string, reallocate it. */ guint32 -gi_ir_write_string (const gchar *str, +gi_ir_write_string (const char *str, GHashTable *strings, guchar *data, guint32 *offset) @@ -2436,7 +2436,7 @@ gi_ir_write_string (const gchar *str, start = *offset; *offset = ALIGN_VALUE (start + strlen (str) + 1, 4); - strcpy ((gchar*)&data[start], str); + strcpy ((char *)&data[start], str); return start; } diff --git a/girepository/giroffsets.c b/girepository/giroffsets.c index 3a443c6b6..8031e03a8 100644 --- a/girepository/giroffsets.c +++ b/girepository/giroffsets.c @@ -337,7 +337,7 @@ get_field_size_alignment (GIIrTypelibBuild *build, gint *alignment) { GIIrModule *module = build->module; - gchar *who; + char *who; gboolean success; who = g_strdup_printf ("field %s.%s.%s", module->name, parent_node->name, ((GIIrNode *)field)->name); diff --git a/girepository/girparser-private.h b/girepository/girparser-private.h index a2dcb6a85..473b08c19 100644 --- a/girepository/girparser-private.h +++ b/girepository/girparser-private.h @@ -34,16 +34,16 @@ typedef struct _GIIrParser GIIrParser; GIIrParser *gi_ir_parser_new (void); void gi_ir_parser_free (GIIrParser *parser); void gi_ir_parser_set_includes (GIIrParser *parser, - const gchar *const *includes); + const char *const *includes); GIIrModule *gi_ir_parser_parse_string (GIIrParser *parser, - const gchar *namespace, - const gchar *filename, - const gchar *buffer, + const char *namespace, + const char *filename, + const char *buffer, gssize length, GError **error); GIIrModule *gi_ir_parser_parse_file (GIIrParser *parser, - const gchar *filename, + const char *filename, GError **error); G_END_DECLS diff --git a/girepository/girparser.c b/girepository/girparser.c index 9d49798c2..1ad0562e5 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -58,8 +58,8 @@ struct _GIIrParser { - gchar **includes; - gchar **gi_gir_path; + char **includes; + char **gi_gir_path; GList *parsed_modules; /* All previously parsed modules */ }; @@ -133,17 +133,17 @@ struct _ParseContext #define CURRENT_NODE(ctx) ((GIIrNode *)((ctx)->node_stack->data)) static void start_element_handler (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, void *user_data, GError **error); static void end_element_handler (GMarkupParseContext *context, - const gchar *element_name, + const char *element_name, void *user_data, GError **error); static void text_handler (GMarkupParseContext *context, - const gchar *text, + const char *text, gsize text_len, void *user_data, GError **error); @@ -164,22 +164,22 @@ static GMarkupParser markup_parser = static gboolean start_alias (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error); static gboolean start_type (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error); -static const gchar *find_attribute (const gchar *name, - const gchar **attribute_names, - const gchar **attribute_values); +static const char *find_attribute (const char *name, + const char **attribute_names, + const char **attribute_values); GIIrParser * @@ -210,7 +210,7 @@ gi_ir_parser_free (GIIrParser *parser) void gi_ir_parser_set_includes (GIIrParser *parser, - const gchar *const *includes) + const char *const *includes) { g_strfreev (parser->includes); @@ -219,9 +219,9 @@ gi_ir_parser_set_includes (GIIrParser *parser, static void firstpass_start_element_handler (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, void *user_data, GError **error) { @@ -239,9 +239,9 @@ firstpass_start_element_handler (GMarkupParseContext *context, } else if (strcmp (element_name, "record") == 0) { - const gchar *name; - const gchar *disguised; - const gchar *pointer; + const char *name; + const char *disguised; + const char *pointer; name = find_attribute ("name", attribute_names, attribute_values); disguised = find_attribute ("disguised", attribute_names, attribute_values); @@ -266,7 +266,7 @@ firstpass_start_element_handler (GMarkupParseContext *context, static void firstpass_end_element_handler (GMarkupParseContext *context, - const gchar *element_name, + const char *element_name, void *user_data, GError **error) { @@ -294,8 +294,8 @@ static char * locate_gir (GIIrParser *parser, const char *girname) { - const gchar *const *datadirs; - const gchar *const *dir; + const char *const *datadirs; + const char *const *dir; char *path = NULL; g_debug ("Looking for %s", girname); @@ -303,7 +303,7 @@ locate_gir (GIIrParser *parser, if (parser->includes != NULL) { - for (dir = (const gchar *const *)parser->includes; *dir; dir++) + for (dir = (const char *const *)parser->includes; *dir; dir++) { path = g_build_filename (*dir, girname, NULL); g_debug ("Trying %s from includes", path); @@ -315,7 +315,7 @@ locate_gir (GIIrParser *parser, if (parser->gi_gir_path != NULL) { - for (dir = (const gchar *const *) parser->gi_gir_path; *dir; dir++) + for (dir = (const char *const *) parser->gi_gir_path; *dir; dir++) { if (**dir == '\0') continue; @@ -378,10 +378,10 @@ locate_gir (GIIrParser *parser, line_number, char_number, attribute, element); \ } while (0) -static const gchar * -find_attribute (const gchar *name, - const gchar **attribute_names, - const gchar **attribute_values) +static const char * +find_attribute (const char *name, + const char **attribute_names, + const char **attribute_values) { gint i; @@ -428,11 +428,13 @@ push_node (ParseContext *ctx, GIIrNode *node) } static GIIrNodeType * parse_type_internal (GIIrModule *module, - const gchar *str, gchar **next, gboolean in_glib, + const char *str, + char **next, + gboolean in_glib, gboolean in_gobject); typedef struct { - const gchar *str; + const char *str; guint size; guint is_signed : 1; } IntegerAliasInfo; @@ -453,7 +455,7 @@ static IntegerAliasInfo integer_aliases[] = { }; typedef struct { - const gchar *str; + const char *str; gint tag; gboolean pointer; } BasicTypeInfo; @@ -532,7 +534,7 @@ parse_basic (const char *str) static GIIrNodeType * parse_type_internal (GIIrModule *module, - const gchar *str, + const char *str, char **next, gboolean in_glib, gboolean in_gobject) @@ -676,13 +678,13 @@ parse_type_internal (GIIrModule *module, } static const char * -resolve_aliases (ParseContext *ctx, const gchar *type) +resolve_aliases (ParseContext *ctx, const char *type) { void *orig; void *value; GSList *seen_values = NULL; - const gchar *lookup; - gchar *prefixed; + const char *lookup; + char *prefixed; if (strchr (type, '.') == NULL) { @@ -717,12 +719,12 @@ resolve_aliases (ParseContext *ctx, const gchar *type) static void is_pointer_or_disguised_structure (ParseContext *ctx, - const gchar *type, + const char *type, gboolean *is_pointer, gboolean *is_disguised) { - const gchar *lookup; - gchar *prefixed; + const char *lookup; + char *prefixed; if (strchr (type, '.') == NULL) { @@ -744,7 +746,7 @@ is_pointer_or_disguised_structure (ParseContext *ctx, } static GIIrNodeType * -parse_type (ParseContext *ctx, const gchar *type) +parse_type (ParseContext *ctx, const char *type) { GIIrNodeType *node; const BasicTypeInfo *basic; @@ -769,13 +771,13 @@ parse_type (ParseContext *ctx, const gchar *type) static gboolean introspectable_prelude (GMarkupParseContext *context, - const gchar **attribute_names, - const gchar **attribute_values, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, ParseState new_state) { - const gchar *introspectable_arg; - const gchar *shadowed_by; + const char *introspectable_arg; + const char *shadowed_by; gboolean introspectable; g_assert (ctx->state != STATE_PASSTHROUGH); @@ -795,16 +797,16 @@ introspectable_prelude (GMarkupParseContext *context, static gboolean start_glib_boxed (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { - const gchar *name; - const gchar *typename; - const gchar *typeinit; - const gchar *deprecated; + const char *name; + const char *typename; + const char *typeinit; + const char *deprecated; GIIrNodeBoxed *boxed; if (!(strcmp (element_name, "glib:boxed") == 0 && @@ -855,19 +857,19 @@ start_glib_boxed (GMarkupParseContext *context, static gboolean start_function (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { - const gchar *name; - const gchar *shadows; - const gchar *symbol; - const gchar *deprecated; - const gchar *throws; - const gchar *set_property; - const gchar *get_property; + const char *name; + const char *shadows; + const char *symbol; + const char *deprecated; + const char *throws; + const char *set_property; + const char *get_property; GIIrNodeFunction *function; gboolean found = FALSE; ParseState in_embedded_state = STATE_NONE; @@ -1055,7 +1057,7 @@ start_function (GMarkupParseContext *context, static void parse_property_transfer (GIIrNodeProperty *property, - const gchar *transfer, + const char *transfer, ParseContext *ctx) { if (transfer == NULL) @@ -1095,7 +1097,7 @@ parse_property_transfer (GIIrNodeProperty *property, } static gboolean -parse_param_transfer (GIIrNodeParam *param, const gchar *transfer, const gchar *name, +parse_param_transfer (GIIrNodeParam *param, const char *transfer, const char *name, GError **error) { if (transfer == NULL) @@ -1132,13 +1134,13 @@ parse_param_transfer (GIIrNodeParam *param, const gchar *transfer, const gchar * static gboolean start_instance_parameter (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { - const gchar *transfer; + const char *transfer; gboolean transfer_full; if (!(strcmp (element_name, "instance-parameter") == 0 && @@ -1197,24 +1199,24 @@ start_instance_parameter (GMarkupParseContext *context, static gboolean start_parameter (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { - const gchar *name; - const gchar *direction; - const gchar *retval; - const gchar *optional; - const gchar *caller_allocates; - const gchar *allow_none; - const gchar *transfer; - const gchar *scope; - const gchar *closure; - const gchar *destroy; - const gchar *skip; - const gchar *nullable; + const char *name; + const char *direction; + const char *retval; + const char *optional; + const char *caller_allocates; + const char *allow_none; + const char *transfer; + const char *scope; + const char *closure; + const char *destroy; + const char *skip; + const char *nullable; GIIrNodeParam *param; if (!(strcmp (element_name, "parameter") == 0 && @@ -1350,17 +1352,17 @@ start_parameter (GMarkupParseContext *context, static gboolean start_field (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { - const gchar *name; - const gchar *readable; - const gchar *writable; - const gchar *bits; - const gchar *branch; + const char *name; + const char *readable; + const char *writable; + const char *bits; + const char *branch; GIIrNodeField *field; ParseState target_state; gboolean introspectable; @@ -1495,13 +1497,13 @@ start_field (GMarkupParseContext *context, static gboolean start_alias (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { - const gchar *name; + const char *name; name = find_attribute ("name", attribute_names, attribute_values); if (name == NULL) @@ -1518,17 +1520,17 @@ start_alias (GMarkupParseContext *context, static gboolean start_enum (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { - const gchar *name; - const gchar *typename; - const gchar *typeinit; - const gchar *deprecated; - const gchar *error_domain; + const char *name; + const char *typename; + const char *typeinit; + const char *deprecated; + const char *error_domain; GIIrNodeEnum *enum_; if (!((strcmp (element_name, "enumeration") == 0 && ctx->state == STATE_NAMESPACE) || @@ -1575,21 +1577,21 @@ start_enum (GMarkupParseContext *context, static gboolean start_property (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { ParseState target_state; - const gchar *name; - const gchar *readable; - const gchar *writable; - const gchar *construct; - const gchar *construct_only; - const gchar *transfer; - const gchar *setter; - const gchar *getter; + const char *name; + const char *readable; + const char *writable; + const char *construct; + const char *construct_only; + const char *transfer; + const char *setter; + const char *getter; GIIrNodeProperty *property; GIIrNodeInterface *iface; @@ -1660,9 +1662,9 @@ start_property (GMarkupParseContext *context, } static gint64 -parse_value (const gchar *str) +parse_value (const char *str) { - gchar *shift_op; + char *shift_op; /* FIXME just a quick hack */ shift_op = strstr (str, "<<"); @@ -1684,16 +1686,16 @@ parse_value (const gchar *str) static gboolean start_member (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { - const gchar *name; - const gchar *value; - const gchar *deprecated; - const gchar *c_identifier; + const char *name; + const char *value; + const char *deprecated; + const char *c_identifier; GIIrNodeEnum *enum_; GIIrNodeValue *value_; @@ -1736,17 +1738,17 @@ start_member (GMarkupParseContext *context, static gboolean start_constant (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { ParseState prev_state; ParseState target_state; - const gchar *name; - const gchar *value; - const gchar *deprecated; + const char *name; + const char *value; + const char *deprecated; GIIrNodeConstant *constant; if (!(strcmp (element_name, "constant") == 0 && @@ -1822,17 +1824,17 @@ start_constant (GMarkupParseContext *context, static gboolean start_interface (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { - const gchar *name; - const gchar *typename; - const gchar *typeinit; - const gchar *deprecated; - const gchar *glib_type_struct; + const char *name; + const char *typename; + const char *typeinit; + const char *deprecated; + const char *glib_type_struct; GIIrNodeInterface *iface; if (!(strcmp (element_name, "interface") == 0 && @@ -1884,25 +1886,25 @@ start_interface (GMarkupParseContext *context, static gboolean start_class (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { - const gchar *name; - const gchar *parent; - const gchar *glib_type_struct; - const gchar *typename; - const gchar *typeinit; - const gchar *deprecated; - const gchar *abstract; - const gchar *fundamental; - const gchar *final; - const gchar *ref_func; - const gchar *unref_func; - const gchar *set_value_func; - const gchar *get_value_func; + const char *name; + const char *parent; + const char *glib_type_struct; + const char *typename; + const char *typeinit; + const char *deprecated; + const char *abstract; + const char *fundamental; + const char *final; + const char *ref_func; + const char *unref_func; + const char *set_value_func; + const char *get_value_func; GIIrNodeInterface *iface; if (!(strcmp (element_name, "class") == 0 && @@ -1977,14 +1979,14 @@ start_class (GMarkupParseContext *context, static gboolean start_type (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { - const gchar *name; - const gchar *ctype; + const char *name; + const char *ctype; gboolean in_alias = FALSE; gboolean is_array; gboolean is_varargs; @@ -2299,14 +2301,14 @@ end_type (ParseContext *ctx) static gboolean start_attribute (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { - const gchar *name; - const gchar *value; + const char *name; + const char *value; GIIrNode *curnode; if (strcmp (element_name, "attribute") != 0 || ctx->node_stack == NULL) @@ -2344,16 +2346,16 @@ start_attribute (GMarkupParseContext *context, static gboolean start_return_value (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { GIIrNodeParam *param; - const gchar *transfer; - const gchar *skip; - const gchar *nullable; + const char *transfer; + const char *skip; + const char *nullable; if (!(strcmp (element_name, "return-value") == 0 && ctx->state == STATE_FUNCTION)) @@ -2413,9 +2415,9 @@ start_return_value (GMarkupParseContext *context, static gboolean start_implements (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { @@ -2443,19 +2445,19 @@ start_implements (GMarkupParseContext *context, static gboolean start_glib_signal (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { - const gchar *name; - const gchar *when; - const gchar *no_recurse; - const gchar *detailed; - const gchar *action; - const gchar *no_hooks; - const gchar *has_class_closure; + const char *name; + const char *when; + const char *no_recurse; + const char *detailed; + const char *action; + const char *no_hooks; + const char *has_class_closure; GIIrNodeInterface *iface; GIIrNodeSignal *signal; @@ -2526,19 +2528,19 @@ start_glib_signal (GMarkupParseContext *context, static gboolean start_vfunc (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { - const gchar *name; - const gchar *must_chain_up; - const gchar *override; - const gchar *is_class_closure; - const gchar *offset; - const gchar *invoker; - const gchar *throws; + const char *name; + const char *must_chain_up; + const char *override; + const char *is_class_closure; + const char *offset; + const char *invoker; + const char *throws; GIIrNodeInterface *iface; GIIrNodeVFunc *vfunc; @@ -2617,23 +2619,23 @@ start_vfunc (GMarkupParseContext *context, static gboolean start_struct (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { - const gchar *name; - const gchar *deprecated; - const gchar *disguised; - const gchar *opaque; - const gchar *pointer; - const gchar *gtype_name; - const gchar *gtype_init; - const gchar *gtype_struct; - const gchar *foreign; - const gchar *copy_func; - const gchar *free_func; + const char *name; + const char *deprecated; + const char *disguised; + const char *opaque; + const char *pointer; + const char *gtype_name; + const char *gtype_init; + const char *gtype_struct; + const char *foreign; + const char *copy_func; + const char *free_func; GIIrNodeStruct *struct_; if (!(strcmp (element_name, "record") == 0 && @@ -2711,18 +2713,18 @@ start_struct (GMarkupParseContext *context, static gboolean start_union (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { - const gchar *name; - const gchar *deprecated; - const gchar *typename; - const gchar *typeinit; - const gchar *copy_func; - const gchar *free_func; + const char *name; + const char *deprecated; + const char *typename; + const char *typeinit; + const char *copy_func; + const char *free_func; GIIrNodeUnion *union_; if (!(strcmp (element_name, "union") == 0 && @@ -2770,14 +2772,14 @@ start_union (GMarkupParseContext *context, static gboolean start_discriminator (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, ParseContext *ctx, GError **error) { - const gchar *type; - const gchar *offset; + const char *type; + const char *offset; if (!(strcmp (element_name, "discriminator") == 0 && ctx->state == STATE_UNION)) return FALSE; @@ -2810,9 +2812,9 @@ parse_include (GMarkupParseContext *context, const char *version) { GError *error = NULL; - gchar *buffer; + char *buffer; gsize length; - gchar *girpath, *girname; + char *girpath, *girname; GIIrModule *module; GList *l; @@ -2882,9 +2884,9 @@ extern GLogLevelFlags logged_levels; static void start_element_handler (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *element_name, + const char **attribute_names, + const char **attribute_values, void *user_data, GError **error) { @@ -3004,8 +3006,8 @@ start_element_handler (GMarkupParseContext *context, if (strcmp (element_name, "include") == 0 && ctx->state == STATE_REPOSITORY) { - const gchar *name; - const gchar *version; + const char *name; + const char *version; name = find_attribute ("name", attribute_names, attribute_values); version = find_attribute ("version", attribute_names, attribute_values); @@ -3072,7 +3074,7 @@ start_element_handler (GMarkupParseContext *context, case 'n': if (strcmp (element_name, "namespace") == 0 && ctx->state == STATE_REPOSITORY) { - const gchar *name, *version, *shared_library, *cprefix; + const char *name, *version, *shared_library, *cprefix; if (ctx->current_module != NULL) { @@ -3149,7 +3151,7 @@ start_element_handler (GMarkupParseContext *context, else if (strcmp (element_name, "prerequisite") == 0 && ctx->state == STATE_INTERFACE) { - const gchar *name; + const char *name; name = find_attribute ("name", attribute_names, attribute_values); @@ -3177,7 +3179,7 @@ start_element_handler (GMarkupParseContext *context, case 'r': if (strcmp (element_name, "repository") == 0 && ctx->state == STATE_START) { - const gchar *version; + const char *version; version = find_attribute ("version", attribute_names, attribute_values); @@ -3301,7 +3303,7 @@ require_one_of_end_elements (GMarkupParseContext *context, static gboolean state_switch_end_struct_or_union (GMarkupParseContext *context, ParseContext *ctx, - const gchar *element_name, + const char *element_name, GError **error) { pop_node (ctx); @@ -3345,7 +3347,7 @@ require_end_element (GMarkupParseContext *context, static void end_element_handler (GMarkupParseContext *context, - const gchar *element_name, + const char *element_name, void *user_data, GError **error) { @@ -3646,7 +3648,7 @@ end_element_handler (GMarkupParseContext *context, static void text_handler (GMarkupParseContext *context, - const gchar *text, + const char *text, gsize text_len, void *user_data, GError **error) @@ -3688,9 +3690,9 @@ cleanup (GMarkupParseContext *context, */ GIIrModule * gi_ir_parser_parse_string (GIIrParser *parser, - const gchar *namespace, - const gchar *filename, - const gchar *buffer, + const char *namespace, + const char *filename, + const char *buffer, gssize length, GError **error) { @@ -3773,10 +3775,10 @@ gi_ir_parser_parse_string (GIIrParser *parser, */ GIIrModule * gi_ir_parser_parse_file (GIIrParser *parser, - const gchar *filename, + const char *filename, GError **error) { - gchar *buffer; + char *buffer; gsize length; GIIrModule *module; char *dash; diff --git a/girepository/girwriter.c b/girepository/girwriter.c index fc109deca..5d9763bf7 100644 --- a/girepository/girwriter.c +++ b/girepository/girwriter.c @@ -173,7 +173,7 @@ check_unresolved (GIBaseInfo *info) } static void -write_type_name (const gchar *ns, +write_type_name (const char *ns, GIBaseInfo *info, Xml *file) { @@ -184,7 +184,7 @@ write_type_name (const gchar *ns, } static void -write_type_name_attribute (const gchar *ns, +write_type_name_attribute (const char *ns, GIBaseInfo *info, const char *attr_name, Xml *file) @@ -215,7 +215,7 @@ write_ownership_transfer (GITransfer transfer, } static void -write_type_info (const gchar *ns, +write_type_info (const char *ns, GITypeInfo *info, Xml *file) { @@ -379,23 +379,23 @@ write_return_value_attributes (Xml *file, } static void -write_constant_value (const gchar *ns, +write_constant_value (const char *ns, GITypeInfo *info, GIArgument *argument, Xml *file); static void -write_callback_info (const gchar *ns, +write_callback_info (const char *ns, GICallbackInfo *info, Xml *file); static void -write_field_info (const gchar *ns, +write_field_info (const char *ns, GIFieldInfo *info, GIConstantInfo *branch, Xml *file) { - const gchar *name; + const char *name; GIFieldInfoFlags flags; gint size; gint offset; @@ -457,7 +457,7 @@ write_field_info (const gchar *ns, } static void -write_callable_info (const gchar *ns, +write_callable_info (const char *ns, GICallableInfo *info, Xml *file) { @@ -568,14 +568,14 @@ write_callable_info (const gchar *ns, } static void -write_function_info (const gchar *ns, +write_function_info (const char *ns, GIFunctionInfo *info, Xml *file) { GIFunctionInfoFlags flags; - const gchar *tag; - const gchar *name; - const gchar *symbol; + const char *tag; + const char *name; + const char *symbol; gboolean deprecated; flags = gi_function_info_get_flags (info); @@ -619,11 +619,11 @@ write_function_info (const gchar *ns, } static void -write_callback_info (const gchar *ns, +write_callback_info (const char *ns, GICallbackInfo *info, Xml *file) { - const gchar *name; + const char *name; gboolean deprecated; name = gi_base_info_get_name ((GIBaseInfo *)info); @@ -640,14 +640,14 @@ write_callback_info (const gchar *ns, } static void -write_struct_info (const gchar *ns, +write_struct_info (const char *ns, GIStructInfo *info, Xml *file) { - const gchar *name; - const gchar *type_name; - const gchar *type_init; - const gchar *func; + const char *name; + const char *type_name; + const char *type_init; + const char *func; gboolean deprecated; gboolean is_gtype_struct; gboolean foreign; @@ -722,13 +722,13 @@ write_struct_info (const gchar *ns, } static void -write_value_info (const gchar *ns, +write_value_info (const char *ns, GIValueInfo *info, Xml *file) { - const gchar *name; + const char *name; gint64 value; - gchar *value_str; + char *value_str; gboolean deprecated; name = gi_base_info_get_name ((GIBaseInfo *)info); @@ -749,7 +749,7 @@ write_value_info (const gchar *ns, } static void -write_constant_value (const gchar *ns, +write_constant_value (const char *ns, GITypeInfo *type, GIArgument *value, Xml *file) @@ -799,12 +799,12 @@ write_constant_value (const gchar *ns, } static void -write_constant_info (const gchar *ns, +write_constant_info (const char *ns, GIConstantInfo *info, Xml *file) { GITypeInfo *type; - const gchar *name; + const char *name; GIArgument value; name = gi_base_info_get_name ((GIBaseInfo *)info); @@ -830,14 +830,14 @@ write_constant_info (const gchar *ns, static void -write_enum_info (const gchar *ns, +write_enum_info (const char *ns, GIEnumInfo *info, Xml *file) { - const gchar *name; - const gchar *type_name; - const gchar *type_init; - const gchar *error_domain; + const char *name; + const char *type_name; + const char *type_init; + const char *error_domain; gboolean deprecated; name = gi_base_info_get_name ((GIBaseInfo *)info); @@ -874,12 +874,12 @@ write_enum_info (const gchar *ns, } static void -write_signal_info (const gchar *ns, +write_signal_info (const char *ns, GISignalInfo *info, Xml *file) { GSignalFlags flags; - const gchar *name; + const char *name; gboolean deprecated; name = gi_base_info_get_name ((GIBaseInfo *)info); @@ -917,12 +917,12 @@ write_signal_info (const gchar *ns, } static void -write_vfunc_info (const gchar *ns, +write_vfunc_info (const char *ns, GIVFuncInfo *info, Xml *file) { GIVFuncInfoFlags flags; - const gchar *name; + const char *name; GIFunctionInfo *invoker; gboolean deprecated; gint offset; @@ -961,12 +961,12 @@ write_vfunc_info (const gchar *ns, } static void -write_property_info (const gchar *ns, +write_property_info (const char *ns, GIPropertyInfo *info, Xml *file) { GParamFlags flags; - const gchar *name; + const char *name; gboolean deprecated; GITypeInfo *type; @@ -1026,14 +1026,14 @@ write_property_info (const gchar *ns, } static void -write_object_info (const gchar *ns, +write_object_info (const char *ns, GIObjectInfo *info, Xml *file) { - const gchar *name; - const gchar *type_name; - const gchar *type_init; - const gchar *func; + const char *name; + const char *type_name; + const char *type_init; + const char *func; gboolean deprecated; gboolean is_abstract; gboolean is_fundamental; @@ -1156,13 +1156,13 @@ write_object_info (const gchar *ns, } static void -write_interface_info (const gchar *ns, +write_interface_info (const char *ns, GIInterfaceInfo *info, Xml *file) { - const gchar *name; - const gchar *type_name; - const gchar *type_init; + const char *name; + const char *type_name; + const char *type_init; GIStructInfo *class_struct; gboolean deprecated; @@ -1240,14 +1240,14 @@ write_interface_info (const gchar *ns, } static void -write_union_info (const gchar *ns, +write_union_info (const char *ns, GIUnionInfo *info, Xml *file) { - const gchar *name; - const gchar *type_name; - const gchar *type_init; - const gchar *func; + const char *name; + const char *type_name; + const char *type_init; + const char *func; gboolean deprecated; gsize size; @@ -1346,7 +1346,7 @@ gi_ir_writer_write (const char *filename, ofile = stdout; else { - gchar *full_filename; + char *full_filename; if (needs_prefix) full_filename = g_strdup_printf ("%s-%s", ns, filename); @@ -1391,7 +1391,7 @@ gi_ir_writer_write (const char *filename, if (TRUE) { const char * const *shared_libraries; - const gchar *c_prefix; + const char *c_prefix; const char *cur_ns = ns; const char *cur_version; gint n_infos; diff --git a/girepository/gistructinfo.c b/girepository/gistructinfo.c index 5955a0846..37edd0009 100644 --- a/girepository/gistructinfo.c +++ b/girepository/gistructinfo.c @@ -127,7 +127,7 @@ gi_struct_info_get_field (GIStructInfo *info, */ GIFieldInfo * gi_struct_info_find_field (GIStructInfo *info, - const gchar *name) + const char *name) { GIRealInfo *rinfo = (GIRealInfo *)info; StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -138,7 +138,7 @@ gi_struct_info_find_field (GIStructInfo *info, for (i = 0; i < blob->n_fields; i++) { FieldBlob *field_blob = (FieldBlob *)&rinfo->typelib->data[offset]; - const gchar *fname = (const gchar *)&rinfo->typelib->data[field_blob->name]; + const char *fname = (const char *)&rinfo->typelib->data[field_blob->name]; if (strcmp (name, fname) == 0) { @@ -213,7 +213,7 @@ gi_struct_info_get_method (GIStructInfo *info, */ GIFunctionInfo * gi_struct_info_find_method (GIStructInfo *info, - const gchar *name) + const char *name) { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; diff --git a/girepository/gistructinfo.h b/girepository/gistructinfo.h index 21c85327b..d8e04fd28 100644 --- a/girepository/gistructinfo.h +++ b/girepository/gistructinfo.h @@ -53,7 +53,7 @@ GIFieldInfo * gi_struct_info_get_field (GIStructInfo *info, GI_AVAILABLE_IN_ALL GIFieldInfo * gi_struct_info_find_field (GIStructInfo *info, - const gchar *name); + const char *name); GI_AVAILABLE_IN_ALL guint gi_struct_info_get_n_methods (GIStructInfo *info); @@ -64,7 +64,7 @@ GIFunctionInfo * gi_struct_info_get_method (GIStructInfo *info, GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_struct_info_find_method (GIStructInfo *info, - const gchar *name); + const char *name); GI_AVAILABLE_IN_ALL gsize gi_struct_info_get_size (GIStructInfo *info); diff --git a/girepository/gitypeinfo.h b/girepository/gitypeinfo.h index dbc46ce7f..c6b99f056 100644 --- a/girepository/gitypeinfo.h +++ b/girepository/gitypeinfo.h @@ -76,10 +76,10 @@ G_BEGIN_DECLS ((tag) >= GI_TYPE_TAG_GLIST && (tag) <= GI_TYPE_TAG_GHASH)) GI_AVAILABLE_IN_ALL -const gchar* gi_type_tag_to_string (GITypeTag type); +const char * gi_type_tag_to_string (GITypeTag type); GI_AVAILABLE_IN_ALL -const gchar* gi_info_type_to_string (GIInfoType type); +const char * gi_info_type_to_string (GIInfoType type); GI_AVAILABLE_IN_ALL diff --git a/girepository/gitypelib-internal.h b/girepository/gitypelib-internal.h index dc66eb100..0600ef320 100644 --- a/girepository/gitypelib-internal.h +++ b/girepository/gitypelib-internal.h @@ -287,7 +287,7 @@ _blob_is_registered_type (GITypelibBlobType blob_type) * Since: 2.80 */ typedef struct { - gchar magic[16]; + char magic[16]; guint8 major_version; guint8 minor_version; guint16 reserved; @@ -1328,13 +1328,13 @@ DirEntry *gi_typelib_get_dir_entry_by_name (GITypelib *typelib, const char *name); DirEntry *gi_typelib_get_dir_entry_by_gtype_name (GITypelib *typelib, - const gchar *gtype_name); + const char *gtype_name); DirEntry *gi_typelib_get_dir_entry_by_error_domain (GITypelib *typelib, GQuark error_domain); gboolean gi_typelib_matches_gtype_name_prefix (GITypelib *typelib, - const gchar *gtype_name); + const char *gtype_name); GI_AVAILABLE_IN_ALL @@ -1350,7 +1350,7 @@ void gi_typelib_check_format (void); * Returns: TODO * Since: 2.80 */ -#define gi_typelib_get_string(typelib,offset) ((const gchar*)&(typelib->data)[(offset)]) +#define gi_typelib_get_string(typelib,offset) ((const char*)&(typelib->data)[(offset)]) /** diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index 703553d05..4f733c37d 100644 --- a/girepository/gitypelib.c +++ b/girepository/gitypelib.c @@ -244,7 +244,7 @@ gi_typelib_get_dir_entry_by_name (GITypelib *typelib, */ DirEntry * gi_typelib_get_dir_entry_by_gtype_name (GITypelib *typelib, - const gchar *gtype_name) + const char *gtype_name) { Header *header = (Header *)typelib->data; guint i; @@ -340,11 +340,11 @@ strsplit_iter_clear (StrSplitIter *iter) */ gboolean gi_typelib_matches_gtype_name_prefix (GITypelib *typelib, - const gchar *gtype_name) + const char *gtype_name) { Header *header = (Header *)typelib->data; const char *c_prefix; - const gchar *prefix; + const char *prefix; gboolean ret = FALSE; StrSplitIter split_iter; gsize gtype_name_len; @@ -2342,7 +2342,7 @@ gi_typelib_do_dlopen (GITypelib *typelib) if (shlib_str != NULL && shlib_str[0] != '\0') { - gchar **shlibs; + char **shlibs; gint i; /* shared-library is a comma-separated list of libraries */ @@ -2522,7 +2522,7 @@ gi_typelib_free (GITypelib *typelib) * Returns: name of the namespace represented by @typelib * Since: 2.80 */ -const gchar * +const char * gi_typelib_get_namespace (GITypelib *typelib) { return gi_typelib_get_string (typelib, ((Header *) typelib->data)->namespace); diff --git a/girepository/gitypelib.h b/girepository/gitypelib.h index 66f01ddfe..d43e8fd95 100644 --- a/girepository/gitypelib.h +++ b/girepository/gitypelib.h @@ -55,11 +55,11 @@ void gi_typelib_free (GITypelib *typelib); GI_AVAILABLE_IN_ALL gboolean gi_typelib_symbol (GITypelib *typelib, - const gchar *symbol_name, + const char *symbol_name, void **symbol); GI_AVAILABLE_IN_ALL -const gchar * gi_typelib_get_namespace (GITypelib *typelib); +const char * gi_typelib_get_namespace (GITypelib *typelib); G_END_DECLS diff --git a/girepository/gitypes.h b/girepository/gitypes.h index 5957881ca..2c8f92b9e 100644 --- a/girepository/gitypes.h +++ b/girepository/gitypes.h @@ -132,7 +132,7 @@ union _GIArgument gulong v_ulong; gssize v_ssize; gsize v_size; - gchar * v_string; + char *v_string; void *v_pointer; }; diff --git a/girepository/giunioninfo.c b/girepository/giunioninfo.c index 6e9434fb4..7c311bad1 100644 --- a/girepository/giunioninfo.c +++ b/girepository/giunioninfo.c @@ -238,7 +238,7 @@ gi_union_info_get_discriminator (GIUnionInfo *info, */ GIFunctionInfo * gi_union_info_find_method (GIUnionInfo *info, - const gchar *name) + const char *name) { gint offset; GIRealInfo *rinfo = (GIRealInfo *)info; diff --git a/girepository/giunioninfo.h b/girepository/giunioninfo.h index fb50ed9a5..6db369d87 100644 --- a/girepository/giunioninfo.h +++ b/girepository/giunioninfo.h @@ -72,7 +72,7 @@ GIConstantInfo * gi_union_info_get_discriminator (GIUnionInfo *info, GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_union_info_find_method (GIUnionInfo *info, - const gchar *name); + const char *name); GI_AVAILABLE_IN_ALL gsize gi_union_info_get_size (GIUnionInfo *info); diff --git a/girepository/givfuncinfo.c b/girepository/givfuncinfo.c index ab447a4d3..38fcc52e7 100644 --- a/girepository/givfuncinfo.c +++ b/girepository/givfuncinfo.c @@ -49,7 +49,7 @@ GIVFuncInfo * gi_base_info_find_vfunc (GIRealInfo *rinfo, guint32 offset, guint n_vfuncs, - const gchar *name) + const char *name) { /* FIXME hash */ Header *header = (Header *)rinfo->typelib->data; @@ -57,7 +57,7 @@ gi_base_info_find_vfunc (GIRealInfo *rinfo, for (guint i = 0; i < n_vfuncs; i++) { VFuncBlob *fblob = (VFuncBlob *)&rinfo->typelib->data[offset]; - const gchar *fname = (const gchar *)&rinfo->typelib->data[fblob->name]; + const char *fname = (const char *)&rinfo->typelib->data[fblob->name]; if (strcmp (name, fname) == 0) return (GIVFuncInfo *) gi_info_new (GI_INFO_TYPE_VFUNC, (GIBaseInfo*) rinfo, From e5353ef0c10fee8faa2fc0e654af014ff41dd895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 03:00:07 +0100 Subject: [PATCH 05/27] girnode: Assign negative value to signed integer --- girepository/girnode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/girepository/girnode.c b/girepository/girnode.c index 6da186e86..6efa65fd8 100644 --- a/girepository/girnode.c +++ b/girepository/girnode.c @@ -1196,7 +1196,7 @@ get_index_of_member_type (GIIrNodeInterface *node, GIIrNodeTypeId type, const char *name) { - guint index = -1; + gint index = -1; GList *l; for (l = node->members; l; l = l->next) From 9f33015a25e725d82c8bb58df725546dd0a29179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 15 Jan 2024 22:20:02 +0100 Subject: [PATCH 06/27] girrepository: Use standard int sized types instead of g[u]int* --- girepository/cmph/cmph_types.h | 17 +- girepository/gdump.c | 35 +- girepository/giarginfo.c | 4 +- girepository/giarginfo.h | 4 +- girepository/gibaseinfo.c | 14 +- girepository/gibaseinfo.h | 2 +- girepository/gicallableinfo.c | 40 +- girepository/gicallableinfo.h | 6 +- girepository/giconstantinfo.c | 20 +- girepository/gienuminfo.c | 20 +- girepository/gienuminfo.h | 14 +- girepository/gifieldinfo.c | 46 +-- girepository/gifunctioninfo.c | 6 +- girepository/giinterfaceinfo.c | 42 +-- girepository/giinterfaceinfo.h | 24 +- girepository/ginvoke.c | 2 +- girepository/giobjectinfo.c | 56 +-- girepository/giobjectinfo.h | 28 +- girepository/girepository-private.h | 24 +- girepository/girepository.c | 20 +- girepository/girepository.h | 6 +- girepository/girffi.c | 2 +- girepository/girmodule-private.h | 4 +- girepository/girmodule.c | 46 +-- girepository/girnode-private.h | 58 +-- girepository/girnode.c | 120 +++--- girepository/giroffsets.c | 46 +-- girepository/girparser.c | 32 +- girepository/girwriter.c | 78 ++-- girepository/gistructinfo.c | 24 +- girepository/gistructinfo.h | 8 +- girepository/gitypeinfo.c | 18 +- girepository/gitypeinfo.h | 6 +- girepository/gitypelib-internal.h | 560 ++++++++++++++-------------- girepository/gitypelib.c | 157 ++++---- girepository/gitypelib.h | 4 +- girepository/gitypes.h | 40 +- girepository/giunioninfo.c | 18 +- girepository/giunioninfo.h | 12 +- girepository/givfuncinfo.c | 8 +- girepository/givfuncinfo.h | 2 +- girepository/gthash.c | 58 +-- girepository/tests/cmph-bdz.c | 30 +- girepository/tests/gthash.c | 5 +- 44 files changed, 883 insertions(+), 883 deletions(-) diff --git a/girepository/cmph/cmph_types.h b/girepository/cmph/cmph_types.h index 288323587..d5db4c4b5 100644 --- a/girepository/cmph/cmph_types.h +++ b/girepository/cmph/cmph_types.h @@ -1,19 +1,20 @@ +#include #include #ifndef __CMPH_TYPES_H__ #define __CMPH_TYPES_H__ -typedef gint8 cmph_int8; -typedef guint8 cmph_uint8; +typedef int8_t cmph_int8; +typedef uint8_t cmph_uint8; -typedef gint16 cmph_int16; -typedef guint16 cmph_uint16; +typedef int16_t cmph_int16; +typedef uint16_t cmph_uint16; -typedef gint32 cmph_int32; -typedef guint32 cmph_uint32; +typedef int32_t cmph_int32; +typedef uint32_t cmph_uint32; -typedef gint64 cmph_int64; -typedef guint64 cmph_uint64; +typedef int64_t cmph_int64; +typedef uint64_t cmph_uint64; typedef enum { CMPH_HASH_JENKINS, CMPH_HASH_COUNT } CMPH_HASH; extern const char *cmph_hash_names[]; diff --git a/girepository/gdump.c b/girepository/gdump.c index d7ec6b62f..6877ca24c 100644 --- a/girepository/gdump.c +++ b/girepository/gdump.c @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -70,12 +71,12 @@ read_line (FILE *input, size_t *len_out) { GByteArray *buffer = g_byte_array_new (); - const guint8 nul = '\0'; + const uint8_t nul = '\0'; while (TRUE) { size_t ret; - guint8 byte; + uint8_t byte; ret = fread (&byte, 1, 1, input); if (ret == 0) @@ -250,8 +251,8 @@ value_to_string (const GValue *value) static void dump_properties (GType type, FILE *out) { - guint i; - guint n_properties = 0; + unsigned int i; + unsigned int n_properties = 0; GParamSpec **props; if (G_TYPE_FUNDAMENTAL (type) == G_TYPE_OBJECT) @@ -303,16 +304,16 @@ dump_properties (GType type, FILE *out) static void dump_signals (GType type, FILE *out) { - guint i; - guint n_sigs; - guint *sig_ids; + unsigned int i; + unsigned int n_sigs; + unsigned int *sig_ids; sig_ids = g_signal_list_ids (type, &n_sigs); for (i = 0; i < n_sigs; i++) { - guint sigid; + unsigned int sigid; GSignalQuery query; - guint j; + unsigned int j; sigid = sig_ids[i]; g_signal_query (sigid, &query); @@ -355,8 +356,8 @@ dump_signals (GType type, FILE *out) static void dump_object_type (GType type, const char *symbol, FILE *out) { - guint n_interfaces; - guint i; + unsigned int n_interfaces; + unsigned int i; GType *interfaces; escaped_printf (out, " \n", @@ -449,7 +450,7 @@ dump_boxed_type (GType type, const char *symbol, FILE *out) static void dump_flags_type (GType type, const char *symbol, FILE *out) { - guint i; + unsigned int i; GFlagsClass *klass; klass = g_type_class_ref (type); @@ -469,7 +470,7 @@ dump_flags_type (GType type, const char *symbol, FILE *out) static void dump_enum_type (GType type, const char *symbol, FILE *out) { - guint i; + unsigned int i; GEnumClass *klass; klass = g_type_class_ref (type); @@ -489,8 +490,8 @@ dump_enum_type (GType type, const char *symbol, FILE *out) static void dump_fundamental_type (GType type, const char *symbol, FILE *out) { - guint n_interfaces; - guint i; + unsigned int n_interfaces; + unsigned int i; GType *interfaces; GString *parent_str; GType parent; diff --git a/girepository/giarginfo.c b/girepository/giarginfo.c index 59894c951..a4c690d9a 100644 --- a/girepository/giarginfo.c +++ b/girepository/giarginfo.c @@ -269,7 +269,7 @@ gi_arg_info_get_scope (GIArgInfo *info) * Returns: Index of the user data argument or `-1` if there is none * Since: 2.80 */ -gint +int gi_arg_info_get_closure_index (GIArgInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -294,7 +294,7 @@ gi_arg_info_get_closure_index (GIArgInfo *info) * none * Since: 2.80 */ -gint +int gi_arg_info_get_destroy_index (GIArgInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; diff --git a/girepository/giarginfo.h b/girepository/giarginfo.h index 2564de83e..fcedb5a28 100644 --- a/girepository/giarginfo.h +++ b/girepository/giarginfo.h @@ -69,10 +69,10 @@ GI_AVAILABLE_IN_ALL GIScopeType gi_arg_info_get_scope (GIArgInfo *info); GI_AVAILABLE_IN_ALL -gint gi_arg_info_get_closure_index (GIArgInfo *info); +int gi_arg_info_get_closure_index (GIArgInfo *info); GI_AVAILABLE_IN_ALL -gint gi_arg_info_get_destroy_index (GIArgInfo *info); +int gi_arg_info_get_destroy_index (GIArgInfo *info); GI_AVAILABLE_IN_ALL GITypeInfo * gi_arg_info_get_type_info (GIArgInfo *info); diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c index 14b3903e5..85bf3c26c 100644 --- a/girepository/gibaseinfo.c +++ b/girepository/gibaseinfo.c @@ -315,7 +315,7 @@ gi_info_new_full (GIInfoType type, GIRepository *repository, GIBaseInfo *container, GITypelib *typelib, - guint32 offset) + uint32_t offset) { GIRealInfo *info; @@ -357,7 +357,7 @@ GIBaseInfo * gi_info_new (GIInfoType type, GIBaseInfo *container, GITypelib *typelib, - guint32 offset) + uint32_t offset) { return gi_info_new_full (type, ((GIRealInfo*)container)->repository, container, typelib, offset); } @@ -382,7 +382,7 @@ gi_info_init (GIRealInfo *info, GIRepository *repository, GIBaseInfo *container, GITypelib *typelib, - guint32 offset) + uint32_t offset) { memset (info, 0, sizeof (GIRealInfo)); @@ -401,7 +401,7 @@ gi_info_init (GIRealInfo *info, GIBaseInfo * gi_info_from_entry (GIRepository *repository, GITypelib *typelib, - guint16 index) + uint16_t index) { GIBaseInfo *result; DirEntry *entry = gi_typelib_get_dir_entry (typelib, index); @@ -438,7 +438,7 @@ gi_info_from_entry (GIRepository *repository, GITypeInfo * gi_type_info_new (GIBaseInfo *container, GITypelib *typelib, - guint32 offset) + uint32_t offset) { SimpleTypeBlob *type = (SimpleTypeBlob *)&typelib->data[offset]; @@ -450,7 +450,7 @@ void gi_type_info_init (GIBaseInfo *info, GIBaseInfo *container, GITypelib *typelib, - guint32 offset) + uint32_t offset) { GIRealInfo *rinfo = (GIRealInfo*)container; SimpleTypeBlob *type = (SimpleTypeBlob *)&typelib->data[offset]; @@ -800,7 +800,7 @@ cmp_attribute (const void *av, */ AttributeBlob * _attribute_blob_find_first (GIBaseInfo *info, - guint32 blob_offset) + uint32_t blob_offset) { GIRealInfo *rinfo = (GIRealInfo *) info; Header *header = (Header *)rinfo->typelib->data; diff --git a/girepository/gibaseinfo.h b/girepository/gibaseinfo.h index 08feb3223..c6aaee604 100644 --- a/girepository/gibaseinfo.h +++ b/girepository/gibaseinfo.h @@ -96,6 +96,6 @@ GI_AVAILABLE_IN_ALL GIBaseInfo * gi_info_new (GIInfoType type, GIBaseInfo *container, GITypelib *typelib, - guint32 offset); + uint32_t offset); G_END_DECLS diff --git a/girepository/gicallableinfo.c b/girepository/gicallableinfo.c index 3d7e7020f..9eccfc2a7 100644 --- a/girepository/gicallableinfo.c +++ b/girepository/gicallableinfo.c @@ -54,7 +54,7 @@ * Since: 2.80 */ -static guint32 +static uint32_t signature_offset (GICallableInfo *info) { GIRealInfo *rinfo = (GIRealInfo*)info; @@ -78,7 +78,7 @@ signature_offset (GICallableInfo *info) g_assert_not_reached (); } if (sigoff >= 0) - return *(guint32 *)&rinfo->typelib->data[rinfo->offset + sigoff]; + return *(uint32_t *)&rinfo->typelib->data[rinfo->offset + sigoff]; return 0; } @@ -180,7 +180,7 @@ GITypeInfo * gi_callable_info_get_return_type (GICallableInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; - guint32 offset; + uint32_t offset; g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_CALLABLE_INFO (info), NULL); @@ -208,7 +208,7 @@ gi_callable_info_load_return_type (GICallableInfo *info, GITypeInfo *type) { GIRealInfo *rinfo = (GIRealInfo *)info; - guint32 offset; + uint32_t offset; g_return_if_fail (info != NULL); g_return_if_fail (GI_IS_CALLABLE_INFO (info)); @@ -331,11 +331,11 @@ gi_callable_info_get_instance_ownership_transfer (GICallableInfo *info) * Returns: The number of arguments this callable expects. * Since: 2.80 */ -guint +unsigned int gi_callable_info_get_n_args (GICallableInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; - gint offset; + uint32_t offset; SignatureBlob *blob; g_return_val_if_fail (info != NULL, -1); @@ -360,11 +360,11 @@ gi_callable_info_get_n_args (GICallableInfo *info) */ GIArgInfo * gi_callable_info_get_arg (GICallableInfo *info, - guint n) + unsigned int n) { GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; - gint offset; + uint32_t offset; g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_CALLABLE_INFO (info), NULL); @@ -392,12 +392,12 @@ gi_callable_info_get_arg (GICallableInfo *info, */ void gi_callable_info_load_arg (GICallableInfo *info, - guint n, + unsigned int n, GIArgInfo *arg) { GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; - gint offset; + uint32_t offset; g_return_if_fail (info != NULL); g_return_if_fail (GI_IS_CALLABLE_INFO (info)); @@ -466,7 +466,7 @@ gi_callable_info_iterate_return_attributes (GICallableInfo *info, GIRealInfo *rinfo = (GIRealInfo *)info; Header *header = (Header *)rinfo->typelib->data; AttributeBlob *next, *after; - guint32 blob_offset; + uint32_t blob_offset; after = (AttributeBlob *) &rinfo->typelib->data[header->attributes + header->n_attributes * header->attribute_blob_size]; @@ -518,30 +518,30 @@ gi_type_tag_extract_ffi_return_value (GITypeTag return_tag, { switch (return_tag) { case GI_TYPE_TAG_INT8: - arg->v_int8 = (gint8) ffi_value->v_long; + arg->v_int8 = (int8_t) ffi_value->v_long; break; case GI_TYPE_TAG_UINT8: - arg->v_uint8 = (guint8) ffi_value->v_ulong; + arg->v_uint8 = (uint8_t) ffi_value->v_ulong; break; case GI_TYPE_TAG_INT16: - arg->v_int16 = (gint16) ffi_value->v_long; + arg->v_int16 = (int16_t) ffi_value->v_long; break; case GI_TYPE_TAG_UINT16: - arg->v_uint16 = (guint16) ffi_value->v_ulong; + arg->v_uint16 = (uint16_t) ffi_value->v_ulong; break; case GI_TYPE_TAG_INT32: - arg->v_int32 = (gint32) ffi_value->v_long; + arg->v_int32 = (int32_t) ffi_value->v_long; break; case GI_TYPE_TAG_UINT32: case GI_TYPE_TAG_BOOLEAN: case GI_TYPE_TAG_UNICHAR: - arg->v_uint32 = (guint32) ffi_value->v_ulong; + arg->v_uint32 = (uint32_t) ffi_value->v_ulong; break; case GI_TYPE_TAG_INT64: - arg->v_int64 = (gint64) ffi_value->v_int64; + arg->v_int64 = (int64_t) ffi_value->v_int64; break; case GI_TYPE_TAG_UINT64: - arg->v_uint64 = (guint64) ffi_value->v_uint64; + arg->v_uint64 = (uint64_t) ffi_value->v_uint64; break; case GI_TYPE_TAG_FLOAT: arg->v_float = ffi_value->v_float; @@ -553,7 +553,7 @@ gi_type_tag_extract_ffi_return_value (GITypeTag return_tag, switch(interface_type) { case GI_INFO_TYPE_ENUM: case GI_INFO_TYPE_FLAGS: - arg->v_int32 = (gint32) ffi_value->v_long; + arg->v_int32 = (int32_t) ffi_value->v_long; break; default: arg->v_pointer = (void *) ffi_value->v_pointer; diff --git a/girepository/gicallableinfo.h b/girepository/gicallableinfo.h index 9a76457bc..3ff1c0450 100644 --- a/girepository/gicallableinfo.h +++ b/girepository/gicallableinfo.h @@ -80,15 +80,15 @@ GI_AVAILABLE_IN_ALL gboolean gi_callable_info_skip_return (GICallableInfo *info); GI_AVAILABLE_IN_ALL -guint gi_callable_info_get_n_args (GICallableInfo *info); +unsigned int gi_callable_info_get_n_args (GICallableInfo *info); GI_AVAILABLE_IN_ALL GIArgInfo * gi_callable_info_get_arg (GICallableInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL void gi_callable_info_load_arg (GICallableInfo *info, - guint n, + unsigned int n, GIArgInfo *arg); GI_AVAILABLE_IN_ALL diff --git a/girepository/giconstantinfo.c b/girepository/giconstantinfo.c index dd9ed3849..e16aca8fe 100644 --- a/girepository/giconstantinfo.c +++ b/girepository/giconstantinfo.c @@ -145,34 +145,34 @@ gi_constant_info_get_value (GIConstantInfo *info, value->v_boolean = *(gboolean*)&rinfo->typelib->data[blob->offset]; break; case GI_TYPE_TAG_INT8: - value->v_int8 = *(gint8*)&rinfo->typelib->data[blob->offset]; + value->v_int8 = *(int8_t*)&rinfo->typelib->data[blob->offset]; break; case GI_TYPE_TAG_UINT8: - value->v_uint8 = *(guint8*)&rinfo->typelib->data[blob->offset]; + value->v_uint8 = *(uint8_t*)&rinfo->typelib->data[blob->offset]; break; case GI_TYPE_TAG_INT16: - value->v_int16 = *(gint16*)&rinfo->typelib->data[blob->offset]; + value->v_int16 = *(int16_t*)&rinfo->typelib->data[blob->offset]; break; case GI_TYPE_TAG_UINT16: - value->v_uint16 = *(guint16*)&rinfo->typelib->data[blob->offset]; + value->v_uint16 = *(uint16_t*)&rinfo->typelib->data[blob->offset]; break; case GI_TYPE_TAG_INT32: - value->v_int32 = *(gint32*)&rinfo->typelib->data[blob->offset]; + value->v_int32 = *(int32_t*)&rinfo->typelib->data[blob->offset]; break; case GI_TYPE_TAG_UINT32: - value->v_uint32 = *(guint32*)&rinfo->typelib->data[blob->offset]; + value->v_uint32 = *(uint32_t*)&rinfo->typelib->data[blob->offset]; break; case GI_TYPE_TAG_INT64: - DO_ALIGNED_COPY(&value->v_int64, &rinfo->typelib->data[blob->offset], gint64); + DO_ALIGNED_COPY (&value->v_int64, &rinfo->typelib->data[blob->offset], int64_t); break; case GI_TYPE_TAG_UINT64: - DO_ALIGNED_COPY(&value->v_uint64, &rinfo->typelib->data[blob->offset], guint64); + DO_ALIGNED_COPY (&value->v_uint64, &rinfo->typelib->data[blob->offset], uint64_t); break; case GI_TYPE_TAG_FLOAT: - DO_ALIGNED_COPY(&value->v_float, &rinfo->typelib->data[blob->offset], gfloat); + DO_ALIGNED_COPY (&value->v_float, &rinfo->typelib->data[blob->offset], float); break; case GI_TYPE_TAG_DOUBLE: - DO_ALIGNED_COPY(&value->v_double, &rinfo->typelib->data[blob->offset], gdouble); + DO_ALIGNED_COPY (&value->v_double, &rinfo->typelib->data[blob->offset], double); break; default: g_assert_not_reached (); diff --git a/girepository/gienuminfo.c b/girepository/gienuminfo.c index d0bf5105e..1fa346f2e 100644 --- a/girepository/gienuminfo.c +++ b/girepository/gienuminfo.c @@ -55,7 +55,7 @@ * Returns: the number of enumeration values * Since: 2.80 */ -guint +unsigned int gi_enum_info_get_n_values (GIEnumInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -110,11 +110,11 @@ gi_enum_info_get_error_domain (GIEnumInfo *info) */ GIValueInfo * gi_enum_info_get_value (GIEnumInfo *info, - guint n) + unsigned int n) { GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; - gint offset; + int offset; g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_ENUM_INFO (info), NULL); @@ -135,7 +135,7 @@ gi_enum_info_get_value (GIEnumInfo *info, * Returns: number of methods * Since: 2.80 */ -guint +unsigned int gi_enum_info_get_n_methods (GIEnumInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -162,9 +162,9 @@ gi_enum_info_get_n_methods (GIEnumInfo *info) */ GIFunctionInfo * gi_enum_info_get_method (GIEnumInfo *info, - guint n) + unsigned int n) { - gint offset; + int offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; EnumBlob *blob; @@ -238,11 +238,11 @@ gi_enum_info_class_init (gpointer g_class, * Obtain the enumeration value of the `GIValueInfo`. * * Returns: the enumeration value. This will always be representable - * as a 32-bit signed or unsigned value. The use of `gint64` as the + * as a 32-bit signed or unsigned value. The use of `int64_t` as the * return type is to allow both. * Since: 2.80 */ -gint64 +int64_t gi_value_info_get_value (GIValueInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -254,9 +254,9 @@ gi_value_info_get_value (GIValueInfo *info) blob = (ValueBlob *)&rinfo->typelib->data[rinfo->offset]; if (blob->unsigned_value) - return (gint64)(guint32)blob->value; + return (int64_t)(uint32_t)blob->value; else - return (gint64)blob->value; + return (int64_t)blob->value; } void diff --git a/girepository/gienuminfo.h b/girepository/gienuminfo.h index 344058aa9..ba1d33d09 100644 --- a/girepository/gienuminfo.h +++ b/girepository/gienuminfo.h @@ -57,18 +57,18 @@ G_BEGIN_DECLS GI_AVAILABLE_IN_ALL -guint gi_enum_info_get_n_values (GIEnumInfo *info); +unsigned int gi_enum_info_get_n_values (GIEnumInfo *info); GI_AVAILABLE_IN_ALL -GIValueInfo * gi_enum_info_get_value (GIEnumInfo *info, - guint n); +GIValueInfo * gi_enum_info_get_value (GIEnumInfo *info, + unsigned int n); GI_AVAILABLE_IN_ALL -guint gi_enum_info_get_n_methods (GIEnumInfo *info); +unsigned int gi_enum_info_get_n_methods (GIEnumInfo *info); GI_AVAILABLE_IN_ALL -GIFunctionInfo * gi_enum_info_get_method (GIEnumInfo *info, - guint n); +GIFunctionInfo * gi_enum_info_get_method (GIEnumInfo *info, + unsigned int n); GI_AVAILABLE_IN_ALL GITypeTag gi_enum_info_get_storage_type (GIEnumInfo *info); @@ -78,6 +78,6 @@ const char * gi_enum_info_get_error_domain (GIEnumInfo *info); GI_AVAILABLE_IN_ALL -gint64 gi_value_info_get_value (GIValueInfo *info); +int64_t gi_value_info_get_value (GIValueInfo *info); G_END_DECLS diff --git a/girepository/gifieldinfo.c b/girepository/gifieldinfo.c index 533c2d243..9abc1ae40 100644 --- a/girepository/gifieldinfo.c +++ b/girepository/gifieldinfo.c @@ -222,35 +222,35 @@ gi_field_info_get_field (GIFieldInfo *field_info, 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 (uint8_t, mem, offset); result = TRUE; break; case GI_TYPE_TAG_INT16: case GI_TYPE_TAG_UINT16: - value->v_uint16 = G_STRUCT_MEMBER (guint16, mem, offset); + value->v_uint16 = G_STRUCT_MEMBER (uint16_t, mem, offset); result = TRUE; break; case GI_TYPE_TAG_INT32: case GI_TYPE_TAG_UINT32: case GI_TYPE_TAG_UNICHAR: - value->v_uint32 = G_STRUCT_MEMBER (guint32, mem, offset); + value->v_uint32 = G_STRUCT_MEMBER (uint32_t, 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 (uint64_t, mem, offset); result = TRUE; break; case GI_TYPE_TAG_GTYPE: - value->v_size = G_STRUCT_MEMBER (gsize, mem, offset); + value->v_size = G_STRUCT_MEMBER (size_t, 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 (float, 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 (double, mem, offset); result = TRUE; break; case GI_TYPE_TAG_ARRAY: @@ -287,8 +287,8 @@ gi_field_info_get_field (GIFieldInfo *field_info, case GI_INFO_TYPE_FLAGS: { /* FIXME: there's a mismatch here between the value->v_int we use - * here and the gint64 result returned from gi_value_info_get_value(). - * But to switch this to gint64, we'd have to make gi_function_info_invoke() + * here and the int64_t result returned from gi_value_info_get_value(). + * But to switch this to int64_t, we'd have to make gi_function_info_invoke() * translate value->v_int64 to the proper ABI for an enum function * call parameter, which will usually be int, and then fix up language * bindings. @@ -298,22 +298,22 @@ gi_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 = (int)G_STRUCT_MEMBER (uint8_t, mem, offset); result = TRUE; break; case GI_TYPE_TAG_INT16: case GI_TYPE_TAG_UINT16: - value->v_int = (gint)G_STRUCT_MEMBER (guint16, mem, offset); + value->v_int = (int)G_STRUCT_MEMBER (uint16_t, mem, offset); result = TRUE; break; case GI_TYPE_TAG_INT32: case GI_TYPE_TAG_UINT32: - value->v_int = (gint)G_STRUCT_MEMBER (guint32, mem, offset); + value->v_int = (int)G_STRUCT_MEMBER (uint32_t, 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 = (int)G_STRUCT_MEMBER (uint64_t, mem, offset); result = TRUE; break; default: @@ -413,23 +413,23 @@ gi_field_info_set_field (GIFieldInfo *field_info, break; case GI_TYPE_TAG_INT8: case GI_TYPE_TAG_UINT8: - G_STRUCT_MEMBER (guint8, mem, offset) = value->v_uint8; + G_STRUCT_MEMBER (uint8_t, mem, offset) = value->v_uint8; result = TRUE; break; case GI_TYPE_TAG_INT16: case GI_TYPE_TAG_UINT16: - G_STRUCT_MEMBER (guint16, mem, offset) = value->v_uint16; + G_STRUCT_MEMBER (uint16_t, mem, offset) = value->v_uint16; result = TRUE; break; case GI_TYPE_TAG_INT32: case GI_TYPE_TAG_UINT32: case GI_TYPE_TAG_UNICHAR: - G_STRUCT_MEMBER (guint32, mem, offset) = value->v_uint32; + G_STRUCT_MEMBER (uint32_t, 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 (uint64_t, mem, offset) = value->v_uint64; result = TRUE; break; case GI_TYPE_TAG_GTYPE: @@ -437,11 +437,11 @@ gi_field_info_set_field (GIFieldInfo *field_info, result = TRUE; break; case GI_TYPE_TAG_FLOAT: - G_STRUCT_MEMBER (gfloat, mem, offset) = value->v_float; + G_STRUCT_MEMBER (float, 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 (double, mem, offset)= value->v_double; result = TRUE; break; case GI_TYPE_TAG_UTF8: @@ -479,22 +479,22 @@ gi_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 (uint8_t, mem, offset) = (uint8_t)value->v_int; result = TRUE; break; case GI_TYPE_TAG_INT16: case GI_TYPE_TAG_UINT16: - G_STRUCT_MEMBER (guint16, mem, offset) = (guint16)value->v_int; + G_STRUCT_MEMBER (uint16_t, mem, offset) = (uint16_t)value->v_int; result = TRUE; break; case GI_TYPE_TAG_INT32: case GI_TYPE_TAG_UINT32: - G_STRUCT_MEMBER (guint32, mem, offset) = (guint32)value->v_int; + G_STRUCT_MEMBER (uint32_t, mem, offset) = (uint32_t)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 (uint64_t, mem, offset) = (uint64_t)value->v_int; result = TRUE; break; default: diff --git a/girepository/gifunctioninfo.c b/girepository/gifunctioninfo.c index a79e874fe..525cd1ba1 100644 --- a/girepository/gifunctioninfo.c +++ b/girepository/gifunctioninfo.c @@ -50,15 +50,15 @@ GIFunctionInfo * gi_base_info_find_method (GIBaseInfo *base, - guint32 offset, - guint n_methods, + uint32_t offset, + unsigned n_methods, const char *name) { /* FIXME hash */ GIRealInfo *rinfo = (GIRealInfo*)base; Header *header = (Header *)rinfo->typelib->data; - for (guint i = 0; i < n_methods; i++) + for (unsigned i = 0; i < n_methods; i++) { FunctionBlob *fblob = (FunctionBlob *)&rinfo->typelib->data[offset]; const char *fname = (const char *)&rinfo->typelib->data[fblob->name]; diff --git a/girepository/giinterfaceinfo.c b/girepository/giinterfaceinfo.c index aad79cbad..e2eff78f0 100644 --- a/girepository/giinterfaceinfo.c +++ b/girepository/giinterfaceinfo.c @@ -55,7 +55,7 @@ * Returns: number of prerequisites * Since: 2.80 */ -guint +unsigned int gi_interface_info_get_n_prerequisites (GIInterfaceInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -82,7 +82,7 @@ gi_interface_info_get_n_prerequisites (GIInterfaceInfo *info) */ GIBaseInfo * gi_interface_info_get_prerequisite (GIInterfaceInfo *info, - guint n) + unsigned int n) { GIRealInfo *rinfo = (GIRealInfo *)info; InterfaceBlob *blob; @@ -106,7 +106,7 @@ gi_interface_info_get_prerequisite (GIInterfaceInfo *info, * Returns: number of properties * Since: 2.80 */ -guint +unsigned int gi_interface_info_get_n_properties (GIInterfaceInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -133,9 +133,9 @@ gi_interface_info_get_n_properties (GIInterfaceInfo *info) */ GIPropertyInfo * gi_interface_info_get_property (GIInterfaceInfo *info, - guint n) + unsigned int n) { - gint offset; + int offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; InterfaceBlob *blob; @@ -163,7 +163,7 @@ gi_interface_info_get_property (GIInterfaceInfo *info, * Returns: number of methods * Since: 2.80 */ -guint +unsigned int gi_interface_info_get_n_methods (GIInterfaceInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -190,9 +190,9 @@ gi_interface_info_get_n_methods (GIInterfaceInfo *info) */ GIFunctionInfo * gi_interface_info_get_method (GIInterfaceInfo *info, - guint n) + unsigned int n) { - gint offset; + int offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; InterfaceBlob *blob; @@ -230,7 +230,7 @@ GIFunctionInfo * gi_interface_info_find_method (GIInterfaceInfo *info, const char *name) { - gint offset; + int offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header = (Header *)rinfo->typelib->data; InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -251,7 +251,7 @@ gi_interface_info_find_method (GIInterfaceInfo *info, * Returns: number of signals * Since: 2.80 */ -guint +unsigned int gi_interface_info_get_n_signals (GIInterfaceInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -278,9 +278,9 @@ gi_interface_info_get_n_signals (GIInterfaceInfo *info) */ GISignalInfo * gi_interface_info_get_signal (GIInterfaceInfo *info, - guint n) + unsigned int n) { - gint offset; + int offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; InterfaceBlob *blob; @@ -319,10 +319,10 @@ GISignalInfo * gi_interface_info_find_signal (GIInterfaceInfo *info, const char *name) { - guint n_signals; + unsigned int n_signals; n_signals = gi_interface_info_get_n_signals (info); - for (guint i = 0; i < n_signals; i++) + for (unsigned int i = 0; i < n_signals; i++) { GISignalInfo *siginfo = gi_interface_info_get_signal (info, i); @@ -346,7 +346,7 @@ gi_interface_info_find_signal (GIInterfaceInfo *info, * Returns: number of virtual functions * Since: 2.80 */ -guint +unsigned int gi_interface_info_get_n_vfuncs (GIInterfaceInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -373,9 +373,9 @@ gi_interface_info_get_n_vfuncs (GIInterfaceInfo *info) */ GIVFuncInfo * gi_interface_info_get_vfunc (GIInterfaceInfo *info, - guint n) + unsigned int n) { - gint offset; + int offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; InterfaceBlob *blob; @@ -416,7 +416,7 @@ GIVFuncInfo * gi_interface_info_find_vfunc (GIInterfaceInfo *info, const char *name) { - gint offset; + int offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; InterfaceBlob *blob; @@ -445,7 +445,7 @@ gi_interface_info_find_vfunc (GIInterfaceInfo *info, * Returns: number of constants * Since: 2.80 */ -guint +unsigned int gi_interface_info_get_n_constants (GIInterfaceInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -472,9 +472,9 @@ gi_interface_info_get_n_constants (GIInterfaceInfo *info) */ GIConstantInfo * gi_interface_info_get_constant (GIInterfaceInfo *info, - guint n) + unsigned int n) { - gint offset; + int offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; InterfaceBlob *blob; diff --git a/girepository/giinterfaceinfo.h b/girepository/giinterfaceinfo.h index 638f56bd4..798d8bc84 100644 --- a/girepository/giinterfaceinfo.h +++ b/girepository/giinterfaceinfo.h @@ -45,58 +45,58 @@ G_BEGIN_DECLS GI_AVAILABLE_IN_ALL -guint gi_interface_info_get_n_prerequisites (GIInterfaceInfo *info); +unsigned int gi_interface_info_get_n_prerequisites (GIInterfaceInfo *info); GI_AVAILABLE_IN_ALL GIBaseInfo * gi_interface_info_get_prerequisite (GIInterfaceInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL -guint gi_interface_info_get_n_properties (GIInterfaceInfo *info); +unsigned int gi_interface_info_get_n_properties (GIInterfaceInfo *info); GI_AVAILABLE_IN_ALL GIPropertyInfo * gi_interface_info_get_property (GIInterfaceInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL -guint gi_interface_info_get_n_methods (GIInterfaceInfo *info); +unsigned int gi_interface_info_get_n_methods (GIInterfaceInfo *info); GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_interface_info_get_method (GIInterfaceInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_interface_info_find_method (GIInterfaceInfo *info, const char *name); GI_AVAILABLE_IN_ALL -guint gi_interface_info_get_n_signals (GIInterfaceInfo *info); +unsigned int gi_interface_info_get_n_signals (GIInterfaceInfo *info); GI_AVAILABLE_IN_ALL GISignalInfo * gi_interface_info_get_signal (GIInterfaceInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL GISignalInfo * gi_interface_info_find_signal (GIInterfaceInfo *info, const char *name); GI_AVAILABLE_IN_ALL -guint gi_interface_info_get_n_vfuncs (GIInterfaceInfo *info); +unsigned int gi_interface_info_get_n_vfuncs (GIInterfaceInfo *info); GI_AVAILABLE_IN_ALL GIVFuncInfo * gi_interface_info_get_vfunc (GIInterfaceInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL GIVFuncInfo * gi_interface_info_find_vfunc (GIInterfaceInfo *info, const char *name); GI_AVAILABLE_IN_ALL -guint gi_interface_info_get_n_constants (GIInterfaceInfo *info); +unsigned int gi_interface_info_get_n_constants (GIInterfaceInfo *info); GI_AVAILABLE_IN_ALL GIConstantInfo * gi_interface_info_get_constant (GIInterfaceInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL diff --git a/girepository/ginvoke.c b/girepository/ginvoke.c index 5b9399a20..20d882cdc 100644 --- a/girepository/ginvoke.c +++ b/girepository/ginvoke.c @@ -270,7 +270,7 @@ g_value_from_ffi_value (GValue *gvalue, void gi_cclosure_marshal_generic (GClosure *closure, GValue *return_gvalue, - guint n_param_values, + unsigned int n_param_values, const GValue *param_values, void *invocation_hint, void *marshal_data) diff --git a/girepository/giobjectinfo.c b/girepository/giobjectinfo.c index 097ad5f37..995f489e7 100644 --- a/girepository/giobjectinfo.c +++ b/girepository/giobjectinfo.c @@ -59,20 +59,20 @@ * Returns: field offset, in bytes * Since: 2.80 */ -static gint32 +static uint32_t gi_object_info_get_field_offset (GIObjectInfo *info, - guint n) + unsigned int n) { GIRealInfo *rinfo = (GIRealInfo *)info; Header *header = (Header *)rinfo->typelib->data; ObjectBlob *blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; - guint32 offset; + uint32_t offset; FieldBlob *field_blob; offset = rinfo->offset + header->object_blob_size + (blob->n_interfaces + blob->n_interfaces % 2) * 2; - for (guint i = 0; i < n; i++) + for (unsigned int i = 0; i < n; i++) { field_blob = (FieldBlob *)&rinfo->typelib->data[offset]; offset += header->field_blob_size; @@ -241,7 +241,7 @@ gi_object_info_get_type_init_function_name (GIObjectInfo *info) * Returns: number of interfaces * Since: 2.80 */ -guint +unsigned int gi_object_info_get_n_interfaces (GIObjectInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -268,7 +268,7 @@ gi_object_info_get_n_interfaces (GIObjectInfo *info) */ GIInterfaceInfo * gi_object_info_get_interface (GIObjectInfo *info, - guint n) + unsigned int n) { GIRealInfo *rinfo = (GIRealInfo *)info; ObjectBlob *blob; @@ -291,7 +291,7 @@ gi_object_info_get_interface (GIObjectInfo *info, * Returns: number of fields * Since: 2.80 */ -guint +unsigned int gi_object_info_get_n_fields (GIObjectInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -318,9 +318,9 @@ gi_object_info_get_n_fields (GIObjectInfo *info) */ GIFieldInfo * gi_object_info_get_field (GIObjectInfo *info, - guint n) + unsigned int n) { - gint offset; + int offset; GIRealInfo *rinfo = (GIRealInfo *)info; g_return_val_if_fail (info != NULL, NULL); @@ -340,7 +340,7 @@ gi_object_info_get_field (GIObjectInfo *info, * Returns: number of properties * Since: 2.80 */ -guint +unsigned int gi_object_info_get_n_properties (GIObjectInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -366,9 +366,9 @@ gi_object_info_get_n_properties (GIObjectInfo *info) */ GIPropertyInfo * gi_object_info_get_property (GIObjectInfo *info, - guint n) + unsigned int n) { - gint offset; + int offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; ObjectBlob *blob; @@ -398,7 +398,7 @@ gi_object_info_get_property (GIObjectInfo *info, * Returns: number of methods * Since: 2.80 */ -guint +unsigned int gi_object_info_get_n_methods (GIObjectInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -425,9 +425,9 @@ gi_object_info_get_n_methods (GIObjectInfo *info) */ GIFunctionInfo * gi_object_info_get_method (GIObjectInfo *info, - guint n) + unsigned int n) { - gint offset; + int offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; ObjectBlob *blob; @@ -468,7 +468,7 @@ GIFunctionInfo * gi_object_info_find_method (GIObjectInfo *info, const char *name) { - gint offset; + int offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; ObjectBlob *blob; @@ -559,7 +559,7 @@ gi_object_info_find_method_using_interfaces (GIObjectInfo *info, * Returns: number of signals * Since: 2.80 */ -guint +unsigned int gi_object_info_get_n_signals (GIObjectInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -586,9 +586,9 @@ gi_object_info_get_n_signals (GIObjectInfo *info) */ GISignalInfo * gi_object_info_get_signal (GIObjectInfo *info, - guint n) + unsigned int n) { - gint offset; + int offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; ObjectBlob *blob; @@ -629,10 +629,10 @@ GISignalInfo * gi_object_info_find_signal (GIObjectInfo *info, const char *name) { - guint n_signals; + unsigned int n_signals; n_signals = gi_object_info_get_n_signals (info); - for (guint i = 0; i < n_signals; i++) + for (unsigned int i = 0; i < n_signals; i++) { GISignalInfo *siginfo = gi_object_info_get_signal (info, i); @@ -657,7 +657,7 @@ gi_object_info_find_signal (GIObjectInfo *info, * Returns: number of virtual functions * Since: 2.80 */ -guint +unsigned int gi_object_info_get_n_vfuncs (GIObjectInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -684,9 +684,9 @@ gi_object_info_get_n_vfuncs (GIObjectInfo *info) */ GIVFuncInfo * gi_object_info_get_vfunc (GIObjectInfo *info, - guint n) + unsigned int n) { - gint offset; + int offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; ObjectBlob *blob; @@ -734,7 +734,7 @@ GIVFuncInfo * gi_object_info_find_vfunc (GIObjectInfo *info, const char *name) { - gint offset; + int offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; ObjectBlob *blob; @@ -832,7 +832,7 @@ gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *info, * Returns: number of constants * Since: 2.80 */ -guint +unsigned int gi_object_info_get_n_constants (GIObjectInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -859,9 +859,9 @@ gi_object_info_get_n_constants (GIObjectInfo *info) */ GIConstantInfo * gi_object_info_get_constant (GIObjectInfo *info, - guint n) + unsigned int n) { - gint offset; + int offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; ObjectBlob *blob; diff --git a/girepository/giobjectinfo.h b/girepository/giobjectinfo.h index d0e950403..c8b071d67 100644 --- a/girepository/giobjectinfo.h +++ b/girepository/giobjectinfo.h @@ -106,32 +106,32 @@ GI_AVAILABLE_IN_ALL GIObjectInfo * gi_object_info_get_parent (GIObjectInfo *info); GI_AVAILABLE_IN_ALL -guint gi_object_info_get_n_interfaces (GIObjectInfo *info); +unsigned int gi_object_info_get_n_interfaces (GIObjectInfo *info); GI_AVAILABLE_IN_ALL GIInterfaceInfo * gi_object_info_get_interface (GIObjectInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL -guint gi_object_info_get_n_fields (GIObjectInfo *info); +unsigned int gi_object_info_get_n_fields (GIObjectInfo *info); GI_AVAILABLE_IN_ALL GIFieldInfo * gi_object_info_get_field (GIObjectInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL -guint gi_object_info_get_n_properties (GIObjectInfo *info); +unsigned int gi_object_info_get_n_properties (GIObjectInfo *info); GI_AVAILABLE_IN_ALL GIPropertyInfo * gi_object_info_get_property (GIObjectInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL -guint gi_object_info_get_n_methods (GIObjectInfo *info); +unsigned int gi_object_info_get_n_methods (GIObjectInfo *info); GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_object_info_get_method (GIObjectInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_object_info_find_method (GIObjectInfo *info, @@ -145,11 +145,11 @@ GIFunctionInfo * gi_object_info_find_method_using_interfaces (GIObjectInfo *in GI_AVAILABLE_IN_ALL -guint gi_object_info_get_n_signals (GIObjectInfo *info); +unsigned int gi_object_info_get_n_signals (GIObjectInfo *info); GI_AVAILABLE_IN_ALL GISignalInfo * gi_object_info_get_signal (GIObjectInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL @@ -158,11 +158,11 @@ GISignalInfo * gi_object_info_find_signal (GIObjectInfo *info, GI_AVAILABLE_IN_ALL -guint gi_object_info_get_n_vfuncs (GIObjectInfo *info); +unsigned int gi_object_info_get_n_vfuncs (GIObjectInfo *info); GI_AVAILABLE_IN_ALL GIVFuncInfo * gi_object_info_get_vfunc (GIObjectInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL GIVFuncInfo * gi_object_info_find_vfunc (GIObjectInfo *info, @@ -174,11 +174,11 @@ GIVFuncInfo * gi_object_info_find_vfunc_using_interfaces (GIObjectInfo *inf GIObjectInfo **implementor); GI_AVAILABLE_IN_ALL -guint gi_object_info_get_n_constants (GIObjectInfo *info); +unsigned int gi_object_info_get_n_constants (GIObjectInfo *info); GI_AVAILABLE_IN_ALL GIConstantInfo * gi_object_info_get_constant (GIObjectInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL GIStructInfo * gi_object_info_get_class_struct (GIObjectInfo *info); diff --git a/girepository/girepository-private.h b/girepository/girepository-private.h index a9fb655ef..f3641ac5f 100644 --- a/girepository/girepository-private.h +++ b/girepository/girepository-private.h @@ -39,7 +39,7 @@ typedef struct _GIBaseInfo GIRealInfo; /* We changed a gint32 -> gint in the structure below, which should be * valid everywhere we care about. */ -G_STATIC_ASSERT (sizeof (int) == sizeof (gint32)); +G_STATIC_ASSERT (sizeof (int) == sizeof (int32_t)); /* * We just use one structure for all of the info object @@ -57,9 +57,9 @@ struct _GIBaseInfo GIBaseInfo *container; GITypelib *typelib; - guint32 offset; + uint32_t offset; - guint32 type_is_embedded : 1; /* Used by GITypeInfo */ + uint32_t type_is_embedded : 1; /* Used by GITypeInfo */ }; /* Subtypes */ @@ -215,33 +215,33 @@ void gi_info_init (GIRealInfo *info, GIRepository *repository, GIBaseInfo *container, GITypelib *typelib, - guint32 offset); + uint32_t offset); GIBaseInfo * gi_info_from_entry (GIRepository *repository, GITypelib *typelib, - guint16 index); + uint16_t index); GIBaseInfo * gi_info_new_full (GIInfoType type, GIRepository *repository, GIBaseInfo *container, GITypelib *typelib, - guint32 offset); + uint32_t offset); GITypeInfo * gi_type_info_new (GIBaseInfo *container, GITypelib *typelib, - guint32 offset); + uint32_t offset); void gi_type_info_init (GIBaseInfo *info, GIBaseInfo *container, GITypelib *typelib, - guint32 offset); + uint32_t offset); GIFunctionInfo * gi_base_info_find_method (GIBaseInfo *base, - guint32 offset, - guint n_methods, + uint32_t offset, + unsigned n_methods, const char *name); GIVFuncInfo * gi_base_info_find_vfunc (GIRealInfo *rinfo, - guint32 offset, - guint n_vfuncs, + uint32_t offset, + unsigned n_vfuncs, const char *name); diff --git a/girepository/girepository.c b/girepository/girepository.c index cd8512448..2d08047af 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -69,7 +69,7 @@ static GIRepository *default_repository = NULL; static GPtrArray *typelib_search_path = NULL; typedef struct { - guint n_interfaces; + unsigned int n_interfaces; GIBaseInfo *interfaces[]; } GTypeInterfaceCache; @@ -77,9 +77,8 @@ static void gtype_interface_cache_free (gpointer data) { GTypeInterfaceCache *cache = data; - guint i; - for (i = 0; i < cache->n_interfaces; i++) + for (unsigned int i = 0; i < cache->n_interfaces; i++) gi_base_info_unref ((GIBaseInfo*) cache->interfaces[i]); g_free (cache); } @@ -528,12 +527,11 @@ get_typelib_dependencies_transitive (GIRepository *repository, GITypelib *typelib, GHashTable *transitive_dependencies) { - guint i; char **immediate_dependencies; immediate_dependencies = get_typelib_dependencies (typelib); - for (i = 0; immediate_dependencies != NULL && immediate_dependencies[i]; i++) + for (unsigned int i = 0; immediate_dependencies != NULL && immediate_dependencies[i]; i++) { char *dependency; const char *last_dash; @@ -753,12 +751,12 @@ gi_repository_new (void) * Returns: number of metadata entries * Since: 2.80 */ -guint +unsigned int gi_repository_get_n_infos (GIRepository *repository, const char *namespace) { GITypelib *typelib; - guint n_interfaces = 0; + unsigned int n_interfaces = 0; g_return_val_if_fail (namespace != NULL, -1); @@ -794,7 +792,7 @@ gi_repository_get_n_infos (GIRepository *repository, GIBaseInfo * gi_repository_get_info (GIRepository *repository, const char *namespace, - guint idx) + unsigned int idx) { GITypelib *typelib; DirEntry *entry; @@ -1087,8 +1085,8 @@ gi_repository_get_object_gtype_interfaces (GIRepository *repository, if (cache == NULL) { GType *interfaces; - guint n_interfaces; - guint i; + unsigned int i; + unsigned int n_interfaces; GList *interface_infos = NULL, *iter; interfaces = g_type_interfaces (gtype, &n_interfaces); @@ -1154,7 +1152,7 @@ gi_repository_get_loaded_namespaces (GIRepository *repository) { GList *l, *list = NULL; char **names; - gint i; + int i; repository = get_repository (repository); diff --git a/girepository/girepository.h b/girepository/girepository.h index 6f8883d99..cac9413a8 100644 --- a/girepository/girepository.h +++ b/girepository/girepository.h @@ -169,13 +169,13 @@ void gi_repository_get_object_gtype_interfaces (GIRepository *repo GIInterfaceInfo ***interfaces_out); GI_AVAILABLE_IN_ALL -guint gi_repository_get_n_infos (GIRepository *repository, +unsigned int gi_repository_get_n_infos (GIRepository *repository, const char *namespace_); GI_AVAILABLE_IN_ALL GIBaseInfo * gi_repository_get_info (GIRepository *repository, const char *namespace_, - guint idx); + unsigned int idx); GI_AVAILABLE_IN_ALL GIEnumInfo * gi_repository_find_by_error_domain (GIRepository *repository, @@ -249,7 +249,7 @@ GQuark gi_repository_error_quark (void); GI_AVAILABLE_IN_ALL void gi_cclosure_marshal_generic (GClosure *closure, GValue *return_gvalue, - guint n_param_values, + unsigned int n_param_values, const GValue *param_values, void *invocation_hint, void *marshal_data); diff --git a/girepository/girffi.c b/girepository/girffi.c index 1629cfa16..7532fe3f5 100644 --- a/girepository/girffi.c +++ b/girepository/girffi.c @@ -176,7 +176,7 @@ gi_callable_info_get_ffi_arg_types (GICallableInfo *callable_info, ffi_type **arg_types; gboolean is_method, throws; size_t n_invoke_args; - guint n_args, i, offset; + unsigned int n_args, i, offset; g_return_val_if_fail (callable_info != NULL, NULL); diff --git a/girepository/girmodule-private.h b/girepository/girmodule-private.h index d99a5d3b4..8f1d62887 100644 --- a/girepository/girmodule-private.h +++ b/girepository/girmodule-private.h @@ -36,7 +36,7 @@ struct _GIIrTypelibBuild { GHashTable *strings; GHashTable *types; GList *nodes_with_attributes; - guint32 n_attributes; + uint32_t n_attributes; guchar *data; GList *stack; }; @@ -77,7 +77,7 @@ void gi_ir_module_add_include_module (GIIrModule *module, GITypelib * gi_ir_module_build_typelib (GIIrModule *module); -void gi_ir_module_fatal (GIIrTypelibBuild *build, guint line, const char *msg, ...) G_GNUC_PRINTF (3, 4) G_GNUC_NORETURN; +void gi_ir_module_fatal (GIIrTypelibBuild *build, unsigned int line, const char *msg, ...) G_GNUC_PRINTF (3, 4) G_GNUC_NORETURN; void gi_ir_node_init_stats (void); void gi_ir_node_dump_stats (void); diff --git a/girepository/girmodule.c b/girepository/girmodule.c index f7850632c..20c592aa2 100644 --- a/girepository/girmodule.c +++ b/girepository/girmodule.c @@ -98,7 +98,7 @@ gi_ir_module_free (GIIrModule *module) */ void gi_ir_module_fatal (GIIrTypelibBuild *build, - guint line, + unsigned int line, const char *msg, ...) { @@ -190,19 +190,19 @@ gi_ir_module_add_include_module (GIIrModule *module, struct AttributeWriteData { - guint count; + unsigned int count; guchar *databuf; GIIrNode *node; GHashTable *strings; - guint32 *offset; - guint32 *offset2; + uint32_t *offset; + uint32_t *offset2; }; static void write_attribute (gpointer key, gpointer value, gpointer datap) { struct AttributeWriteData *data = datap; - guint32 old_offset = *(data->offset); + uint32_t old_offset = *(data->offset); AttributeBlob *blob = (AttributeBlob*)&(data->databuf[old_offset]); *(data->offset) += sizeof (AttributeBlob); @@ -214,13 +214,13 @@ write_attribute (gpointer key, gpointer value, gpointer datap) data->count++; } -static guint +static unsigned write_attributes (GIIrModule *module, GIIrNode *node, GHashTable *strings, guchar *data, - guint32 *offset, - guint32 *offset2) + uint32_t *offset, + uint32_t *offset2) { struct AttributeWriteData wdata; wdata.count = 0; @@ -245,7 +245,7 @@ node_cmp_offset_func (const void *a, } static void -alloc_section (guint8 *data, SectionType section_id, guint32 offset) +alloc_section (uint8_t *data, SectionType section_id, uint32_t offset) { int i; Header *header = (Header*)data; @@ -266,21 +266,21 @@ alloc_section (guint8 *data, SectionType section_id, guint32 offset) g_assert_not_reached (); } -static guint8* -add_directory_index_section (guint8 *data, GIIrModule *module, guint32 *offset2) +static uint8_t * +add_directory_index_section (uint8_t *data, GIIrModule *module, uint32_t *offset2) { DirEntry *entry; Header *header = (Header*)data; GITypelibHashBuilder *dirindex_builder; - guint i, n_interfaces; - guint16 required_size; - guint32 new_offset; + uint16_t n_interfaces; + uint16_t required_size; + uint32_t new_offset; dirindex_builder = gi_typelib_hash_builder_new (); n_interfaces = ((Header *)data)->n_local_entries; - for (i = 0; i < n_interfaces; i++) + for (uint16_t i = 0; i < n_interfaces; i++) { const char *str; entry = (DirEntry *)&data[header->directory + (i * header->entry_blob_size)]; @@ -306,7 +306,7 @@ add_directory_index_section (guint8 *data, GIIrModule *module, guint32 *offset2) data = g_realloc (data, new_offset); - gi_typelib_hash_builder_pack (dirindex_builder, ((guint8*)data) + *offset2, required_size); + gi_typelib_hash_builder_pack (dirindex_builder, ((uint8_t*)data) + *offset2, required_size); *offset2 = new_offset; @@ -320,20 +320,20 @@ gi_ir_module_build_typelib (GIIrModule *module) GError *error = NULL; GITypelib *typelib; gsize length; - guint i; + unsigned int i; GList *e; Header *header; DirEntry *entry; - guint32 header_size; - guint32 dir_size; - guint32 n_entries; - guint32 n_local_entries; - guint32 size, offset, offset2, old_offset; + uint32_t header_size; + uint32_t dir_size; + uint32_t n_entries; + uint32_t n_local_entries; + uint32_t size, offset, offset2, old_offset; GHashTable *strings; GHashTable *types; GList *nodes_with_attributes; char *dependencies; - guchar *data; + uint8_t *data; Section *section; header_size = ALIGN_VALUE (sizeof (Header), 4); diff --git a/girepository/girnode-private.h b/girepository/girnode-private.h index 21f034423..8cd5d4a40 100644 --- a/girepository/girnode-private.h +++ b/girepository/girnode-private.h @@ -76,7 +76,7 @@ struct _GIIrNode char *name; GIIrModule *module; - guint32 offset; /* Assigned as we build the typelib */ + uint32_t offset; /* Assigned as we build the typelib */ GHashTable *attributes; }; @@ -122,16 +122,16 @@ struct _GIIrNodeType gboolean is_ghashtable; gboolean is_interface; gboolean is_error; - gint tag; + int tag; char *unparsed; gboolean zero_terminated; gboolean has_length; - gint length; + int length; gboolean has_size; - gint size; - gint array_type; + int size; + int array_type; GIIrNodeType *parameter_type1; GIIrNodeType *parameter_type2; @@ -155,8 +155,8 @@ struct _GIIrNodeParam gboolean shallow_transfer; GIScopeType scope; - gint8 closure; - gint8 destroy; + int8_t closure; + int8_t destroy; GIIrNodeType *type; }; @@ -199,7 +199,7 @@ struct _GIIrNodeSignal gboolean has_class_closure; gboolean true_stops_emit; - gint class_closure; + int class_closure; GList *parameters; GIIrNodeParam *result; @@ -222,7 +222,7 @@ struct _GIIrNodeVFunc GList *parameters; GIIrNodeParam *result; - gint offset; + int offset; }; struct _GIIrNodeField @@ -231,8 +231,8 @@ struct _GIIrNodeField gboolean readable; gboolean writable; - gint bits; - gint offset; + int bits; + int offset; GIIrNodeFunction *callback; GIIrNodeType *type; @@ -261,8 +261,8 @@ struct _GIIrNodeInterface GList *interfaces; GList *prerequisites; - gint alignment; - gint size; + int alignment; + int size; GList *members; }; @@ -273,7 +273,7 @@ struct _GIIrNodeValue gboolean deprecated; - gint64 value; + int64_t value; }; struct _GIIrNodeConstant @@ -292,7 +292,7 @@ struct _GIIrNodeEnum GIIrNode node; gboolean deprecated; - gint storage_type; + int storage_type; char *gtype_name; char *gtype_init; @@ -311,8 +311,8 @@ struct _GIIrNodeBoxed char *gtype_name; char *gtype_init; - gint alignment; - gint size; + int alignment; + int size; GList *members; }; @@ -334,8 +334,8 @@ struct _GIIrNodeStruct char *copy_func; char *free_func; - gint alignment; - gint size; + int alignment; + int size; GList *members; }; @@ -355,10 +355,10 @@ struct _GIIrNodeUnion char *copy_func; char *free_func; - gint alignment; - gint size; + int alignment; + int size; - gint discriminator_offset; + int discriminator_offset; GIIrNodeType *discriminator_type; }; @@ -366,23 +366,23 @@ struct _GIIrNodeUnion GIIrNode *gi_ir_node_new (GIIrNodeTypeId type, GIIrModule *module); void gi_ir_node_free (GIIrNode *node); -guint32 gi_ir_node_get_size (GIIrNode *node); -guint32 gi_ir_node_get_full_size (GIIrNode *node); +uint32_t gi_ir_node_get_size (GIIrNode *node); +uint32_t gi_ir_node_get_full_size (GIIrNode *node); void gi_ir_node_build_typelib (GIIrNode *node, GIIrNode *parent, GIIrTypelibBuild *build, - guint32 *offset, - guint32 *offset2, - guint16 *count2); + uint32_t *offset, + uint32_t *offset2, + uint16_t *count2); int gi_ir_node_cmp (GIIrNode *node, GIIrNode *other); gboolean gi_ir_node_can_have_member (GIIrNode *node); void gi_ir_node_add_member (GIIrNode *node, GIIrNodeFunction *member); -guint32 gi_ir_write_string (const char *str, +uint32_t gi_ir_write_string (const char *str, GHashTable *strings, guchar *data, - guint32 *offset); + uint32_t *offset); const char * gi_ir_node_param_direction_string (GIIrNodeParam * node); const char * gi_ir_node_type_to_string (GIIrNodeTypeId type); diff --git a/girepository/girnode.c b/girepository/girnode.c index 6efa65fd8..b77bbf97f 100644 --- a/girepository/girnode.c +++ b/girepository/girnode.c @@ -431,11 +431,11 @@ gi_ir_node_free (GIIrNode *node) } /* returns the fixed size of the blob */ -guint32 +uint32_t gi_ir_node_get_size (GIIrNode *node) { GList *l; - gint size, n; + int size, n; switch (node->type) { @@ -575,7 +575,7 @@ add_attribute_size (gpointer key, gpointer value, gpointer data) { const char *key_str = key; const char *value_str = value; - gint *size_p = data; + int *size_p = data; *size_p += sizeof (AttributeBlob); *size_p += ALIGN_VALUE (strlen (key_str) + 1, 4); @@ -583,12 +583,12 @@ add_attribute_size (gpointer key, gpointer value, gpointer data) } /* returns the full size of the blob including variable-size parts (including attributes) */ -static guint32 +static uint32_t gi_ir_node_get_full_size_internal (GIIrNode *parent, GIIrNode *node) { GList *l; - gint size, n; + int size, n; if (node == NULL && parent != NULL) g_error ("Caught NULL node, parent=%s", parent->name); @@ -893,7 +893,7 @@ gi_ir_node_get_full_size_internal (GIIrNode *parent, return size; } -guint32 +uint32_t gi_ir_node_get_full_size (GIIrNode *node) { return gi_ir_node_get_full_size_internal (NULL, node); @@ -1009,19 +1009,19 @@ gi_ir_node_param_direction_string (GIIrNodeParam * node) return "in"; } -static gint64 +static int64_t parse_int_value (const char *str) { return g_ascii_strtoll (str, NULL, 0); } -static guint64 +static uint64_t parse_uint_value (const char *str) { return g_ascii_strtoull (str, NULL, 0); } -static gdouble +static double parse_float_value (const char *str) { return g_ascii_strtod (str, NULL); @@ -1042,13 +1042,13 @@ parse_boolean_value (const char *str) static GIIrNode * find_entry_node (GIIrTypelibBuild *build, const char *name, - guint16 *idx) + uint16_t *idx) { GIIrModule *module = build->module; GList *l; - gint i; - gint n_names; + int i; + int n_names; char **names; GIIrNode *result = NULL; @@ -1112,11 +1112,11 @@ find_entry_node (GIIrTypelibBuild *build, return result; } -static guint16 +static uint16_t find_entry (GIIrTypelibBuild *build, const char *name) { - guint16 idx = 0; + uint16_t idx = 0; find_entry_node (build, name, &idx); @@ -1155,7 +1155,7 @@ gi_ir_find_node (GIIrTypelibBuild *build, GList *l; GIIrNode *return_node = NULL; char **names = g_strsplit (name, ".", 0); - gint n_names = g_strv_length (names); + int n_names = g_strv_length (names); const char *target_name; GIIrModule *target_module; @@ -1196,7 +1196,7 @@ get_index_of_member_type (GIIrNodeInterface *node, GIIrNodeTypeId type, const char *name) { - gint index = -1; + int index = -1; GList *l; for (l = node->members; l; l = l->next) @@ -1220,7 +1220,7 @@ serialize_type (GIIrTypelibBuild *build, GIIrNodeType *node, GString *str) { - gint i; + int i; if (GI_TYPE_TAG_IS_BASIC (node->tag)) { @@ -1341,12 +1341,12 @@ serialize_type (GIIrTypelibBuild *build, static void gi_ir_node_build_members (GList **members, GIIrNodeTypeId type, - guint16 *count, + uint16_t *count, GIIrNode *parent, GIIrTypelibBuild *build, - guint32 *offset, - guint32 *offset2, - guint16 *count2) + uint32_t *offset, + uint32_t *offset2, + uint16_t *count2) { GList *l = *members; @@ -1398,17 +1398,17 @@ void gi_ir_node_build_typelib (GIIrNode *node, GIIrNode *parent, GIIrTypelibBuild *build, - guint32 *offset, - guint32 *offset2, - guint16 *count2) + uint32_t *offset, + uint32_t *offset2, + uint16_t *count2) { gboolean appended_stack; GHashTable *strings = build->strings; GHashTable *types = build->types; guchar *data = build->data; GList *l; - guint32 old_offset = *offset; - guint32 old_offset2 = *offset2; + uint32_t old_offset = *offset; + uint32_t old_offset2 = *offset2; g_assert (node != NULL); @@ -1480,7 +1480,7 @@ gi_ir_node_build_typelib (GIIrNode *node, case GI_TYPE_TAG_ARRAY: { ArrayTypeBlob *array = (ArrayTypeBlob *)&data[*offset2]; - guint32 pos; + uint32_t pos; array->pointer = type->is_pointer; array->reserved = 0; @@ -1523,7 +1523,7 @@ gi_ir_node_build_typelib (GIIrNode *node, case GI_TYPE_TAG_GSLIST: { ParamTypeBlob *param = (ParamTypeBlob *)&data[*offset2]; - guint32 pos; + uint32_t pos; param->pointer = 1; param->reserved = 0; @@ -1542,7 +1542,7 @@ gi_ir_node_build_typelib (GIIrNode *node, case GI_TYPE_TAG_GHASH: { ParamTypeBlob *param = (ParamTypeBlob *)&data[*offset2]; - guint32 pos; + uint32_t pos; param->pointer = 1; param->reserved = 0; @@ -1653,7 +1653,7 @@ gi_ir_node_build_typelib (GIIrNode *node, g_error ("Unknown setter %s for property %s:%s", prop->setter, parent->name, node->name); } - blob->setter = (guint) index; + blob->setter = (unsigned int) index; } else blob->setter = ACCESSOR_SENTINEL; @@ -1668,7 +1668,7 @@ gi_ir_node_build_typelib (GIIrNode *node, g_error ("Unknown getter %s for property %s:%s", prop->getter, parent->name, node->name); } - blob->getter = (guint) index; + blob->getter = (unsigned int) index; } else blob->getter = ACCESSOR_SENTINEL; @@ -1683,8 +1683,8 @@ gi_ir_node_build_typelib (GIIrNode *node, FunctionBlob *blob = (FunctionBlob *)&data[*offset]; SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2]; GIIrNodeFunction *function = (GIIrNodeFunction *)node; - guint32 signature; - gint n; + uint32_t signature; + int n; signature = *offset2; n = g_list_length (function->parameters); @@ -1717,7 +1717,7 @@ gi_ir_node_build_typelib (GIIrNode *node, blob->setter = function->is_setter; blob->getter = function->is_getter; - blob->index = (guint) index; + blob->index = (unsigned int) index; } /* function->result is special since it doesn't appear in the serialized format but @@ -1759,8 +1759,8 @@ gi_ir_node_build_typelib (GIIrNode *node, CallbackBlob *blob = (CallbackBlob *)&data[*offset]; SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2]; GIIrNodeFunction *function = (GIIrNodeFunction *)node; - guint32 signature; - gint n; + uint32_t signature; + unsigned int n; signature = *offset2; n = g_list_length (function->parameters); @@ -1800,8 +1800,8 @@ gi_ir_node_build_typelib (GIIrNode *node, SignalBlob *blob = (SignalBlob *)&data[*offset]; SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2]; GIIrNodeSignal *signal = (GIIrNodeSignal *)node; - guint32 signature; - gint n; + uint32_t signature; + unsigned int n; signature = *offset2; n = g_list_length (signal->parameters); @@ -1858,8 +1858,8 @@ gi_ir_node_build_typelib (GIIrNode *node, VFuncBlob *blob = (VFuncBlob *)&data[*offset]; SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2]; GIIrNodeVFunc *vfunc = (GIIrNodeVFunc *)node; - guint32 signature; - gint n; + uint32_t signature; + unsigned int n; signature = *offset2; n = g_list_length (vfunc->parameters); @@ -1882,7 +1882,7 @@ gi_ir_node_build_typelib (GIIrNode *node, { g_error ("Unknown member function %s for vfunc %s", vfunc->invoker, node->name); } - blob->invoker = (guint) index; + blob->invoker = (unsigned int) index; } else blob->invoker = 0x3ff; /* max of 10 bits */ @@ -2204,7 +2204,7 @@ gi_ir_node_build_typelib (GIIrNode *node, for (l = object->interfaces; l; l = l->next) { blob->n_interfaces++; - *(guint16*)&data[*offset] = find_entry (build, (char *)l->data); + *(uint16_t *)&data[*offset] = find_entry (build, (char *)l->data); *offset += 2; } @@ -2267,7 +2267,7 @@ gi_ir_node_build_typelib (GIIrNode *node, for (l = iface->prerequisites; l; l = l->next) { blob->n_prerequisites++; - *(guint16*)&data[*offset] = find_entry (build, (char *)l->data); + *(uint16_t *)&data[*offset] = find_entry (build, (char *)l->data); *offset += 2; } @@ -2310,7 +2310,7 @@ gi_ir_node_build_typelib (GIIrNode *node, blob->reserved = 0; blob->unsigned_value = value->value >= 0 ? 1 : 0; blob->name = gi_ir_write_string (node->name, strings, data, offset2); - blob->value = (gint32)value->value; + blob->value = (int32_t) value->value; } break; @@ -2318,7 +2318,7 @@ gi_ir_node_build_typelib (GIIrNode *node, { GIIrNodeConstant *constant = (GIIrNodeConstant *)node; ConstantBlob *blob = (ConstantBlob *)&data[*offset]; - guint32 pos; + uint32_t pos; pos = *offset + G_STRUCT_OFFSET (ConstantBlob, type); *offset += sizeof (ConstantBlob); @@ -2337,43 +2337,43 @@ gi_ir_node_build_typelib (GIIrNode *node, break; case GI_TYPE_TAG_INT8: blob->size = 1; - *(gint8*)&data[blob->offset] = (gint8) parse_int_value (constant->value); + *(int8_t *)&data[blob->offset] = (int8_t) parse_int_value (constant->value); break; case GI_TYPE_TAG_UINT8: blob->size = 1; - *(guint8*)&data[blob->offset] = (guint8) parse_uint_value (constant->value); + *(uint8_t *)&data[blob->offset] = (uint8_t) parse_uint_value (constant->value); break; case GI_TYPE_TAG_INT16: blob->size = 2; - *(gint16*)&data[blob->offset] = (gint16) parse_int_value (constant->value); + *(int16_t *)&data[blob->offset] = (int16_t) parse_int_value (constant->value); break; case GI_TYPE_TAG_UINT16: blob->size = 2; - *(guint16*)&data[blob->offset] = (guint16) parse_uint_value (constant->value); + *(uint16_t *)&data[blob->offset] = (uint16_t) parse_uint_value (constant->value); break; case GI_TYPE_TAG_INT32: blob->size = 4; - *(gint32*)&data[blob->offset] = (gint32) parse_int_value (constant->value); + *(int32_t *)&data[blob->offset] = (int32_t) parse_int_value (constant->value); break; case GI_TYPE_TAG_UINT32: blob->size = 4; - *(guint32*)&data[blob->offset] = (guint32) parse_uint_value (constant->value); + *(uint32_t*)&data[blob->offset] = (uint32_t) parse_uint_value (constant->value); break; case GI_TYPE_TAG_INT64: blob->size = 8; - DO_ALIGNED_COPY(&data[blob->offset], parse_int_value (constant->value), gint64); + DO_ALIGNED_COPY (&data[blob->offset], parse_int_value (constant->value), int64_t); break; case GI_TYPE_TAG_UINT64: blob->size = 8; - DO_ALIGNED_COPY(&data[blob->offset], parse_uint_value (constant->value), guint64); + DO_ALIGNED_COPY (&data[blob->offset], parse_uint_value (constant->value), uint64_t); break; case GI_TYPE_TAG_FLOAT: - blob->size = sizeof (gfloat); - DO_ALIGNED_COPY(&data[blob->offset], parse_float_value (constant->value), gfloat); + blob->size = sizeof (float); + DO_ALIGNED_COPY (&data[blob->offset], parse_float_value (constant->value), float); break; case GI_TYPE_TAG_DOUBLE: - blob->size = sizeof (gdouble); - DO_ALIGNED_COPY(&data[blob->offset], parse_float_value (constant->value), gdouble); + blob->size = sizeof (double); + DO_ALIGNED_COPY (&data[blob->offset], parse_float_value (constant->value), double); break; case GI_TYPE_TAG_UTF8: case GI_TYPE_TAG_FILENAME: @@ -2411,13 +2411,13 @@ gi_ir_node_build_typelib (GIIrNode *node, * to the typelib at offset, put it in the pool and update offset. If the * typelib is not large enough to hold the string, reallocate it. */ -guint32 +uint32_t gi_ir_write_string (const char *str, GHashTable *strings, guchar *data, - guint32 *offset) + uint32_t *offset) { - guint32 start; + uint32_t start; void *value; string_count += 1; diff --git a/girepository/giroffsets.c b/girepository/giroffsets.c index 8031e03a8..91b81cf64 100644 --- a/girepository/giroffsets.c +++ b/girepository/giroffsets.c @@ -54,7 +54,7 @@ typedef enum { } Enum5; typedef enum { - ENUM_6 = ((guint)G_MAXINT) + 1 /* compiler could use uint32 */ + ENUM_6 = ((unsigned int)G_MAXINT) + 1 /* compiler could use uint32 */ } Enum6; typedef enum { @@ -73,8 +73,8 @@ static void compute_enum_storage_type (GIIrNodeEnum *enum_node) { GList *l; - gint64 max_value = 0; - gint64 min_value = 0; + int64_t max_value = 0; + int64_t min_value = 0; int width; gboolean signed_type; @@ -106,32 +106,32 @@ compute_enum_storage_type (GIIrNodeEnum *enum_node) if (max_value <= 127) { width = sizeof (Enum1); - signed_type = (gint64)(Enum1)(-1) < 0; + signed_type = (int64_t)(Enum1)(-1) < 0; } else if (max_value <= 255) { width = sizeof (Enum2); - signed_type = (gint64)(Enum2)(-1) < 0; + signed_type = (int64_t)(Enum2)(-1) < 0; } else if (max_value <= G_MAXSHORT) { width = sizeof (Enum3); - signed_type = (gint64)(Enum3)(-1) < 0; + signed_type = (int64_t)(Enum3)(-1) < 0; } else if (max_value <= G_MAXUSHORT) { width = sizeof (Enum4); - signed_type = (gint64)(Enum4)(-1) < 0; + signed_type = (int64_t)(Enum4)(-1) < 0; } else if (max_value <= G_MAXINT) { width = sizeof (Enum5); - signed_type = (gint64)(Enum5)(-1) < 0; + signed_type = (int64_t)(Enum5)(-1) < 0; } else { width = sizeof (Enum6); - signed_type = (gint64)(Enum6)(-1) < 0; + signed_type = (int64_t)(Enum6)(-1) < 0; } } @@ -149,8 +149,8 @@ compute_enum_storage_type (GIIrNodeEnum *enum_node) static gboolean get_enum_size_alignment (GIIrNodeEnum *enum_node, - gint *size, - gint *alignment) + int *size, + int *alignment) { ffi_type *type_ffi; @@ -188,8 +188,8 @@ get_enum_size_alignment (GIIrNodeEnum *enum_node, static gboolean get_interface_size_alignment (GIIrTypelibBuild *build, GIIrNodeType *type, - gint *size, - gint *alignment, + int *size, + int *alignment, const char *who) { GIIrNode *iface; @@ -265,8 +265,8 @@ get_interface_size_alignment (GIIrTypelibBuild *build, static gboolean get_type_size_alignment (GIIrTypelibBuild *build, GIIrNodeType *type, - gint *size, - gint *alignment, + int *size, + int *alignment, const char *who) { ffi_type *type_ffi; @@ -277,7 +277,7 @@ get_type_size_alignment (GIIrTypelibBuild *build, } else if (type->tag == GI_TYPE_TAG_ARRAY) { - gint elt_size, elt_alignment; + int elt_size, elt_alignment; if (!type->has_size || !get_type_size_alignment(build, type->parameter_type1, @@ -333,8 +333,8 @@ static gboolean get_field_size_alignment (GIIrTypelibBuild *build, GIIrNodeField *field, GIIrNode *parent_node, - gint *size, - gint *alignment) + int *size, + int *alignment) { GIIrModule *module = build->module; char *who; @@ -361,8 +361,8 @@ static gboolean compute_struct_field_offsets (GIIrTypelibBuild *build, GIIrNode *node, GList *members, - gint *size_out, - gint *alignment_out) + int *size_out, + int *alignment_out) { int size = 0; int alignment = 1; @@ -428,8 +428,8 @@ static gboolean compute_union_field_offsets (GIIrTypelibBuild *build, GIIrNode *node, GList *members, - gint *size_out, - gint *alignment_out) + int *size_out, + int *alignment_out) { int size = 0; int alignment = 1; @@ -483,7 +483,7 @@ compute_union_field_offsets (GIIrTypelibBuild *build, static gboolean check_needs_computation (GIIrTypelibBuild *build, GIIrNode *node, - gint alignment) + int alignment) { GIIrModule *module = build->module; /* diff --git a/girepository/girparser.c b/girepository/girparser.c index 1ad0562e5..f0336a2e2 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -383,9 +383,7 @@ find_attribute (const char *name, const char **attribute_names, const char **attribute_values) { - gint i; - - for (i = 0; attribute_names[i] != NULL; i++) + for (int i = 0; attribute_names[i] != NULL; i++) if (strcmp (attribute_names[i], name) == 0) return attribute_values[i]; @@ -435,8 +433,8 @@ static GIIrNodeType * parse_type_internal (GIIrModule *module, typedef struct { const char *str; - guint size; - guint is_signed : 1; + unsigned int size; + unsigned int is_signed : 1; } IntegerAliasInfo; static IntegerAliasInfo integer_aliases[] = { @@ -456,7 +454,7 @@ static IntegerAliasInfo integer_aliases[] = { typedef struct { const char *str; - gint tag; + int tag; gboolean pointer; } BasicTypeInfo; @@ -486,8 +484,8 @@ static BasicTypeInfo basic_types[] = { static const BasicTypeInfo * parse_basic (const char *str) { - guint i; - guint n_basic = G_N_ELEMENTS (basic_types); + unsigned int i; + unsigned int n_basic = G_N_ELEMENTS (basic_types); for (i = 0; i < n_basic; i++) { @@ -500,25 +498,25 @@ parse_basic (const char *str) { switch (integer_aliases[i].size) { - case sizeof(guint8): + case sizeof (uint8_t): if (integer_aliases[i].is_signed) return &basic_types[BASIC_TYPE_FIXED_OFFSET]; else return &basic_types[BASIC_TYPE_FIXED_OFFSET+1]; break; - case sizeof(guint16): + case sizeof (uint16_t): if (integer_aliases[i].is_signed) return &basic_types[BASIC_TYPE_FIXED_OFFSET+2]; else return &basic_types[BASIC_TYPE_FIXED_OFFSET+3]; break; - case sizeof(guint32): + case sizeof (uint32_t): if (integer_aliases[i].is_signed) return &basic_types[BASIC_TYPE_FIXED_OFFSET+4]; else return &basic_types[BASIC_TYPE_FIXED_OFFSET+5]; break; - case sizeof(guint64): + case sizeof (uint64_t): if (integer_aliases[i].is_signed) return &basic_types[BASIC_TYPE_FIXED_OFFSET+6]; else @@ -705,7 +703,7 @@ resolve_aliases (ParseContext *ctx, const char *type) if (g_slist_find_custom (seen_values, lookup, (GCompareFunc)strcmp) != NULL) break; - seen_values = g_slist_prepend (seen_values, (gchar*)lookup); + seen_values = g_slist_prepend (seen_values, (char*) lookup); } g_slist_free (seen_values); @@ -1661,7 +1659,7 @@ start_property (GMarkupParseContext *context, return TRUE; } -static gint64 +static int64_t parse_value (const char *str) { char *shift_op; @@ -1671,7 +1669,7 @@ parse_value (const char *str) if (shift_op) { - gint64 base, shift; + int64_t base, shift; base = g_ascii_strtoll (str, NULL, 10); shift = g_ascii_strtoll (shift_op + 3, NULL, 10); @@ -3243,7 +3241,7 @@ start_element_handler (GMarkupParseContext *context, if (*error == NULL && ctx->state != STATE_PASSTHROUGH) { - gint line_number, char_number; + int line_number, char_number; g_markup_parse_context_get_position (context, &line_number, &char_number); if (!g_str_has_prefix (element_name, "c:")) g_printerr ("%s:%d:%d: warning: element %s from state %d is unknown, ignoring\n", @@ -3255,7 +3253,7 @@ start_element_handler (GMarkupParseContext *context, out: if (*error) { - gint line_number, char_number; + int line_number, char_number; g_markup_parse_context_get_position (context, &line_number, &char_number); g_printerr ("%s:%d:%d: error: %s\n", ctx->file_path, line_number, char_number, (*error)->message); diff --git a/girepository/girwriter.c b/girepository/girwriter.c index 5d9763bf7..c9dcc7f0e 100644 --- a/girepository/girwriter.c +++ b/girepository/girwriter.c @@ -45,7 +45,7 @@ typedef struct { typedef struct { char *name; - guint has_children : 1; + unsigned has_children : 1; } XmlElement; static XmlElement * @@ -173,7 +173,7 @@ check_unresolved (GIBaseInfo *info) } static void -write_type_name (const char *ns, +write_type_name (const char *ns, GIBaseInfo *info, Xml *file) { @@ -184,7 +184,7 @@ write_type_name (const char *ns, } static void -write_type_name_attribute (const char *ns, +write_type_name_attribute (const char *ns, GIBaseInfo *info, const char *attr_name, Xml *file) @@ -215,11 +215,11 @@ write_ownership_transfer (GITransfer transfer, } static void -write_type_info (const char *ns, +write_type_info (const char *ns, GITypeInfo *info, Xml *file) { - gint tag; + int tag; GITypeInfo *type; gboolean is_pointer; @@ -244,7 +244,7 @@ write_type_info (const char *ns, } else if (tag == GI_TYPE_TAG_ARRAY) { - gint length; + int length; gssize size; const char *name = NULL; @@ -379,7 +379,7 @@ write_return_value_attributes (Xml *file, } static void -write_constant_value (const char *ns, +write_constant_value (const char *ns, GITypeInfo *info, GIArgument *argument, Xml *file); @@ -390,15 +390,15 @@ write_callback_info (const char *ns, Xml *file); static void -write_field_info (const char *ns, +write_field_info (const char *ns, GIFieldInfo *info, GIConstantInfo *branch, Xml *file) { const char *name; GIFieldInfoFlags flags; - gint size; - gint offset; + int size; + int offset; GITypeInfo *type; GIBaseInfo *interface; GIArgument value; @@ -490,7 +490,7 @@ write_callable_info (const char *ns, return; xml_start_element (file, "parameters"); - for (guint i = 0; i < gi_callable_info_get_n_args (info); i++) + for (unsigned int i = 0; i < gi_callable_info_get_n_args (info); i++) { GIArgInfo *arg = gi_callable_info_get_arg (info, i); @@ -568,7 +568,7 @@ write_callable_info (const char *ns, } static void -write_function_info (const char *ns, +write_function_info (const char *ns, GIFunctionInfo *info, Xml *file) { @@ -651,8 +651,8 @@ write_struct_info (const char *ns, gboolean deprecated; gboolean is_gtype_struct; gboolean foreign; - gint size; - guint n_elts; + int size; + unsigned int n_elts; name = gi_base_info_get_name ((GIBaseInfo *)info); deprecated = gi_base_info_is_deprecated ((GIBaseInfo *)info); @@ -702,14 +702,14 @@ write_struct_info (const char *ns, n_elts = gi_struct_info_get_n_fields (info) + gi_struct_info_get_n_methods (info); if (n_elts > 0) { - for (guint i = 0; i < gi_struct_info_get_n_fields (info); i++) + for (unsigned int i = 0; i < gi_struct_info_get_n_fields (info); i++) { GIFieldInfo *field = gi_struct_info_get_field (info, i); write_field_info (ns, field, NULL, file); gi_base_info_unref ((GIBaseInfo *)field); } - for (guint i = 0; i < gi_struct_info_get_n_methods (info); i++) + for (unsigned int i = 0; i < gi_struct_info_get_n_methods (info); i++) { GIFunctionInfo *function = gi_struct_info_get_method (info, i); write_function_info (ns, function, file); @@ -722,12 +722,12 @@ write_struct_info (const char *ns, } static void -write_value_info (const char *ns, +write_value_info (const char *ns, GIValueInfo *info, Xml *file) { const char *name; - gint64 value; + int64_t value; char *value_str; gboolean deprecated; @@ -863,7 +863,7 @@ write_enum_info (const char *ns, write_attributes (file, (GIBaseInfo*) info); - for (guint i = 0; i < gi_enum_info_get_n_values (info); i++) + for (unsigned int i = 0; i < gi_enum_info_get_n_values (info); i++) { GIValueInfo *value = gi_enum_info_get_value (info, i); write_value_info (ns, value, file); @@ -925,7 +925,7 @@ write_vfunc_info (const char *ns, const char *name; GIFunctionInfo *invoker; gboolean deprecated; - gint offset; + int offset; name = gi_base_info_get_name ((GIBaseInfo *)info); flags = gi_vfunc_info_get_flags (info); @@ -1100,7 +1100,7 @@ write_object_info (const char *ns, if (gi_object_info_get_n_interfaces (info) > 0) { - for (guint i = 0; i < gi_object_info_get_n_interfaces (info); i++) + for (unsigned int i = 0; i < gi_object_info_get_n_interfaces (info); i++) { GIInterfaceInfo *imp = gi_object_info_get_interface (info, i); xml_start_element (file, "implements"); @@ -1110,42 +1110,42 @@ write_object_info (const char *ns, } } - for (guint i = 0; i < gi_object_info_get_n_fields (info); i++) + for (unsigned int i = 0; i < gi_object_info_get_n_fields (info); i++) { GIFieldInfo *field = gi_object_info_get_field (info, i); write_field_info (ns, field, NULL, file); gi_base_info_unref ((GIBaseInfo *)field); } - for (guint i = 0; i < gi_object_info_get_n_methods (info); i++) + for (unsigned int i = 0; i < gi_object_info_get_n_methods (info); i++) { GIFunctionInfo *function = gi_object_info_get_method (info, i); write_function_info (ns, function, file); gi_base_info_unref ((GIBaseInfo *)function); } - for (guint i = 0; i < gi_object_info_get_n_properties (info); i++) + for (unsigned int i = 0; i < gi_object_info_get_n_properties (info); i++) { GIPropertyInfo *prop = gi_object_info_get_property (info, i); write_property_info (ns, prop, file); gi_base_info_unref ((GIBaseInfo *)prop); } - for (guint i = 0; i < gi_object_info_get_n_signals (info); i++) + for (unsigned int i = 0; i < gi_object_info_get_n_signals (info); i++) { GISignalInfo *signal = gi_object_info_get_signal (info, i); write_signal_info (ns, signal, file); gi_base_info_unref ((GIBaseInfo *)signal); } - for (guint i = 0; i < gi_object_info_get_n_vfuncs (info); i++) + for (unsigned int i = 0; i < gi_object_info_get_n_vfuncs (info); i++) { GIVFuncInfo *vfunc = gi_object_info_get_vfunc (info, i); write_vfunc_info (ns, vfunc, file); gi_base_info_unref ((GIBaseInfo *)vfunc); } - for (guint i = 0; i < gi_object_info_get_n_constants (info); i++) + for (unsigned int i = 0; i < gi_object_info_get_n_constants (info); i++) { GIConstantInfo *constant = gi_object_info_get_constant (info, i); write_constant_info (ns, constant, file); @@ -1189,7 +1189,7 @@ write_interface_info (const char *ns, if (gi_interface_info_get_n_prerequisites (info) > 0) { - for (guint i = 0; i < gi_interface_info_get_n_prerequisites (info); i++) + for (unsigned int i = 0; i < gi_interface_info_get_n_prerequisites (info); i++) { GIBaseInfo *req = gi_interface_info_get_prerequisite (info, i); @@ -1201,35 +1201,35 @@ write_interface_info (const char *ns, } } - for (guint i = 0; i < gi_interface_info_get_n_methods (info); i++) + for (unsigned int i = 0; i < gi_interface_info_get_n_methods (info); i++) { GIFunctionInfo *function = gi_interface_info_get_method (info, i); write_function_info (ns, function, file); gi_base_info_unref ((GIBaseInfo *)function); } - for (guint i = 0; i < gi_interface_info_get_n_properties (info); i++) + for (unsigned int i = 0; i < gi_interface_info_get_n_properties (info); i++) { GIPropertyInfo *prop = gi_interface_info_get_property (info, i); write_property_info (ns, prop, file); gi_base_info_unref ((GIBaseInfo *)prop); } - for (guint i = 0; i < gi_interface_info_get_n_signals (info); i++) + for (unsigned int i = 0; i < gi_interface_info_get_n_signals (info); i++) { GISignalInfo *signal = gi_interface_info_get_signal (info, i); write_signal_info (ns, signal, file); gi_base_info_unref ((GIBaseInfo *)signal); } - for (guint i = 0; i < gi_interface_info_get_n_vfuncs (info); i++) + for (unsigned int i = 0; i < gi_interface_info_get_n_vfuncs (info); i++) { GIVFuncInfo *vfunc = gi_interface_info_get_vfunc (info, i); write_vfunc_info (ns, vfunc, file); gi_base_info_unref ((GIBaseInfo *)vfunc); } - for (guint i = 0; i < gi_interface_info_get_n_constants (info); i++) + for (unsigned int i = 0; i < gi_interface_info_get_n_constants (info); i++) { GIConstantInfo *constant = gi_interface_info_get_constant (info, i); write_constant_info (ns, constant, file); @@ -1240,7 +1240,7 @@ write_interface_info (const char *ns, } static void -write_union_info (const char *ns, +write_union_info (const char *ns, GIUnionInfo *info, Xml *file) { @@ -1282,7 +1282,7 @@ write_union_info (const char *ns, if (gi_union_info_is_discriminated (info)) { - guint offset; + unsigned int offset; GITypeInfo *type; offset = gi_union_info_get_discriminator_offset (info); @@ -1295,7 +1295,7 @@ write_union_info (const char *ns, gi_base_info_unref ((GIBaseInfo *)type); } - for (guint i = 0; i < gi_union_info_get_n_fields (info); i++) + for (unsigned int i = 0; i < gi_union_info_get_n_fields (info); i++) { GIFieldInfo *field = gi_union_info_get_field (info, i); GIConstantInfo *constant = gi_union_info_get_discriminator (info, i); @@ -1305,7 +1305,7 @@ write_union_info (const char *ns, gi_base_info_unref ((GIBaseInfo *)constant); } - for (guint i = 0; i < gi_union_info_get_n_methods (info); i++) + for (unsigned int i = 0; i < gi_union_info_get_n_methods (info); i++) { GIFunctionInfo *function = gi_union_info_get_method (info, i); write_function_info (ns, function, file); @@ -1335,7 +1335,7 @@ gi_ir_writer_write (const char *filename, gboolean show_all) { FILE *ofile; - gint i, j; + int i, j; char **dependencies; GIRepository *repository; Xml *xml; @@ -1394,7 +1394,7 @@ gi_ir_writer_write (const char *filename, const char *c_prefix; const char *cur_ns = ns; const char *cur_version; - gint n_infos; + int n_infos; cur_version = gi_repository_get_version (repository, cur_ns); diff --git a/girepository/gistructinfo.c b/girepository/gistructinfo.c index 37edd0009..e06e78d8a 100644 --- a/girepository/gistructinfo.c +++ b/girepository/gistructinfo.c @@ -53,7 +53,7 @@ * Returns: number of fields * Since: 2.80 */ -guint +unsigned int gi_struct_info_get_n_fields (GIStructInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -72,16 +72,16 @@ gi_struct_info_get_n_fields (GIStructInfo *info) * Returns: field offset, in bytes * Since: 2.80 */ -static gint32 +static int32_t gi_struct_get_field_offset (GIStructInfo *info, - guint n) + unsigned int n) { GIRealInfo *rinfo = (GIRealInfo *)info; Header *header = (Header *)rinfo->typelib->data; - guint32 offset = rinfo->offset + header->struct_blob_size; + uint32_t offset = rinfo->offset + header->struct_blob_size; FieldBlob *field_blob; - for (guint i = 0; i < n; i++) + for (unsigned int i = 0; i < n; i++) { field_blob = (FieldBlob *)&rinfo->typelib->data[offset]; offset += header->field_blob_size; @@ -105,7 +105,7 @@ gi_struct_get_field_offset (GIStructInfo *info, */ GIFieldInfo * gi_struct_info_get_field (GIStructInfo *info, - guint n) + unsigned int n) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -132,8 +132,8 @@ gi_struct_info_find_field (GIStructInfo *info, GIRealInfo *rinfo = (GIRealInfo *)info; StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset]; Header *header = (Header *)rinfo->typelib->data; - guint32 offset = rinfo->offset + header->struct_blob_size; - gint i; + uint32_t offset = rinfo->offset + header->struct_blob_size; + int i; for (i = 0; i < blob->n_fields; i++) { @@ -165,7 +165,7 @@ gi_struct_info_find_field (GIStructInfo *info, * Returns: number of methods * Since: 2.80 */ -guint +unsigned int gi_struct_info_get_n_methods (GIStructInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -187,12 +187,12 @@ gi_struct_info_get_n_methods (GIStructInfo *info) */ GIFunctionInfo * gi_struct_info_get_method (GIStructInfo *info, - guint n) + unsigned int n) { GIRealInfo *rinfo = (GIRealInfo *)info; StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset]; Header *header = (Header *)rinfo->typelib->data; - gint offset; + int offset; offset = gi_struct_get_field_offset (info, blob->n_fields) + n * header->function_blob_size; return (GIFunctionInfo *) gi_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info, @@ -215,7 +215,7 @@ GIFunctionInfo * gi_struct_info_find_method (GIStructInfo *info, const char *name) { - gint offset; + int offset; GIRealInfo *rinfo = (GIRealInfo *)info; StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset]; diff --git a/girepository/gistructinfo.h b/girepository/gistructinfo.h index d8e04fd28..95a30d80e 100644 --- a/girepository/gistructinfo.h +++ b/girepository/gistructinfo.h @@ -45,22 +45,22 @@ G_BEGIN_DECLS GI_AVAILABLE_IN_ALL -guint gi_struct_info_get_n_fields (GIStructInfo *info); +unsigned int gi_struct_info_get_n_fields (GIStructInfo *info); GI_AVAILABLE_IN_ALL GIFieldInfo * gi_struct_info_get_field (GIStructInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL GIFieldInfo * gi_struct_info_find_field (GIStructInfo *info, const char *name); GI_AVAILABLE_IN_ALL -guint gi_struct_info_get_n_methods (GIStructInfo *info); +unsigned int gi_struct_info_get_n_methods (GIStructInfo *info); GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_struct_info_get_method (GIStructInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_struct_info_find_method (GIStructInfo *info, diff --git a/girepository/gitypeinfo.c b/girepository/gitypeinfo.c index 13957f772..349e0f879 100644 --- a/girepository/gitypeinfo.c +++ b/girepository/gitypeinfo.c @@ -135,8 +135,8 @@ gi_type_info_get_tag (GITypeInfo *info) * Since: 2.80 */ GITypeInfo * -gi_type_info_get_param_type (GITypeInfo *info, - guint n) +gi_type_info_get_param_type (GITypeInfo *info, + unsigned int n) { GIRealInfo *rinfo = (GIRealInfo *)info; SimpleTypeBlob *type; @@ -241,7 +241,7 @@ gi_type_info_get_interface (GITypeInfo *info) * or it has no length argument * Since: 2.80 */ -gint +int gi_type_info_get_array_length_index (GITypeInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -435,23 +435,23 @@ gi_type_tag_argument_from_hash_pointer (GITypeTag storage_type, arg->v_boolean = !!GPOINTER_TO_INT (hash_pointer); break; case GI_TYPE_TAG_INT8: - arg->v_int8 = (gint8)GPOINTER_TO_INT (hash_pointer); + arg->v_int8 = (int8_t) GPOINTER_TO_INT (hash_pointer); break; case GI_TYPE_TAG_UINT8: - arg->v_uint8 = (guint8)GPOINTER_TO_UINT (hash_pointer); + arg->v_uint8 = (uint8_t) GPOINTER_TO_UINT (hash_pointer); break; case GI_TYPE_TAG_INT16: - arg->v_int16 = (gint16)GPOINTER_TO_INT (hash_pointer); + arg->v_int16 = (int16_t) GPOINTER_TO_INT (hash_pointer); break; case GI_TYPE_TAG_UINT16: - arg->v_uint16 = (guint16)GPOINTER_TO_UINT (hash_pointer); + arg->v_uint16 = (uint16_t) GPOINTER_TO_UINT (hash_pointer); break; case GI_TYPE_TAG_INT32: - arg->v_int32 = (gint32)GPOINTER_TO_INT (hash_pointer); + arg->v_int32 = (int32_t) GPOINTER_TO_INT (hash_pointer); break; case GI_TYPE_TAG_UINT32: case GI_TYPE_TAG_UNICHAR: - arg->v_uint32 = (guint32)GPOINTER_TO_UINT (hash_pointer); + arg->v_uint32 = (uint32_t) GPOINTER_TO_UINT (hash_pointer); break; case GI_TYPE_TAG_GTYPE: arg->v_size = GPOINTER_TO_SIZE (hash_pointer); diff --git a/girepository/gitypeinfo.h b/girepository/gitypeinfo.h index c6b99f056..56a5c7c24 100644 --- a/girepository/gitypeinfo.h +++ b/girepository/gitypeinfo.h @@ -89,14 +89,14 @@ GI_AVAILABLE_IN_ALL GITypeTag gi_type_info_get_tag (GITypeInfo *info); GI_AVAILABLE_IN_ALL -GITypeInfo * gi_type_info_get_param_type (GITypeInfo *info, - guint n); +GITypeInfo * gi_type_info_get_param_type (GITypeInfo *info, + unsigned int n); GI_AVAILABLE_IN_ALL GIBaseInfo * gi_type_info_get_interface (GITypeInfo *info); GI_AVAILABLE_IN_ALL -gint gi_type_info_get_array_length_index (GITypeInfo *info); +int gi_type_info_get_array_length_index (GITypeInfo *info); GI_AVAILABLE_IN_ALL gssize gi_type_info_get_array_fixed_size (GITypeInfo *info); diff --git a/girepository/gitypelib-internal.h b/girepository/gitypelib-internal.h index 0600ef320..6e7a1e8f6 100644 --- a/girepository/gitypelib-internal.h +++ b/girepository/gitypelib-internal.h @@ -288,46 +288,46 @@ _blob_is_registered_type (GITypelibBlobType blob_type) */ typedef struct { char magic[16]; - guint8 major_version; - guint8 minor_version; - guint16 reserved; - guint16 n_entries; - guint16 n_local_entries; - guint32 directory; - guint32 n_attributes; - guint32 attributes; + uint8_t major_version; + uint8_t minor_version; + uint16_t reserved; + uint16_t n_entries; + uint16_t n_local_entries; + uint32_t directory; + uint32_t n_attributes; + uint32_t attributes; - guint32 dependencies; + uint32_t dependencies; - guint32 size; - guint32 namespace; - guint32 nsversion; - guint32 shared_library; - guint32 c_prefix; + uint32_t size; + uint32_t namespace; + uint32_t nsversion; + uint32_t shared_library; + uint32_t c_prefix; - guint16 entry_blob_size; - guint16 function_blob_size; - guint16 callback_blob_size; - guint16 signal_blob_size; - guint16 vfunc_blob_size; - guint16 arg_blob_size; - guint16 property_blob_size; - guint16 field_blob_size; - guint16 value_blob_size; - guint16 attribute_blob_size; - guint16 constant_blob_size; - guint16 error_domain_blob_size; + uint16_t entry_blob_size; + uint16_t function_blob_size; + uint16_t callback_blob_size; + uint16_t signal_blob_size; + uint16_t vfunc_blob_size; + uint16_t arg_blob_size; + uint16_t property_blob_size; + uint16_t field_blob_size; + uint16_t value_blob_size; + uint16_t attribute_blob_size; + uint16_t constant_blob_size; + uint16_t error_domain_blob_size; - guint16 signature_blob_size; - guint16 enum_blob_size; - guint16 struct_blob_size; - guint16 object_blob_size; - guint16 interface_blob_size; - guint16 union_blob_size; + uint16_t signature_blob_size; + uint16_t enum_blob_size; + uint16_t struct_blob_size; + uint16_t object_blob_size; + uint16_t interface_blob_size; + uint16_t union_blob_size; - guint32 sections; + uint32_t sections; - guint16 padding[6]; + uint16_t padding[6]; } Header; /** @@ -357,8 +357,8 @@ typedef enum { * Since: 2.80 */ typedef struct { - guint32 id; - guint32 offset; + uint32_t id; + uint32_t offset; } Section; @@ -380,12 +380,12 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint16 blob_type; + uint16_t blob_type; - guint16 local : 1; - guint16 reserved :15; - guint32 name; - guint32 offset; + uint16_t local : 1; + uint16_t reserved :15; + uint32_t name; + uint32_t offset; } DirEntry; /** @@ -401,17 +401,17 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint reserved : 8; - guint reserved2 :16; - guint pointer : 1; - guint reserved3 : 2; - guint tag : 5; + unsigned reserved : 8; + unsigned reserved2 :16; + unsigned pointer : 1; + unsigned reserved3 : 2; + unsigned tag : 5; } SimpleTypeBlobFlags; union _SimpleTypeBlob { SimpleTypeBlobFlags flags; - guint32 offset; + uint32_t offset; }; /** @@ -489,23 +489,23 @@ typedef union _SimpleTypeBlob SimpleTypeBlob; * Since: 2.80 */ typedef struct { - guint32 name; + uint32_t name; - guint in : 1; - guint out : 1; - guint caller_allocates : 1; - guint nullable : 1; - guint optional : 1; - guint transfer_ownership : 1; - guint transfer_container_ownership : 1; - guint return_value : 1; - guint scope : 3; - guint skip : 1; - guint reserved :20; - gint8 closure; - gint8 destroy; + unsigned in : 1; + unsigned out : 1; + unsigned caller_allocates : 1; + unsigned nullable : 1; + unsigned optional : 1; + unsigned transfer_ownership : 1; + unsigned transfer_container_ownership : 1; + unsigned return_value : 1; + unsigned scope : 3; + unsigned skip : 1; + unsigned reserved :20; + int8_t closure; + int8_t destroy; - guint16 padding; + uint16_t padding; SimpleTypeBlob arg_type; } ArgBlob; @@ -538,15 +538,15 @@ typedef struct { typedef struct { SimpleTypeBlob return_type; - guint16 may_return_null : 1; - guint16 caller_owns_return_value : 1; - guint16 caller_owns_return_container : 1; - guint16 skip_return : 1; - guint16 instance_transfer_ownership : 1; - guint16 throws : 1; - guint16 reserved :10; + uint16_t may_return_null : 1; + uint16_t caller_owns_return_value : 1; + uint16_t caller_owns_return_container : 1; + uint16_t skip_return : 1; + uint16_t instance_transfer_ownership : 1; + uint16_t throws : 1; + uint16_t reserved :10; - guint16 n_arguments; + uint16_t n_arguments; ArgBlob arguments[]; } SignatureBlob; @@ -566,11 +566,11 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint16 blob_type; /* 1 */ + uint16_t blob_type; /* 1 */ - guint16 deprecated : 1; - guint16 reserved :15; - guint32 name; + uint16_t deprecated : 1; + uint16_t reserved :15; + uint32_t name; } CommonBlob; /** @@ -605,26 +605,26 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint16 blob_type; /* 1 */ + uint16_t blob_type; /* 1 */ - guint16 deprecated : 1; - guint16 setter : 1; - guint16 getter : 1; - guint16 constructor : 1; - guint16 wraps_vfunc : 1; - guint16 throws : 1; - guint16 index :10; + uint16_t deprecated : 1; + uint16_t setter : 1; + uint16_t getter : 1; + uint16_t constructor : 1; + uint16_t wraps_vfunc : 1; + uint16_t throws : 1; + uint16_t index :10; /* Note the bits above need to match CommonBlob * and are thus exhausted, extend things using * the reserved block below. */ - guint32 name; - guint32 symbol; - guint32 signature; + uint32_t name; + uint32_t symbol; + uint32_t signature; - guint16 is_static : 1; - guint16 reserved : 15; - guint16 reserved2 : 16; + uint16_t is_static : 1; + uint16_t reserved : 15; + uint16_t reserved2 : 16; } FunctionBlob; /** @@ -641,12 +641,12 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint16 blob_type; /* 2 */ + uint16_t blob_type; /* 2 */ - guint16 deprecated : 1; - guint16 reserved :15; - guint32 name; - guint32 signature; + uint16_t deprecated : 1; + uint16_t reserved :15; + uint32_t name; + uint32_t signature; } CallbackBlob; /** @@ -662,11 +662,11 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint8 pointer :1; - guint8 reserved :2; - guint8 tag :5; - guint8 reserved2; - guint16 interface; + uint8_t pointer :1; + uint8_t reserved :2; + uint8_t tag :5; + uint8_t reserved2; + uint16_t interface; } InterfaceTypeBlob; /** @@ -679,8 +679,8 @@ typedef struct { * Since: 2.80 */ typedef union { - guint16 length; - guint16 size; + uint16_t length; + uint16_t size; } ArrayTypeDimension; /** @@ -706,15 +706,15 @@ typedef union { * Since: 2.80 */ typedef struct { - guint16 pointer :1; - guint16 reserved :2; - guint16 tag :5; + uint16_t pointer :1; + uint16_t reserved :2; + uint16_t tag :5; - guint16 zero_terminated :1; - guint16 has_length :1; - guint16 has_size :1; - guint16 array_type :2; - guint16 reserved2 :3; + uint16_t zero_terminated :1; + uint16_t has_length :1; + uint16_t has_size :1; + uint16_t array_type :2; + uint16_t reserved2 :3; ArrayTypeDimension dimensions; @@ -735,12 +735,12 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint8 pointer :1; - guint8 reserved :2; - guint8 tag :5; + uint8_t pointer :1; + uint8_t reserved :2; + uint8_t tag :5; - guint8 reserved2; - guint16 n_types; + uint8_t reserved2; + uint16_t n_types; SimpleTypeBlob type[]; } ParamTypeBlob; @@ -759,20 +759,20 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint8 pointer :1; - guint8 reserved :2; - guint8 tag :5; + uint8_t pointer :1; + uint8_t reserved :2; + uint8_t tag :5; - guint8 reserved2; + uint8_t reserved2; - guint16 n_domains; /* Must be 0 */ - guint16 domains[]; + uint16_t n_domains; /* Must be 0 */ + uint16_t domains[]; } ErrorTypeBlob; /** * ValueBlob: * @deprecated: Whether this value is deprecated - * @unsigned_value: if set, value is a 32-bit unsigned integer cast to gint32 + * @unsigned_value: if set, value is a 32-bit unsigned integer cast to int32_t * @reserved: Reserved for future use. * @name: Name of blob * @value: The numerical value @@ -782,11 +782,11 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint32 deprecated : 1; - guint32 unsigned_value : 1; - guint32 reserved :30; - guint32 name; - gint32 value; + uint32_t deprecated : 1; + uint32_t unsigned_value : 1; + uint32_t reserved :30; + uint32_t name; + int32_t value; } ValueBlob; /** @@ -808,17 +808,17 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint32 name; + uint32_t name; - guint8 readable :1; - guint8 writable :1; - guint8 has_embedded_type :1; - guint8 reserved :5; - guint8 bits; + uint8_t readable :1; + uint8_t writable :1; + uint8_t has_embedded_type :1; + uint8_t reserved :5; + uint8_t bits; - guint16 struct_offset; + uint16_t struct_offset; - guint32 reserved2; + uint32_t reserved2; SimpleTypeBlob type; } FieldBlob; @@ -839,14 +839,14 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint16 blob_type; - guint16 deprecated : 1; - guint16 unregistered : 1; - guint16 reserved :14; - guint32 name; + uint16_t blob_type; + uint16_t deprecated : 1; + uint16_t unregistered : 1; + uint16_t reserved :14; + uint32_t name; - guint32 gtype_name; - guint32 gtype_init; + uint32_t gtype_name; + uint32_t gtype_init; } RegisteredTypeBlob; /** @@ -876,27 +876,27 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint16 blob_type; + uint16_t blob_type; - guint16 deprecated : 1; - guint16 unregistered : 1; - guint16 is_gtype_struct : 1; - guint16 alignment : 6; - guint16 foreign : 1; - guint16 reserved : 6; + uint16_t deprecated : 1; + uint16_t unregistered : 1; + uint16_t is_gtype_struct : 1; + uint16_t alignment : 6; + uint16_t foreign : 1; + uint16_t reserved : 6; - guint32 name; + uint32_t name; - guint32 gtype_name; - guint32 gtype_init; + uint32_t gtype_name; + uint32_t gtype_init; - guint32 size; + uint32_t size; - guint16 n_fields; - guint16 n_methods; + uint16_t n_fields; + uint16_t n_methods; - guint32 copy_func; - guint32 free_func; + uint32_t copy_func; + uint32_t free_func; } StructBlob; /** @@ -927,26 +927,26 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint16 blob_type; - guint16 deprecated : 1; - guint16 unregistered : 1; - guint16 discriminated : 1; - guint16 alignment : 6; - guint16 reserved : 7; - guint32 name; + uint16_t blob_type; + uint16_t deprecated : 1; + uint16_t unregistered : 1; + uint16_t discriminated : 1; + uint16_t alignment : 6; + uint16_t reserved : 7; + uint32_t name; - guint32 gtype_name; - guint32 gtype_init; + uint32_t gtype_name; + uint32_t gtype_init; - guint32 size; + uint32_t size; - guint16 n_fields; - guint16 n_functions; + uint16_t n_fields; + uint16_t n_functions; - guint32 copy_func; - guint32 free_func; + uint32_t copy_func; + uint32_t free_func; - gint32 discriminator_offset; + int32_t discriminator_offset; SimpleTypeBlob discriminator_type; } UnionBlob; @@ -971,22 +971,22 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint16 blob_type; + uint16_t blob_type; - guint16 deprecated : 1; - guint16 unregistered : 1; - guint16 storage_type : 5; - guint16 reserved : 9; + uint16_t deprecated : 1; + uint16_t unregistered : 1; + uint16_t storage_type : 5; + uint16_t reserved : 9; - guint32 name; + uint32_t name; - guint32 gtype_name; - guint32 gtype_init; + uint32_t gtype_name; + uint32_t gtype_init; - guint16 n_values; - guint16 n_methods; + uint16_t n_values; + uint16_t n_methods; - guint32 error_domain; + uint32_t error_domain; ValueBlob values[]; } EnumBlob; @@ -1021,20 +1021,20 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint32 name; + uint32_t name; - guint32 deprecated : 1; - guint32 readable : 1; - guint32 writable : 1; - guint32 construct : 1; - guint32 construct_only : 1; - guint32 transfer_ownership : 1; - guint32 transfer_container_ownership : 1; - guint32 setter :10; - guint32 getter :10; - guint32 reserved : 5; + uint32_t deprecated : 1; + uint32_t readable : 1; + uint32_t writable : 1; + uint32_t construct : 1; + uint32_t construct_only : 1; + uint32_t transfer_ownership : 1; + uint32_t transfer_container_ownership : 1; + uint32_t setter :10; + uint32_t getter :10; + uint32_t reserved : 5; - guint32 reserved2; + uint32_t reserved2; SimpleTypeBlob type; } PropertyBlob; @@ -1064,25 +1064,25 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint16 deprecated : 1; - guint16 run_first : 1; - guint16 run_last : 1; - guint16 run_cleanup : 1; - guint16 no_recurse : 1; - guint16 detailed : 1; - guint16 action : 1; - guint16 no_hooks : 1; - guint16 has_class_closure : 1; - guint16 true_stops_emit : 1; - guint16 reserved : 6; + uint16_t deprecated : 1; + uint16_t run_first : 1; + uint16_t run_last : 1; + uint16_t run_cleanup : 1; + uint16_t no_recurse : 1; + uint16_t detailed : 1; + uint16_t action : 1; + uint16_t no_hooks : 1; + uint16_t has_class_closure : 1; + uint16_t true_stops_emit : 1; + uint16_t reserved : 6; - guint16 class_closure; + uint16_t class_closure; - guint32 name; + uint32_t name; - guint32 reserved2; + uint32_t reserved2; - guint32 signature; + uint32_t signature; } SignalBlob; /** @@ -1115,22 +1115,22 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint32 name; + uint32_t name; - guint16 must_chain_up : 1; - guint16 must_be_implemented : 1; - guint16 must_not_be_implemented : 1; - guint16 class_closure : 1; - guint16 throws : 1; - guint16 reserved :11; - guint16 signal; + uint16_t must_chain_up : 1; + uint16_t must_be_implemented : 1; + uint16_t must_not_be_implemented : 1; + uint16_t class_closure : 1; + uint16_t throws : 1; + uint16_t reserved :11; + uint16_t signal; - guint16 struct_offset; - guint16 invoker : 10; /* Number of bits matches @index in FunctionBlob */ - guint16 reserved2 : 6; + uint16_t struct_offset; + uint16_t invoker : 10; /* Number of bits matches @index in FunctionBlob */ + uint16_t reserved2 : 6; - guint32 reserved3; - guint32 signature; + uint32_t reserved3; + uint32_t signature; } VFuncBlob; /** @@ -1177,38 +1177,38 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint16 blob_type; /* 7 */ - guint16 deprecated : 1; - guint16 abstract : 1; - guint16 fundamental : 1; - guint16 final_ : 1; - guint16 reserved :12; - guint32 name; + uint16_t blob_type; /* 7 */ + uint16_t deprecated : 1; + uint16_t abstract : 1; + uint16_t fundamental : 1; + uint16_t final_ : 1; + uint16_t reserved :12; + uint32_t name; - guint32 gtype_name; - guint32 gtype_init; + uint32_t gtype_name; + uint32_t gtype_init; - guint16 parent; - guint16 gtype_struct; + uint16_t parent; + uint16_t gtype_struct; - guint16 n_interfaces; - guint16 n_fields; - guint16 n_properties; - guint16 n_methods; - guint16 n_signals; - guint16 n_vfuncs; - guint16 n_constants; - guint16 n_field_callbacks; + uint16_t n_interfaces; + uint16_t n_fields; + uint16_t n_properties; + uint16_t n_methods; + uint16_t n_signals; + uint16_t n_vfuncs; + uint16_t n_constants; + uint16_t n_field_callbacks; - guint32 ref_func; - guint32 unref_func; - guint32 set_value_func; - guint32 get_value_func; + uint32_t ref_func; + uint32_t unref_func; + uint32_t set_value_func; + uint32_t get_value_func; - guint32 reserved3; - guint32 reserved4; + uint32_t reserved3; + uint32_t reserved4; - guint16 interfaces[]; + uint16_t interfaces[]; } ObjectBlob; /** @@ -1239,28 +1239,28 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint16 blob_type; - guint16 deprecated : 1; - guint16 reserved :15; - guint32 name; + uint16_t blob_type; + uint16_t deprecated : 1; + uint16_t reserved :15; + uint32_t name; - guint32 gtype_name; - guint32 gtype_init; - guint16 gtype_struct; + uint32_t gtype_name; + uint32_t gtype_init; + uint16_t gtype_struct; - guint16 n_prerequisites; - guint16 n_properties; - guint16 n_methods; - guint16 n_signals; - guint16 n_vfuncs; - guint16 n_constants; + uint16_t n_prerequisites; + uint16_t n_properties; + uint16_t n_methods; + uint16_t n_signals; + uint16_t n_vfuncs; + uint16_t n_constants; - guint16 padding; + uint16_t padding; - guint32 reserved2; - guint32 reserved3; + uint32_t reserved2; + uint32_t reserved3; - guint16 prerequisites[]; + uint16_t prerequisites[]; } InterfaceBlob; /** @@ -1280,17 +1280,17 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint16 blob_type; - guint16 deprecated : 1; - guint16 reserved :15; - guint32 name; + uint16_t blob_type; + uint16_t deprecated : 1; + uint16_t reserved :15; + uint32_t name; SimpleTypeBlob type; - guint32 size; - guint32 offset; + uint32_t size; + uint32_t offset; - guint32 reserved2; + uint32_t reserved2; } ConstantBlob; /** @@ -1306,9 +1306,9 @@ typedef struct { * Since: 2.80 */ typedef struct { - guint32 offset; - guint32 name; - guint32 value; + uint32_t offset; + uint32_t name; + uint32_t value; } AttributeBlob; struct _GITypelib { @@ -1322,7 +1322,7 @@ struct _GITypelib { }; DirEntry *gi_typelib_get_dir_entry (GITypelib *typelib, - guint16 index); + uint16_t index); DirEntry *gi_typelib_get_dir_entry_by_name (GITypelib *typelib, const char *name); @@ -1393,7 +1393,7 @@ gboolean gi_typelib_validate (GITypelib *typelib, /* defined in gibaseinfo.c */ AttributeBlob *_attribute_blob_find_first (GIBaseInfo *info, - guint32 blob_offset); + uint32_t blob_offset); /** * GITypelibHashBuilder: @@ -1406,17 +1406,17 @@ typedef struct _GITypelibHashBuilder GITypelibHashBuilder; GITypelibHashBuilder * gi_typelib_hash_builder_new (void); -void gi_typelib_hash_builder_add_string (GITypelibHashBuilder *builder, const char *str, guint16 value); +void gi_typelib_hash_builder_add_string (GITypelibHashBuilder *builder, const char *str, uint16_t value); gboolean gi_typelib_hash_builder_prepare (GITypelibHashBuilder *builder); -guint32 gi_typelib_hash_builder_get_buffer_size (GITypelibHashBuilder *builder); +uint32_t gi_typelib_hash_builder_get_buffer_size (GITypelibHashBuilder *builder); -void gi_typelib_hash_builder_pack (GITypelibHashBuilder *builder, guint8* mem, guint32 size); +void gi_typelib_hash_builder_pack (GITypelibHashBuilder *builder, uint8_t* mem, uint32_t size); void gi_typelib_hash_builder_destroy (GITypelibHashBuilder *builder); -guint16 gi_typelib_hash_search (guint8* memory, const char *str, guint n_entries); +uint16_t gi_typelib_hash_search (uint8_t* memory, const char *str, uint32_t n_entries); G_END_DECLS diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index 4f733c37d..6f5f1c9ae 100644 --- a/girepository/gitypelib.c +++ b/girepository/gitypelib.c @@ -65,16 +65,16 @@ pop_context (ValidateContext *ctx) static gboolean validate_interface_blob (ValidateContext *ctx, - guint32 offset, + uint32_t offset, GError **error); static DirEntry * get_dir_entry_checked (GITypelib *typelib, - guint16 index, + uint16_t index, GError **error) { Header *header = (Header *)typelib->data; - guint32 offset; + uint32_t offset; if (index == 0 || index > header->n_entries) { @@ -102,7 +102,7 @@ get_dir_entry_checked (GITypelib *typelib, static CommonBlob * get_blob (GITypelib *typelib, - guint32 offset, + uint32_t offset, GError **error) { if (typelib->len < offset + sizeof (CommonBlob)) @@ -155,7 +155,7 @@ get_type_blob (GITypelib *typelib, */ DirEntry * gi_typelib_get_dir_entry (GITypelib *typelib, - guint16 index) + uint16_t index) { Header *header = (Header *)typelib->data; @@ -198,7 +198,7 @@ gi_typelib_get_dir_entry_by_name (GITypelib *typelib, const char *name) { Section *dirindex; - gint i, n_entries; + int i, n_entries; const char *entry_name; DirEntry *entry; @@ -218,8 +218,8 @@ gi_typelib_get_dir_entry_by_name (GITypelib *typelib, } else { - guint8 *hash = (guint8*) &typelib->data[dirindex->offset]; - guint16 index; + uint8_t *hash = (uint8_t *) &typelib->data[dirindex->offset]; + uint16_t index; index = gi_typelib_hash_search (hash, name, n_entries); entry = gi_typelib_get_dir_entry (typelib, index + 1); @@ -247,7 +247,7 @@ gi_typelib_get_dir_entry_by_gtype_name (GITypelib *typelib, const char *gtype_name) { Header *header = (Header *)typelib->data; - guint i; + unsigned int i; for (i = 1; i <= header->n_local_entries; i++) { @@ -400,12 +400,11 @@ gi_typelib_get_dir_entry_by_error_domain (GITypelib *typelib, GQuark error_domain) { Header *header = (Header *)typelib->data; - guint n_entries = header->n_local_entries; + unsigned int n_entries = header->n_local_entries; const char *domain_string = g_quark_to_string (error_domain); DirEntry *entry; - guint i; - for (i = 1; i <= n_entries; i++) + for (unsigned int i = 1; i <= n_entries; i++) { EnumBlob *blob; const char *enum_domain_string; @@ -490,7 +489,7 @@ gi_typelib_check_format (void) static gboolean -is_aligned (guint32 offset) +is_aligned (uint32_t offset) { return offset == ALIGN_VALUE (offset, 4); } @@ -498,7 +497,7 @@ is_aligned (guint32 offset) #define MAX_NAME_LEN 2048 static const char * -get_string (GITypelib *typelib, guint32 offset, GError **error) +get_string (GITypelib *typelib, uint32_t offset, GError **error) { if (typelib->len < offset) { @@ -513,7 +512,7 @@ get_string (GITypelib *typelib, guint32 offset, GError **error) } static const char * -get_string_nofail (GITypelib *typelib, guint32 offset) +get_string_nofail (GITypelib *typelib, uint32_t offset) { const char *ret = get_string (typelib, offset, NULL); g_assert (ret); @@ -523,7 +522,8 @@ get_string_nofail (GITypelib *typelib, guint32 offset) static gboolean validate_name (GITypelib *typelib, const char *msg, - const guchar *data, guint32 offset, + const guchar *data, + uint32_t offset, GError **error) { const char *name; @@ -557,7 +557,7 @@ validate_name (GITypelib *typelib, /* Fast path sanity check, operates on a memory blob */ static gboolean -validate_header_basic (const guint8 *memory, +validate_header_basic (const uint8_t *memory, gsize len, GError **error) { @@ -695,15 +695,15 @@ validate_header (ValidateContext *ctx, } static gboolean validate_type_blob (GITypelib *typelib, - guint32 offset, - guint32 signature_offset, + uint32_t offset, + uint32_t signature_offset, gboolean return_type, GError **error); static gboolean validate_array_type_blob (GITypelib *typelib, - guint32 offset, - guint32 signature_offset, + uint32_t offset, + uint32_t signature_offset, gboolean return_type, GError **error) { @@ -719,8 +719,8 @@ validate_array_type_blob (GITypelib *typelib, static gboolean validate_iface_type_blob (GITypelib *typelib, - guint32 offset, - guint32 signature_offset, + uint32_t offset, + uint32_t signature_offset, gboolean return_type, GError **error) { @@ -741,14 +741,14 @@ validate_iface_type_blob (GITypelib *typelib, static gboolean validate_param_type_blob (GITypelib *typelib, - guint32 offset, - guint32 signature_offset, + uint32_t offset, + uint32_t signature_offset, gboolean return_type, - gint n_params, + int n_params, GError **error) { ParamTypeBlob *blob; - gint i; + int i; blob = (ParamTypeBlob*)&typelib->data[offset]; @@ -784,8 +784,8 @@ validate_param_type_blob (GITypelib *typelib, static gboolean validate_error_type_blob (GITypelib *typelib, - guint32 offset, - guint32 signature_offset, + uint32_t offset, + uint32_t signature_offset, gboolean return_type, GError **error) { @@ -807,8 +807,8 @@ validate_error_type_blob (GITypelib *typelib, static gboolean validate_type_blob (GITypelib *typelib, - guint32 offset, - guint32 signature_offset, + uint32_t offset, + uint32_t signature_offset, gboolean return_type, GError **error) { @@ -886,8 +886,8 @@ validate_type_blob (GITypelib *typelib, static gboolean validate_arg_blob (GITypelib *typelib, - guint32 offset, - guint32 signature_offset, + uint32_t offset, + uint32_t signature_offset, GError **error) { ArgBlob *blob; @@ -916,7 +916,7 @@ validate_arg_blob (GITypelib *typelib, static SimpleTypeBlob * return_type_from_signature (GITypelib *typelib, - guint32 offset, + uint32_t offset, GError **error) { SignatureBlob *blob; @@ -944,11 +944,10 @@ return_type_from_signature (GITypelib *typelib, static gboolean validate_signature_blob (GITypelib *typelib, - guint32 offset, + uint32_t offset, GError **error) { SignatureBlob *blob; - gint i; if (typelib->len < offset + sizeof (SignatureBlob)) { @@ -969,7 +968,7 @@ validate_signature_blob (GITypelib *typelib, return FALSE; } - for (i = 0; i < blob->n_arguments; i++) + for (int i = 0; i < blob->n_arguments; i++) { if (!validate_arg_blob (typelib, offset + sizeof (SignatureBlob) + @@ -986,8 +985,8 @@ validate_signature_blob (GITypelib *typelib, static gboolean validate_function_blob (ValidateContext *ctx, - guint32 offset, - guint16 container_type, + uint32_t offset, + uint16_t container_type, GError **error) { GITypelib *typelib = ctx->typelib; @@ -1106,7 +1105,7 @@ validate_function_blob (ValidateContext *ctx, static gboolean validate_callback_blob (ValidateContext *ctx, - guint32 offset, + uint32_t offset, GError **error) { GITypelib *typelib = ctx->typelib; @@ -1147,10 +1146,10 @@ validate_callback_blob (ValidateContext *ctx, static gboolean validate_constant_blob (GITypelib *typelib, - guint32 offset, + uint32_t offset, GError **error) { - guint value_size[] = { + unsigned int value_size[] = { 0, /* VOID */ 4, /* BOOLEAN */ 1, /* INT8 */ @@ -1161,8 +1160,8 @@ validate_constant_blob (GITypelib *typelib, 4, /* UINT32 */ 8, /* INT64 */ 8, /* UINT64 */ - sizeof (gfloat), - sizeof (gdouble), + sizeof (float), + sizeof (double), 0, /* GTYPE */ 0, /* UTF8 */ 0, /* FILENAME */ @@ -1244,7 +1243,7 @@ validate_constant_blob (GITypelib *typelib, static gboolean validate_value_blob (GITypelib *typelib, - guint32 offset, + uint32_t offset, GError **error) { ValueBlob *blob; @@ -1268,7 +1267,7 @@ validate_value_blob (GITypelib *typelib, static gboolean validate_field_blob (ValidateContext *ctx, - guint32 offset, + uint32_t offset, GError **error) { GITypelib *typelib = ctx->typelib; @@ -1304,7 +1303,7 @@ validate_field_blob (ValidateContext *ctx, static gboolean validate_property_blob (GITypelib *typelib, - guint32 offset, + uint32_t offset, GError **error) { PropertyBlob *blob; @@ -1333,12 +1332,12 @@ validate_property_blob (GITypelib *typelib, static gboolean validate_signal_blob (GITypelib *typelib, - guint32 offset, - guint32 container_offset, + uint32_t offset, + uint32_t container_offset, GError **error) { SignalBlob *blob; - gint n_signals; + int n_signals; if (typelib->len < offset + sizeof (SignalBlob)) { @@ -1402,12 +1401,12 @@ validate_signal_blob (GITypelib *typelib, static gboolean validate_vfunc_blob (GITypelib *typelib, - guint32 offset, - guint32 container_offset, + uint32_t offset, + uint32_t container_offset, GError **error) { VFuncBlob *blob; - gint n_vfuncs; + int n_vfuncs; if (typelib->len < offset + sizeof (VFuncBlob)) { @@ -1460,14 +1459,14 @@ validate_vfunc_blob (GITypelib *typelib, static gboolean validate_struct_blob (ValidateContext *ctx, - guint32 offset, - guint16 blob_type, - GError **error) + uint32_t offset, + uint16_t blob_type, + GError **error) { GITypelib *typelib = ctx->typelib; StructBlob *blob; - gint i; - guint32 field_offset; + int i; + uint32_t field_offset; if (typelib->len < offset + sizeof (StructBlob)) { @@ -1557,14 +1556,14 @@ validate_struct_blob (ValidateContext *ctx, static gboolean validate_enum_blob (ValidateContext *ctx, - guint32 offset, - guint16 blob_type, + uint32_t offset, + uint16_t blob_type, GError **error) { GITypelib *typelib = ctx->typelib; EnumBlob *blob; - gint i; - guint32 offset2; + int i; + uint32_t offset2; if (typelib->len < offset + sizeof (EnumBlob)) { @@ -1665,15 +1664,15 @@ validate_enum_blob (ValidateContext *ctx, static gboolean validate_object_blob (ValidateContext *ctx, - guint32 offset, + uint32_t offset, GError **error) { GITypelib *typelib = ctx->typelib; Header *header; ObjectBlob *blob; - gint i; - guint32 offset2; - guint16 n_field_callbacks; + int i; + uint32_t offset2; + uint16_t n_field_callbacks; header = (Header *)typelib->data; @@ -1771,10 +1770,10 @@ validate_object_blob (ValidateContext *ctx, for (i = 0; i < blob->n_interfaces; i++, offset2 += 2) { - guint16 iface; + uint16_t iface; DirEntry *entry; - iface = *(guint16*)&typelib->data[offset2]; + iface = *(uint16_t *)&typelib->data[offset2]; if (iface == 0 || iface > header->n_entries) { g_set_error (error, @@ -1867,14 +1866,14 @@ validate_object_blob (ValidateContext *ctx, static gboolean validate_interface_blob (ValidateContext *ctx, - guint32 offset, + uint32_t offset, GError **error) { GITypelib *typelib = ctx->typelib; Header *header; InterfaceBlob *blob; - gint i; - guint32 offset2; + int i; + uint32_t offset2; header = (Header *)typelib->data; @@ -1928,9 +1927,9 @@ validate_interface_blob (ValidateContext *ctx, for (i = 0; i < blob->n_prerequisites; i++, offset2 += 2) { DirEntry *entry; - guint16 req; + uint16_t req; - req = *(guint16*)&typelib->data[offset2]; + req = *(uint16_t *)&typelib->data[offset2]; if (req == 0 || req > header->n_entries) { g_set_error (error, @@ -1994,7 +1993,7 @@ validate_interface_blob (ValidateContext *ctx, static gboolean validate_union_blob (GITypelib *typelib, - guint32 offset, + uint32_t offset, GError **error) { return TRUE; @@ -2002,7 +2001,7 @@ validate_union_blob (GITypelib *typelib, static gboolean validate_blob (ValidateContext *ctx, - guint32 offset, + uint32_t offset, GError **error) { GITypelib *typelib = ctx->typelib; @@ -2073,7 +2072,7 @@ validate_directory (ValidateContext *ctx, GITypelib *typelib = ctx->typelib; Header *header = (Header *)typelib->data; DirEntry *entry; - gint i; + int i; if (typelib->len < header->directory + header->n_entries * sizeof (DirEntry)) { @@ -2343,7 +2342,7 @@ gi_typelib_do_dlopen (GITypelib *typelib) if (shlib_str != NULL && shlib_str[0] != '\0') { char **shlibs; - gint i; + int i; /* shared-library is a comma-separated list of libraries */ shlibs = g_strsplit (shlib_str, ",", 0); @@ -2410,7 +2409,7 @@ gi_typelib_ensure_open (GITypelib *typelib) * Since: 2.80 */ GITypelib * -gi_typelib_new_from_memory (guint8 *memory, +gi_typelib_new_from_memory (uint8_t *memory, gsize len, GError **error) { @@ -2474,7 +2473,7 @@ gi_typelib_new_from_mapped_file (GMappedFile *mfile, GError **error) { GITypelib *meta; - guint8 *data = (guint8 *) g_mapped_file_get_contents (mfile); + uint8_t *data = (uint8_t *) g_mapped_file_get_contents (mfile); gsize len = g_mapped_file_get_length (mfile); if (!validate_header_basic (data, len, error)) diff --git a/girepository/gitypelib.h b/girepository/gitypelib.h index d43e8fd95..dc2499ddd 100644 --- a/girepository/gitypelib.h +++ b/girepository/gitypelib.h @@ -37,12 +37,12 @@ G_BEGIN_DECLS typedef struct _GITypelib GITypelib; GI_AVAILABLE_IN_ALL -GITypelib * gi_typelib_new_from_memory (guint8 *memory, +GITypelib * gi_typelib_new_from_memory (uint8_t *memory, gsize len, GError **error); GI_AVAILABLE_IN_ALL -GITypelib * gi_typelib_new_from_const_memory (const guint8 *memory, +GITypelib * gi_typelib_new_from_const_memory (const uint8_t *memory, gsize len, GError **error); diff --git a/girepository/gitypes.h b/girepository/gitypes.h index 2c8f92b9e..77e64fa5e 100644 --- a/girepository/gitypes.h +++ b/girepository/gitypes.h @@ -28,6 +28,8 @@ #error "Only can be included directly." #endif +#include + #include #include @@ -113,25 +115,25 @@ GI_AVAILABLE_IN_ALL GType gi_unresolved_info_get_type (void); union _GIArgument { - gboolean v_boolean; - gint8 v_int8; - guint8 v_uint8; - gint16 v_int16; - guint16 v_uint16; - gint32 v_int32; - guint32 v_uint32; - gint64 v_int64; - guint64 v_uint64; - gfloat v_float; - gdouble v_double; - gshort v_short; - gushort v_ushort; - gint v_int; - guint v_uint; - glong v_long; - gulong v_ulong; - gssize v_ssize; - gsize v_size; + gboolean v_boolean; + int8_t v_int8; + uint8_t v_uint8; + int16_t v_int16; + uint16_t v_uint16; + int32_t v_int32; + uint32_t v_uint32; + int64_t v_int64; + uint64_t v_uint64; + float v_float; + double v_double; + short v_short; + unsigned short v_ushort; + int v_int; + unsigned int v_uint; + long v_long; + unsigned long v_ulong; + gssize v_ssize; + gsize v_size; char *v_string; void *v_pointer; }; diff --git a/girepository/giunioninfo.c b/girepository/giunioninfo.c index 7c311bad1..e3c4397a4 100644 --- a/girepository/giunioninfo.c +++ b/girepository/giunioninfo.c @@ -53,7 +53,7 @@ * Returns: number of fields * Since: 2.80 */ -guint +unsigned int gi_union_info_get_n_fields (GIUnionInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -75,7 +75,7 @@ gi_union_info_get_n_fields (GIUnionInfo *info) */ GIFieldInfo * gi_union_info_get_field (GIUnionInfo *info, - guint n) + unsigned int n) { GIRealInfo *rinfo = (GIRealInfo *)info; Header *header = (Header *)rinfo->typelib->data; @@ -94,7 +94,7 @@ gi_union_info_get_field (GIUnionInfo *info, * Returns: number of methods * Since: 2.80 */ -guint +unsigned int gi_union_info_get_n_methods (GIUnionInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -116,12 +116,12 @@ gi_union_info_get_n_methods (GIUnionInfo *info) */ GIFunctionInfo * gi_union_info_get_method (GIUnionInfo *info, - guint n) + unsigned int n) { GIRealInfo *rinfo = (GIRealInfo *)info; UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset]; Header *header = (Header *)rinfo->typelib->data; - gint offset; + int offset; offset = rinfo->offset + header->union_blob_size + blob->n_fields * header->field_blob_size @@ -157,7 +157,7 @@ gi_union_info_is_discriminated (GIUnionInfo *info) * Returns: offset, in bytes, of the discriminator * Since: 2.80 */ -guint +unsigned int gi_union_info_get_discriminator_offset (GIUnionInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -202,7 +202,7 @@ gi_union_info_get_discriminator_type (GIUnionInfo *info) */ GIConstantInfo * gi_union_info_get_discriminator (GIUnionInfo *info, - guint n) + unsigned int n) { GIRealInfo *rinfo = (GIRealInfo *)info; UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -210,7 +210,7 @@ gi_union_info_get_discriminator (GIUnionInfo *info, if (blob->discriminated) { Header *header = (Header *)rinfo->typelib->data; - gint offset; + int offset; offset = rinfo->offset + header->union_blob_size + blob->n_fields * header->field_blob_size @@ -240,7 +240,7 @@ GIFunctionInfo * gi_union_info_find_method (GIUnionInfo *info, const char *name) { - gint offset; + int offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header = (Header *)rinfo->typelib->data; UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset]; diff --git a/girepository/giunioninfo.h b/girepository/giunioninfo.h index 6db369d87..df24d0bf4 100644 --- a/girepository/giunioninfo.h +++ b/girepository/giunioninfo.h @@ -44,31 +44,31 @@ G_BEGIN_DECLS (gi_base_info_get_info_type ((GIBaseInfo*) info) == GI_INFO_TYPE_UNION) GI_AVAILABLE_IN_ALL -guint gi_union_info_get_n_fields (GIUnionInfo *info); +unsigned int gi_union_info_get_n_fields (GIUnionInfo *info); GI_AVAILABLE_IN_ALL GIFieldInfo * gi_union_info_get_field (GIUnionInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL -guint gi_union_info_get_n_methods (GIUnionInfo *info); +unsigned int gi_union_info_get_n_methods (GIUnionInfo *info); GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_union_info_get_method (GIUnionInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL gboolean gi_union_info_is_discriminated (GIUnionInfo *info); GI_AVAILABLE_IN_ALL -guint gi_union_info_get_discriminator_offset (GIUnionInfo *info); +unsigned int gi_union_info_get_discriminator_offset (GIUnionInfo *info); GI_AVAILABLE_IN_ALL GITypeInfo * gi_union_info_get_discriminator_type (GIUnionInfo *info); GI_AVAILABLE_IN_ALL GIConstantInfo * gi_union_info_get_discriminator (GIUnionInfo *info, - guint n); + unsigned int n); GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_union_info_find_method (GIUnionInfo *info, diff --git a/girepository/givfuncinfo.c b/girepository/givfuncinfo.c index 38fcc52e7..1ac79be96 100644 --- a/girepository/givfuncinfo.c +++ b/girepository/givfuncinfo.c @@ -47,14 +47,14 @@ GIVFuncInfo * gi_base_info_find_vfunc (GIRealInfo *rinfo, - guint32 offset, - guint n_vfuncs, + uint32_t offset, + unsigned n_vfuncs, const char *name) { /* FIXME hash */ Header *header = (Header *)rinfo->typelib->data; - for (guint i = 0; i < n_vfuncs; i++) + for (unsigned i = 0; i < n_vfuncs; i++) { VFuncBlob *fblob = (VFuncBlob *)&rinfo->typelib->data[offset]; const char *fname = (const char *)&rinfo->typelib->data[fblob->name]; @@ -121,7 +121,7 @@ gi_vfunc_info_get_flags (GIVFuncInfo *info) * Returns: the struct offset or `0xFFFF` if it’s unknown * Since: 2.80 */ -guint +unsigned int gi_vfunc_info_get_offset (GIVFuncInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; diff --git a/girepository/givfuncinfo.h b/girepository/givfuncinfo.h index 2e0cded3b..85f23c707 100644 --- a/girepository/givfuncinfo.h +++ b/girepository/givfuncinfo.h @@ -47,7 +47,7 @@ GI_AVAILABLE_IN_ALL GIVFuncInfoFlags gi_vfunc_info_get_flags (GIVFuncInfo *info); GI_AVAILABLE_IN_ALL -guint gi_vfunc_info_get_offset (GIVFuncInfo *info); +unsigned int gi_vfunc_info_get_offset (GIVFuncInfo *info); GI_AVAILABLE_IN_ALL GISignalInfo * gi_vfunc_info_get_signal (GIVFuncInfo *info); diff --git a/girepository/gthash.c b/girepository/gthash.c index cdb0d8ce1..954cd6fce 100644 --- a/girepository/gthash.c +++ b/girepository/gthash.c @@ -48,7 +48,7 @@ * INT32 mph_size * MPH (mph_size bytes) * (padding for alignment to uint32 if necessary) - * INDEX (array of guint16) + * INDEX (array of uint16_t) * * Because BDZ is not order preserving, we need a lookaside table which * maps the hash value into the directory index. @@ -59,8 +59,8 @@ struct _GITypelibHashBuilder { gboolean buildable; cmph_t *c; GHashTable *strings; - guint32 dirmap_offset; - guint32 packed_size; + uint32_t dirmap_offset; + uint32_t packed_size; }; GITypelibHashBuilder * @@ -75,10 +75,10 @@ gi_typelib_hash_builder_new (void) void gi_typelib_hash_builder_add_string (GITypelibHashBuilder *builder, const char *str, - guint16 value) + uint16_t value) { g_return_if_fail (builder->c == NULL); - g_hash_table_insert (builder->strings, g_strdup (str), GUINT_TO_POINTER ((guint) value)); + g_hash_table_insert (builder->strings, g_strdup (str), GUINT_TO_POINTER (value)); } gboolean @@ -89,9 +89,9 @@ gi_typelib_hash_builder_prepare (GITypelibHashBuilder *builder) void *key, *value; cmph_io_adapter_t *io; cmph_config_t *config; - guint32 num_elts; - guint32 offset; - guint i; + uint32_t num_elts; + uint32_t offset; + unsigned i; if (builder->prepared) return builder->buildable; @@ -127,9 +127,9 @@ gi_typelib_hash_builder_prepare (GITypelibHashBuilder *builder) g_assert (cmph_size (builder->c) == num_elts); /* Pack a size counter at front */ - offset = sizeof(guint32) + cmph_packed_size (builder->c); + offset = sizeof (uint32_t) + cmph_packed_size (builder->c); builder->dirmap_offset = ALIGN_VALUE (offset, 4); - builder->packed_size = builder->dirmap_offset + (num_elts * sizeof(guint16)); + builder->packed_size = builder->dirmap_offset + (num_elts * sizeof (uint16_t)); out: g_strfreev (strs); cmph_config_destroy (config); @@ -137,7 +137,7 @@ gi_typelib_hash_builder_prepare (GITypelibHashBuilder *builder) return builder->buildable; } -guint32 +uint32_t gi_typelib_hash_builder_get_buffer_size (GITypelibHashBuilder *builder) { g_return_val_if_fail (builder != NULL, 0); @@ -148,15 +148,15 @@ gi_typelib_hash_builder_get_buffer_size (GITypelibHashBuilder *builder) } void -gi_typelib_hash_builder_pack (GITypelibHashBuilder *builder, guint8* mem, guint32 len) +gi_typelib_hash_builder_pack (GITypelibHashBuilder *builder, uint8_t* mem, uint32_t len) { - guint16 *table; + uint16_t *table; GHashTableIter hashiter; void *key, *value; #ifndef G_DISABLE_ASSERT - guint32 num_elts; + uint32_t num_elts; #endif - guint8 *packed_mem; + uint8_t *packed_mem; g_return_if_fail (builder != NULL); g_return_if_fail (builder->prepared); @@ -167,11 +167,11 @@ gi_typelib_hash_builder_pack (GITypelibHashBuilder *builder, guint8* mem, guint3 memset (mem, 0, len); - *((guint32*) mem) = builder->dirmap_offset; - packed_mem = (guint8*)(mem + sizeof(guint32)); + *((uint32_t*) mem) = builder->dirmap_offset; + packed_mem = (uint8_t*)(mem + sizeof (uint32_t)); cmph_pack (builder->c, packed_mem); - table = (guint16*) (mem + builder->dirmap_offset); + table = (uint16_t*) (mem + builder->dirmap_offset); #ifndef G_DISABLE_ASSERT num_elts = g_hash_table_size (builder->strings); @@ -180,8 +180,8 @@ gi_typelib_hash_builder_pack (GITypelibHashBuilder *builder, guint8* mem, guint3 while (g_hash_table_iter_next (&hashiter, &key, &value)) { const char *str = key; - guint16 strval = (guint16)GPOINTER_TO_UINT(value); - guint32 hashv; + uint16_t strval = (uint16_t)GPOINTER_TO_UINT(value); + uint32_t hashv; hashv = cmph_search_packed (packed_mem, str, strlen (str)); g_assert (hashv < num_elts); @@ -201,16 +201,16 @@ gi_typelib_hash_builder_destroy (GITypelibHashBuilder *builder) g_slice_free (GITypelibHashBuilder, builder); } -guint16 -gi_typelib_hash_search (guint8* memory, const char *str, guint n_entries) +uint16_t +gi_typelib_hash_search (uint8_t* memory, const char *str, uint32_t n_entries) { - guint32 *mph; - guint16 *table; - guint32 dirmap_offset; - guint32 offset; + uint32_t *mph; + uint16_t *table; + uint32_t dirmap_offset; + uint32_t offset; g_assert ((((size_t)memory) & 0x3) == 0); - mph = ((guint32*)memory)+1; + mph = ((uint32_t*)memory)+1; offset = cmph_search_packed (mph, str, strlen (str)); @@ -222,8 +222,8 @@ gi_typelib_hash_search (guint8* memory, const char *str, guint n_entries) if (offset >= n_entries) offset = 0; - dirmap_offset = *((guint32*)memory); - table = (guint16*) (memory + dirmap_offset); + dirmap_offset = *((uint32_t*)memory); + table = (uint16_t*) (memory + dirmap_offset); return table[offset]; } diff --git a/girepository/tests/cmph-bdz.c b/girepository/tests/cmph-bdz.c index 56aac0979..09bbbdec6 100644 --- a/girepository/tests/cmph-bdz.c +++ b/girepository/tests/cmph-bdz.c @@ -30,7 +30,7 @@ build (void) cmph_io_adapter_t *io; char **strings; cmph_t *c; - guint32 size; + uint32_t size; strings = g_strsplit ("foo,bar,baz", ",", -1); @@ -50,14 +50,14 @@ build (void) } static void -assert_hashes_unique (guint n_hashes, - guint32* hashes) +assert_hashes_unique (unsigned n_hashes, + uint32_t* hashes) { - guint i; + unsigned i; for (i = 0; i < n_hashes; i++) { - guint j = 0; + unsigned j = 0; for (j = 0; j < n_hashes; j++) { if (j != i) @@ -70,10 +70,10 @@ static void test_search (void) { cmph_t *c = build(); - guint i; - guint32 hash; - guint32 hashes[3]; - guint32 size; + unsigned i; + uint32_t hash; + uint32_t hashes[3]; + uint32_t size; size = cmph_size (c); @@ -102,12 +102,12 @@ static void test_search_packed (void) { cmph_t *c = build(); - guint32 bufsize; - guint i; - guint32 hash; - guint32 hashes[3]; - guint32 size; - guint8 *buf; + unsigned i; + uint32_t bufsize; + uint32_t hash; + uint32_t hashes[3]; + uint32_t size; + uint8_t *buf; bufsize = cmph_packed_size (c); buf = g_malloc (bufsize); diff --git a/girepository/tests/gthash.c b/girepository/tests/gthash.c index 1b5dce115..6c674c1da 100644 --- a/girepository/tests/gthash.c +++ b/girepository/tests/gthash.c @@ -21,6 +21,7 @@ * Boston, MA 02111-1307, USA. */ +#include #include #include "gitypelib-internal.h" @@ -28,8 +29,8 @@ static void test_build_retrieve (void) { GITypelibHashBuilder *builder; - guint32 bufsize; - guint8* buf; + uint32_t bufsize; + uint8_t* buf; builder = gi_typelib_hash_builder_new (); From 5c96b0231a33dd6df6ac059012069386f06d653b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 15 Jan 2024 22:47:52 +0100 Subject: [PATCH 07/27] girnode: Use unsigned type for unsigned values Also use proper sized casting for blob values. --- girepository/girnode.c | 16 ++++++++-------- girepository/gitypelib.c | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/girepository/girnode.c b/girepository/girnode.c index b77bbf97f..3fa0b9c54 100644 --- a/girepository/girnode.c +++ b/girepository/girnode.c @@ -1047,8 +1047,8 @@ find_entry_node (GIIrTypelibBuild *build, { GIIrModule *module = build->module; GList *l; - int i; - int n_names; + unsigned int i; + unsigned int n_names; char **names; GIIrNode *result = NULL; @@ -1155,7 +1155,7 @@ gi_ir_find_node (GIIrTypelibBuild *build, GList *l; GIIrNode *return_node = NULL; char **names = g_strsplit (name, ".", 0); - int n_names = g_strv_length (names); + unsigned n_names = g_strv_length (names); const char *target_name; GIIrModule *target_module; @@ -1653,7 +1653,7 @@ gi_ir_node_build_typelib (GIIrNode *node, g_error ("Unknown setter %s for property %s:%s", prop->setter, parent->name, node->name); } - blob->setter = (unsigned int) index; + blob->setter = (uint16_t) index; } else blob->setter = ACCESSOR_SENTINEL; @@ -1668,7 +1668,7 @@ gi_ir_node_build_typelib (GIIrNode *node, g_error ("Unknown getter %s for property %s:%s", prop->getter, parent->name, node->name); } - blob->getter = (unsigned int) index; + blob->getter = (uint16_t) index; } else blob->getter = ACCESSOR_SENTINEL; @@ -1684,7 +1684,7 @@ gi_ir_node_build_typelib (GIIrNode *node, SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2]; GIIrNodeFunction *function = (GIIrNodeFunction *)node; uint32_t signature; - int n; + unsigned int n; signature = *offset2; n = g_list_length (function->parameters); @@ -1717,7 +1717,7 @@ gi_ir_node_build_typelib (GIIrNode *node, blob->setter = function->is_setter; blob->getter = function->is_getter; - blob->index = (unsigned int) index; + blob->index = (uint16_t) index; } /* function->result is special since it doesn't appear in the serialized format but @@ -1882,7 +1882,7 @@ gi_ir_node_build_typelib (GIIrNode *node, { g_error ("Unknown member function %s for vfunc %s", vfunc->invoker, node->name); } - blob->invoker = (unsigned int) index; + blob->invoker = (uint16_t) index; } else blob->invoker = 0x3ff; /* max of 10 bits */ diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index 6f5f1c9ae..f670332da 100644 --- a/girepository/gitypelib.c +++ b/girepository/gitypelib.c @@ -968,7 +968,7 @@ validate_signature_blob (GITypelib *typelib, return FALSE; } - for (int i = 0; i < blob->n_arguments; i++) + for (unsigned int i = 0; i < blob->n_arguments; i++) { if (!validate_arg_blob (typelib, offset + sizeof (SignatureBlob) + From e3aac4281dbe1dd1e224cca7181b2f94b3eeca83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 15 Jan 2024 23:17:02 +0100 Subject: [PATCH 08/27] girrepository: Remove unneeded static check The check was added to ensure compatibility with previous versions but this is not something we care anymore with this API/ABI break. --- girepository/girepository-private.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/girepository/girepository-private.h b/girepository/girepository-private.h index f3641ac5f..3f76ffa0a 100644 --- a/girepository/girepository-private.h +++ b/girepository/girepository-private.h @@ -36,11 +36,6 @@ * be removed. */ typedef struct _GIBaseInfo GIRealInfo; -/* We changed a gint32 -> gint in the structure below, which should be - * valid everywhere we care about. - */ -G_STATIC_ASSERT (sizeof (int) == sizeof (int32_t)); - /* * We just use one structure for all of the info object * types; in general, we should be reading data directly From c8aecbb8348ed8bb422c4267860b023411ec10d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 00:10:43 +0100 Subject: [PATCH 09/27] girepository: Use uint8_t pointers instead of guchar --- girepository/girmodule-private.h | 2 +- girepository/girmodule.c | 4 ++-- girepository/girnode-private.h | 2 +- girepository/girnode.c | 4 ++-- girepository/gitypelib-internal.h | 2 +- girepository/gitypelib.c | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/girepository/girmodule-private.h b/girepository/girmodule-private.h index 8f1d62887..9db6b42db 100644 --- a/girepository/girmodule-private.h +++ b/girepository/girmodule-private.h @@ -37,7 +37,7 @@ struct _GIIrTypelibBuild { GHashTable *types; GList *nodes_with_attributes; uint32_t n_attributes; - guchar *data; + uint8_t *data; GList *stack; }; diff --git a/girepository/girmodule.c b/girepository/girmodule.c index 20c592aa2..9ed3a7509 100644 --- a/girepository/girmodule.c +++ b/girepository/girmodule.c @@ -191,7 +191,7 @@ gi_ir_module_add_include_module (GIIrModule *module, struct AttributeWriteData { unsigned int count; - guchar *databuf; + uint8_t *databuf; GIIrNode *node; GHashTable *strings; uint32_t *offset; @@ -218,7 +218,7 @@ static unsigned write_attributes (GIIrModule *module, GIIrNode *node, GHashTable *strings, - guchar *data, + uint8_t *data, uint32_t *offset, uint32_t *offset2) { diff --git a/girepository/girnode-private.h b/girepository/girnode-private.h index 8cd5d4a40..51cfe6647 100644 --- a/girepository/girnode-private.h +++ b/girepository/girnode-private.h @@ -381,7 +381,7 @@ void gi_ir_node_add_member (GIIrNode *node, GIIrNodeFunction *member); uint32_t gi_ir_write_string (const char *str, GHashTable *strings, - guchar *data, + uint8_t *data, uint32_t *offset); const char * gi_ir_node_param_direction_string (GIIrNodeParam * node); diff --git a/girepository/girnode.c b/girepository/girnode.c index 3fa0b9c54..95ba5b14c 100644 --- a/girepository/girnode.c +++ b/girepository/girnode.c @@ -1405,7 +1405,7 @@ gi_ir_node_build_typelib (GIIrNode *node, gboolean appended_stack; GHashTable *strings = build->strings; GHashTable *types = build->types; - guchar *data = build->data; + uint8_t *data = build->data; GList *l; uint32_t old_offset = *offset; uint32_t old_offset2 = *offset2; @@ -2414,7 +2414,7 @@ gi_ir_node_build_typelib (GIIrNode *node, uint32_t gi_ir_write_string (const char *str, GHashTable *strings, - guchar *data, + uint8_t *data, uint32_t *offset) { uint32_t start; diff --git a/girepository/gitypelib-internal.h b/girepository/gitypelib-internal.h index 6e7a1e8f6..ceff41d01 100644 --- a/girepository/gitypelib-internal.h +++ b/girepository/gitypelib-internal.h @@ -1313,7 +1313,7 @@ typedef struct { struct _GITypelib { /*< private >*/ - guchar *data; + uint8_t *data; gsize len; gboolean owns_memory; GMappedFile *mfile; diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index f670332da..1a990c5dd 100644 --- a/girepository/gitypelib.c +++ b/girepository/gitypelib.c @@ -522,7 +522,7 @@ get_string_nofail (GITypelib *typelib, uint32_t offset) static gboolean validate_name (GITypelib *typelib, const char *msg, - const guchar *data, + const uint8_t *data, uint32_t offset, GError **error) { @@ -2439,7 +2439,7 @@ gi_typelib_new_from_memory (uint8_t *memory, * Since: 2.80 */ GITypelib * -gi_typelib_new_from_const_memory (const guchar *memory, +gi_typelib_new_from_const_memory (const uint8_t *memory, gsize len, GError **error) { @@ -2449,7 +2449,7 @@ gi_typelib_new_from_const_memory (const guchar *memory, return NULL; meta = g_slice_new0 (GITypelib); - meta->data = (guchar *) memory; + meta->data = (uint8_t *) memory; meta->len = len; meta->owns_memory = FALSE; meta->modules = NULL; From bc2e4b3de5af7ce15a621693dade9edbfecb3245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 00:35:23 +0100 Subject: [PATCH 10/27] girrepository: Replace usage of gsize with standard size_t We just do a safe s/gsize/size_t/ replacement here without doing any changes to places in which different size of size_t and gsize may be actually different and create troubles. --- girepository/gdump.c | 10 +++++----- girepository/gibaseinfo-private.h | 2 +- girepository/gibaseinfo.c | 8 ++++---- girepository/gicallableinfo.c | 6 +++--- girepository/gicallableinfo.h | 4 ++-- girepository/giconstantinfo.c | 4 ++-- girepository/giconstantinfo.h | 2 +- girepository/gifieldinfo.c | 6 +++--- girepository/gifieldinfo.h | 4 ++-- girepository/gifunctioninfo.c | 4 ++-- girepository/gifunctioninfo.h | 4 ++-- girepository/girepository.c | 2 +- girepository/girepository.h | 2 +- girepository/girmodule.c | 4 ++-- girepository/girparser.c | 2 +- girepository/girwriter.c | 2 +- girepository/gistructinfo.c | 4 ++-- girepository/gistructinfo.h | 4 ++-- girepository/gitypelib-internal.h | 2 +- girepository/gitypelib.c | 23 +++++++++++------------ girepository/gitypelib.h | 4 ++-- girepository/gitypes.h | 2 +- girepository/giunioninfo.c | 4 ++-- girepository/giunioninfo.h | 4 ++-- girepository/givfuncinfo.c | 4 ++-- girepository/givfuncinfo.h | 4 ++-- 26 files changed, 60 insertions(+), 61 deletions(-) diff --git a/girepository/gdump.c b/girepository/gdump.c index 6877ca24c..2388626d8 100644 --- a/girepository/gdump.c +++ b/girepository/gdump.c @@ -44,8 +44,8 @@ static gboolean write_all (FILE *out, const void *buffer, - gsize count, - gsize *bytes_written, + size_t count, + size_t *bytes_written, GError **error) { size_t ret; @@ -104,7 +104,7 @@ escaped_printf (FILE *out, const char *fmt, ...) { char *str; va_list args; - gsize written; + size_t written; GError *error = NULL; va_start (args, fmt); @@ -123,7 +123,7 @@ escaped_printf (FILE *out, const char *fmt, ...) static void goutput_write (FILE *out, const char *str) { - gsize written; + size_t written; GError *error = NULL; if (!write_all (out, str, strlen (str), &written, &error)) { @@ -662,7 +662,7 @@ gi_repository_dump (const char *input_filename, while (TRUE) { - gsize len; + size_t len; char *line = read_line (input, &len); const char *function; diff --git a/girepository/gibaseinfo-private.h b/girepository/gibaseinfo-private.h index 4d583538e..a756f7072 100644 --- a/girepository/gibaseinfo-private.h +++ b/girepository/gibaseinfo-private.h @@ -45,7 +45,7 @@ struct _GIBaseInfoClass void gi_base_info_init_types (void); GType gi_base_info_type_register_static (const char *type_name, - gsize instance_size, + size_t instance_size, GClassInitFunc class_init); G_END_DECLS diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c index 85bf3c26c..4c34355de 100644 --- a/girepository/gibaseinfo.c +++ b/girepository/gibaseinfo.c @@ -213,7 +213,7 @@ gi_base_info_get_type (void) */ GType gi_base_info_type_register_static (const char *type_name, - gsize instance_size, + size_t instance_size, GClassInitFunc class_init) { GTypeInfo info; @@ -264,7 +264,7 @@ GI_DEFINE_BASE_INFO_TYPE (gi_unresolved_info, GI_INFO_TYPE_UNRESOLVED) void gi_base_info_init_types (void) { - static gsize register_types_once = 0; + static size_t register_types_once = 0; if (g_once_init_enter (®ister_types_once)) { @@ -272,7 +272,7 @@ gi_base_info_init_types (void) { GIInfoType info_type; const char *type_name; - gsize instance_size; + size_t instance_size; GClassInitFunc class_init; } types[] = @@ -297,7 +297,7 @@ gi_base_info_init_types (void) { GI_INFO_TYPE_UNRESOLVED, "GIUnresolvedInfo", sizeof (GIUnresolvedInfo), gi_unresolved_info_class_init }, }; - for (gsize i = 0; i < G_N_ELEMENTS (types); i++) + for (size_t i = 0; i < G_N_ELEMENTS (types); i++) { GType registered_type = gi_base_info_type_register_static (g_intern_static_string (types[i].type_name), types[i].instance_size, diff --git a/girepository/gicallableinfo.c b/girepository/gicallableinfo.c index 9eccfc2a7..1c170a9db 100644 --- a/girepository/gicallableinfo.c +++ b/girepository/gicallableinfo.c @@ -631,9 +631,9 @@ gboolean gi_callable_info_invoke (GICallableInfo *info, void *function, const GIArgument *in_args, - gsize n_in_args, + size_t n_in_args, GIArgument *out_args, - gsize n_out_args, + size_t n_out_args, GIArgument *return_value, GError **error) { @@ -644,7 +644,7 @@ gi_callable_info_invoke (GICallableInfo *info, GITypeInfo *rinfo; GITypeTag rtag; GIArgInfo *ainfo; - gsize n_args, n_invoke_args, in_pos, out_pos, i; + size_t n_args, n_invoke_args, in_pos, out_pos, i; void **args; gboolean success = FALSE; GError *local_error = NULL; diff --git a/girepository/gicallableinfo.h b/girepository/gicallableinfo.h index 3ff1c0450..5f057ab8a 100644 --- a/girepository/gicallableinfo.h +++ b/girepository/gicallableinfo.h @@ -95,9 +95,9 @@ GI_AVAILABLE_IN_ALL gboolean gi_callable_info_invoke (GICallableInfo *info, void *function, const GIArgument *in_args, - gsize n_in_args, + size_t n_in_args, GIArgument *out_args, - gsize n_out_args, + size_t n_out_args, GIArgument *return_value, GError **error); diff --git a/girepository/giconstantinfo.c b/girepository/giconstantinfo.c index e16aca8fe..efe7d853a 100644 --- a/girepository/giconstantinfo.c +++ b/girepository/giconstantinfo.c @@ -116,7 +116,7 @@ gi_constant_info_free_value (GIConstantInfo *info, * Returns: size of the constant, in bytes * Since: 2.80 */ -gsize +size_t gi_constant_info_get_value (GIConstantInfo *info, GIArgument *value) { @@ -133,7 +133,7 @@ gi_constant_info_get_value (GIConstantInfo *info, { if (blob->type.flags.pointer) { - gsize blob_size = blob->size; + size_t blob_size = blob->size; value->v_pointer = g_memdup2 (&rinfo->typelib->data[blob->offset], blob_size); } diff --git a/girepository/giconstantinfo.h b/girepository/giconstantinfo.h index c28c5ddbf..5885d5465 100644 --- a/girepository/giconstantinfo.h +++ b/girepository/giconstantinfo.h @@ -52,6 +52,6 @@ void gi_constant_info_free_value (GIConstantInfo *info, GIArgument *value); GI_AVAILABLE_IN_ALL -gsize gi_constant_info_get_value (GIConstantInfo *info, +size_t gi_constant_info_get_value (GIConstantInfo *info, GIArgument *value); G_END_DECLS diff --git a/girepository/gifieldinfo.c b/girepository/gifieldinfo.c index 9abc1ae40..69c0fec20 100644 --- a/girepository/gifieldinfo.c +++ b/girepository/gifieldinfo.c @@ -95,7 +95,7 @@ gi_field_info_get_flags (GIFieldInfo *info) * Returns: the field size, in bits * Since: 2.80 */ -gsize +size_t gi_field_info_get_size (GIFieldInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -119,7 +119,7 @@ gi_field_info_get_size (GIFieldInfo *info) * Returns: the field offset, in bytes * Since: 2.80 */ -gsize +size_t gi_field_info_get_offset (GIFieldInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -433,7 +433,7 @@ gi_field_info_set_field (GIFieldInfo *field_info, result = TRUE; break; case GI_TYPE_TAG_GTYPE: - G_STRUCT_MEMBER (gsize, mem, offset) = value->v_size; + G_STRUCT_MEMBER (size_t, mem, offset) = value->v_size; result = TRUE; break; case GI_TYPE_TAG_FLOAT: diff --git a/girepository/gifieldinfo.h b/girepository/gifieldinfo.h index c7df49e54..9ac6449b6 100644 --- a/girepository/gifieldinfo.h +++ b/girepository/gifieldinfo.h @@ -48,10 +48,10 @@ GI_AVAILABLE_IN_ALL GIFieldInfoFlags gi_field_info_get_flags (GIFieldInfo *info); GI_AVAILABLE_IN_ALL -gsize gi_field_info_get_size (GIFieldInfo *info); +size_t gi_field_info_get_size (GIFieldInfo *info); GI_AVAILABLE_IN_ALL -gsize gi_field_info_get_offset (GIFieldInfo *info); +size_t gi_field_info_get_offset (GIFieldInfo *info); GI_AVAILABLE_IN_ALL GITypeInfo * gi_field_info_get_type_info (GIFieldInfo *info); diff --git a/girepository/gifunctioninfo.c b/girepository/gifunctioninfo.c index 525cd1ba1..74f49020c 100644 --- a/girepository/gifunctioninfo.c +++ b/girepository/gifunctioninfo.c @@ -266,9 +266,9 @@ gi_invoke_error_quark (void) gboolean gi_function_info_invoke (GIFunctionInfo *info, const GIArgument *in_args, - gsize n_in_args, + size_t n_in_args, GIArgument *out_args, - gsize n_out_args, + size_t n_out_args, GIArgument *return_value, GError **error) { diff --git a/girepository/gifunctioninfo.h b/girepository/gifunctioninfo.h index aa799dc90..9a9f52551 100644 --- a/girepository/gifunctioninfo.h +++ b/girepository/gifunctioninfo.h @@ -92,9 +92,9 @@ typedef enum GI_AVAILABLE_IN_ALL gboolean gi_function_info_invoke (GIFunctionInfo *info, const GIArgument *in_args, - gsize n_in_args, + size_t n_in_args, GIArgument *out_args, - gsize n_out_args, + size_t n_out_args, GIArgument *return_value, GError **error); diff --git a/girepository/girepository.c b/girepository/girepository.c index 2d08047af..74842e4ea 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -1071,7 +1071,7 @@ gi_repository_find_by_error_domain (GIRepository *repository, void gi_repository_get_object_gtype_interfaces (GIRepository *repository, GType gtype, - gsize *n_interfaces_out, + size_t *n_interfaces_out, GIInterfaceInfo ***interfaces_out) { GTypeInterfaceCache *cache; diff --git a/girepository/girepository.h b/girepository/girepository.h index cac9413a8..52ef28a8d 100644 --- a/girepository/girepository.h +++ b/girepository/girepository.h @@ -165,7 +165,7 @@ GIBaseInfo * gi_repository_find_by_gtype (GIRepository *repository, GI_AVAILABLE_IN_ALL void gi_repository_get_object_gtype_interfaces (GIRepository *repository, GType gtype, - gsize *n_interfaces_out, + size_t *n_interfaces_out, GIInterfaceInfo ***interfaces_out); GI_AVAILABLE_IN_ALL diff --git a/girepository/girmodule.c b/girepository/girmodule.c index 9ed3a7509..5e9b3d2c5 100644 --- a/girepository/girmodule.c +++ b/girepository/girmodule.c @@ -319,8 +319,8 @@ gi_ir_module_build_typelib (GIIrModule *module) { GError *error = NULL; GITypelib *typelib; - gsize length; - unsigned int i; + size_t length; + size_t i; GList *e; Header *header; DirEntry *entry; diff --git a/girepository/girparser.c b/girepository/girparser.c index f0336a2e2..d23035aec 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -433,7 +433,7 @@ static GIIrNodeType * parse_type_internal (GIIrModule *module, typedef struct { const char *str; - unsigned int size; + size_t size; unsigned int is_signed : 1; } IntegerAliasInfo; diff --git a/girepository/girwriter.c b/girepository/girwriter.c index c9dcc7f0e..869412aed 100644 --- a/girepository/girwriter.c +++ b/girepository/girwriter.c @@ -1249,7 +1249,7 @@ write_union_info (const char *ns, const char *type_init; const char *func; gboolean deprecated; - gsize size; + size_t size; name = gi_base_info_get_name ((GIBaseInfo *)info); deprecated = gi_base_info_is_deprecated ((GIBaseInfo *)info); diff --git a/girepository/gistructinfo.c b/girepository/gistructinfo.c index e06e78d8a..cf4e0f94f 100644 --- a/girepository/gistructinfo.c +++ b/girepository/gistructinfo.c @@ -232,7 +232,7 @@ gi_struct_info_find_method (GIStructInfo *info, * Returns: size of the structure, in bytes * Since: 2.80 */ -gsize +size_t gi_struct_info_get_size (GIStructInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -250,7 +250,7 @@ gi_struct_info_get_size (GIStructInfo *info) * Returns: required alignment, in bytes * Since: 2.80 */ -gsize +size_t gi_struct_info_get_alignment (GIStructInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; diff --git a/girepository/gistructinfo.h b/girepository/gistructinfo.h index 95a30d80e..eaab4f42e 100644 --- a/girepository/gistructinfo.h +++ b/girepository/gistructinfo.h @@ -67,10 +67,10 @@ GIFunctionInfo * gi_struct_info_find_method (GIStructInfo *info, const char *name); GI_AVAILABLE_IN_ALL -gsize gi_struct_info_get_size (GIStructInfo *info); +size_t gi_struct_info_get_size (GIStructInfo *info); GI_AVAILABLE_IN_ALL -gsize gi_struct_info_get_alignment (GIStructInfo *info); +size_t gi_struct_info_get_alignment (GIStructInfo *info); GI_AVAILABLE_IN_ALL gboolean gi_struct_info_is_gtype_struct (GIStructInfo *info); diff --git a/girepository/gitypelib-internal.h b/girepository/gitypelib-internal.h index ceff41d01..26de62916 100644 --- a/girepository/gitypelib-internal.h +++ b/girepository/gitypelib-internal.h @@ -1314,7 +1314,7 @@ typedef struct { struct _GITypelib { /*< private >*/ uint8_t *data; - gsize len; + size_t len; gboolean owns_memory; GMappedFile *mfile; GList *modules; diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index 1a990c5dd..93b2c7410 100644 --- a/girepository/gitypelib.c +++ b/girepository/gitypelib.c @@ -271,7 +271,7 @@ gi_typelib_get_dir_entry_by_gtype_name (GITypelib *typelib, typedef struct { const char *s; const char *separator; - gsize sep_len; + size_t sep_len; GString buf; } StrSplitIter; @@ -294,7 +294,7 @@ strsplit_iter_next (StrSplitIter *iter, { const char *s = iter->s; const char *next; - gsize len; + size_t len; if (!s) return FALSE; @@ -347,7 +347,7 @@ gi_typelib_matches_gtype_name_prefix (GITypelib *typelib, const char *prefix; gboolean ret = FALSE; StrSplitIter split_iter; - gsize gtype_name_len; + size_t gtype_name_len; c_prefix = gi_typelib_get_string (typelib, header->c_prefix); if (c_prefix == NULL || strlen (c_prefix) == 0) @@ -558,7 +558,7 @@ validate_name (GITypelib *typelib, /* Fast path sanity check, operates on a memory blob */ static gboolean validate_header_basic (const uint8_t *memory, - gsize len, + size_t len, GError **error) { Header *header = (Header *)memory; @@ -568,8 +568,7 @@ validate_header_basic (const uint8_t *memory, g_set_error (error, GI_TYPELIB_ERROR, GI_TYPELIB_ERROR_INVALID, - "The specified typelib length %" G_GSIZE_FORMAT " is too short", - len); + "The specified typelib length %zu is too short", len); return FALSE; } @@ -608,8 +607,8 @@ validate_header_basic (const uint8_t *memory, g_set_error (error, GI_TYPELIB_ERROR, GI_TYPELIB_ERROR_INVALID_HEADER, - "Typelib size %" G_GSIZE_FORMAT " does not match %" G_GSIZE_FORMAT, - (gsize) header->size, len); + "Typelib size %zu does not match %zu", + (size_t) header->size, len); return FALSE; } @@ -2410,7 +2409,7 @@ gi_typelib_ensure_open (GITypelib *typelib) */ GITypelib * gi_typelib_new_from_memory (uint8_t *memory, - gsize len, + size_t len, GError **error) { GITypelib *meta; @@ -2440,8 +2439,8 @@ gi_typelib_new_from_memory (uint8_t *memory, */ GITypelib * gi_typelib_new_from_const_memory (const uint8_t *memory, - gsize len, - GError **error) + size_t len, + GError **error) { GITypelib *meta; @@ -2474,7 +2473,7 @@ gi_typelib_new_from_mapped_file (GMappedFile *mfile, { GITypelib *meta; uint8_t *data = (uint8_t *) g_mapped_file_get_contents (mfile); - gsize len = g_mapped_file_get_length (mfile); + size_t len = g_mapped_file_get_length (mfile); if (!validate_header_basic (data, len, error)) return NULL; diff --git a/girepository/gitypelib.h b/girepository/gitypelib.h index dc2499ddd..ec03759d5 100644 --- a/girepository/gitypelib.h +++ b/girepository/gitypelib.h @@ -38,12 +38,12 @@ typedef struct _GITypelib GITypelib; GI_AVAILABLE_IN_ALL GITypelib * gi_typelib_new_from_memory (uint8_t *memory, - gsize len, + size_t len, GError **error); GI_AVAILABLE_IN_ALL GITypelib * gi_typelib_new_from_const_memory (const uint8_t *memory, - gsize len, + size_t len, GError **error); GI_AVAILABLE_IN_ALL diff --git a/girepository/gitypes.h b/girepository/gitypes.h index 77e64fa5e..b9b4b9faa 100644 --- a/girepository/gitypes.h +++ b/girepository/gitypes.h @@ -133,7 +133,7 @@ union _GIArgument long v_long; unsigned long v_ulong; gssize v_ssize; - gsize v_size; + size_t v_size; char *v_string; void *v_pointer; }; diff --git a/girepository/giunioninfo.c b/girepository/giunioninfo.c index e3c4397a4..36b777893 100644 --- a/girepository/giunioninfo.c +++ b/girepository/giunioninfo.c @@ -260,7 +260,7 @@ gi_union_info_find_method (GIUnionInfo *info, * Returns: size of the union, in bytes * Since: 2.80 */ -gsize +size_t gi_union_info_get_size (GIUnionInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -278,7 +278,7 @@ gi_union_info_get_size (GIUnionInfo *info) * Returns: required alignment, in bytes * Since: 2.80 */ -gsize +size_t gi_union_info_get_alignment (GIUnionInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; diff --git a/girepository/giunioninfo.h b/girepository/giunioninfo.h index df24d0bf4..9cd5ad05e 100644 --- a/girepository/giunioninfo.h +++ b/girepository/giunioninfo.h @@ -75,10 +75,10 @@ GIFunctionInfo * gi_union_info_find_method (GIUnionInfo *info, const char *name); GI_AVAILABLE_IN_ALL -gsize gi_union_info_get_size (GIUnionInfo *info); +size_t gi_union_info_get_size (GIUnionInfo *info); GI_AVAILABLE_IN_ALL -gsize gi_union_info_get_alignment (GIUnionInfo *info); +size_t gi_union_info_get_alignment (GIUnionInfo *info); GI_AVAILABLE_IN_ALL const char * gi_union_info_get_copy_function_name (GIUnionInfo *info); diff --git a/girepository/givfuncinfo.c b/girepository/givfuncinfo.c index 1ac79be96..cb37d7e76 100644 --- a/girepository/givfuncinfo.c +++ b/girepository/givfuncinfo.c @@ -341,9 +341,9 @@ gboolean gi_vfunc_info_invoke (GIVFuncInfo *info, GType implementor, const GIArgument *in_args, - gsize n_in_args, + size_t n_in_args, GIArgument *out_args, - gsize n_out_args, + size_t n_out_args, GIArgument *return_value, GError **error) { diff --git a/girepository/givfuncinfo.h b/girepository/givfuncinfo.h index 85f23c707..776317ad4 100644 --- a/girepository/givfuncinfo.h +++ b/girepository/givfuncinfo.h @@ -64,9 +64,9 @@ GI_AVAILABLE_IN_ALL gboolean gi_vfunc_info_invoke (GIVFuncInfo *info, GType implementor, const GIArgument *in_args, - gsize n_in_args, + size_t n_in_args, GIArgument *out_args, - gsize n_out_args, + size_t n_out_args, GIArgument *return_value, GError **error); From a3d29b64373c4ba266e033c97ce5b830dc734ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 00:42:53 +0100 Subject: [PATCH 11/27] giarginfo: Use gssize to return the closure and destroy indexes Use a bigger integer value, even though int is more than enough, but to make it clearer that we're returning a size-related value. --- girepository/giarginfo.c | 4 ++-- girepository/giarginfo.h | 4 ++-- girepository/girwriter.c | 6 ++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/girepository/giarginfo.c b/girepository/giarginfo.c index a4c690d9a..a0ec63301 100644 --- a/girepository/giarginfo.c +++ b/girepository/giarginfo.c @@ -269,7 +269,7 @@ gi_arg_info_get_scope (GIArgInfo *info) * Returns: Index of the user data argument or `-1` if there is none * Since: 2.80 */ -int +gssize gi_arg_info_get_closure_index (GIArgInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -294,7 +294,7 @@ gi_arg_info_get_closure_index (GIArgInfo *info) * none * Since: 2.80 */ -int +gssize gi_arg_info_get_destroy_index (GIArgInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; diff --git a/girepository/giarginfo.h b/girepository/giarginfo.h index fcedb5a28..42592ea67 100644 --- a/girepository/giarginfo.h +++ b/girepository/giarginfo.h @@ -69,10 +69,10 @@ GI_AVAILABLE_IN_ALL GIScopeType gi_arg_info_get_scope (GIArgInfo *info); GI_AVAILABLE_IN_ALL -int gi_arg_info_get_closure_index (GIArgInfo *info); +gssize gi_arg_info_get_closure_index (GIArgInfo *info); GI_AVAILABLE_IN_ALL -int gi_arg_info_get_destroy_index (GIArgInfo *info); +gssize gi_arg_info_get_destroy_index (GIArgInfo *info); GI_AVAILABLE_IN_ALL GITypeInfo * gi_arg_info_get_type_info (GIArgInfo *info); diff --git a/girepository/girwriter.c b/girepository/girwriter.c index 869412aed..22b366bd2 100644 --- a/girepository/girwriter.c +++ b/girepository/girwriter.c @@ -545,10 +545,12 @@ write_callable_info (const char *ns, } if (gi_arg_info_get_closure_index (arg) >= 0) - xml_printf (file, " closure=\"%d\"", gi_arg_info_get_closure_index (arg)); + xml_printf (file, " closure=\"%" G_GSSIZE_FORMAT "\"", + gi_arg_info_get_closure_index (arg)); if (gi_arg_info_get_destroy_index (arg) >= 0) - xml_printf (file, " destroy=\"%d\"", gi_arg_info_get_destroy_index (arg)); + xml_printf (file, " destroy=\"%" G_GSSIZE_FORMAT "\"", + gi_arg_info_get_destroy_index (arg)); if (gi_arg_info_is_skip (arg)) xml_printf (file, " skip=\"1\""); From de8ac339fb52e88b3e2a6285503e5d3cfc77237e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 00:44:08 +0100 Subject: [PATCH 12/27] gitypeinfo: Use gssize to return the array length index Use a bigger integer value, even though int is more than enough, but to make it clearer that we're returning a size-related value. --- girepository/girwriter.c | 4 ++-- girepository/gitypeinfo.c | 2 +- girepository/gitypeinfo.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/girepository/girwriter.c b/girepository/girwriter.c index 22b366bd2..6c52ed054 100644 --- a/girepository/girwriter.c +++ b/girepository/girwriter.c @@ -244,7 +244,7 @@ write_type_info (const char *ns, } else if (tag == GI_TYPE_TAG_ARRAY) { - int length; + gssize length; gssize size; const char *name = NULL; @@ -273,7 +273,7 @@ write_type_info (const char *ns, length = gi_type_info_get_array_length_index (info); if (length >= 0) - xml_printf (file, " length=\"%d\"", length); + xml_printf (file, " length=\"%" G_GSSIZE_FORMAT "\"", length); size = gi_type_info_get_array_fixed_size (info); if (size >= 0) diff --git a/girepository/gitypeinfo.c b/girepository/gitypeinfo.c index 349e0f879..5086ec2a2 100644 --- a/girepository/gitypeinfo.c +++ b/girepository/gitypeinfo.c @@ -241,7 +241,7 @@ gi_type_info_get_interface (GITypeInfo *info) * or it has no length argument * Since: 2.80 */ -int +gssize gi_type_info_get_array_length_index (GITypeInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; diff --git a/girepository/gitypeinfo.h b/girepository/gitypeinfo.h index 56a5c7c24..d12790a36 100644 --- a/girepository/gitypeinfo.h +++ b/girepository/gitypeinfo.h @@ -96,7 +96,7 @@ GI_AVAILABLE_IN_ALL GIBaseInfo * gi_type_info_get_interface (GITypeInfo *info); GI_AVAILABLE_IN_ALL -int gi_type_info_get_array_length_index (GITypeInfo *info); +gssize gi_type_info_get_array_length_index (GITypeInfo *info); GI_AVAILABLE_IN_ALL gssize gi_type_info_get_array_fixed_size (GITypeInfo *info); From 157f93d2ee5a80d3d5fe8f9ff05a1fbf71e4e44c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 01:00:07 +0100 Subject: [PATCH 13/27] girepository: Use size_t for size-related arguments and return types We used to use unsigned values, while they should be big enough to old the data we're handling here, it's cleaner and clearer if we use size_t as type for such values, as it makes straight forward to understand what a value should contain. It also makes these values more future proof. --- girepository/gibaseinfo.c | 2 +- girepository/gibaseinfo.h | 2 +- girepository/gienuminfo.c | 4 ++-- girepository/giinterfaceinfo.c | 14 +++++++------- girepository/giobjectinfo.c | 24 ++++++++++++------------ girepository/girwriter.c | 27 +++++++++++++-------------- girepository/gistructinfo.c | 9 ++++----- girepository/giunioninfo.c | 10 +++++----- girepository/giunioninfo.h | 4 ++-- girepository/givfuncinfo.c | 2 +- girepository/givfuncinfo.h | 2 +- 11 files changed, 49 insertions(+), 51 deletions(-) diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c index 4c34355de..456a0832b 100644 --- a/girepository/gibaseinfo.c +++ b/girepository/gibaseinfo.c @@ -357,7 +357,7 @@ GIBaseInfo * gi_info_new (GIInfoType type, GIBaseInfo *container, GITypelib *typelib, - uint32_t offset) + size_t offset) { return gi_info_new_full (type, ((GIRealInfo*)container)->repository, container, typelib, offset); } diff --git a/girepository/gibaseinfo.h b/girepository/gibaseinfo.h index c6aaee604..25a61d52b 100644 --- a/girepository/gibaseinfo.h +++ b/girepository/gibaseinfo.h @@ -96,6 +96,6 @@ GI_AVAILABLE_IN_ALL GIBaseInfo * gi_info_new (GIInfoType type, GIBaseInfo *container, GITypelib *typelib, - uint32_t offset); + size_t offset); G_END_DECLS diff --git a/girepository/gienuminfo.c b/girepository/gienuminfo.c index 1fa346f2e..e66ff5811 100644 --- a/girepository/gienuminfo.c +++ b/girepository/gienuminfo.c @@ -114,7 +114,7 @@ gi_enum_info_get_value (GIEnumInfo *info, { GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; - int offset; + size_t offset; g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_ENUM_INFO (info), NULL); @@ -164,7 +164,7 @@ GIFunctionInfo * gi_enum_info_get_method (GIEnumInfo *info, unsigned int n) { - int offset; + size_t offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; EnumBlob *blob; diff --git a/girepository/giinterfaceinfo.c b/girepository/giinterfaceinfo.c index e2eff78f0..ebfb1dccc 100644 --- a/girepository/giinterfaceinfo.c +++ b/girepository/giinterfaceinfo.c @@ -135,7 +135,7 @@ GIPropertyInfo * gi_interface_info_get_property (GIInterfaceInfo *info, unsigned int n) { - int offset; + size_t offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; InterfaceBlob *blob; @@ -192,7 +192,7 @@ GIFunctionInfo * gi_interface_info_get_method (GIInterfaceInfo *info, unsigned int n) { - int offset; + size_t offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; InterfaceBlob *blob; @@ -230,7 +230,7 @@ GIFunctionInfo * gi_interface_info_find_method (GIInterfaceInfo *info, const char *name) { - int offset; + size_t offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header = (Header *)rinfo->typelib->data; InterfaceBlob *blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -280,7 +280,7 @@ GISignalInfo * gi_interface_info_get_signal (GIInterfaceInfo *info, unsigned int n) { - int offset; + size_t offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; InterfaceBlob *blob; @@ -375,7 +375,7 @@ GIVFuncInfo * gi_interface_info_get_vfunc (GIInterfaceInfo *info, unsigned int n) { - int offset; + size_t offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; InterfaceBlob *blob; @@ -416,7 +416,7 @@ GIVFuncInfo * gi_interface_info_find_vfunc (GIInterfaceInfo *info, const char *name) { - int offset; + size_t offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; InterfaceBlob *blob; @@ -474,7 +474,7 @@ GIConstantInfo * gi_interface_info_get_constant (GIInterfaceInfo *info, unsigned int n) { - int offset; + size_t offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; InterfaceBlob *blob; diff --git a/girepository/giobjectinfo.c b/girepository/giobjectinfo.c index 995f489e7..a6b0ea36c 100644 --- a/girepository/giobjectinfo.c +++ b/girepository/giobjectinfo.c @@ -59,9 +59,9 @@ * Returns: field offset, in bytes * Since: 2.80 */ -static uint32_t +static size_t gi_object_info_get_field_offset (GIObjectInfo *info, - unsigned int n) + size_t n) { GIRealInfo *rinfo = (GIRealInfo *)info; Header *header = (Header *)rinfo->typelib->data; @@ -320,7 +320,7 @@ GIFieldInfo * gi_object_info_get_field (GIObjectInfo *info, unsigned int n) { - int offset; + size_t offset; GIRealInfo *rinfo = (GIRealInfo *)info; g_return_val_if_fail (info != NULL, NULL); @@ -368,7 +368,7 @@ GIPropertyInfo * gi_object_info_get_property (GIObjectInfo *info, unsigned int n) { - int offset; + size_t offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; ObjectBlob *blob; @@ -427,7 +427,7 @@ GIFunctionInfo * gi_object_info_get_method (GIObjectInfo *info, unsigned int n) { - int offset; + size_t offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; ObjectBlob *blob; @@ -468,7 +468,7 @@ GIFunctionInfo * gi_object_info_find_method (GIObjectInfo *info, const char *name) { - int offset; + size_t offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; ObjectBlob *blob; @@ -588,7 +588,7 @@ GISignalInfo * gi_object_info_get_signal (GIObjectInfo *info, unsigned int n) { - int offset; + size_t offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; ObjectBlob *blob; @@ -629,10 +629,10 @@ GISignalInfo * gi_object_info_find_signal (GIObjectInfo *info, const char *name) { - unsigned int n_signals; + size_t n_signals; n_signals = gi_object_info_get_n_signals (info); - for (unsigned int i = 0; i < n_signals; i++) + for (size_t i = 0; i < n_signals; i++) { GISignalInfo *siginfo = gi_object_info_get_signal (info, i); @@ -686,7 +686,7 @@ GIVFuncInfo * gi_object_info_get_vfunc (GIObjectInfo *info, unsigned int n) { - int offset; + size_t offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; ObjectBlob *blob; @@ -734,7 +734,7 @@ GIVFuncInfo * gi_object_info_find_vfunc (GIObjectInfo *info, const char *name) { - int offset; + size_t offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; ObjectBlob *blob; @@ -861,7 +861,7 @@ GIConstantInfo * gi_object_info_get_constant (GIObjectInfo *info, unsigned int n) { - int offset; + size_t offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header; ObjectBlob *blob; diff --git a/girepository/girwriter.c b/girepository/girwriter.c index 6c52ed054..f87936cc9 100644 --- a/girepository/girwriter.c +++ b/girepository/girwriter.c @@ -397,8 +397,8 @@ write_field_info (const char *ns, { const char *name; GIFieldInfoFlags flags; - int size; - int offset; + size_t size; + size_t offset; GITypeInfo *type; GIBaseInfo *interface; GIArgument value; @@ -420,7 +420,7 @@ write_field_info (const char *ns, xml_printf (file, " writable=\"1\""); if (size) - xml_printf (file, " bits=\"%d\"", size); + xml_printf (file, " bits=\"%zu\"", size); write_attributes (file, (GIBaseInfo*) info); @@ -438,8 +438,7 @@ write_field_info (const char *ns, if (file->show_all) { - if (offset >= 0) - xml_printf (file, "offset=\"%d\"", offset); + xml_printf (file, "offset=\"%zu\"", offset); } interface = gi_type_info_get_interface (type); @@ -653,7 +652,7 @@ write_struct_info (const char *ns, gboolean deprecated; gboolean is_gtype_struct; gboolean foreign; - int size; + size_t size; unsigned int n_elts; name = gi_base_info_get_name ((GIBaseInfo *)info); @@ -694,8 +693,8 @@ write_struct_info (const char *ns, write_attributes (file, (GIBaseInfo*) info); size = gi_struct_info_get_size (info); - if (file->show_all && size >= 0) - xml_printf (file, " size=\"%d\"", size); + if (file->show_all) + xml_printf (file, " size=\"%zu\"", size); foreign = gi_struct_info_is_foreign (info); if (foreign) @@ -927,7 +926,7 @@ write_vfunc_info (const char *ns, const char *name; GIFunctionInfo *invoker; gboolean deprecated; - int offset; + size_t offset; name = gi_base_info_get_name ((GIBaseInfo *)info); flags = gi_vfunc_info_get_flags (info); @@ -949,7 +948,7 @@ write_vfunc_info (const char *ns, else if (flags & GI_VFUNC_MUST_NOT_OVERRIDE) xml_printf (file, " override=\"never\""); - xml_printf (file, " offset=\"%d\"", offset); + xml_printf (file, " offset=\"%zu\"", offset); if (invoker) { @@ -1284,14 +1283,14 @@ write_union_info (const char *ns, if (gi_union_info_is_discriminated (info)) { - unsigned int offset; + size_t offset; GITypeInfo *type; offset = gi_union_info_get_discriminator_offset (info); type = gi_union_info_get_discriminator_type (info); xml_start_element (file, "discriminator"); - xml_printf (file, " offset=\"%d\" type=\"", offset); + xml_printf (file, " offset=\"%zu\" type=\"", offset); write_type_info (ns, type, file); xml_end_element (file, "discriminator"); gi_base_info_unref ((GIBaseInfo *)type); @@ -1337,7 +1336,7 @@ gi_ir_writer_write (const char *filename, gboolean show_all) { FILE *ofile; - int i, j; + size_t i, j; char **dependencies; GIRepository *repository; Xml *xml; @@ -1396,7 +1395,7 @@ gi_ir_writer_write (const char *filename, const char *c_prefix; const char *cur_ns = ns; const char *cur_version; - int n_infos; + unsigned int n_infos; cur_version = gi_repository_get_version (repository, cur_ns); diff --git a/girepository/gistructinfo.c b/girepository/gistructinfo.c index cf4e0f94f..be7e43d49 100644 --- a/girepository/gistructinfo.c +++ b/girepository/gistructinfo.c @@ -132,10 +132,9 @@ gi_struct_info_find_field (GIStructInfo *info, GIRealInfo *rinfo = (GIRealInfo *)info; StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset]; Header *header = (Header *)rinfo->typelib->data; - uint32_t offset = rinfo->offset + header->struct_blob_size; - int i; + size_t offset = rinfo->offset + header->struct_blob_size; - for (i = 0; i < blob->n_fields; i++) + for (size_t i = 0; i < blob->n_fields; i++) { FieldBlob *field_blob = (FieldBlob *)&rinfo->typelib->data[offset]; const char *fname = (const char *)&rinfo->typelib->data[field_blob->name]; @@ -192,7 +191,7 @@ gi_struct_info_get_method (GIStructInfo *info, GIRealInfo *rinfo = (GIRealInfo *)info; StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset]; Header *header = (Header *)rinfo->typelib->data; - int offset; + size_t offset; offset = gi_struct_get_field_offset (info, blob->n_fields) + n * header->function_blob_size; return (GIFunctionInfo *) gi_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info, @@ -215,7 +214,7 @@ GIFunctionInfo * gi_struct_info_find_method (GIStructInfo *info, const char *name) { - int offset; + size_t offset; GIRealInfo *rinfo = (GIRealInfo *)info; StructBlob *blob = (StructBlob *)&rinfo->typelib->data[rinfo->offset]; diff --git a/girepository/giunioninfo.c b/girepository/giunioninfo.c index 36b777893..d64ec2c01 100644 --- a/girepository/giunioninfo.c +++ b/girepository/giunioninfo.c @@ -121,7 +121,7 @@ gi_union_info_get_method (GIUnionInfo *info, GIRealInfo *rinfo = (GIRealInfo *)info; UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset]; Header *header = (Header *)rinfo->typelib->data; - int offset; + size_t offset; offset = rinfo->offset + header->union_blob_size + blob->n_fields * header->field_blob_size @@ -157,7 +157,7 @@ gi_union_info_is_discriminated (GIUnionInfo *info) * Returns: offset, in bytes, of the discriminator * Since: 2.80 */ -unsigned int +size_t gi_union_info_get_discriminator_offset (GIUnionInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; @@ -202,7 +202,7 @@ gi_union_info_get_discriminator_type (GIUnionInfo *info) */ GIConstantInfo * gi_union_info_get_discriminator (GIUnionInfo *info, - unsigned int n) + size_t n) { GIRealInfo *rinfo = (GIRealInfo *)info; UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -210,7 +210,7 @@ gi_union_info_get_discriminator (GIUnionInfo *info, if (blob->discriminated) { Header *header = (Header *)rinfo->typelib->data; - int offset; + size_t offset; offset = rinfo->offset + header->union_blob_size + blob->n_fields * header->field_blob_size @@ -240,7 +240,7 @@ GIFunctionInfo * gi_union_info_find_method (GIUnionInfo *info, const char *name) { - int offset; + size_t offset; GIRealInfo *rinfo = (GIRealInfo *)info; Header *header = (Header *)rinfo->typelib->data; UnionBlob *blob = (UnionBlob *)&rinfo->typelib->data[rinfo->offset]; diff --git a/girepository/giunioninfo.h b/girepository/giunioninfo.h index 9cd5ad05e..30ebc9549 100644 --- a/girepository/giunioninfo.h +++ b/girepository/giunioninfo.h @@ -61,14 +61,14 @@ GI_AVAILABLE_IN_ALL gboolean gi_union_info_is_discriminated (GIUnionInfo *info); GI_AVAILABLE_IN_ALL -unsigned int gi_union_info_get_discriminator_offset (GIUnionInfo *info); +size_t gi_union_info_get_discriminator_offset (GIUnionInfo *info); GI_AVAILABLE_IN_ALL GITypeInfo * gi_union_info_get_discriminator_type (GIUnionInfo *info); GI_AVAILABLE_IN_ALL GIConstantInfo * gi_union_info_get_discriminator (GIUnionInfo *info, - unsigned int n); + size_t n); GI_AVAILABLE_IN_ALL GIFunctionInfo * gi_union_info_find_method (GIUnionInfo *info, diff --git a/girepository/givfuncinfo.c b/girepository/givfuncinfo.c index cb37d7e76..e5ce6bdf1 100644 --- a/girepository/givfuncinfo.c +++ b/girepository/givfuncinfo.c @@ -121,7 +121,7 @@ gi_vfunc_info_get_flags (GIVFuncInfo *info) * Returns: the struct offset or `0xFFFF` if it’s unknown * Since: 2.80 */ -unsigned int +size_t gi_vfunc_info_get_offset (GIVFuncInfo *info) { GIRealInfo *rinfo = (GIRealInfo *)info; diff --git a/girepository/givfuncinfo.h b/girepository/givfuncinfo.h index 776317ad4..540e80666 100644 --- a/girepository/givfuncinfo.h +++ b/girepository/givfuncinfo.h @@ -47,7 +47,7 @@ GI_AVAILABLE_IN_ALL GIVFuncInfoFlags gi_vfunc_info_get_flags (GIVFuncInfo *info); GI_AVAILABLE_IN_ALL -unsigned int gi_vfunc_info_get_offset (GIVFuncInfo *info); +size_t gi_vfunc_info_get_offset (GIVFuncInfo *info); GI_AVAILABLE_IN_ALL GISignalInfo * gi_vfunc_info_get_signal (GIVFuncInfo *info); From acabaa156850fb2f2de3aba13bb638d6ede19b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 01:18:23 +0100 Subject: [PATCH 14/27] gibaseinfo: Ensure the typelib offset is within the allowed limits Even though we expose the offset as a size_t value, we actually have a less space for it, so let's ensure this is the case at runtime. --- girepository/gibaseinfo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/girepository/gibaseinfo.c b/girepository/gibaseinfo.c index 456a0832b..031635c3a 100644 --- a/girepository/gibaseinfo.c +++ b/girepository/gibaseinfo.c @@ -321,6 +321,7 @@ gi_info_new_full (GIInfoType type, g_return_val_if_fail (container != NULL || repository != NULL, NULL); g_return_val_if_fail (GI_IS_REPOSITORY (repository), NULL); + g_return_val_if_fail (offset <= G_MAXUINT32, NULL); gi_base_info_init_types (); g_assert (gi_base_info_types[type] != G_TYPE_INVALID); From 19476db82579cd61e94182570286b0e741fba06e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 01:40:09 +0100 Subject: [PATCH 15/27] girepository: Ensure indexed access on members is not overflowing Even though we expose member access as size_t, a GI info blob can typically just access to an a number of values that is never bigger than uint16_t, as that's how the typelib is defined (cfr. typelib internal header blob sizes and n_* elements). So let's avoid this to happen by adding a check. --- girepository/gicallableinfo.c | 2 ++ girepository/gienuminfo.c | 2 ++ girepository/giinterfaceinfo.c | 6 ++++++ girepository/giobjectinfo.c | 7 +++++++ girepository/girepository.c | 1 + girepository/gistructinfo.c | 4 ++++ 6 files changed, 22 insertions(+) diff --git a/girepository/gicallableinfo.c b/girepository/gicallableinfo.c index 1c170a9db..17dbc50bd 100644 --- a/girepository/gicallableinfo.c +++ b/girepository/gicallableinfo.c @@ -368,6 +368,7 @@ gi_callable_info_get_arg (GICallableInfo *info, g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_CALLABLE_INFO (info), NULL); + g_return_val_if_fail (n <= G_MAXUINT16, NULL); offset = signature_offset (info); header = (Header *)rinfo->typelib->data; @@ -401,6 +402,7 @@ gi_callable_info_load_arg (GICallableInfo *info, g_return_if_fail (info != NULL); g_return_if_fail (GI_IS_CALLABLE_INFO (info)); + g_return_if_fail (n <= G_MAXUINT16); offset = signature_offset (info); header = (Header *)rinfo->typelib->data; diff --git a/girepository/gienuminfo.c b/girepository/gienuminfo.c index e66ff5811..6f30ea08e 100644 --- a/girepository/gienuminfo.c +++ b/girepository/gienuminfo.c @@ -118,6 +118,7 @@ gi_enum_info_get_value (GIEnumInfo *info, g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_ENUM_INFO (info), NULL); + g_return_val_if_fail (n <= G_MAXUINT16, NULL); header = (Header *)rinfo->typelib->data; offset = rinfo->offset + header->enum_blob_size @@ -171,6 +172,7 @@ gi_enum_info_get_method (GIEnumInfo *info, g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_ENUM_INFO (info), NULL); + g_return_val_if_fail (n <= G_MAXUINT16, NULL); header = (Header *)rinfo->typelib->data; blob = (EnumBlob *)&rinfo->typelib->data[rinfo->offset]; diff --git a/girepository/giinterfaceinfo.c b/girepository/giinterfaceinfo.c index ebfb1dccc..a083a26a8 100644 --- a/girepository/giinterfaceinfo.c +++ b/girepository/giinterfaceinfo.c @@ -89,6 +89,7 @@ gi_interface_info_get_prerequisite (GIInterfaceInfo *info, g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL); + g_return_val_if_fail (n <= G_MAXUINT16, NULL); blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -142,6 +143,7 @@ gi_interface_info_get_property (GIInterfaceInfo *info, g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL); + g_return_val_if_fail (n <= G_MAXUINT16, NULL); header = (Header *)rinfo->typelib->data; blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -199,6 +201,7 @@ gi_interface_info_get_method (GIInterfaceInfo *info, g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL); + g_return_val_if_fail (n <= G_MAXUINT16, NULL); header = (Header *)rinfo->typelib->data; blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -287,6 +290,7 @@ gi_interface_info_get_signal (GIInterfaceInfo *info, g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL); + g_return_val_if_fail (n <= G_MAXUINT16, NULL); header = (Header *)rinfo->typelib->data; blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -382,6 +386,7 @@ gi_interface_info_get_vfunc (GIInterfaceInfo *info, g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL); + g_return_val_if_fail (n <= G_MAXUINT16, NULL); header = (Header *)rinfo->typelib->data; blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -481,6 +486,7 @@ gi_interface_info_get_constant (GIInterfaceInfo *info, g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_INTERFACE_INFO (info), NULL); + g_return_val_if_fail (n <= G_MAXUINT16, NULL); header = (Header *)rinfo->typelib->data; blob = (InterfaceBlob *)&rinfo->typelib->data[rinfo->offset]; diff --git a/girepository/giobjectinfo.c b/girepository/giobjectinfo.c index a6b0ea36c..e4890153a 100644 --- a/girepository/giobjectinfo.c +++ b/girepository/giobjectinfo.c @@ -275,6 +275,7 @@ gi_object_info_get_interface (GIObjectInfo *info, g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL); + g_return_val_if_fail (n <= G_MAXUINT16, NULL); blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -325,6 +326,7 @@ gi_object_info_get_field (GIObjectInfo *info, g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL); + g_return_val_if_fail (n <= G_MAXUINT16, NULL); offset = gi_object_info_get_field_offset(info, n); @@ -375,6 +377,7 @@ gi_object_info_get_property (GIObjectInfo *info, g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL); + g_return_val_if_fail (n <= G_MAXUINT16, NULL); header = (Header *)rinfo->typelib->data; blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -434,6 +437,7 @@ gi_object_info_get_method (GIObjectInfo *info, g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL); + g_return_val_if_fail (n <= G_MAXUINT16, NULL); header = (Header *)rinfo->typelib->data; blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -595,6 +599,7 @@ gi_object_info_get_signal (GIObjectInfo *info, g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL); + g_return_val_if_fail (n <= G_MAXUINT16, NULL); header = (Header *)rinfo->typelib->data; blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -693,6 +698,7 @@ gi_object_info_get_vfunc (GIObjectInfo *info, g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL); + g_return_val_if_fail (n <= G_MAXUINT16, NULL); header = (Header *)rinfo->typelib->data; blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; @@ -868,6 +874,7 @@ gi_object_info_get_constant (GIObjectInfo *info, g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (GI_IS_OBJECT_INFO (info), NULL); + g_return_val_if_fail (n <= G_MAXUINT16, NULL); header = (Header *)rinfo->typelib->data; blob = (ObjectBlob *)&rinfo->typelib->data[rinfo->offset]; diff --git a/girepository/girepository.c b/girepository/girepository.c index 74842e4ea..ba3d677f7 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -798,6 +798,7 @@ gi_repository_get_info (GIRepository *repository, DirEntry *entry; g_return_val_if_fail (namespace != NULL, NULL); + g_return_val_if_fail (idx < G_MAXUINT16, NULL); repository = get_repository (repository); diff --git a/girepository/gistructinfo.c b/girepository/gistructinfo.c index be7e43d49..cac545ff7 100644 --- a/girepository/gistructinfo.c +++ b/girepository/gistructinfo.c @@ -109,6 +109,8 @@ gi_struct_info_get_field (GIStructInfo *info, { GIRealInfo *rinfo = (GIRealInfo *)info; + g_return_val_if_fail (n <= G_MAXUINT16, NULL); + return (GIFieldInfo *) gi_info_new (GI_INFO_TYPE_FIELD, (GIBaseInfo*)info, rinfo->typelib, gi_struct_get_field_offset (info, n)); } @@ -193,6 +195,8 @@ gi_struct_info_get_method (GIStructInfo *info, Header *header = (Header *)rinfo->typelib->data; size_t offset; + g_return_val_if_fail (n <= G_MAXUINT16, NULL); + offset = gi_struct_get_field_offset (info, blob->n_fields) + n * header->function_blob_size; return (GIFunctionInfo *) gi_info_new (GI_INFO_TYPE_FUNCTION, (GIBaseInfo*)info, rinfo->typelib, offset); From 13791b47f6f7fc73072a387784afe8d49a791706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 01:41:43 +0100 Subject: [PATCH 16/27] gistructinfo: Use proper types for offset lookup This is a private function so we can just use the expected types. Also this avoids a signed/unsigned conversion. --- girepository/gistructinfo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/girepository/gistructinfo.c b/girepository/gistructinfo.c index cac545ff7..d2c31c15a 100644 --- a/girepository/gistructinfo.c +++ b/girepository/gistructinfo.c @@ -72,16 +72,16 @@ gi_struct_info_get_n_fields (GIStructInfo *info) * Returns: field offset, in bytes * Since: 2.80 */ -static int32_t +static size_t gi_struct_get_field_offset (GIStructInfo *info, - unsigned int n) + uint16_t n) { GIRealInfo *rinfo = (GIRealInfo *)info; Header *header = (Header *)rinfo->typelib->data; - uint32_t offset = rinfo->offset + header->struct_blob_size; + size_t offset = rinfo->offset + header->struct_blob_size; FieldBlob *field_blob; - for (unsigned int i = 0; i < n; i++) + for (uint16_t i = 0; i < n; i++) { field_blob = (FieldBlob *)&rinfo->typelib->data[offset]; offset += header->field_blob_size; From 91a33990273eb7aff191c680f770f1b245b3be56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 01:47:01 +0100 Subject: [PATCH 17/27] girmodule: Ensure we actually use unsigned for gi_ir_module_fatal line --- girepository/girmodule-private.h | 5 ++++- girepository/girmodule.c | 2 +- girepository/girnode.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/girepository/girmodule-private.h b/girepository/girmodule-private.h index 9db6b42db..f6ea314f0 100644 --- a/girepository/girmodule-private.h +++ b/girepository/girmodule-private.h @@ -77,7 +77,10 @@ void gi_ir_module_add_include_module (GIIrModule *module, GITypelib * gi_ir_module_build_typelib (GIIrModule *module); -void gi_ir_module_fatal (GIIrTypelibBuild *build, unsigned int line, const char *msg, ...) G_GNUC_PRINTF (3, 4) G_GNUC_NORETURN; +void gi_ir_module_fatal (GIIrTypelibBuild *build, + unsigned int line, + const char *msg, + ...) G_GNUC_PRINTF (3, 4) G_GNUC_NORETURN; void gi_ir_node_init_stats (void); void gi_ir_node_dump_stats (void); diff --git a/girepository/girmodule.c b/girepository/girmodule.c index 5e9b3d2c5..500d749d4 100644 --- a/girepository/girmodule.c +++ b/girepository/girmodule.c @@ -114,7 +114,7 @@ gi_ir_module_fatal (GIIrTypelibBuild *build, context = g_string_new (""); if (line > 0) - g_string_append_printf (context, "%d: ", line); + g_string_append_printf (context, "%u: ", line); if (build->stack) g_string_append (context, "In "); for (link = g_list_last (build->stack); link; link = link->prev) diff --git a/girepository/girnode.c b/girepository/girnode.c index 95ba5b14c..7ecee4ca6 100644 --- a/girepository/girnode.c +++ b/girepository/girnode.c @@ -1104,7 +1104,7 @@ find_entry_node (GIIrTypelibBuild *build, } - gi_ir_module_fatal (build, -1, "type reference '%s' not found", name); + gi_ir_module_fatal (build, 0, "type reference '%s' not found", name); out: g_strfreev (names); From 25ae968fc2be329fca502ea03d9ee10a4219ad6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 01:57:09 +0100 Subject: [PATCH 18/27] girepository: Use expected signed types for iterating We are using various indexes types, but not always using the correct sign or size, so let's adapt this to ensure we're consistent with the values we're comparing with. --- girepository/gifunctioninfo.c | 4 ++-- girepository/giinterfaceinfo.c | 4 ++-- girepository/giobjectinfo.c | 2 +- girepository/girepository-private.h | 4 ++-- girepository/girepository.c | 4 ++-- girepository/girffi.c | 3 +-- girepository/girnode.c | 4 ++-- girepository/girparser.c | 8 ++++--- girepository/gitypelib.c | 35 +++++++++++++---------------- girepository/givfuncinfo.c | 4 ++-- 10 files changed, 35 insertions(+), 37 deletions(-) diff --git a/girepository/gifunctioninfo.c b/girepository/gifunctioninfo.c index 74f49020c..9b3b1e8d6 100644 --- a/girepository/gifunctioninfo.c +++ b/girepository/gifunctioninfo.c @@ -51,14 +51,14 @@ GIFunctionInfo * gi_base_info_find_method (GIBaseInfo *base, uint32_t offset, - unsigned n_methods, + uint16_t n_methods, const char *name) { /* FIXME hash */ GIRealInfo *rinfo = (GIRealInfo*)base; Header *header = (Header *)rinfo->typelib->data; - for (unsigned i = 0; i < n_methods; i++) + for (uint16_t i = 0; i < n_methods; i++) { FunctionBlob *fblob = (FunctionBlob *)&rinfo->typelib->data[offset]; const char *fname = (const char *)&rinfo->typelib->data[fblob->name]; diff --git a/girepository/giinterfaceinfo.c b/girepository/giinterfaceinfo.c index a083a26a8..b207d195d 100644 --- a/girepository/giinterfaceinfo.c +++ b/girepository/giinterfaceinfo.c @@ -323,10 +323,10 @@ GISignalInfo * gi_interface_info_find_signal (GIInterfaceInfo *info, const char *name) { - unsigned int n_signals; + uint32_t n_signals; n_signals = gi_interface_info_get_n_signals (info); - for (unsigned int i = 0; i < n_signals; i++) + for (uint32_t i = 0; i < n_signals; i++) { GISignalInfo *siginfo = gi_interface_info_get_signal (info, i); diff --git a/girepository/giobjectinfo.c b/girepository/giobjectinfo.c index e4890153a..b55390ed9 100644 --- a/girepository/giobjectinfo.c +++ b/girepository/giobjectinfo.c @@ -72,7 +72,7 @@ gi_object_info_get_field_offset (GIObjectInfo *info, offset = rinfo->offset + header->object_blob_size + (blob->n_interfaces + blob->n_interfaces % 2) * 2; - for (unsigned int i = 0; i < n; i++) + for (size_t i = 0; i < n; i++) { field_blob = (FieldBlob *)&rinfo->typelib->data[offset]; offset += header->field_blob_size; diff --git a/girepository/girepository-private.h b/girepository/girepository-private.h index 3f76ffa0a..f0f700744 100644 --- a/girepository/girepository-private.h +++ b/girepository/girepository-private.h @@ -233,10 +233,10 @@ void gi_type_info_init (GIBaseInfo *info, GIFunctionInfo * gi_base_info_find_method (GIBaseInfo *base, uint32_t offset, - unsigned n_methods, + uint16_t n_methods, const char *name); GIVFuncInfo * gi_base_info_find_vfunc (GIRealInfo *rinfo, uint32_t offset, - unsigned n_vfuncs, + uint16_t n_vfuncs, const char *name); diff --git a/girepository/girepository.c b/girepository/girepository.c index ba3d677f7..24579df59 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -531,7 +531,7 @@ get_typelib_dependencies_transitive (GIRepository *repository, immediate_dependencies = get_typelib_dependencies (typelib); - for (unsigned int i = 0; immediate_dependencies != NULL && immediate_dependencies[i]; i++) + for (size_t i = 0; immediate_dependencies != NULL && immediate_dependencies[i]; i++) { char *dependency; const char *last_dash; @@ -1153,7 +1153,7 @@ gi_repository_get_loaded_namespaces (GIRepository *repository) { GList *l, *list = NULL; char **names; - int i; + size_t i; repository = get_repository (repository); diff --git a/girepository/girffi.c b/girepository/girffi.c index 7532fe3f5..b9e6ee8b4 100644 --- a/girepository/girffi.c +++ b/girepository/girffi.c @@ -175,8 +175,7 @@ gi_callable_info_get_ffi_arg_types (GICallableInfo *callable_info, { ffi_type **arg_types; gboolean is_method, throws; - size_t n_invoke_args; - unsigned int n_args, i, offset; + size_t n_args, n_invoke_args, i, offset; g_return_val_if_fail (callable_info != NULL, NULL); diff --git a/girepository/girnode.c b/girepository/girnode.c index 7ecee4ca6..c6e8fa4cb 100644 --- a/girepository/girnode.c +++ b/girepository/girnode.c @@ -1047,7 +1047,7 @@ find_entry_node (GIIrTypelibBuild *build, { GIIrModule *module = build->module; GList *l; - unsigned int i; + size_t i; unsigned int n_names; char **names; GIIrNode *result = NULL; @@ -1220,7 +1220,7 @@ serialize_type (GIIrTypelibBuild *build, GIIrNodeType *node, GString *str) { - int i; + size_t i; if (GI_TYPE_TAG_IS_BASIC (node->tag)) { diff --git a/girepository/girparser.c b/girepository/girparser.c index d23035aec..06e32aa96 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -383,7 +383,9 @@ find_attribute (const char *name, const char **attribute_names, const char **attribute_values) { - for (int i = 0; attribute_names[i] != NULL; i++) + size_t i; + + for (i = 0; attribute_names[i] != NULL; i++) if (strcmp (attribute_names[i], name) == 0) return attribute_values[i]; @@ -484,8 +486,8 @@ static BasicTypeInfo basic_types[] = { static const BasicTypeInfo * parse_basic (const char *str) { - unsigned int i; - unsigned int n_basic = G_N_ELEMENTS (basic_types); + size_t i; + size_t n_basic = G_N_ELEMENTS (basic_types); for (i = 0; i < n_basic; i++) { diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index 93b2c7410..1164784cf 100644 --- a/girepository/gitypelib.c +++ b/girepository/gitypelib.c @@ -198,7 +198,7 @@ gi_typelib_get_dir_entry_by_name (GITypelib *typelib, const char *name) { Section *dirindex; - int i, n_entries; + size_t i, n_entries; const char *entry_name; DirEntry *entry; @@ -247,9 +247,8 @@ gi_typelib_get_dir_entry_by_gtype_name (GITypelib *typelib, const char *gtype_name) { Header *header = (Header *)typelib->data; - unsigned int i; - for (i = 1; i <= header->n_local_entries; i++) + for (size_t i = 1; i <= header->n_local_entries; i++) { RegisteredTypeBlob *blob; const char *type; @@ -400,11 +399,11 @@ gi_typelib_get_dir_entry_by_error_domain (GITypelib *typelib, GQuark error_domain) { Header *header = (Header *)typelib->data; - unsigned int n_entries = header->n_local_entries; + size_t n_entries = header->n_local_entries; const char *domain_string = g_quark_to_string (error_domain); DirEntry *entry; - for (unsigned int i = 1; i <= n_entries; i++) + for (size_t i = 1; i <= n_entries; i++) { EnumBlob *blob; const char *enum_domain_string; @@ -743,11 +742,11 @@ validate_param_type_blob (GITypelib *typelib, uint32_t offset, uint32_t signature_offset, gboolean return_type, - int n_params, + unsigned int n_params, GError **error) { ParamTypeBlob *blob; - int i; + unsigned int i; blob = (ParamTypeBlob*)&typelib->data[offset]; @@ -967,7 +966,7 @@ validate_signature_blob (GITypelib *typelib, return FALSE; } - for (unsigned int i = 0; i < blob->n_arguments; i++) + for (size_t i = 0; i < blob->n_arguments; i++) { if (!validate_arg_blob (typelib, offset + sizeof (SignatureBlob) + @@ -1336,7 +1335,7 @@ validate_signal_blob (GITypelib *typelib, GError **error) { SignalBlob *blob; - int n_signals; + size_t n_signals; if (typelib->len < offset + sizeof (SignalBlob)) { @@ -1405,7 +1404,7 @@ validate_vfunc_blob (GITypelib *typelib, GError **error) { VFuncBlob *blob; - int n_vfuncs; + size_t n_vfuncs; if (typelib->len < offset + sizeof (VFuncBlob)) { @@ -1464,7 +1463,7 @@ validate_struct_blob (ValidateContext *ctx, { GITypelib *typelib = ctx->typelib; StructBlob *blob; - int i; + size_t i; uint32_t field_offset; if (typelib->len < offset + sizeof (StructBlob)) @@ -1561,7 +1560,6 @@ validate_enum_blob (ValidateContext *ctx, { GITypelib *typelib = ctx->typelib; EnumBlob *blob; - int i; uint32_t offset2; if (typelib->len < offset + sizeof (EnumBlob)) @@ -1622,7 +1620,7 @@ validate_enum_blob (ValidateContext *ctx, push_context (ctx, get_string_nofail (typelib, blob->name)); - for (i = 0; i < blob->n_values; i++, offset2 += sizeof (ValueBlob)) + for (size_t i = 0; i < blob->n_values; i++, offset2 += sizeof (ValueBlob)) { if (!validate_value_blob (typelib, offset2, @@ -1650,7 +1648,7 @@ validate_enum_blob (ValidateContext *ctx, #endif } - for (i = 0; i < blob->n_methods; i++, offset2 += sizeof (FunctionBlob)) + for (size_t i = 0; i < blob->n_methods; i++, offset2 += sizeof (FunctionBlob)) { if (!validate_function_blob (ctx, offset2, BLOB_TYPE_ENUM, error)) return FALSE; @@ -1669,7 +1667,7 @@ validate_object_blob (ValidateContext *ctx, GITypelib *typelib = ctx->typelib; Header *header; ObjectBlob *blob; - int i; + size_t i; uint32_t offset2; uint16_t n_field_callbacks; @@ -1871,7 +1869,7 @@ validate_interface_blob (ValidateContext *ctx, GITypelib *typelib = ctx->typelib; Header *header; InterfaceBlob *blob; - int i; + size_t i; uint32_t offset2; header = (Header *)typelib->data; @@ -2071,7 +2069,7 @@ validate_directory (ValidateContext *ctx, GITypelib *typelib = ctx->typelib; Header *header = (Header *)typelib->data; DirEntry *entry; - int i; + size_t i; if (typelib->len < header->directory + header->n_entries * sizeof (DirEntry)) { @@ -2341,7 +2339,6 @@ gi_typelib_do_dlopen (GITypelib *typelib) if (shlib_str != NULL && shlib_str[0] != '\0') { char **shlibs; - int i; /* shared-library is a comma-separated list of libraries */ shlibs = g_strsplit (shlib_str, ",", 0); @@ -2350,7 +2347,7 @@ gi_typelib_do_dlopen (GITypelib *typelib) * again with g_module_open(), the same file handle will be returned. See bug: * http://bugzilla.gnome.org/show_bug.cgi?id=555294 */ - for (i = 0; shlibs[i]; i++) + for (size_t i = 0; shlibs[i]; i++) { GModule *module; diff --git a/girepository/givfuncinfo.c b/girepository/givfuncinfo.c index e5ce6bdf1..3baff909f 100644 --- a/girepository/givfuncinfo.c +++ b/girepository/givfuncinfo.c @@ -48,13 +48,13 @@ GIVFuncInfo * gi_base_info_find_vfunc (GIRealInfo *rinfo, uint32_t offset, - unsigned n_vfuncs, + uint16_t n_vfuncs, const char *name) { /* FIXME hash */ Header *header = (Header *)rinfo->typelib->data; - for (unsigned i = 0; i < n_vfuncs; i++) + for (uint16_t i = 0; i < n_vfuncs; i++) { VFuncBlob *fblob = (VFuncBlob *)&rinfo->typelib->data[offset]; const char *fname = (const char *)&rinfo->typelib->data[fblob->name]; From 6ef67b9a0d30f2b092420fc9b948ea162652ca07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 02:03:12 +0100 Subject: [PATCH 19/27] gtypelib: Use proper formatting for sizeof value That returns a size_t, so we should use the z printf directive. --- girepository/gitypelib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index 1164784cf..868b68982 100644 --- a/girepository/gitypelib.c +++ b/girepository/gitypelib.c @@ -442,7 +442,7 @@ gi_typelib_check_format (void) #define CHECK_SIZE(s,n) \ if (sizeof(s) != n) \ { \ - g_printerr ("sizeof("#s") is expected to be %d but is %"G_GSIZE_FORMAT".\n", \ + g_printerr ("sizeof("#s") is expected to be %d but is %zu.\n", \ n, sizeof (s)); \ size_check_ok = FALSE; \ } From bd29b0bf65a35a662f6bd67f0eb0816e0e1e4dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 02:09:10 +0100 Subject: [PATCH 20/27] gtypelib: Use size_t for size-related arguments --- girepository/gitypelib.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index 868b68982..8d56836cb 100644 --- a/girepository/gitypelib.c +++ b/girepository/gitypelib.c @@ -742,11 +742,10 @@ validate_param_type_blob (GITypelib *typelib, uint32_t offset, uint32_t signature_offset, gboolean return_type, - unsigned int n_params, + size_t n_params, GError **error) { ParamTypeBlob *blob; - unsigned int i; blob = (ParamTypeBlob*)&typelib->data[offset]; @@ -768,7 +767,7 @@ validate_param_type_blob (GITypelib *typelib, return FALSE; } - for (i = 0; i < n_params; i++) + for (size_t i = 0; i < n_params; i++) { if (!validate_type_blob (typelib, offset + sizeof (ParamTypeBlob) + @@ -1147,7 +1146,7 @@ validate_constant_blob (GITypelib *typelib, uint32_t offset, GError **error) { - unsigned int value_size[] = { + size_t value_size[] = { 0, /* VOID */ 4, /* BOOLEAN */ 1, /* INT8 */ From a73cc6d5a205fa0b096f36eb461a929f87e2bf42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 02:11:41 +0100 Subject: [PATCH 21/27] girepository: Use size_t to keep track of the number of interfaces --- girepository/girepository.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/girepository/girepository.c b/girepository/girepository.c index 24579df59..8d883644c 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -69,7 +69,7 @@ static GIRepository *default_repository = NULL; static GPtrArray *typelib_search_path = NULL; typedef struct { - unsigned int n_interfaces; + size_t n_interfaces; GIBaseInfo *interfaces[]; } GTypeInterfaceCache; @@ -78,7 +78,7 @@ gtype_interface_cache_free (gpointer data) { GTypeInterfaceCache *cache = data; - for (unsigned int i = 0; i < cache->n_interfaces; i++) + for (size_t i = 0; i < cache->n_interfaces; i++) gi_base_info_unref ((GIBaseInfo*) cache->interfaces[i]); g_free (cache); } From c8eeca9492cfac069c7980e7dccfbf733a03baa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 02:22:24 +0100 Subject: [PATCH 22/27] girnode: Use size_t to compute gir node size and ensure value is valid --- girepository/girnode.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/girepository/girnode.c b/girepository/girnode.c index c6e8fa4cb..b1f243fbd 100644 --- a/girepository/girnode.c +++ b/girepository/girnode.c @@ -435,7 +435,7 @@ uint32_t gi_ir_node_get_size (GIIrNode *node) { GList *l; - int size, n; + size_t size, n; switch (node->type) { @@ -564,9 +564,11 @@ gi_ir_node_get_size (GIIrNode *node) size = 0; } - g_debug ("node %p type '%s' size %d", node, + g_debug ("node %p type '%s' size %zu", node, gi_ir_node_type_to_string (node->type), size); + g_assert (size <= G_MAXUINT32); + return size; } @@ -575,7 +577,7 @@ add_attribute_size (gpointer key, gpointer value, gpointer data) { const char *key_str = key; const char *value_str = value; - int *size_p = data; + size_t *size_p = data; *size_p += sizeof (AttributeBlob); *size_p += ALIGN_VALUE (strlen (key_str) + 1, 4); @@ -588,7 +590,7 @@ gi_ir_node_get_full_size_internal (GIIrNode *parent, GIIrNode *node) { GList *l; - int size, n; + size_t size, n; if (node == NULL && parent != NULL) g_error ("Caught NULL node, parent=%s", parent->name); @@ -882,7 +884,7 @@ gi_ir_node_get_full_size_internal (GIIrNode *parent, size = 0; } - g_debug ("node %s%s%s%p type '%s' full size %d", + g_debug ("node %s%s%s%p type '%s' full size %zu", node->name ? "'" : "", node->name ? node->name : "", node->name ? "' " : "", @@ -890,6 +892,8 @@ gi_ir_node_get_full_size_internal (GIIrNode *parent, g_hash_table_foreach (node->attributes, add_attribute_size, &size); + g_assert (size <= G_MAXUINT32); + return size; } From 223acf44bab3016f4bc8fc01c3a038a2a7c3527a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 02:29:53 +0100 Subject: [PATCH 23/27] gitypelib: Replace gi_typelib_check_format with compile-time static checks only There's no much time to have checks at runtime when the compiler can make sure that the structures size match the expected ones. --- girepository/gitypelib-internal.h | 3 - girepository/gitypelib.c | 95 +++++++++++-------------------- 2 files changed, 32 insertions(+), 66 deletions(-) diff --git a/girepository/gitypelib-internal.h b/girepository/gitypelib-internal.h index 26de62916..94626055d 100644 --- a/girepository/gitypelib-internal.h +++ b/girepository/gitypelib-internal.h @@ -1337,9 +1337,6 @@ gboolean gi_typelib_matches_gtype_name_prefix (GITypelib *typelib, const char *gtype_name); -GI_AVAILABLE_IN_ALL -void gi_typelib_check_format (void); - /** * gi_typelib_get_string: * @typelib: TODO diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c index 8d56836cb..e2d1abec6 100644 --- a/girepository/gitypelib.c +++ b/girepository/gitypelib.c @@ -423,69 +423,39 @@ gi_typelib_get_dir_entry_by_error_domain (GITypelib *typelib, return NULL; } -/** - * gi_typelib_check_format: +/* When changing the size of a typelib structure, you are required to update + * the hardcoded size here. Do NOT change these to use sizeof(); these + * should match whatever is defined in the text specification and serve as + * a sanity check on structure modifications. * - * Check compile-time sizes of various typelib file format types are as - * expected. - * - * Since: 2.80 + * Everything else in the code however should be using sizeof(). */ -void -gi_typelib_check_format (void) -{ -#ifndef G_DISABLE_ASSERT - /* Check that struct layout is as we expect */ - - gboolean size_check_ok = TRUE; - -#define CHECK_SIZE(s,n) \ - if (sizeof(s) != n) \ - { \ - g_printerr ("sizeof("#s") is expected to be %d but is %zu.\n", \ - n, sizeof (s)); \ - size_check_ok = FALSE; \ - } - - /* When changing the size of a typelib structure, you are required to update - * the hardcoded size here. Do NOT change these to use sizeof(); these - * should match whatever is defined in the text specification and serve as - * a sanity check on structure modifications. - * - * Everything else in the code however should be using sizeof(). - */ - - CHECK_SIZE (Header, 112); - CHECK_SIZE (DirEntry, 12); - CHECK_SIZE (SimpleTypeBlob, 4); - CHECK_SIZE (ArgBlob, 16); - CHECK_SIZE (SignatureBlob, 8); - CHECK_SIZE (CommonBlob, 8); - CHECK_SIZE (FunctionBlob, 20); - CHECK_SIZE (CallbackBlob, 12); - CHECK_SIZE (InterfaceTypeBlob, 4); - CHECK_SIZE (ArrayTypeBlob, 8); - CHECK_SIZE (ParamTypeBlob, 4); - CHECK_SIZE (ErrorTypeBlob, 4); - CHECK_SIZE (ValueBlob, 12); - CHECK_SIZE (FieldBlob, 16); - CHECK_SIZE (RegisteredTypeBlob, 16); - CHECK_SIZE (StructBlob, 32); - CHECK_SIZE (EnumBlob, 24); - CHECK_SIZE (PropertyBlob, 16); - CHECK_SIZE (SignalBlob, 16); - CHECK_SIZE (VFuncBlob, 20); - CHECK_SIZE (ObjectBlob, 60); - CHECK_SIZE (InterfaceBlob, 40); - CHECK_SIZE (ConstantBlob, 24); - CHECK_SIZE (AttributeBlob, 12); - CHECK_SIZE (UnionBlob, 40); -#undef CHECK_SIZE - - g_assert (size_check_ok); -#endif /* !G_DISABLE_ASSERT */ -} +G_STATIC_ASSERT (sizeof (Header) == 112); +G_STATIC_ASSERT (sizeof (DirEntry) == 12); +G_STATIC_ASSERT (sizeof (SimpleTypeBlob) == 4); +G_STATIC_ASSERT (sizeof (ArgBlob) == 16); +G_STATIC_ASSERT (sizeof (SignatureBlob) == 8); +G_STATIC_ASSERT (sizeof (CommonBlob) == 8); +G_STATIC_ASSERT (sizeof (FunctionBlob) == 20); +G_STATIC_ASSERT (sizeof (CallbackBlob) == 12); +G_STATIC_ASSERT (sizeof (InterfaceTypeBlob) == 4); +G_STATIC_ASSERT (sizeof (ArrayTypeBlob) == 8); +G_STATIC_ASSERT (sizeof (ParamTypeBlob) == 4); +G_STATIC_ASSERT (sizeof (ErrorTypeBlob) == 4); +G_STATIC_ASSERT (sizeof (ValueBlob) == 12); +G_STATIC_ASSERT (sizeof (FieldBlob) == 16); +G_STATIC_ASSERT (sizeof (RegisteredTypeBlob) == 16); +G_STATIC_ASSERT (sizeof (StructBlob) == 32); +G_STATIC_ASSERT (sizeof (EnumBlob) == 24); +G_STATIC_ASSERT (sizeof (PropertyBlob) == 16); +G_STATIC_ASSERT (sizeof (SignalBlob) == 16); +G_STATIC_ASSERT (sizeof (VFuncBlob) == 20); +G_STATIC_ASSERT (sizeof (ObjectBlob) == 60); +G_STATIC_ASSERT (sizeof (InterfaceBlob) == 40); +G_STATIC_ASSERT (sizeof (ConstantBlob) == 24); +G_STATIC_ASSERT (sizeof (AttributeBlob) == 12); +G_STATIC_ASSERT (sizeof (UnionBlob) == 40); static gboolean is_aligned (uint32_t offset) @@ -614,9 +584,8 @@ validate_header_basic (const uint8_t *memory, /* This is a sanity check for a specific typelib; it * prevents us from loading an incompatible typelib. * - * The hardcoded checks in gi_typelib_check_format to - * protect against inadvertent or buggy changes to the typelib format - * itself. + * The hardcoded static checks to protect against inadvertent + * or buggy changes to the typelib format itself. */ if (header->entry_blob_size != sizeof (DirEntry) || From b68857e707dbee7be01e4e5e5eea8d280bd6e982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 02:30:53 +0100 Subject: [PATCH 24/27] giroffsets: Use size types for size and alignments Note that for alignments we should actually use size_t, but this would imply some refactors since this value can be acually set to -1 in our implementation. So we use gssize for now, that at least on gcc is defined. --- girepository/girnode-private.h | 16 +++++++------- girepository/giroffsets.c | 39 +++++++++++++++++----------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/girepository/girnode-private.h b/girepository/girnode-private.h index 51cfe6647..69cac5b66 100644 --- a/girepository/girnode-private.h +++ b/girepository/girnode-private.h @@ -261,8 +261,8 @@ struct _GIIrNodeInterface GList *interfaces; GList *prerequisites; - int alignment; - int size; + gssize alignment; + size_t size; GList *members; }; @@ -311,8 +311,8 @@ struct _GIIrNodeBoxed char *gtype_name; char *gtype_init; - int alignment; - int size; + gssize alignment; + size_t size; GList *members; }; @@ -334,8 +334,8 @@ struct _GIIrNodeStruct char *copy_func; char *free_func; - int alignment; - int size; + gssize alignment; + size_t size; GList *members; }; @@ -355,8 +355,8 @@ struct _GIIrNodeUnion char *copy_func; char *free_func; - int alignment; - int size; + gssize alignment; + size_t size; int discriminator_offset; GIIrNodeType *discriminator_type; diff --git a/girepository/giroffsets.c b/girepository/giroffsets.c index 91b81cf64..6d2866b03 100644 --- a/girepository/giroffsets.c +++ b/girepository/giroffsets.c @@ -148,9 +148,9 @@ compute_enum_storage_type (GIIrNodeEnum *enum_node) } static gboolean -get_enum_size_alignment (GIIrNodeEnum *enum_node, - int *size, - int *alignment) +get_enum_size_alignment (GIIrNodeEnum *enum_node, + size_t *size, + gssize *alignment) { ffi_type *type_ffi; @@ -188,8 +188,8 @@ get_enum_size_alignment (GIIrNodeEnum *enum_node, static gboolean get_interface_size_alignment (GIIrTypelibBuild *build, GIIrNodeType *type, - int *size, - int *alignment, + size_t *size, + gssize *alignment, const char *who) { GIIrNode *iface; @@ -265,8 +265,8 @@ get_interface_size_alignment (GIIrTypelibBuild *build, static gboolean get_type_size_alignment (GIIrTypelibBuild *build, GIIrNodeType *type, - int *size, - int *alignment, + size_t *size, + gssize *alignment, const char *who) { ffi_type *type_ffi; @@ -277,7 +277,8 @@ get_type_size_alignment (GIIrTypelibBuild *build, } else if (type->tag == GI_TYPE_TAG_ARRAY) { - int elt_size, elt_alignment; + size_t elt_size; + gssize elt_alignment; if (!type->has_size || !get_type_size_alignment(build, type->parameter_type1, @@ -333,8 +334,8 @@ static gboolean get_field_size_alignment (GIIrTypelibBuild *build, GIIrNodeField *field, GIIrNode *parent_node, - int *size, - int *alignment) + size_t *size, + gssize *alignment) { GIIrModule *module = build->module; char *who; @@ -361,8 +362,8 @@ static gboolean compute_struct_field_offsets (GIIrTypelibBuild *build, GIIrNode *node, GList *members, - int *size_out, - int *alignment_out) + size_t *size_out, + gssize *alignment_out) { int size = 0; int alignment = 1; @@ -381,8 +382,8 @@ compute_struct_field_offsets (GIIrTypelibBuild *build, if (!have_error) { - int member_size; - int member_alignment; + size_t member_size; + gssize member_alignment; if (get_field_size_alignment (build, field, node, &member_size, &member_alignment)) @@ -428,10 +429,10 @@ static gboolean compute_union_field_offsets (GIIrTypelibBuild *build, GIIrNode *node, GList *members, - int *size_out, - int *alignment_out) + size_t *size_out, + gssize *alignment_out) { - int size = 0; + size_t size = 0; int alignment = 1; GList *l; gboolean have_error = FALSE; @@ -448,8 +449,8 @@ compute_union_field_offsets (GIIrTypelibBuild *build, if (!have_error) { - int member_size; - int member_alignment; + size_t member_size; + gssize member_alignment; if (get_field_size_alignment (build,field, node, &member_size, &member_alignment)) From a201cbd719081632064b018eb9b5235dca246aa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 02:34:02 +0100 Subject: [PATCH 25/27] girepository: Various indentation cleanups Various random syntax cleanups found while refactoring --- girepository/girepository.c | 20 +- girepository/girmodule-private.h | 2 +- girepository/girparser.c | 394 +++++++++++++++---------------- girepository/givfuncinfo.c | 2 +- 4 files changed, 209 insertions(+), 209 deletions(-) diff --git a/girepository/girepository.c b/girepository/girepository.c index 8d883644c..5beb830d1 100644 --- a/girepository/girepository.c +++ b/girepository/girepository.c @@ -633,10 +633,10 @@ gi_repository_get_dependencies (GIRepository *repository, * Since: 2.80 */ const char * -gi_repository_load_typelib (GIRepository *repository, - GITypelib *typelib, - GIRepositoryLoadFlags flags, - GError **error) +gi_repository_load_typelib (GIRepository *repository, + GITypelib *typelib, + GIRepositoryLoadFlags flags, + GError **error) { Header *header; const char *namespace; @@ -1851,12 +1851,12 @@ gi_repository_require (GIRepository *repository, * Since: 2.80 */ GITypelib * -gi_repository_require_private (GIRepository *repository, - const char *typelib_dir, - const char *namespace, - const char *version, - GIRepositoryLoadFlags flags, - GError **error) +gi_repository_require_private (GIRepository *repository, + const char *typelib_dir, + const char *namespace, + const char *version, + GIRepositoryLoadFlags flags, + GError **error) { const char * const search_path[] = { typelib_dir, NULL }; diff --git a/girepository/girmodule-private.h b/girepository/girmodule-private.h index f6ea314f0..c3cb9df2a 100644 --- a/girepository/girmodule-private.h +++ b/girepository/girmodule-private.h @@ -38,7 +38,7 @@ struct _GIIrTypelibBuild { GList *nodes_with_attributes; uint32_t n_attributes; uint8_t *data; - GList *stack; + GList *stack; }; struct _GIIrModule diff --git a/girepository/girparser.c b/girepository/girparser.c index 06e32aa96..3924259a0 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -132,21 +132,21 @@ struct _ParseContext }; #define CURRENT_NODE(ctx) ((GIIrNode *)((ctx)->node_stack->data)) -static void start_element_handler (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - void *user_data, - GError **error); -static void end_element_handler (GMarkupParseContext *context, - const char *element_name, - void *user_data, - GError **error); -static void text_handler (GMarkupParseContext *context, - const char *text, - gsize text_len, - void *user_data, - GError **error); +static void start_element_handler (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + void *user_data, + GError **error); +static void end_element_handler (GMarkupParseContext *context, + const char *element_name, + void *user_data, + GError **error); +static void text_handler (GMarkupParseContext *context, + const char *text, + gsize text_len, + void *user_data, + GError **error); static void cleanup (GMarkupParseContext *context, GError *error, void *user_data); @@ -163,21 +163,21 @@ static GMarkupParser markup_parser = }; static gboolean -start_alias (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error); +start_alias (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error); static gboolean -start_type (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error); +start_type (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error); -static const char *find_attribute (const char *name, +static const char *find_attribute (const char *name, const char **attribute_names, const char **attribute_values); @@ -218,12 +218,12 @@ gi_ir_parser_set_includes (GIIrParser *parser, } static void -firstpass_start_element_handler (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - void *user_data, - GError **error) +firstpass_start_element_handler (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + void *user_data, + GError **error) { ParseContext *ctx = user_data; @@ -265,10 +265,10 @@ firstpass_start_element_handler (GMarkupParseContext *context, } static void -firstpass_end_element_handler (GMarkupParseContext *context, - const char *element_name, - void *user_data, - GError **error) +firstpass_end_element_handler (GMarkupParseContext *context, + const char *element_name, + gpointer user_data, + GError **error) { ParseContext *ctx = user_data; if (strcmp (element_name, "alias") == 0) @@ -770,11 +770,11 @@ parse_type (ParseContext *ctx, const char *type) } static gboolean -introspectable_prelude (GMarkupParseContext *context, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - ParseState new_state) +introspectable_prelude (GMarkupParseContext *context, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + ParseState new_state) { const char *introspectable_arg; const char *shadowed_by; @@ -796,12 +796,12 @@ introspectable_prelude (GMarkupParseContext *context, } static gboolean -start_glib_boxed (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_glib_boxed (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { const char *name; const char *typename; @@ -856,12 +856,12 @@ start_glib_boxed (GMarkupParseContext *context, } static gboolean -start_function (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_function (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { const char *name; const char *shadows; @@ -1133,12 +1133,12 @@ parse_param_transfer (GIIrNodeParam *param, const char *transfer, const char *na } static gboolean -start_instance_parameter (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_instance_parameter (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { const char *transfer; gboolean transfer_full; @@ -1198,12 +1198,12 @@ start_instance_parameter (GMarkupParseContext *context, } static gboolean -start_parameter (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_parameter (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { const char *name; const char *direction; @@ -1351,12 +1351,12 @@ start_parameter (GMarkupParseContext *context, } static gboolean -start_field (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_field (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { const char *name; const char *readable; @@ -1496,12 +1496,12 @@ start_field (GMarkupParseContext *context, } static gboolean -start_alias (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_alias (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { const char *name; @@ -1519,12 +1519,12 @@ start_alias (GMarkupParseContext *context, } static gboolean -start_enum (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_enum (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { const char *name; const char *typename; @@ -1576,12 +1576,12 @@ start_enum (GMarkupParseContext *context, } static gboolean -start_property (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_property (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { ParseState target_state; const char *name; @@ -1685,12 +1685,12 @@ parse_value (const char *str) } static gboolean -start_member (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_member (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { const char *name; const char *value; @@ -1737,12 +1737,12 @@ start_member (GMarkupParseContext *context, } static gboolean -start_constant (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_constant (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { ParseState prev_state; ParseState target_state; @@ -1823,12 +1823,12 @@ start_constant (GMarkupParseContext *context, } static gboolean -start_interface (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_interface (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { const char *name; const char *typename; @@ -1885,12 +1885,12 @@ start_interface (GMarkupParseContext *context, } static gboolean -start_class (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_class (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { const char *name; const char *parent; @@ -1978,12 +1978,12 @@ start_class (GMarkupParseContext *context, } static gboolean -start_type (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_type (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { const char *name; const char *ctype; @@ -2300,12 +2300,12 @@ end_type (ParseContext *ctx) } static gboolean -start_attribute (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_attribute (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { const char *name; const char *value; @@ -2345,12 +2345,12 @@ start_attribute (GMarkupParseContext *context, } static gboolean -start_return_value (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_return_value (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { GIIrNodeParam *param; const char *transfer; @@ -2414,12 +2414,12 @@ start_return_value (GMarkupParseContext *context, } static gboolean -start_implements (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_implements (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { GIIrNodeInterface *iface; const char *name; @@ -2444,12 +2444,12 @@ start_implements (GMarkupParseContext *context, } static gboolean -start_glib_signal (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_glib_signal (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { const char *name; const char *when; @@ -2527,12 +2527,12 @@ start_glib_signal (GMarkupParseContext *context, } static gboolean -start_vfunc (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_vfunc (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { const char *name; const char *must_chain_up; @@ -2618,12 +2618,12 @@ start_vfunc (GMarkupParseContext *context, } static gboolean -start_struct (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_struct (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { const char *name; const char *deprecated; @@ -2712,12 +2712,12 @@ start_struct (GMarkupParseContext *context, } static gboolean -start_union (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_union (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { const char *name; const char *deprecated; @@ -2771,12 +2771,12 @@ start_union (GMarkupParseContext *context, } static gboolean -start_discriminator (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - ParseContext *ctx, - GError **error) +start_discriminator (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + ParseContext *ctx, + GError **error) { const char *type; const char *offset; @@ -2883,12 +2883,12 @@ parse_include (GMarkupParseContext *context, extern GLogLevelFlags logged_levels; static void -start_element_handler (GMarkupParseContext *context, - const char *element_name, - const char **attribute_names, - const char **attribute_values, - void *user_data, - GError **error) +start_element_handler (GMarkupParseContext *context, + const char *element_name, + const char **attribute_names, + const char **attribute_values, + gpointer user_data, + GError **error) { ParseContext *ctx = user_data; @@ -3263,10 +3263,10 @@ start_element_handler (GMarkupParseContext *context, } static gboolean -require_one_of_end_elements (GMarkupParseContext *context, - ParseContext *ctx, - const char *actual_name, - GError **error, +require_one_of_end_elements (GMarkupParseContext *context, + ParseContext *ctx, + const char *actual_name, + GError **error, ...) { va_list args; @@ -3301,10 +3301,10 @@ require_one_of_end_elements (GMarkupParseContext *context, } static gboolean -state_switch_end_struct_or_union (GMarkupParseContext *context, - ParseContext *ctx, - const char *element_name, - GError **error) +state_switch_end_struct_or_union (GMarkupParseContext *context, + ParseContext *ctx, + const char *element_name, + GError **error) { pop_node (ctx); if (ctx->node_stack == NULL) @@ -3336,20 +3336,20 @@ state_switch_end_struct_or_union (GMarkupParseContext *context, } static gboolean -require_end_element (GMarkupParseContext *context, - ParseContext *ctx, - const char *expected_name, - const char *actual_name, - GError **error) +require_end_element (GMarkupParseContext *context, + ParseContext *ctx, + const char *expected_name, + const char *actual_name, + GError **error) { return require_one_of_end_elements (context, ctx, actual_name, error, expected_name, NULL); } static void -end_element_handler (GMarkupParseContext *context, - const char *element_name, - void *user_data, - GError **error) +end_element_handler (GMarkupParseContext *context, + const char *element_name, + gpointer user_data, + GError **error) { ParseContext *ctx = user_data; @@ -3647,11 +3647,11 @@ end_element_handler (GMarkupParseContext *context, } static void -text_handler (GMarkupParseContext *context, - const char *text, - gsize text_len, - void *user_data, - GError **error) +text_handler (GMarkupParseContext *context, + const char *text, + gsize text_len, + gpointer user_data, + GError **error) { /* FIXME warn about non-whitespace text */ } diff --git a/girepository/givfuncinfo.c b/girepository/givfuncinfo.c index 3baff909f..0e61d598d 100644 --- a/girepository/givfuncinfo.c +++ b/girepository/givfuncinfo.c @@ -61,7 +61,7 @@ gi_base_info_find_vfunc (GIRealInfo *rinfo, if (strcmp (name, fname) == 0) return (GIVFuncInfo *) gi_info_new (GI_INFO_TYPE_VFUNC, (GIBaseInfo*) rinfo, - rinfo->typelib, offset); + rinfo->typelib, offset); offset += header->vfunc_blob_size; } From e9bdbfaf4b3f0eff43997dfbbeb4795a905e32c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 16 Jan 2024 02:34:14 +0100 Subject: [PATCH 26/27] cmph-bdz-test: Use more size_t --- girepository/tests/cmph-bdz.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/girepository/tests/cmph-bdz.c b/girepository/tests/cmph-bdz.c index 09bbbdec6..9c5f05270 100644 --- a/girepository/tests/cmph-bdz.c +++ b/girepository/tests/cmph-bdz.c @@ -50,15 +50,14 @@ build (void) } static void -assert_hashes_unique (unsigned n_hashes, +assert_hashes_unique (size_t n_hashes, uint32_t* hashes) { - unsigned i; + size_t i; for (i = 0; i < n_hashes; i++) { - unsigned j = 0; - for (j = 0; j < n_hashes; j++) + for (size_t j = 0; j < n_hashes; j++) { if (j != i) g_assert_cmpuint (hashes[i], !=, hashes[j]); @@ -70,7 +69,7 @@ static void test_search (void) { cmph_t *c = build(); - unsigned i; + size_t i; uint32_t hash; uint32_t hashes[3]; uint32_t size; @@ -102,7 +101,7 @@ static void test_search_packed (void) { cmph_t *c = build(); - unsigned i; + size_t i; uint32_t bufsize; uint32_t hash; uint32_t hashes[3]; From 6cc655f86e41d5a97e14281f1f19d2135639530d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 21 Dec 2023 02:39:52 +0100 Subject: [PATCH 27/27] girepository: Use single-bit sized elements for the GIIrNode structures Leave to the compiler some more hints to optimize these structures for being packed when possible. --- girepository/girnode-private.h | 144 ++++++++++++++++----------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/girepository/girnode-private.h b/girepository/girnode-private.h index 69cac5b66..d94eaf954 100644 --- a/girepository/girnode-private.h +++ b/girepository/girnode-private.h @@ -92,16 +92,16 @@ struct _GIIrNodeFunction { GIIrNode node; - gboolean deprecated; - gboolean is_varargs; /* Not in typelib yet */ + uint8_t deprecated : 1; + uint8_t is_varargs : 1; /* Not in typelib yet */ - gboolean is_method; - gboolean is_setter; - gboolean is_getter; - gboolean is_constructor; - gboolean wraps_vfunc; - gboolean throws; - gboolean instance_transfer_full; + uint8_t is_method : 1; + uint8_t is_setter : 1; + uint8_t is_getter : 1; + uint8_t is_constructor : 1; + uint8_t wraps_vfunc : 1; + uint8_t throws : 1; + uint8_t instance_transfer_full : 1; char *symbol; char *property; @@ -114,22 +114,22 @@ struct _GIIrNodeType { GIIrNode node; - gboolean is_pointer; - gboolean is_basic; - gboolean is_array; - gboolean is_glist; - gboolean is_gslist; - gboolean is_ghashtable; - gboolean is_interface; - gboolean is_error; + uint8_t is_pointer : 1; + uint8_t is_basic : 1; + uint8_t is_array : 1; + uint8_t is_glist : 1; + uint8_t is_gslist : 1; + uint8_t is_ghashtable : 1; + uint8_t is_interface : 1; + uint8_t is_error : 1; int tag; char *unparsed; - gboolean zero_terminated; - gboolean has_length; + uint8_t zero_terminated : 1; + uint8_t has_length : 1; int length; - gboolean has_size; + uint8_t has_size : 1; int size; int array_type; @@ -144,16 +144,16 @@ struct _GIIrNodeParam { GIIrNode node; - gboolean in; - gboolean out; - gboolean caller_allocates; - gboolean optional; - gboolean retval; - gboolean nullable; - gboolean skip; - gboolean transfer; - gboolean shallow_transfer; - GIScopeType scope; + uint8_t in : 1; + uint8_t out : 1; + uint8_t caller_allocates : 1; + uint8_t optional : 1; + uint8_t retval : 1; + uint8_t nullable : 1; + uint8_t skip : 1; + uint8_t transfer : 1; + uint8_t shallow_transfer : 1; + GIScopeType scope : 3; int8_t closure; int8_t destroy; @@ -165,15 +165,15 @@ struct _GIIrNodeProperty { GIIrNode node; - gboolean deprecated; + uint8_t deprecated : 1; char *name; - gboolean readable; - gboolean writable; - gboolean construct; - gboolean construct_only; - gboolean transfer; - gboolean shallow_transfer; + uint8_t readable : 1; + uint8_t writable : 1; + uint8_t construct : 1; + uint8_t construct_only : 1; + uint8_t transfer : 1; + uint8_t shallow_transfer : 1; char *setter; char *getter; @@ -185,19 +185,19 @@ struct _GIIrNodeSignal { GIIrNode node; - gboolean deprecated; + uint8_t deprecated : 1; - gboolean run_first; - gboolean run_last; - gboolean run_cleanup; - gboolean no_recurse; - gboolean detailed; - gboolean action; - gboolean no_hooks; - gboolean instance_transfer_full; + uint8_t run_first : 1; + uint8_t run_last : 1; + uint8_t run_cleanup : 1; + uint8_t no_recurse : 1; + uint8_t detailed : 1; + uint8_t action : 1; + uint8_t no_hooks : 1; + uint8_t instance_transfer_full : 1; - gboolean has_class_closure; - gboolean true_stops_emit; + uint8_t has_class_closure : 1; + uint8_t true_stops_emit : 1; int class_closure; @@ -209,13 +209,13 @@ struct _GIIrNodeVFunc { GIIrNode node; - gboolean is_varargs; /* Not in typelib yet */ - gboolean must_chain_up; - gboolean must_be_implemented; - gboolean must_not_be_implemented; - gboolean is_class_closure; - gboolean throws; - gboolean instance_transfer_full; + uint8_t is_varargs : 1; /* Not in typelib yet */ + uint8_t must_chain_up : 1; + uint8_t must_be_implemented : 1; + uint8_t must_not_be_implemented : 1; + uint8_t is_class_closure : 1; + uint8_t throws : 1; + uint8_t instance_transfer_full : 1; char *invoker; @@ -229,8 +229,8 @@ struct _GIIrNodeField { GIIrNode node; - gboolean readable; - gboolean writable; + uint8_t readable : 1; + uint8_t writable : 1; int bits; int offset; GIIrNodeFunction *callback; @@ -242,10 +242,10 @@ struct _GIIrNodeInterface { GIIrNode node; - gboolean abstract; - gboolean deprecated; - gboolean fundamental; - gboolean final_; + uint8_t abstract : 1; + uint8_t deprecated : 1; + uint8_t fundamental : 1; + uint8_t final_ : 1; char *gtype_name; char *gtype_init; @@ -271,7 +271,7 @@ struct _GIIrNodeValue { GIIrNode node; - gboolean deprecated; + uint8_t deprecated : 1; int64_t value; }; @@ -280,7 +280,7 @@ struct _GIIrNodeConstant { GIIrNode node; - gboolean deprecated; + uint8_t deprecated : 1; GIIrNodeType *type; @@ -291,7 +291,7 @@ struct _GIIrNodeEnum { GIIrNode node; - gboolean deprecated; + uint8_t deprecated : 1; int storage_type; char *gtype_name; @@ -306,7 +306,7 @@ struct _GIIrNodeBoxed { GIIrNode node; - gboolean deprecated; + uint8_t deprecated : 1; char *gtype_name; char *gtype_init; @@ -321,12 +321,12 @@ struct _GIIrNodeStruct { GIIrNode node; - gboolean deprecated; - gboolean disguised; - gboolean opaque; - gboolean pointer; - gboolean is_gtype_struct; - gboolean foreign; + uint8_t deprecated : 1; + uint8_t disguised : 1; + uint8_t opaque : 1; + uint8_t pointer : 1; + uint8_t is_gtype_struct : 1; + uint8_t foreign : 1; char *gtype_name; char *gtype_init; @@ -344,7 +344,7 @@ struct _GIIrNodeUnion { GIIrNode node; - gboolean deprecated; + uint8_t deprecated : 1; GList *members; GList *discriminators;