gir: Rename gir_writer_write()

Use g_ir_writer_write(), as a dual of g_ir_parser_parse_*().

Also, don't abuse C++ reserved keywords for argument names.
This commit is contained in:
Emmanuele Bassi 2023-11-08 00:23:35 +00:00
parent 9a6c518d31
commit db5c42fad0
2 changed files with 84 additions and 85 deletions

View File

@ -27,9 +27,9 @@
G_BEGIN_DECLS G_BEGIN_DECLS
void gir_writer_write (const char *filename, void g_ir_writer_write (const char *filename,
const char *namespace, const char *ns,
gboolean needs_prefix, gboolean needs_prefix,
gboolean show_all); gboolean show_all);
G_END_DECLS G_END_DECLS

View File

@ -173,24 +173,24 @@ check_unresolved (GIBaseInfo *info)
} }
static void static void
write_type_name (const gchar *namespace, write_type_name (const gchar *ns,
GIBaseInfo *info, GIBaseInfo *info,
Xml *file) Xml *file)
{ {
if (strcmp (namespace, g_base_info_get_namespace (info)) != 0) if (strcmp (ns, g_base_info_get_namespace (info)) != 0)
xml_printf (file, "%s.", g_base_info_get_namespace (info)); xml_printf (file, "%s.", g_base_info_get_namespace (info));
xml_printf (file, "%s", g_base_info_get_name (info)); xml_printf (file, "%s", g_base_info_get_name (info));
} }
static void static void
write_type_name_attribute (const gchar *namespace, write_type_name_attribute (const gchar *ns,
GIBaseInfo *info, GIBaseInfo *info,
const char *attr_name, const char *attr_name,
Xml *file) Xml *file)
{ {
xml_printf (file, " %s=\"", attr_name); xml_printf (file, " %s=\"", attr_name);
write_type_name (namespace, info, file); write_type_name (ns, info, file);
xml_printf (file, "\""); xml_printf (file, "\"");
} }
@ -215,7 +215,7 @@ write_ownership_transfer (GITransfer transfer,
} }
static void static void
write_type_info (const gchar *namespace, write_type_info (const gchar *ns,
GITypeInfo *info, GITypeInfo *info,
Xml *file) Xml *file)
{ {
@ -281,7 +281,7 @@ write_type_info (const gchar *namespace,
if (g_type_info_is_zero_terminated (info)) if (g_type_info_is_zero_terminated (info))
xml_printf (file, " zero-terminated=\"1\""); xml_printf (file, " zero-terminated=\"1\"");
write_type_info (namespace, type, file); write_type_info (ns, type, file);
g_base_info_unref ((GIBaseInfo *)type); g_base_info_unref ((GIBaseInfo *)type);
@ -291,7 +291,7 @@ write_type_info (const gchar *namespace,
{ {
GIBaseInfo *iface = g_type_info_get_interface (info); GIBaseInfo *iface = g_type_info_get_interface (info);
xml_start_element (file, "type"); xml_start_element (file, "type");
write_type_name_attribute (namespace, iface, "name", file); write_type_name_attribute (ns, iface, "name", file);
xml_end_element (file, "type"); xml_end_element (file, "type");
g_base_info_unref (iface); g_base_info_unref (iface);
} }
@ -302,7 +302,7 @@ write_type_info (const gchar *namespace,
type = g_type_info_get_param_type (info, 0); type = g_type_info_get_param_type (info, 0);
if (type) if (type)
{ {
write_type_info (namespace, type, file); write_type_info (ns, type, file);
g_base_info_unref ((GIBaseInfo *)type); g_base_info_unref ((GIBaseInfo *)type);
} }
xml_end_element (file, "type"); xml_end_element (file, "type");
@ -314,7 +314,7 @@ write_type_info (const gchar *namespace,
type = g_type_info_get_param_type (info, 0); type = g_type_info_get_param_type (info, 0);
if (type) if (type)
{ {
write_type_info (namespace, type, file); write_type_info (ns, type, file);
g_base_info_unref ((GIBaseInfo *)type); g_base_info_unref ((GIBaseInfo *)type);
} }
xml_end_element (file, "type"); xml_end_element (file, "type");
@ -326,10 +326,10 @@ write_type_info (const gchar *namespace,
type = g_type_info_get_param_type (info, 0); type = g_type_info_get_param_type (info, 0);
if (type) if (type)
{ {
write_type_info (namespace, type, file); write_type_info (ns, type, file);
g_base_info_unref ((GIBaseInfo *)type); g_base_info_unref ((GIBaseInfo *)type);
type = g_type_info_get_param_type (info, 1); type = g_type_info_get_param_type (info, 1);
write_type_info (namespace, type, file); write_type_info (ns, type, file);
g_base_info_unref ((GIBaseInfo *)type); g_base_info_unref ((GIBaseInfo *)type);
} }
xml_end_element (file, "type"); xml_end_element (file, "type");
@ -378,18 +378,18 @@ write_return_value_attributes (Xml *file,
} }
static void static void
write_constant_value (const gchar *namespace, write_constant_value (const gchar *ns,
GITypeInfo *info, GITypeInfo *info,
GIArgument *argument, GIArgument *argument,
Xml *file); Xml *file);
static void static void
write_callback_info (const gchar *namespace, write_callback_info (const gchar *ns,
GICallbackInfo *info, GICallbackInfo *info,
Xml *file); Xml *file);
static void static void
write_field_info (const gchar *namespace, write_field_info (const gchar *ns,
GIFieldInfo *info, GIFieldInfo *info,
GIConstantInfo *branch, GIConstantInfo *branch,
Xml *file) Xml *file)
@ -431,7 +431,7 @@ write_field_info (const gchar *namespace,
g_base_info_unref ((GIBaseInfo *)type); g_base_info_unref ((GIBaseInfo *)type);
type = g_constant_info_get_type (branch); type = g_constant_info_get_type (branch);
g_constant_info_get_value (branch, &value); g_constant_info_get_value (branch, &value);
write_constant_value (namespace, type, &value, file); write_constant_value (ns, type, &value, file);
xml_printf (file, "\""); xml_printf (file, "\"");
} }
@ -443,9 +443,9 @@ write_field_info (const gchar *namespace,
interface = g_type_info_get_interface (type); interface = g_type_info_get_interface (type);
if (interface && g_base_info_get_type(interface) == GI_INFO_TYPE_CALLBACK) if (interface && g_base_info_get_type(interface) == GI_INFO_TYPE_CALLBACK)
write_callback_info (namespace, (GICallbackInfo *)interface, file); write_callback_info (ns, (GICallbackInfo *)interface, file);
else else
write_type_info (namespace, type, file); write_type_info (ns, type, file);
if (interface) if (interface)
g_base_info_unref (interface); g_base_info_unref (interface);
@ -456,7 +456,7 @@ write_field_info (const gchar *namespace,
} }
static void static void
write_callable_info (const gchar *namespace, write_callable_info (const gchar *ns,
GICallableInfo *info, GICallableInfo *info,
Xml *file) Xml *file)
{ {
@ -482,7 +482,7 @@ write_callable_info (const gchar *namespace,
write_return_value_attributes (file, info); write_return_value_attributes (file, info);
write_type_info (namespace, type, file); write_type_info (ns, type, file);
xml_end_element (file, "return-value"); xml_end_element (file, "return-value");
@ -556,7 +556,7 @@ write_callable_info (const gchar *namespace,
write_attributes (file, (GIBaseInfo*) arg); write_attributes (file, (GIBaseInfo*) arg);
type = g_arg_info_get_type (arg); type = g_arg_info_get_type (arg);
write_type_info (namespace, type, file); write_type_info (ns, type, file);
xml_end_element (file, "parameter"); xml_end_element (file, "parameter");
@ -568,7 +568,7 @@ write_callable_info (const gchar *namespace,
} }
static void static void
write_function_info (const gchar *namespace, write_function_info (const gchar *ns,
GIFunctionInfo *info, GIFunctionInfo *info,
Xml *file) Xml *file)
{ {
@ -614,12 +614,12 @@ write_function_info (const gchar *namespace,
if (deprecated) if (deprecated)
xml_printf (file, " deprecated=\"1\""); xml_printf (file, " deprecated=\"1\"");
write_callable_info (namespace, (GICallableInfo*)info, file); write_callable_info (ns, (GICallableInfo*)info, file);
xml_end_element (file, tag); xml_end_element (file, tag);
} }
static void static void
write_callback_info (const gchar *namespace, write_callback_info (const gchar *ns,
GICallbackInfo *info, GICallbackInfo *info,
Xml *file) Xml *file)
{ {
@ -635,12 +635,12 @@ write_callback_info (const gchar *namespace,
if (deprecated) if (deprecated)
xml_printf (file, " deprecated=\"1\""); xml_printf (file, " deprecated=\"1\"");
write_callable_info (namespace, (GICallableInfo*)info, file); write_callable_info (ns, (GICallableInfo*)info, file);
xml_end_element (file, "callback"); xml_end_element (file, "callback");
} }
static void static void
write_struct_info (const gchar *namespace, write_struct_info (const gchar *ns,
GIStructInfo *info, GIStructInfo *info,
Xml *file) Xml *file)
{ {
@ -706,14 +706,14 @@ write_struct_info (const gchar *namespace,
for (i = 0; i < g_struct_info_get_n_fields (info); i++) for (i = 0; i < g_struct_info_get_n_fields (info); i++)
{ {
GIFieldInfo *field = g_struct_info_get_field (info, i); GIFieldInfo *field = g_struct_info_get_field (info, i);
write_field_info (namespace, field, NULL, file); write_field_info (ns, field, NULL, file);
g_base_info_unref ((GIBaseInfo *)field); g_base_info_unref ((GIBaseInfo *)field);
} }
for (i = 0; i < g_struct_info_get_n_methods (info); i++) for (i = 0; i < g_struct_info_get_n_methods (info); i++)
{ {
GIFunctionInfo *function = g_struct_info_get_method (info, i); GIFunctionInfo *function = g_struct_info_get_method (info, i);
write_function_info (namespace, function, file); write_function_info (ns, function, file);
g_base_info_unref ((GIBaseInfo *)function); g_base_info_unref ((GIBaseInfo *)function);
} }
@ -723,7 +723,7 @@ write_struct_info (const gchar *namespace,
} }
static void static void
write_value_info (const gchar *namespace, write_value_info (const gchar *ns,
GIValueInfo *info, GIValueInfo *info,
Xml *file) Xml *file)
{ {
@ -750,7 +750,7 @@ write_value_info (const gchar *namespace,
} }
static void static void
write_constant_value (const gchar *namespace, write_constant_value (const gchar *ns,
GITypeInfo *type, GITypeInfo *type,
GIArgument *value, GIArgument *value,
Xml *file) Xml *file)
@ -800,7 +800,7 @@ write_constant_value (const gchar *namespace,
} }
static void static void
write_constant_info (const gchar *namespace, write_constant_info (const gchar *ns,
GIConstantInfo *info, GIConstantInfo *info,
Xml *file) Xml *file)
{ {
@ -817,10 +817,10 @@ write_constant_info (const gchar *namespace,
xml_printf (file, " value=\""); xml_printf (file, " value=\"");
g_constant_info_get_value (info, &value); g_constant_info_get_value (info, &value);
write_constant_value (namespace, type, &value, file); write_constant_value (ns, type, &value, file);
xml_printf (file, "\""); xml_printf (file, "\"");
write_type_info (namespace, type, file); write_type_info (ns, type, file);
write_attributes (file, (GIBaseInfo*) info); write_attributes (file, (GIBaseInfo*) info);
@ -831,7 +831,7 @@ write_constant_info (const gchar *namespace,
static void static void
write_enum_info (const gchar *namespace, write_enum_info (const gchar *ns,
GIEnumInfo *info, GIEnumInfo *info,
Xml *file) Xml *file)
{ {
@ -868,7 +868,7 @@ write_enum_info (const gchar *namespace,
for (i = 0; i < g_enum_info_get_n_values (info); i++) for (i = 0; i < g_enum_info_get_n_values (info); i++)
{ {
GIValueInfo *value = g_enum_info_get_value (info, i); GIValueInfo *value = g_enum_info_get_value (info, i);
write_value_info (namespace, value, file); write_value_info (ns, value, file);
g_base_info_unref ((GIBaseInfo *)value); g_base_info_unref ((GIBaseInfo *)value);
} }
@ -876,7 +876,7 @@ write_enum_info (const gchar *namespace,
} }
static void static void
write_signal_info (const gchar *namespace, write_signal_info (const gchar *ns,
GISignalInfo *info, GISignalInfo *info,
Xml *file) Xml *file)
{ {
@ -913,13 +913,13 @@ write_signal_info (const gchar *namespace,
if (flags & G_SIGNAL_NO_HOOKS) if (flags & G_SIGNAL_NO_HOOKS)
xml_printf (file, " no-hooks=\"1\""); xml_printf (file, " no-hooks=\"1\"");
write_callable_info (namespace, (GICallableInfo*)info, file); write_callable_info (ns, (GICallableInfo*)info, file);
xml_end_element (file, "glib:signal"); xml_end_element (file, "glib:signal");
} }
static void static void
write_vfunc_info (const gchar *namespace, write_vfunc_info (const gchar *ns,
GIVFuncInfo *info, GIVFuncInfo *info,
Xml *file) Xml *file)
{ {
@ -957,13 +957,13 @@ write_vfunc_info (const gchar *namespace,
g_base_info_unref ((GIBaseInfo *)invoker); g_base_info_unref ((GIBaseInfo *)invoker);
} }
write_callable_info (namespace, (GICallableInfo*)info, file); write_callable_info (ns, (GICallableInfo*)info, file);
xml_end_element (file, "virtual-method"); xml_end_element (file, "virtual-method");
} }
static void static void
write_property_info (const gchar *namespace, write_property_info (const gchar *ns,
GIPropertyInfo *info, GIPropertyInfo *info,
Xml *file) Xml *file)
{ {
@ -1022,13 +1022,13 @@ write_property_info (const gchar *namespace,
type = g_property_info_get_type (info); type = g_property_info_get_type (info);
write_type_info (namespace, type, file); write_type_info (ns, type, file);
xml_end_element (file, "property"); xml_end_element (file, "property");
} }
static void static void
write_object_info (const gchar *namespace, write_object_info (const gchar *ns,
GIObjectInfo *info, GIObjectInfo *info,
Xml *file) Xml *file)
{ {
@ -1058,14 +1058,14 @@ write_object_info (const gchar *namespace,
pnode = g_object_info_get_parent (info); pnode = g_object_info_get_parent (info);
if (pnode) if (pnode)
{ {
write_type_name_attribute (namespace, (GIBaseInfo *)pnode, "parent", file); write_type_name_attribute (ns, (GIBaseInfo *)pnode, "parent", file);
g_base_info_unref ((GIBaseInfo *)pnode); g_base_info_unref ((GIBaseInfo *)pnode);
} }
class_struct = g_object_info_get_class_struct (info); class_struct = g_object_info_get_class_struct (info);
if (class_struct) if (class_struct)
{ {
write_type_name_attribute (namespace, (GIBaseInfo*) class_struct, "glib:type-struct", file); write_type_name_attribute (ns, (GIBaseInfo*) class_struct, "glib:type-struct", file);
g_base_info_unref ((GIBaseInfo*)class_struct); g_base_info_unref ((GIBaseInfo*)class_struct);
} }
@ -1107,7 +1107,7 @@ write_object_info (const gchar *namespace,
{ {
GIInterfaceInfo *imp = g_object_info_get_interface (info, i); GIInterfaceInfo *imp = g_object_info_get_interface (info, i);
xml_start_element (file, "implements"); xml_start_element (file, "implements");
write_type_name_attribute (namespace, (GIBaseInfo *)imp, "name", file); write_type_name_attribute (ns, (GIBaseInfo *)imp, "name", file);
xml_end_element (file, "implements"); xml_end_element (file, "implements");
g_base_info_unref ((GIBaseInfo*)imp); g_base_info_unref ((GIBaseInfo*)imp);
} }
@ -1116,42 +1116,42 @@ write_object_info (const gchar *namespace,
for (i = 0; i < g_object_info_get_n_fields (info); i++) for (i = 0; i < g_object_info_get_n_fields (info); i++)
{ {
GIFieldInfo *field = g_object_info_get_field (info, i); GIFieldInfo *field = g_object_info_get_field (info, i);
write_field_info (namespace, field, NULL, file); write_field_info (ns, field, NULL, file);
g_base_info_unref ((GIBaseInfo *)field); g_base_info_unref ((GIBaseInfo *)field);
} }
for (i = 0; i < g_object_info_get_n_methods (info); i++) for (i = 0; i < g_object_info_get_n_methods (info); i++)
{ {
GIFunctionInfo *function = g_object_info_get_method (info, i); GIFunctionInfo *function = g_object_info_get_method (info, i);
write_function_info (namespace, function, file); write_function_info (ns, function, file);
g_base_info_unref ((GIBaseInfo *)function); g_base_info_unref ((GIBaseInfo *)function);
} }
for (i = 0; i < g_object_info_get_n_properties (info); i++) for (i = 0; i < g_object_info_get_n_properties (info); i++)
{ {
GIPropertyInfo *prop = g_object_info_get_property (info, i); GIPropertyInfo *prop = g_object_info_get_property (info, i);
write_property_info (namespace, prop, file); write_property_info (ns, prop, file);
g_base_info_unref ((GIBaseInfo *)prop); g_base_info_unref ((GIBaseInfo *)prop);
} }
for (i = 0; i < g_object_info_get_n_signals (info); i++) for (i = 0; i < g_object_info_get_n_signals (info); i++)
{ {
GISignalInfo *signal = g_object_info_get_signal (info, i); GISignalInfo *signal = g_object_info_get_signal (info, i);
write_signal_info (namespace, signal, file); write_signal_info (ns, signal, file);
g_base_info_unref ((GIBaseInfo *)signal); g_base_info_unref ((GIBaseInfo *)signal);
} }
for (i = 0; i < g_object_info_get_n_vfuncs (info); i++) for (i = 0; i < g_object_info_get_n_vfuncs (info); i++)
{ {
GIVFuncInfo *vfunc = g_object_info_get_vfunc (info, i); GIVFuncInfo *vfunc = g_object_info_get_vfunc (info, i);
write_vfunc_info (namespace, vfunc, file); write_vfunc_info (ns, vfunc, file);
g_base_info_unref ((GIBaseInfo *)vfunc); g_base_info_unref ((GIBaseInfo *)vfunc);
} }
for (i = 0; i < g_object_info_get_n_constants (info); i++) for (i = 0; i < g_object_info_get_n_constants (info); i++)
{ {
GIConstantInfo *constant = g_object_info_get_constant (info, i); GIConstantInfo *constant = g_object_info_get_constant (info, i);
write_constant_info (namespace, constant, file); write_constant_info (ns, constant, file);
g_base_info_unref ((GIBaseInfo *)constant); g_base_info_unref ((GIBaseInfo *)constant);
} }
@ -1159,7 +1159,7 @@ write_object_info (const gchar *namespace,
} }
static void static void
write_interface_info (const gchar *namespace, write_interface_info (const gchar *ns,
GIInterfaceInfo *info, GIInterfaceInfo *info,
Xml *file) Xml *file)
{ {
@ -1182,7 +1182,7 @@ write_interface_info (const gchar *namespace,
class_struct = g_interface_info_get_iface_struct (info); class_struct = g_interface_info_get_iface_struct (info);
if (class_struct) if (class_struct)
{ {
write_type_name_attribute (namespace, (GIBaseInfo*) class_struct, "glib:type-struct", file); write_type_name_attribute (ns, (GIBaseInfo*) class_struct, "glib:type-struct", file);
g_base_info_unref ((GIBaseInfo*)class_struct); g_base_info_unref ((GIBaseInfo*)class_struct);
} }
@ -1198,7 +1198,7 @@ write_interface_info (const gchar *namespace,
GIBaseInfo *req = g_interface_info_get_prerequisite (info, i); GIBaseInfo *req = g_interface_info_get_prerequisite (info, i);
xml_start_element (file, "prerequisite"); xml_start_element (file, "prerequisite");
write_type_name_attribute (namespace, req, "name", file); write_type_name_attribute (ns, req, "name", file);
xml_end_element_unchecked (file); xml_end_element_unchecked (file);
g_base_info_unref (req); g_base_info_unref (req);
@ -1208,35 +1208,35 @@ write_interface_info (const gchar *namespace,
for (i = 0; i < g_interface_info_get_n_methods (info); i++) for (i = 0; i < g_interface_info_get_n_methods (info); i++)
{ {
GIFunctionInfo *function = g_interface_info_get_method (info, i); GIFunctionInfo *function = g_interface_info_get_method (info, i);
write_function_info (namespace, function, file); write_function_info (ns, function, file);
g_base_info_unref ((GIBaseInfo *)function); g_base_info_unref ((GIBaseInfo *)function);
} }
for (i = 0; i < g_interface_info_get_n_properties (info); i++) for (i = 0; i < g_interface_info_get_n_properties (info); i++)
{ {
GIPropertyInfo *prop = g_interface_info_get_property (info, i); GIPropertyInfo *prop = g_interface_info_get_property (info, i);
write_property_info (namespace, prop, file); write_property_info (ns, prop, file);
g_base_info_unref ((GIBaseInfo *)prop); g_base_info_unref ((GIBaseInfo *)prop);
} }
for (i = 0; i < g_interface_info_get_n_signals (info); i++) for (i = 0; i < g_interface_info_get_n_signals (info); i++)
{ {
GISignalInfo *signal = g_interface_info_get_signal (info, i); GISignalInfo *signal = g_interface_info_get_signal (info, i);
write_signal_info (namespace, signal, file); write_signal_info (ns, signal, file);
g_base_info_unref ((GIBaseInfo *)signal); g_base_info_unref ((GIBaseInfo *)signal);
} }
for (i = 0; i < g_interface_info_get_n_vfuncs (info); i++) for (i = 0; i < g_interface_info_get_n_vfuncs (info); i++)
{ {
GIVFuncInfo *vfunc = g_interface_info_get_vfunc (info, i); GIVFuncInfo *vfunc = g_interface_info_get_vfunc (info, i);
write_vfunc_info (namespace, vfunc, file); write_vfunc_info (ns, vfunc, file);
g_base_info_unref ((GIBaseInfo *)vfunc); g_base_info_unref ((GIBaseInfo *)vfunc);
} }
for (i = 0; i < g_interface_info_get_n_constants (info); i++) for (i = 0; i < g_interface_info_get_n_constants (info); i++)
{ {
GIConstantInfo *constant = g_interface_info_get_constant (info, i); GIConstantInfo *constant = g_interface_info_get_constant (info, i);
write_constant_info (namespace, constant, file); write_constant_info (ns, constant, file);
g_base_info_unref ((GIBaseInfo *)constant); g_base_info_unref ((GIBaseInfo *)constant);
} }
@ -1244,7 +1244,7 @@ write_interface_info (const gchar *namespace,
} }
static void static void
write_union_info (const gchar *namespace, write_union_info (const gchar *ns,
GIUnionInfo *info, GIUnionInfo *info,
Xml *file) Xml *file)
{ {
@ -1295,7 +1295,7 @@ write_union_info (const gchar *namespace,
xml_start_element (file, "discriminator"); xml_start_element (file, "discriminator");
xml_printf (file, " offset=\"%d\" type=\"", offset); xml_printf (file, " offset=\"%d\" type=\"", offset);
write_type_info (namespace, type, file); write_type_info (ns, type, file);
xml_end_element (file, "discriminator"); xml_end_element (file, "discriminator");
g_base_info_unref ((GIBaseInfo *)type); g_base_info_unref ((GIBaseInfo *)type);
} }
@ -1304,7 +1304,7 @@ write_union_info (const gchar *namespace,
{ {
GIFieldInfo *field = g_union_info_get_field (info, i); GIFieldInfo *field = g_union_info_get_field (info, i);
GIConstantInfo *constant = g_union_info_get_discriminator (info, i); GIConstantInfo *constant = g_union_info_get_discriminator (info, i);
write_field_info (namespace, field, constant, file); write_field_info (ns, field, constant, file);
g_base_info_unref ((GIBaseInfo *)field); g_base_info_unref ((GIBaseInfo *)field);
if (constant) if (constant)
g_base_info_unref ((GIBaseInfo *)constant); g_base_info_unref ((GIBaseInfo *)constant);
@ -1313,7 +1313,7 @@ write_union_info (const gchar *namespace,
for (i = 0; i < g_union_info_get_n_methods (info); i++) for (i = 0; i < g_union_info_get_n_methods (info); i++)
{ {
GIFunctionInfo *function = g_union_info_get_method (info, i); GIFunctionInfo *function = g_union_info_get_method (info, i);
write_function_info (namespace, function, file); write_function_info (ns, function, file);
g_base_info_unref ((GIBaseInfo *)function); g_base_info_unref ((GIBaseInfo *)function);
} }
@ -1321,21 +1321,21 @@ write_union_info (const gchar *namespace,
} }
/** /*
* gir_writer_write: * g_ir_writer_write:
* @filename: filename to write to * @filename: filename to write to
* @namespace: GIR namespace to write * @ns: GIR namespace to write
* @needs_prefix: if the filename needs prefixing * @needs_prefix: if the filename needs prefixing
* @show_all: if field size calculations should be included * @show_all: if field size calculations should be included
* *
* Writes the output of a typelib represented by @namespace * Writes the output of a typelib represented by @ns
* into a GIR xml file named @filename. * into a GIR xml file named @filename.
*/ */
void void
gir_writer_write (const char *filename, g_ir_writer_write (const char *filename,
const char *namespace, const char *ns,
gboolean needs_prefix, gboolean needs_prefix,
gboolean show_all) gboolean show_all)
{ {
FILE *ofile; FILE *ofile;
gint i, j; gint i, j;
@ -1352,7 +1352,7 @@ gir_writer_write (const char *filename,
gchar *full_filename; gchar *full_filename;
if (needs_prefix) if (needs_prefix)
full_filename = g_strdup_printf ("%s-%s", namespace, filename); full_filename = g_strdup_printf ("%s-%s", ns, filename);
else else
full_filename = g_strdup (filename); full_filename = g_strdup (filename);
ofile = g_fopen (filename, "w"); ofile = g_fopen (filename, "w");
@ -1378,8 +1378,7 @@ gir_writer_write (const char *filename,
" xmlns:c=\"http://www.gtk.org/introspection/c/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:glib=\"http://www.gtk.org/introspection/glib/1.0\"");
dependencies = g_irepository_get_immediate_dependencies (repository, dependencies = g_irepository_get_immediate_dependencies (repository, ns);
namespace);
if (dependencies != NULL) if (dependencies != NULL)
{ {
for (i = 0; dependencies[i]; i++) for (i = 0; dependencies[i]; i++)
@ -1396,25 +1395,25 @@ gir_writer_write (const char *filename,
{ {
const gchar *shared_library; const gchar *shared_library;
const gchar *c_prefix; const gchar *c_prefix;
const char *ns = namespace; const char *cur_ns = ns;
const char *version; const char *cur_version;
gint n_infos; gint n_infos;
version = g_irepository_get_version (repository, ns); cur_version = g_irepository_get_version (repository, cur_ns);
shared_library = g_irepository_get_shared_library (repository, ns); shared_library = g_irepository_get_shared_library (repository, cur_ns);
c_prefix = g_irepository_get_c_prefix (repository, ns); c_prefix = g_irepository_get_c_prefix (repository, cur_ns);
xml_start_element (xml, "namespace"); xml_start_element (xml, "namespace");
xml_printf (xml, " name=\"%s\" version=\"%s\"", ns, version); xml_printf (xml, " name=\"%s\" version=\"%s\"", cur_ns, cur_version);
if (shared_library) if (shared_library)
xml_printf (xml, " shared-library=\"%s\"", shared_library); xml_printf (xml, " shared-library=\"%s\"", shared_library);
if (c_prefix) if (c_prefix)
xml_printf (xml, " c:prefix=\"%s\"", c_prefix); xml_printf (xml, " c:prefix=\"%s\"", c_prefix);
n_infos = g_irepository_get_n_infos (repository, ns); n_infos = g_irepository_get_n_infos (repository, cur_ns);
for (j = 0; j < n_infos; j++) for (j = 0; j < n_infos; j++)
{ {
GIBaseInfo *info = g_irepository_get_info (repository, ns, j); GIBaseInfo *info = g_irepository_get_info (repository, cur_ns, j);
switch (g_base_info_get_type (info)) switch (g_base_info_get_type (info))
{ {
case GI_INFO_TYPE_FUNCTION: case GI_INFO_TYPE_FUNCTION: