girwriter: Take the GIRepository as a parameter

We certainly won't find the requested namespace in a newly-created
repository with no typelibs loaded.

Fixes: 9ab84bc1 "girwriter: Stop using the singleton GIRepository"
Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2024-02-13 16:58:25 +00:00
parent b974fa4e50
commit f80e978f00
3 changed files with 7 additions and 8 deletions

View File

@ -118,7 +118,7 @@ main (int argc, char *argv[])
if (namespace == NULL)
g_error ("failed to load typelib: %s", error->message);
gi_ir_writer_write (output, namespace, needs_prefix, show_all);
gi_ir_writer_write (repository, output, namespace, needs_prefix, show_all);
/* when writing to stdout, stop after the first module */
if (input[i + 1] && !output)

View File

@ -24,10 +24,12 @@
#pragma once
#include <glib.h>
#include <girepository.h>
G_BEGIN_DECLS
void gi_ir_writer_write (const char *filename,
void gi_ir_writer_write (GIRepository *repository,
const char *filename,
const char *ns,
gboolean needs_prefix,
gboolean show_all);

View File

@ -1319,6 +1319,7 @@ write_union_info (const char *ns,
/**
* gi_ir_writer_write:
* @repository: repository containing @ns
* @filename: (type filename): filename to write to
* @ns: GIR namespace to write
* @needs_prefix: if the filename needs prefixing
@ -1330,7 +1331,8 @@ write_union_info (const char *ns,
* Since: 2.80
*/
void
gi_ir_writer_write (const char *filename,
gi_ir_writer_write (GIRepository *repository,
const char *filename,
const char *ns,
gboolean needs_prefix,
gboolean show_all)
@ -1338,11 +1340,8 @@ gi_ir_writer_write (const char *filename,
FILE *ofile;
size_t i, j;
char **dependencies;
GIRepository *repository = NULL;
Xml *xml;
repository = gi_repository_new ();
if (filename == NULL)
ofile = stdout;
else
@ -1446,6 +1445,4 @@ gi_ir_writer_write (const char *filename,
xml_end_element (xml, "repository");
xml_free (xml);
g_clear_object (&repository);
}