Merge branch 'girrepository-cleanups' into 'main'

girepository: Misc cleanups

See merge request GNOME/glib!3823
This commit is contained in:
Philip Withnall 2024-01-15 22:25:03 +00:00
commit 35fe0d0bba
11 changed files with 41 additions and 40 deletions

View File

@ -64,23 +64,3 @@ if cc.get_id() != 'msvc'
'-Wno-type-limits',
])
endif
test_env = environment()
test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
cmph_test = executable('cmph-bdz-test', '../cmph-bdz-test.c',
dependencies: [
cmph_dep,
libglib_dep,
libgobject_dep,
],
c_args: custom_c_args + ['-UG_DISABLE_ASSERT'],
)
test('cmph-bdz-test', cmph_test,
env: test_env,
protocol: test_protocol,
suite: ['girepository'],
timeout: test_timeout,
)

View File

@ -392,7 +392,7 @@ gi_callable_info_create_closure (GICallableInfo *callable_info,
closure = ffi_closure_alloc (sizeof (GIClosureWrapper), &exec_ptr);
if (!closure)
{
g_warning ("could not allocate closure\n");
g_warning ("could not allocate closure");
return NULL;
}
closure->writable_self = closure;
@ -405,7 +405,7 @@ gi_callable_info_create_closure (GICallableInfo *callable_info,
atypes);
if (status != FFI_OK)
{
g_warning ("ffi_prep_cif failed: %d\n", status);
g_warning ("ffi_prep_cif failed: %d", status);
ffi_closure_free (closure);
return NULL;
}
@ -413,7 +413,7 @@ gi_callable_info_create_closure (GICallableInfo *callable_info,
status = ffi_prep_closure_loc (&closure->ffi_closure, cif, callback, user_data, exec_ptr);
if (status != FFI_OK)
{
g_warning ("ffi_prep_closure failed: %d\n", status);
g_warning ("ffi_prep_closure failed: %d", status);
ffi_closure_free (closure);
return NULL;
}

View File

@ -368,7 +368,7 @@ gi_ir_module_build_typelib (GIIrModule *module)
nodes_with_attributes = NULL;
n_entries = g_list_length (module->entries);
g_message ("%d entries (%d local), %d dependencies\n", n_entries, n_local_entries,
g_message ("%d entries (%d local), %d dependencies", n_entries, n_local_entries,
g_list_length (module->dependencies));
dir_size = n_entries * sizeof (DirEntry);
@ -397,7 +397,7 @@ gi_ir_module_build_typelib (GIIrModule *module)
size += sizeof (Section) * NUM_SECTIONS;
g_message ("allocating %d bytes (%d header, %d directory, %d entries)\n",
g_message ("allocating %d bytes (%d header, %d directory, %d entries)",
size, header_size, dir_size, size - header_size - dir_size);
data = g_malloc0 (size);
@ -535,7 +535,7 @@ gi_ir_module_build_typelib (GIIrModule *module)
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\n", 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++;

View File

@ -192,7 +192,7 @@ gi_ir_node_new (GIIrNodeTypeId type,
break;
default:
g_error ("Unhandled node type %d\n", type);
g_error ("Unhandled node type %d", type);
break;
}
@ -421,7 +421,7 @@ gi_ir_node_free (GIIrNode *node)
break;
default:
g_error ("Unhandled node type %d\n", node->type);
g_error ("Unhandled node type %d", node->type);
break;
}
@ -560,8 +560,7 @@ gi_ir_node_get_size (GIIrNode *node)
break;
default:
g_error ("Unhandled node type '%s'\n",
gi_ir_node_type_to_string (node->type));
g_error ("Unhandled node type '%s'", gi_ir_node_type_to_string (node->type));
size = 0;
}
@ -672,7 +671,7 @@ gi_ir_node_get_full_size_internal (GIIrNode *parent,
size += sizeof (ErrorTypeBlob);
break;
default:
g_error ("Unknown type tag %d\n", type->tag);
g_error ("Unknown type tag %d", type->tag);
break;
}
}
@ -879,7 +878,7 @@ gi_ir_node_get_full_size_internal (GIIrNode *parent,
break;
default:
g_error ("Unknown type tag %d\n", node->type);
g_error ("Unknown type tag %d", node->type);
size = 0;
}
@ -991,7 +990,7 @@ gi_ir_node_add_member (GIIrNode *node,
break;
}
default:
g_error ("Cannot add a member to unknown type tag type %d\n",
g_error ("Cannot add a member to unknown type tag type %d",
node->type);
break;
}
@ -1576,7 +1575,7 @@ gi_ir_node_build_typelib (GIIrNode *node,
break;
default:
g_error ("Unknown type tag %d\n", type->tag);
g_error ("Unknown type tag %d", type->tag);
break;
}
}

View File

@ -698,7 +698,7 @@ resolve_aliases (ParseContext *ctx, const gchar *type)
seen_values = g_slist_prepend (seen_values, (char*)lookup);
while (g_hash_table_lookup_extended (ctx->current_module->aliases, lookup, &orig, &value))
{
g_debug ("Resolved: %s => %s\n", lookup, (char*)value);
g_debug ("Resolved: %s => %s", lookup, (char*)value);
lookup = value;
if (g_slist_find_custom (seen_values, lookup,
(GCompareFunc)strcmp) != NULL)
@ -1064,7 +1064,7 @@ parse_property_transfer (GIIrNodeProperty *property,
GIIrNodeInterface *iface = (GIIrNodeInterface *)CURRENT_NODE (ctx);
g_debug ("required attribute 'transfer-ownership' is missing from "
"property '%s' in type '%s.%s'. Assuming 'none'\n",
"property '%s' in type '%s.%s'. Assuming 'none'",
property->node.name, ctx->namespace, iface->node.name);
#endif
transfer = "none";
@ -2849,7 +2849,7 @@ parse_include (GMarkupParseContext *context,
}
g_free (girname);
g_debug ("Parsing include %s\n", girpath);
g_debug ("Parsing include %s", girpath);
if (!g_file_get_contents (girpath, &buffer, &length, &error))
{
@ -3640,7 +3640,7 @@ end_element_handler (GMarkupParseContext *context,
state_switch (ctx, ctx->prev_state);
break;
default:
g_error ("Unhandled state %d in end_element_handler\n", ctx->state);
g_error ("Unhandled state %d in end_element_handler", ctx->state);
}
}

View File

@ -168,7 +168,7 @@ check_unresolved (GIBaseInfo *info)
if (gi_base_info_get_info_type (info) != GI_INFO_TYPE_UNRESOLVED)
return;
g_critical ("Found unresolved type '%s' '%s'\n",
g_critical ("Found unresolved type '%s' '%s'",
gi_base_info_get_name (info), gi_base_info_get_namespace (info));
}
@ -1452,7 +1452,7 @@ gi_ir_writer_write (const char *filename,
break;
default:
g_error ("unknown info type %d\n", gi_base_info_get_info_type (info));
g_error ("unknown info type %d", gi_base_info_get_info_type (info));
}
gi_base_info_unref (info);

View File

@ -131,6 +131,7 @@ gi_typelib_hash_builder_prepare (GITypelibHashBuilder *builder)
builder->dirmap_offset = ALIGN_VALUE (offset, 4);
builder->packed_size = builder->dirmap_offset + (num_elts * sizeof(guint16));
out:
g_strfreev (strs);
cmph_config_destroy (config);
cmph_io_vector_adapter_destroy (io);
return builder->buildable;

View File

@ -53,6 +53,8 @@ test_build_retrieve (void)
g_assert (gi_typelib_hash_search (buf, "ZLibDecompressor", 4) == 42);
g_assert (gi_typelib_hash_search (buf, "VolumeMonitor", 4) == 9);
g_assert (gi_typelib_hash_search (buf, "FileMonitorFlags", 4) == 31);
g_free (buf);
}
int

View File

@ -3,6 +3,10 @@ girepository_tests = {}
# Some GIR files are needed to test against
if enable_gir
girepository_tests += {
'cmph-bdz': {
'dependencies': [cmph_dep],
},
'gthash' : {},
'repository' : {
'depends': [glib_gir, gobject_gir],
},

View File

@ -80,6 +80,7 @@ test_repository_info (void)
GITypelib *typelib = NULL;
GIObjectInfo *object_info = NULL;
GISignalInfo *signal_info = NULL;
GIFunctionInfo *method_info = NULL;
GError *local_error = NULL;
g_test_summary ("Test retrieving some basic info blobs from a typelib");
@ -109,6 +110,20 @@ test_repository_info (void)
g_assert_cmpint (gi_signal_info_get_flags (signal_info), ==,
G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS | G_SIGNAL_ACTION);
g_assert_cmpuint (gi_object_info_get_n_methods (object_info), >, 2);
method_info = gi_object_info_find_method (object_info, "get_property");
g_assert_nonnull (method_info);
g_assert_true (gi_callable_info_is_method ((GICallableInfo *) method_info));
g_assert_cmpuint (gi_callable_info_get_n_args ((GICallableInfo *) method_info), ==, 2);
g_clear_pointer ((GIBaseInfo **) &method_info, gi_base_info_unref);
method_info = gi_object_info_get_method (object_info,
gi_object_info_get_n_methods (object_info) - 1);
g_assert_true (gi_callable_info_is_method ((GICallableInfo *) method_info));
g_assert_cmpuint (gi_callable_info_get_n_args ((GICallableInfo *) method_info), >, 0);
g_clear_pointer ((GIBaseInfo **) &method_info, gi_base_info_unref);
gi_base_info_unref ((GIBaseInfo *) signal_info);
gi_base_info_unref ((GIBaseInfo *) object_info);
g_clear_object (&repository);