2012-02-03 19:42:56 +01:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
|
|
|
* GObject introspection: IDL generator
|
2010-06-07 15:52:43 +02:00
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Matthias Clasen
|
|
|
|
* Copyright (C) 2008,2009 Red Hat, Inc.
|
|
|
|
*
|
2023-10-25 18:10:10 +02:00
|
|
|
* SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
*
|
2010-06-07 15:52:43 +02:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2023-11-08 01:16:58 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "girwriter-private.h"
|
|
|
|
|
|
|
|
#include "girepository.h"
|
|
|
|
#include "gitypelib-internal.h"
|
|
|
|
|
2010-06-07 15:52:43 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <glib-object.h>
|
|
|
|
#include <glib/gstdio.h>
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
FILE *file;
|
|
|
|
GSList *stack;
|
|
|
|
gboolean show_all;
|
|
|
|
} Xml;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char *name;
|
2024-01-15 22:20:02 +01:00
|
|
|
unsigned has_children : 1;
|
2010-06-07 15:52:43 +02:00
|
|
|
} XmlElement;
|
|
|
|
|
|
|
|
static XmlElement *
|
|
|
|
xml_element_new (const char *name)
|
|
|
|
{
|
|
|
|
XmlElement *elem;
|
|
|
|
|
2010-06-12 16:22:26 +02:00
|
|
|
elem = g_slice_new (XmlElement);
|
2010-06-07 15:52:43 +02:00
|
|
|
elem->name = g_strdup (name);
|
|
|
|
elem->has_children = FALSE;
|
|
|
|
return elem;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
xml_element_free (XmlElement *elem)
|
|
|
|
{
|
|
|
|
g_free (elem->name);
|
2010-06-12 16:22:26 +02:00
|
|
|
g_slice_free (XmlElement, elem);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
2018-07-29 15:02:41 +02:00
|
|
|
static void
|
|
|
|
xml_printf (Xml *xml, const char *fmt, ...) G_GNUC_PRINTF (2, 3);
|
|
|
|
|
2010-06-07 15:52:43 +02:00
|
|
|
static void
|
|
|
|
xml_printf (Xml *xml, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
va_start (ap, fmt);
|
|
|
|
s = g_markup_vprintf_escaped (fmt, ap);
|
|
|
|
fputs (s, xml->file);
|
|
|
|
g_free (s);
|
|
|
|
va_end (ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
xml_start_element (Xml *xml, const char *element_name)
|
|
|
|
{
|
|
|
|
XmlElement *parent = NULL;
|
|
|
|
|
|
|
|
if (xml->stack)
|
|
|
|
{
|
|
|
|
parent = xml->stack->data;
|
|
|
|
|
|
|
|
if (!parent->has_children)
|
|
|
|
xml_printf (xml, ">\n");
|
|
|
|
|
|
|
|
parent->has_children = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
xml_printf (xml, "%*s<%s", g_slist_length(xml->stack)*2, "", element_name);
|
|
|
|
|
|
|
|
xml->stack = g_slist_prepend (xml->stack, xml_element_new (element_name));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
xml_end_element (Xml *xml, const char *name)
|
|
|
|
{
|
|
|
|
XmlElement *elem;
|
|
|
|
|
|
|
|
g_assert (xml->stack != NULL);
|
|
|
|
|
|
|
|
elem = xml->stack->data;
|
|
|
|
xml->stack = g_slist_delete_link (xml->stack, xml->stack);
|
|
|
|
|
|
|
|
if (name != NULL)
|
|
|
|
g_assert_cmpstr (name, ==, elem->name);
|
|
|
|
|
|
|
|
if (elem->has_children)
|
|
|
|
xml_printf (xml, "%*s</%s>\n", g_slist_length (xml->stack)*2, "", elem->name);
|
|
|
|
else
|
|
|
|
xml_printf (xml, "/>\n");
|
|
|
|
|
|
|
|
xml_element_free (elem);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
xml_end_element_unchecked (Xml *xml)
|
|
|
|
{
|
|
|
|
xml_end_element (xml, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Xml *
|
|
|
|
xml_open (FILE *file)
|
|
|
|
{
|
|
|
|
Xml *xml;
|
|
|
|
|
2010-06-12 16:22:26 +02:00
|
|
|
xml = g_slice_new (Xml);
|
2010-06-07 15:52:43 +02:00
|
|
|
xml->file = file;
|
|
|
|
xml->stack = NULL;
|
|
|
|
|
|
|
|
return xml;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
xml_close (Xml *xml)
|
|
|
|
{
|
|
|
|
g_assert (xml->stack == NULL);
|
|
|
|
if (xml->file != NULL)
|
|
|
|
{
|
|
|
|
fflush (xml->file);
|
|
|
|
if (xml->file != stdout)
|
|
|
|
fclose (xml->file);
|
|
|
|
xml->file = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
xml_free (Xml *xml)
|
|
|
|
{
|
|
|
|
xml_close (xml);
|
2010-06-12 16:22:26 +02:00
|
|
|
g_slice_free (Xml, xml);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
check_unresolved (GIBaseInfo *info)
|
|
|
|
{
|
2023-12-12 17:16:30 +01:00
|
|
|
if (gi_base_info_get_info_type (info) != GI_INFO_TYPE_UNRESOLVED)
|
2010-06-07 15:52:43 +02:00
|
|
|
return;
|
|
|
|
|
2023-12-20 23:41:10 +01:00
|
|
|
g_critical ("Found unresolved type '%s' '%s'",
|
2024-01-16 17:30:37 +01:00
|
|
|
gi_base_info_get_name (info), gi_base_info_get_namespace (info));
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2024-01-15 22:20:02 +01:00
|
|
|
write_type_name (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GIBaseInfo *info,
|
|
|
|
Xml *file)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
if (strcmp (ns, gi_base_info_get_namespace (info)) != 0)
|
|
|
|
xml_printf (file, "%s.", gi_base_info_get_namespace (info));
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
xml_printf (file, "%s", gi_base_info_get_name (info));
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2024-01-15 22:20:02 +01:00
|
|
|
write_type_name_attribute (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GIBaseInfo *info,
|
|
|
|
const char *attr_name,
|
|
|
|
Xml *file)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
|
|
|
xml_printf (file, " %s=\"", attr_name);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_type_name (ns, info, file);
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_printf (file, "\"");
|
|
|
|
}
|
|
|
|
|
2010-06-08 16:40:35 +02:00
|
|
|
static void
|
|
|
|
write_ownership_transfer (GITransfer transfer,
|
|
|
|
Xml *file)
|
|
|
|
{
|
|
|
|
switch (transfer)
|
|
|
|
{
|
|
|
|
case GI_TRANSFER_NOTHING:
|
|
|
|
xml_printf (file, " transfer-ownership=\"none\"");
|
|
|
|
break;
|
|
|
|
case GI_TRANSFER_CONTAINER:
|
|
|
|
xml_printf (file, " transfer-ownership=\"container\"");
|
|
|
|
break;
|
|
|
|
case GI_TRANSFER_EVERYTHING:
|
|
|
|
xml_printf (file, " transfer-ownership=\"full\"");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-07 15:52:43 +02:00
|
|
|
static void
|
2024-01-15 22:20:02 +01:00
|
|
|
write_type_info (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GITypeInfo *info,
|
|
|
|
Xml *file)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2024-01-15 22:20:02 +01:00
|
|
|
int tag;
|
2010-06-07 15:52:43 +02:00
|
|
|
GITypeInfo *type;
|
|
|
|
gboolean is_pointer;
|
|
|
|
|
|
|
|
check_unresolved ((GIBaseInfo*)info);
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
tag = gi_type_info_get_tag (info);
|
|
|
|
is_pointer = gi_type_info_is_pointer (info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
if (tag == GI_TYPE_TAG_VOID)
|
|
|
|
{
|
|
|
|
xml_start_element (file, "type");
|
|
|
|
|
|
|
|
xml_printf (file, " name=\"%s\"", is_pointer ? "any" : "none");
|
|
|
|
|
|
|
|
xml_end_element (file, "type");
|
|
|
|
}
|
2022-02-13 15:35:53 +01:00
|
|
|
else if (GI_TYPE_TAG_IS_BASIC (tag))
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
|
|
|
xml_start_element (file, "type");
|
2023-11-08 15:17:52 +01:00
|
|
|
xml_printf (file, " name=\"%s\"", gi_type_tag_to_string (tag));
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_end_element (file, "type");
|
|
|
|
}
|
|
|
|
else if (tag == GI_TYPE_TAG_ARRAY)
|
|
|
|
{
|
2024-01-17 00:26:02 +01:00
|
|
|
unsigned int length_index;
|
2024-01-17 00:11:16 +01:00
|
|
|
size_t size;
|
2018-07-29 14:26:44 +02:00
|
|
|
const char *name = NULL;
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_start_element (file, "array");
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
switch (gi_type_info_get_array_type (info)) {
|
2010-06-07 15:52:43 +02:00
|
|
|
case GI_ARRAY_TYPE_C:
|
|
|
|
break;
|
|
|
|
case GI_ARRAY_TYPE_ARRAY:
|
|
|
|
name = "GLib.Array";
|
|
|
|
break;
|
|
|
|
case GI_ARRAY_TYPE_PTR_ARRAY:
|
|
|
|
name = "GLib.PtrArray";
|
|
|
|
break;
|
|
|
|
case GI_ARRAY_TYPE_BYTE_ARRAY:
|
|
|
|
name = "GLib.ByteArray";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
xml_printf (file, " name=\"%s\"", name);
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
type = gi_type_info_get_param_type (info, 0);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2024-01-17 00:26:02 +01:00
|
|
|
if (gi_type_info_get_array_length_index (info, &length_index))
|
|
|
|
xml_printf (file, " length=\"%u\"", length_index);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2024-01-17 00:11:16 +01:00
|
|
|
if (gi_type_info_get_array_fixed_size (info, &size))
|
|
|
|
xml_printf (file, " fixed-size=\"%zu\"", size);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
if (gi_type_info_is_zero_terminated (info))
|
2024-01-16 17:30:37 +01:00
|
|
|
xml_printf (file, " zero-terminated=\"1\"");
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 01:23:35 +01:00
|
|
|
write_type_info (ns, type, file);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)type);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_end_element (file, "array");
|
|
|
|
}
|
|
|
|
else if (tag == GI_TYPE_TAG_INTERFACE)
|
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GIBaseInfo *iface = gi_type_info_get_interface (info);
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_start_element (file, "type");
|
2023-11-08 01:23:35 +01:00
|
|
|
write_type_name_attribute (ns, iface, "name", file);
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_end_element (file, "type");
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref (iface);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
else if (tag == GI_TYPE_TAG_GLIST)
|
|
|
|
{
|
|
|
|
xml_start_element (file, "type");
|
|
|
|
xml_printf (file, " name=\"GLib.List\"");
|
2023-11-08 15:17:52 +01:00
|
|
|
type = gi_type_info_get_param_type (info, 0);
|
2010-06-07 15:52:43 +02:00
|
|
|
if (type)
|
2024-01-16 17:30:37 +01:00
|
|
|
{
|
|
|
|
write_type_info (ns, type, file);
|
|
|
|
gi_base_info_unref ((GIBaseInfo *)type);
|
|
|
|
}
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_end_element (file, "type");
|
|
|
|
}
|
|
|
|
else if (tag == GI_TYPE_TAG_GSLIST)
|
|
|
|
{
|
|
|
|
xml_start_element (file, "type");
|
|
|
|
xml_printf (file, " name=\"GLib.SList\"");
|
2023-11-08 15:17:52 +01:00
|
|
|
type = gi_type_info_get_param_type (info, 0);
|
2010-06-07 15:52:43 +02:00
|
|
|
if (type)
|
2024-01-16 17:30:37 +01:00
|
|
|
{
|
|
|
|
write_type_info (ns, type, file);
|
|
|
|
gi_base_info_unref ((GIBaseInfo *)type);
|
|
|
|
}
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_end_element (file, "type");
|
|
|
|
}
|
|
|
|
else if (tag == GI_TYPE_TAG_GHASH)
|
|
|
|
{
|
|
|
|
xml_start_element (file, "type");
|
|
|
|
xml_printf (file, " name=\"GLib.HashTable\"");
|
2023-11-08 15:17:52 +01:00
|
|
|
type = gi_type_info_get_param_type (info, 0);
|
2010-06-07 15:52:43 +02:00
|
|
|
if (type)
|
2024-01-16 17:30:37 +01:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_end_element (file, "type");
|
|
|
|
}
|
|
|
|
else if (tag == GI_TYPE_TAG_ERROR)
|
|
|
|
{
|
|
|
|
xml_start_element (file, "type");
|
|
|
|
xml_printf (file, " name=\"GLib.Error\"");
|
|
|
|
xml_end_element (file, "type");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_printerr ("Unhandled type tag %d\n", tag);
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
write_attributes (Xml *file,
|
2010-06-15 17:01:37 +02:00
|
|
|
GIBaseInfo *info)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2024-01-18 13:27:46 +01:00
|
|
|
GIAttributeIter iter = GI_ATTRIBUTE_ITER_INIT;
|
2023-12-12 18:34:48 +01:00
|
|
|
const char *name, *value;
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
while (gi_base_info_iterate_attributes (info, &iter, &name, &value))
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
|
|
|
xml_start_element (file, "attribute");
|
|
|
|
xml_printf (file, " name=\"%s\" value=\"%s\"", name, value);
|
|
|
|
xml_end_element (file, "attribute");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-15 17:01:37 +02:00
|
|
|
static void
|
|
|
|
write_return_value_attributes (Xml *file,
|
|
|
|
GICallableInfo *info)
|
|
|
|
{
|
2024-01-18 13:27:46 +01:00
|
|
|
GIAttributeIter iter = GI_ATTRIBUTE_ITER_INIT;
|
2023-12-12 18:34:48 +01:00
|
|
|
const char *name, *value;
|
2010-06-15 17:01:37 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
while (gi_callable_info_iterate_return_attributes (info, &iter, &name, &value))
|
2010-06-15 17:01:37 +02:00
|
|
|
{
|
|
|
|
xml_start_element (file, "attribute");
|
|
|
|
xml_printf (file, " name=\"%s\" value=\"%s\"", name, value);
|
|
|
|
xml_end_element (file, "attribute");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-07 15:52:43 +02:00
|
|
|
static void
|
2024-01-15 22:20:02 +01:00
|
|
|
write_constant_value (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GITypeInfo *info,
|
|
|
|
GIArgument *argument,
|
|
|
|
Xml *file);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
static void
|
2024-01-15 20:20:47 +01:00
|
|
|
write_callback_info (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GICallbackInfo *info,
|
|
|
|
Xml *file);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
static void
|
2024-01-15 22:20:02 +01:00
|
|
|
write_field_info (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GIFieldInfo *info,
|
|
|
|
GIConstantInfo *branch,
|
|
|
|
Xml *file)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2024-01-15 20:20:47 +01:00
|
|
|
const char *name;
|
2010-06-07 15:52:43 +02:00
|
|
|
GIFieldInfoFlags flags;
|
2024-01-16 01:00:07 +01:00
|
|
|
size_t size;
|
|
|
|
size_t offset;
|
2010-06-07 15:52:43 +02:00
|
|
|
GITypeInfo *type;
|
|
|
|
GIBaseInfo *interface;
|
2010-08-31 22:33:06 +02:00
|
|
|
GIArgument value;
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
name = gi_base_info_get_name ((GIBaseInfo *)info);
|
|
|
|
flags = gi_field_info_get_flags (info);
|
|
|
|
size = gi_field_info_get_size (info);
|
|
|
|
offset = gi_field_info_get_offset (info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_start_element (file, "field");
|
|
|
|
xml_printf (file, " name=\"%s\"", name);
|
|
|
|
|
|
|
|
/* Fields are assumed to be read-only
|
|
|
|
* (see also girwriter.py and girparser.c)
|
|
|
|
*/
|
|
|
|
if (!(flags & GI_FIELD_IS_READABLE))
|
|
|
|
xml_printf (file, " readable=\"0\"");
|
|
|
|
if (flags & GI_FIELD_IS_WRITABLE)
|
|
|
|
xml_printf (file, " writable=\"1\"");
|
|
|
|
|
|
|
|
if (size)
|
2024-01-16 01:00:07 +01:00
|
|
|
xml_printf (file, " bits=\"%zu\"", size);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
write_attributes (file, (GIBaseInfo*) info);
|
|
|
|
|
2023-11-28 18:09:26 +01:00
|
|
|
type = gi_field_info_get_type_info (info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
if (branch)
|
|
|
|
{
|
|
|
|
xml_printf (file, " branch=\"");
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)type);
|
2023-11-28 18:09:26 +01:00
|
|
|
type = gi_constant_info_get_type_info (branch);
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_constant_info_get_value (branch, &value);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_constant_value (ns, type, &value, file);
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_printf (file, "\"");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (file->show_all)
|
|
|
|
{
|
2024-01-16 01:00:07 +01:00
|
|
|
xml_printf (file, "offset=\"%zu\"", offset);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
interface = gi_type_info_get_interface (type);
|
2023-12-12 17:16:30 +01:00
|
|
|
if (interface && gi_base_info_get_info_type (interface) == GI_INFO_TYPE_CALLBACK)
|
2023-11-08 01:23:35 +01:00
|
|
|
write_callback_info (ns, (GICallbackInfo *)interface, file);
|
2010-06-07 15:52:43 +02:00
|
|
|
else
|
2023-11-08 01:23:35 +01:00
|
|
|
write_type_info (ns, type, file);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
if (interface)
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref (interface);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)type);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_end_element (file, "field");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2024-01-15 20:20:47 +01:00
|
|
|
write_callable_info (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GICallableInfo *info,
|
|
|
|
Xml *file)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
|
|
|
GITypeInfo *type;
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
if (gi_callable_info_can_throw_gerror (info))
|
2015-06-03 14:24:21 +02:00
|
|
|
xml_printf (file, " throws=\"1\"");
|
|
|
|
|
2010-06-07 15:52:43 +02:00
|
|
|
write_attributes (file, (GIBaseInfo*) info);
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
type = gi_callable_info_get_return_type (info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_start_element (file, "return-value");
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
write_ownership_transfer (gi_callable_info_get_caller_owns (info), file);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
if (gi_callable_info_may_return_null (info))
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_printf (file, " allow-none=\"1\"");
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
if (gi_callable_info_skip_return (info))
|
2011-05-13 18:20:05 +02:00
|
|
|
xml_printf (file, " skip=\"1\"");
|
|
|
|
|
2010-06-15 17:01:37 +02:00
|
|
|
write_return_value_attributes (file, info);
|
|
|
|
|
2023-11-08 01:23:35 +01:00
|
|
|
write_type_info (ns, type, file);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_end_element (file, "return-value");
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
if (gi_callable_info_get_n_args (info) <= 0)
|
2010-06-07 15:52:43 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
xml_start_element (file, "parameters");
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_callable_info_get_n_args (info); i++)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GIArgInfo *arg = gi_callable_info_get_arg (info, i);
|
2024-01-17 11:36:45 +01:00
|
|
|
unsigned int closure_index, destroy_index;
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_start_element (file, "parameter");
|
|
|
|
xml_printf (file, " name=\"%s\"",
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_get_name ((GIBaseInfo *) arg));
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
write_ownership_transfer (gi_arg_info_get_ownership_transfer (arg), file);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
switch (gi_arg_info_get_direction (arg))
|
2024-01-16 17:30:37 +01:00
|
|
|
{
|
|
|
|
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 ();
|
|
|
|
}
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
if (gi_arg_info_may_be_null (arg))
|
2024-01-16 17:30:37 +01:00
|
|
|
xml_printf (file, " allow-none=\"1\"");
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
if (gi_arg_info_is_return_value (arg))
|
2024-01-16 17:30:37 +01:00
|
|
|
xml_printf (file, " retval=\"1\"");
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
if (gi_arg_info_is_optional (arg))
|
2024-01-16 17:30:37 +01:00
|
|
|
xml_printf (file, " optional=\"1\"");
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
switch (gi_arg_info_get_scope (arg))
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
|
|
|
case GI_SCOPE_TYPE_INVALID:
|
|
|
|
break;
|
|
|
|
case GI_SCOPE_TYPE_CALL:
|
|
|
|
xml_printf (file, " scope=\"call\"");
|
|
|
|
break;
|
|
|
|
case GI_SCOPE_TYPE_ASYNC:
|
|
|
|
xml_printf (file, " scope=\"async\"");
|
|
|
|
break;
|
|
|
|
case GI_SCOPE_TYPE_NOTIFIED:
|
|
|
|
xml_printf (file, " scope=\"notified\"");
|
|
|
|
break;
|
2020-04-08 21:04:03 +02:00
|
|
|
case GI_SCOPE_TYPE_FOREVER:
|
|
|
|
xml_printf (file, " scope=\"forever\"");
|
|
|
|
break;
|
2018-07-29 17:13:16 +02:00
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
2024-01-17 11:36:45 +01:00
|
|
|
if (gi_arg_info_get_closure_index (arg, &closure_index))
|
|
|
|
xml_printf (file, " closure=\"%u\"", closure_index);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2024-01-17 11:36:45 +01:00
|
|
|
if (gi_arg_info_get_destroy_index (arg, &destroy_index))
|
|
|
|
xml_printf (file, " destroy=\"%u\"", destroy_index);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
if (gi_arg_info_is_skip (arg))
|
2011-05-13 18:20:05 +02:00
|
|
|
xml_printf (file, " skip=\"1\"");
|
|
|
|
|
2010-06-15 17:01:37 +02:00
|
|
|
write_attributes (file, (GIBaseInfo*) arg);
|
|
|
|
|
2023-11-28 18:09:26 +01:00
|
|
|
type = gi_arg_info_get_type_info (arg);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_type_info (ns, type, file);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_end_element (file, "parameter");
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)arg);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
xml_end_element (file, "parameters");
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)type);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2024-01-15 22:20:02 +01:00
|
|
|
write_function_info (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GIFunctionInfo *info,
|
|
|
|
Xml *file)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
|
|
|
GIFunctionInfoFlags flags;
|
2024-01-15 20:20:47 +01:00
|
|
|
const char *tag;
|
|
|
|
const char *name;
|
|
|
|
const char *symbol;
|
2010-06-07 15:52:43 +02:00
|
|
|
gboolean deprecated;
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
flags = gi_function_info_get_flags (info);
|
|
|
|
name = gi_base_info_get_name ((GIBaseInfo *)info);
|
|
|
|
symbol = gi_function_info_get_symbol (info);
|
|
|
|
deprecated = gi_base_info_is_deprecated ((GIBaseInfo *)info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
if (flags & GI_FUNCTION_IS_CONSTRUCTOR)
|
|
|
|
tag = "constructor";
|
|
|
|
else if (flags & GI_FUNCTION_IS_METHOD)
|
|
|
|
tag = "method";
|
|
|
|
else
|
|
|
|
tag = "function";
|
|
|
|
|
|
|
|
xml_start_element (file, tag);
|
|
|
|
xml_printf (file, " name=\"%s\" c:identifier=\"%s\"",
|
|
|
|
name, symbol);
|
|
|
|
|
2021-06-16 20:17:27 +02:00
|
|
|
if ((flags & GI_FUNCTION_IS_SETTER) || (flags & GI_FUNCTION_IS_GETTER))
|
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GIPropertyInfo *property = gi_function_info_get_property (info);
|
2021-06-16 20:17:27 +02:00
|
|
|
|
|
|
|
if (property != NULL)
|
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
const char *property_name = gi_base_info_get_name ((GIBaseInfo *)property);
|
2021-06-16 20:17:27 +02:00
|
|
|
|
|
|
|
if (flags & GI_FUNCTION_IS_SETTER)
|
|
|
|
xml_printf (file, " glib:set-property=\"%s\"", property_name);
|
|
|
|
else if (flags & GI_FUNCTION_IS_GETTER)
|
|
|
|
xml_printf (file, " glib:get-property=\"%s\"", property_name);
|
|
|
|
|
2023-11-28 18:14:30 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *) property);
|
2021-06-16 20:17:27 +02:00
|
|
|
}
|
|
|
|
}
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
if (deprecated)
|
|
|
|
xml_printf (file, " deprecated=\"1\"");
|
|
|
|
|
2023-11-08 01:23:35 +01:00
|
|
|
write_callable_info (ns, (GICallableInfo*)info, file);
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_end_element (file, tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2024-01-15 20:20:47 +01:00
|
|
|
write_callback_info (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GICallbackInfo *info,
|
|
|
|
Xml *file)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2024-01-15 20:20:47 +01:00
|
|
|
const char *name;
|
2010-06-07 15:52:43 +02:00
|
|
|
gboolean deprecated;
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
name = gi_base_info_get_name ((GIBaseInfo *)info);
|
|
|
|
deprecated = gi_base_info_is_deprecated ((GIBaseInfo *)info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_start_element (file, "callback");
|
|
|
|
xml_printf (file, " name=\"%s\"", name);
|
|
|
|
|
|
|
|
if (deprecated)
|
|
|
|
xml_printf (file, " deprecated=\"1\"");
|
|
|
|
|
2023-11-08 01:23:35 +01:00
|
|
|
write_callable_info (ns, (GICallableInfo*)info, file);
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_end_element (file, "callback");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2024-01-15 20:20:47 +01:00
|
|
|
write_struct_info (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GIStructInfo *info,
|
|
|
|
Xml *file)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2024-01-15 20:20:47 +01:00
|
|
|
const char *name;
|
|
|
|
const char *type_name;
|
|
|
|
const char *type_init;
|
|
|
|
const char *func;
|
2010-06-07 15:52:43 +02:00
|
|
|
gboolean deprecated;
|
|
|
|
gboolean is_gtype_struct;
|
|
|
|
gboolean foreign;
|
2024-01-16 01:00:07 +01:00
|
|
|
size_t size;
|
2024-01-15 22:20:02 +01:00
|
|
|
unsigned int n_elts;
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
name = gi_base_info_get_name ((GIBaseInfo *)info);
|
|
|
|
deprecated = gi_base_info_is_deprecated ((GIBaseInfo *)info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
type_name = gi_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info);
|
2023-12-12 18:54:19 +01:00
|
|
|
type_init = gi_registered_type_info_get_type_init_function_name ((GIRegisteredTypeInfo*)info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-12-12 17:16:30 +01:00
|
|
|
if (gi_base_info_get_info_type ((GIBaseInfo *) info) == GI_INFO_TYPE_BOXED)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
|
|
|
xml_start_element (file, "glib:boxed");
|
|
|
|
xml_printf (file, " glib:name=\"%s\"", name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xml_start_element (file, "record");
|
|
|
|
xml_printf (file, " name=\"%s\"", name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type_name != NULL)
|
|
|
|
xml_printf (file, " glib:type-name=\"%s\" glib:get-type=\"%s\"", type_name, type_init);
|
|
|
|
|
|
|
|
if (deprecated)
|
|
|
|
xml_printf (file, " deprecated=\"1\"");
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
is_gtype_struct = gi_struct_info_is_gtype_struct (info);
|
2010-06-07 15:52:43 +02:00
|
|
|
if (is_gtype_struct)
|
|
|
|
xml_printf (file, " glib:is-gtype-struct=\"1\"");
|
|
|
|
|
2023-12-12 19:18:51 +01:00
|
|
|
func = gi_struct_info_get_copy_function_name (info);
|
2022-10-29 19:09:23 +02:00
|
|
|
if (func)
|
|
|
|
xml_printf (file, " copy-function=\"%s\"", func);
|
|
|
|
|
2023-12-12 19:18:51 +01:00
|
|
|
func = gi_struct_info_get_free_function_name (info);
|
2022-10-29 19:09:23 +02:00
|
|
|
if (func)
|
|
|
|
xml_printf (file, " free-function=\"%s\"", func);
|
|
|
|
|
2010-06-07 15:52:43 +02:00
|
|
|
write_attributes (file, (GIBaseInfo*) info);
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
size = gi_struct_info_get_size (info);
|
2024-01-16 01:00:07 +01:00
|
|
|
if (file->show_all)
|
|
|
|
xml_printf (file, " size=\"%zu\"", size);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
foreign = gi_struct_info_is_foreign (info);
|
2010-06-07 15:52:43 +02:00
|
|
|
if (foreign)
|
|
|
|
xml_printf (file, " foreign=\"1\"");
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
n_elts = gi_struct_info_get_n_fields (info) + gi_struct_info_get_n_methods (info);
|
2010-06-07 15:52:43 +02:00
|
|
|
if (n_elts > 0)
|
|
|
|
{
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_struct_info_get_n_fields (info); i++)
|
2024-01-16 17:30:37 +01:00
|
|
|
{
|
|
|
|
GIFieldInfo *field = gi_struct_info_get_field (info, i);
|
|
|
|
write_field_info (ns, field, NULL, file);
|
|
|
|
gi_base_info_unref ((GIBaseInfo *)field);
|
|
|
|
}
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_struct_info_get_n_methods (info); i++)
|
2024-01-16 17:30:37 +01:00
|
|
|
{
|
|
|
|
GIFunctionInfo *function = gi_struct_info_get_method (info, i);
|
|
|
|
write_function_info (ns, function, file);
|
|
|
|
gi_base_info_unref ((GIBaseInfo *)function);
|
|
|
|
}
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
xml_end_element_unchecked (file);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2024-01-15 22:20:02 +01:00
|
|
|
write_value_info (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GIValueInfo *info,
|
|
|
|
Xml *file)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2024-01-15 20:20:47 +01:00
|
|
|
const char *name;
|
2024-01-15 22:20:02 +01:00
|
|
|
int64_t value;
|
2024-01-15 20:20:47 +01:00
|
|
|
char *value_str;
|
2010-06-07 15:52:43 +02:00
|
|
|
gboolean deprecated;
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
name = gi_base_info_get_name ((GIBaseInfo *)info);
|
|
|
|
value = gi_value_info_get_value (info);
|
|
|
|
deprecated = gi_base_info_is_deprecated ((GIBaseInfo *)info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_start_element (file, "member");
|
2010-09-14 17:59:03 +02:00
|
|
|
value_str = g_strdup_printf ("%" G_GINT64_FORMAT, value);
|
|
|
|
xml_printf (file, " name=\"%s\" value=\"%s\"", name, value_str);
|
|
|
|
g_free (value_str);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
if (deprecated)
|
|
|
|
xml_printf (file, " deprecated=\"1\"");
|
|
|
|
|
|
|
|
write_attributes (file, (GIBaseInfo*) info);
|
|
|
|
|
|
|
|
xml_end_element (file, "member");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2024-01-15 20:20:47 +01:00
|
|
|
write_constant_value (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GITypeInfo *type,
|
|
|
|
GIArgument *value,
|
|
|
|
Xml *file)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
switch (gi_type_info_get_tag (type))
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
|
|
|
case GI_TYPE_TAG_BOOLEAN:
|
|
|
|
xml_printf (file, "%d", value->v_boolean);
|
|
|
|
break;
|
|
|
|
case GI_TYPE_TAG_INT8:
|
|
|
|
xml_printf (file, "%d", value->v_int8);
|
|
|
|
break;
|
|
|
|
case GI_TYPE_TAG_UINT8:
|
|
|
|
xml_printf (file, "%d", value->v_uint8);
|
|
|
|
break;
|
|
|
|
case GI_TYPE_TAG_INT16:
|
|
|
|
xml_printf (file, "%" G_GINT16_FORMAT, value->v_int16);
|
|
|
|
break;
|
|
|
|
case GI_TYPE_TAG_UINT16:
|
|
|
|
xml_printf (file, "%" G_GUINT16_FORMAT, value->v_uint16);
|
|
|
|
break;
|
|
|
|
case GI_TYPE_TAG_INT32:
|
|
|
|
xml_printf (file, "%" G_GINT32_FORMAT, value->v_int32);
|
|
|
|
break;
|
|
|
|
case GI_TYPE_TAG_UINT32:
|
|
|
|
xml_printf (file, "%" G_GUINT32_FORMAT, value->v_uint32);
|
|
|
|
break;
|
|
|
|
case GI_TYPE_TAG_INT64:
|
|
|
|
xml_printf (file, "%" G_GINT64_FORMAT, value->v_int64);
|
|
|
|
break;
|
|
|
|
case GI_TYPE_TAG_UINT64:
|
|
|
|
xml_printf (file, "%" G_GUINT64_FORMAT, value->v_uint64);
|
|
|
|
break;
|
|
|
|
case GI_TYPE_TAG_FLOAT:
|
2018-07-29 14:54:34 +02:00
|
|
|
xml_printf (file, "%f", (double)value->v_float);
|
2010-06-07 15:52:43 +02:00
|
|
|
break;
|
|
|
|
case GI_TYPE_TAG_DOUBLE:
|
|
|
|
xml_printf (file, "%f", value->v_double);
|
|
|
|
break;
|
|
|
|
case GI_TYPE_TAG_UTF8:
|
|
|
|
case GI_TYPE_TAG_FILENAME:
|
|
|
|
xml_printf (file, "%s", value->v_string);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2024-01-15 20:20:47 +01:00
|
|
|
write_constant_info (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GIConstantInfo *info,
|
|
|
|
Xml *file)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
|
|
|
GITypeInfo *type;
|
2024-01-15 20:20:47 +01:00
|
|
|
const char *name;
|
2010-08-31 22:33:06 +02:00
|
|
|
GIArgument value;
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
name = gi_base_info_get_name ((GIBaseInfo *)info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_start_element (file, "constant");
|
|
|
|
xml_printf (file, " name=\"%s\"", name);
|
|
|
|
|
2023-11-28 18:09:26 +01:00
|
|
|
type = gi_constant_info_get_type_info (info);
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_printf (file, " value=\"");
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_constant_info_get_value (info, &value);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_constant_value (ns, type, &value, file);
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_printf (file, "\"");
|
|
|
|
|
2023-11-08 01:23:35 +01:00
|
|
|
write_type_info (ns, type, file);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
write_attributes (file, (GIBaseInfo*) info);
|
|
|
|
|
|
|
|
xml_end_element (file, "constant");
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)type);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2024-01-15 20:20:47 +01:00
|
|
|
write_enum_info (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GIEnumInfo *info,
|
|
|
|
Xml *file)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2024-01-15 20:20:47 +01:00
|
|
|
const char *name;
|
|
|
|
const char *type_name;
|
|
|
|
const char *type_init;
|
|
|
|
const char *error_domain;
|
2010-06-07 15:52:43 +02:00
|
|
|
gboolean deprecated;
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
name = gi_base_info_get_name ((GIBaseInfo *)info);
|
|
|
|
deprecated = gi_base_info_is_deprecated ((GIBaseInfo *)info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
type_name = gi_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info);
|
2023-12-12 18:54:19 +01:00
|
|
|
type_init = gi_registered_type_info_get_type_init_function_name ((GIRegisteredTypeInfo*)info);
|
2023-11-08 15:17:52 +01:00
|
|
|
error_domain = gi_enum_info_get_error_domain (info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-12-12 17:16:30 +01:00
|
|
|
if (gi_base_info_get_info_type ((GIBaseInfo *) info) == GI_INFO_TYPE_ENUM)
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_start_element (file, "enumeration");
|
|
|
|
else
|
|
|
|
xml_start_element (file, "bitfield");
|
|
|
|
xml_printf (file, " name=\"%s\"", name);
|
|
|
|
|
|
|
|
if (type_init)
|
|
|
|
xml_printf (file, " glib:type-name=\"%s\" glib:get-type=\"%s\"", type_name, type_init);
|
2011-05-19 22:21:13 +02:00
|
|
|
if (error_domain)
|
|
|
|
xml_printf (file, " glib:error-domain=\"%s\"", error_domain);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
if (deprecated)
|
|
|
|
xml_printf (file, " deprecated=\"1\"");
|
|
|
|
|
|
|
|
write_attributes (file, (GIBaseInfo*) info);
|
|
|
|
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_enum_info_get_n_values (info); i++)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GIValueInfo *value = gi_enum_info_get_value (info, i);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_value_info (ns, value, file);
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)value);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
xml_end_element_unchecked (file);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2024-01-15 20:20:47 +01:00
|
|
|
write_signal_info (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GISignalInfo *info,
|
|
|
|
Xml *file)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
|
|
|
GSignalFlags flags;
|
2024-01-15 20:20:47 +01:00
|
|
|
const char *name;
|
2010-06-07 15:52:43 +02:00
|
|
|
gboolean deprecated;
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
name = gi_base_info_get_name ((GIBaseInfo *)info);
|
|
|
|
flags = gi_signal_info_get_flags (info);
|
|
|
|
deprecated = gi_base_info_is_deprecated ((GIBaseInfo *)info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_start_element (file, "glib:signal");
|
|
|
|
xml_printf (file, " name=\"%s\"", name);
|
|
|
|
|
|
|
|
if (deprecated)
|
|
|
|
xml_printf (file, " deprecated=\"1\"");
|
|
|
|
|
|
|
|
if (flags & G_SIGNAL_RUN_FIRST)
|
|
|
|
xml_printf (file, " when=\"FIRST\"");
|
|
|
|
else if (flags & G_SIGNAL_RUN_LAST)
|
|
|
|
xml_printf (file, " when=\"LAST\"");
|
|
|
|
else if (flags & G_SIGNAL_RUN_CLEANUP)
|
|
|
|
xml_printf (file, " when=\"CLEANUP\"");
|
|
|
|
|
|
|
|
if (flags & G_SIGNAL_NO_RECURSE)
|
|
|
|
xml_printf (file, " no-recurse=\"1\"");
|
|
|
|
|
|
|
|
if (flags & G_SIGNAL_DETAILED)
|
|
|
|
xml_printf (file, " detailed=\"1\"");
|
|
|
|
|
|
|
|
if (flags & G_SIGNAL_ACTION)
|
|
|
|
xml_printf (file, " action=\"1\"");
|
|
|
|
|
|
|
|
if (flags & G_SIGNAL_NO_HOOKS)
|
|
|
|
xml_printf (file, " no-hooks=\"1\"");
|
|
|
|
|
2023-11-08 01:23:35 +01:00
|
|
|
write_callable_info (ns, (GICallableInfo*)info, file);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_end_element (file, "glib:signal");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2024-01-15 20:20:47 +01:00
|
|
|
write_vfunc_info (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GIVFuncInfo *info,
|
|
|
|
Xml *file)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
|
|
|
GIVFuncInfoFlags flags;
|
2024-01-15 20:20:47 +01:00
|
|
|
const char *name;
|
2010-06-07 15:52:43 +02:00
|
|
|
GIFunctionInfo *invoker;
|
|
|
|
gboolean deprecated;
|
2024-01-16 01:00:07 +01:00
|
|
|
size_t offset;
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
name = gi_base_info_get_name ((GIBaseInfo *)info);
|
|
|
|
flags = gi_vfunc_info_get_flags (info);
|
|
|
|
deprecated = gi_base_info_is_deprecated ((GIBaseInfo *)info);
|
|
|
|
offset = gi_vfunc_info_get_offset (info);
|
|
|
|
invoker = gi_vfunc_info_get_invoker (info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_start_element (file, "virtual-method");
|
|
|
|
xml_printf (file, " name=\"%s\"", name);
|
|
|
|
|
|
|
|
if (deprecated)
|
|
|
|
xml_printf (file, " deprecated=\"1\"");
|
|
|
|
|
|
|
|
if (flags & GI_VFUNC_MUST_CHAIN_UP)
|
|
|
|
xml_printf (file, " must-chain-up=\"1\"");
|
|
|
|
|
|
|
|
if (flags & GI_VFUNC_MUST_OVERRIDE)
|
|
|
|
xml_printf (file, " override=\"always\"");
|
|
|
|
else if (flags & GI_VFUNC_MUST_NOT_OVERRIDE)
|
|
|
|
xml_printf (file, " override=\"never\"");
|
|
|
|
|
2024-01-16 01:00:07 +01:00
|
|
|
xml_printf (file, " offset=\"%zu\"", offset);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
if (invoker)
|
2021-05-20 13:40:23 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
xml_printf (file, " invoker=\"%s\"", gi_base_info_get_name ((GIBaseInfo*)invoker));
|
|
|
|
gi_base_info_unref ((GIBaseInfo *)invoker);
|
2021-05-20 13:40:23 +02:00
|
|
|
}
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 01:23:35 +01:00
|
|
|
write_callable_info (ns, (GICallableInfo*)info, file);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_end_element (file, "virtual-method");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2024-01-15 20:20:47 +01:00
|
|
|
write_property_info (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GIPropertyInfo *info,
|
|
|
|
Xml *file)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
|
|
|
GParamFlags flags;
|
2024-01-15 20:20:47 +01:00
|
|
|
const char *name;
|
2010-06-07 15:52:43 +02:00
|
|
|
gboolean deprecated;
|
|
|
|
GITypeInfo *type;
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
name = gi_base_info_get_name ((GIBaseInfo *)info);
|
|
|
|
flags = gi_property_info_get_flags (info);
|
|
|
|
deprecated = gi_base_info_is_deprecated ((GIBaseInfo *)info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_start_element (file, "property");
|
|
|
|
xml_printf (file, " name=\"%s\"", name);
|
|
|
|
|
|
|
|
if (deprecated)
|
|
|
|
xml_printf (file, " deprecated=\"1\"");
|
|
|
|
|
|
|
|
/* Properties are assumed to be read-only (see also girwriter.py) */
|
|
|
|
if (!(flags & G_PARAM_READABLE))
|
|
|
|
xml_printf (file, " readable=\"0\"");
|
|
|
|
if (flags & G_PARAM_WRITABLE)
|
|
|
|
xml_printf (file, " writable=\"1\"");
|
|
|
|
|
|
|
|
if (flags & G_PARAM_CONSTRUCT)
|
|
|
|
xml_printf (file, " construct=\"1\"");
|
|
|
|
|
|
|
|
if (flags & G_PARAM_CONSTRUCT_ONLY)
|
|
|
|
xml_printf (file, " construct-only=\"1\"");
|
|
|
|
|
Add introspection data for property accessors
A GObject property can be accessed generically through the GObject API,
e.g. g_object_set_property() and g_object_get_property(). Properties
typically also have public accessor functions, which are (according to
our own best practices) called through the generic API.
The introspection data is currently missing the relation between a
property and its public accessor functions. With this information, a
language binding could, for instance, avoid exposing the C API entirely,
thus minimizing the chances of collisions between property names and
accessor functions; alternatively, a binding could call the C API
directly instead of going through the generic GObject API, thus avoiding
the boxing and unboxing from a native type to a GIArgument and finally
into a GValue, and vice versa.
In the GIR, we add two new attributes to the `property` element:
- setter="SYMBOL"
- getter="SYMBOL"
where "symbol" is the C function identifier of the setter and getter
functions, respectively. The `setter` attribute is only applied to
writable, non-construct-only properties; the `getter` attribute is only
applied to readable properties.
We maintain the ABI compatibility of the typelib data by using 20 bits
of the 25 reserved bits inside the PropertyBlob structure. The data is
exposed through two new GIPropertyInfo methods:
- g_property_info_get_setter()
- g_property_info_get_getter()
which return the GIFunctionInfo for the setter and getter functions,
respectively.
2021-06-17 14:07:35 +02:00
|
|
|
if (flags & G_PARAM_READABLE)
|
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GIFunctionInfo *getter = gi_property_info_get_getter (info);
|
Add introspection data for property accessors
A GObject property can be accessed generically through the GObject API,
e.g. g_object_set_property() and g_object_get_property(). Properties
typically also have public accessor functions, which are (according to
our own best practices) called through the generic API.
The introspection data is currently missing the relation between a
property and its public accessor functions. With this information, a
language binding could, for instance, avoid exposing the C API entirely,
thus minimizing the chances of collisions between property names and
accessor functions; alternatively, a binding could call the C API
directly instead of going through the generic GObject API, thus avoiding
the boxing and unboxing from a native type to a GIArgument and finally
into a GValue, and vice versa.
In the GIR, we add two new attributes to the `property` element:
- setter="SYMBOL"
- getter="SYMBOL"
where "symbol" is the C function identifier of the setter and getter
functions, respectively. The `setter` attribute is only applied to
writable, non-construct-only properties; the `getter` attribute is only
applied to readable properties.
We maintain the ABI compatibility of the typelib data by using 20 bits
of the 25 reserved bits inside the PropertyBlob structure. The data is
exposed through two new GIPropertyInfo methods:
- g_property_info_get_setter()
- g_property_info_get_getter()
which return the GIFunctionInfo for the setter and getter functions,
respectively.
2021-06-17 14:07:35 +02:00
|
|
|
|
|
|
|
if (getter != NULL)
|
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
xml_printf (file, " getter=\"%s\"", gi_base_info_get_name ((GIBaseInfo *) getter));
|
|
|
|
gi_base_info_unref ((GIBaseInfo *) getter);
|
Add introspection data for property accessors
A GObject property can be accessed generically through the GObject API,
e.g. g_object_set_property() and g_object_get_property(). Properties
typically also have public accessor functions, which are (according to
our own best practices) called through the generic API.
The introspection data is currently missing the relation between a
property and its public accessor functions. With this information, a
language binding could, for instance, avoid exposing the C API entirely,
thus minimizing the chances of collisions between property names and
accessor functions; alternatively, a binding could call the C API
directly instead of going through the generic GObject API, thus avoiding
the boxing and unboxing from a native type to a GIArgument and finally
into a GValue, and vice versa.
In the GIR, we add two new attributes to the `property` element:
- setter="SYMBOL"
- getter="SYMBOL"
where "symbol" is the C function identifier of the setter and getter
functions, respectively. The `setter` attribute is only applied to
writable, non-construct-only properties; the `getter` attribute is only
applied to readable properties.
We maintain the ABI compatibility of the typelib data by using 20 bits
of the 25 reserved bits inside the PropertyBlob structure. The data is
exposed through two new GIPropertyInfo methods:
- g_property_info_get_setter()
- g_property_info_get_getter()
which return the GIFunctionInfo for the setter and getter functions,
respectively.
2021-06-17 14:07:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & G_PARAM_WRITABLE)
|
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GIFunctionInfo *setter = gi_property_info_get_setter (info);
|
Add introspection data for property accessors
A GObject property can be accessed generically through the GObject API,
e.g. g_object_set_property() and g_object_get_property(). Properties
typically also have public accessor functions, which are (according to
our own best practices) called through the generic API.
The introspection data is currently missing the relation between a
property and its public accessor functions. With this information, a
language binding could, for instance, avoid exposing the C API entirely,
thus minimizing the chances of collisions between property names and
accessor functions; alternatively, a binding could call the C API
directly instead of going through the generic GObject API, thus avoiding
the boxing and unboxing from a native type to a GIArgument and finally
into a GValue, and vice versa.
In the GIR, we add two new attributes to the `property` element:
- setter="SYMBOL"
- getter="SYMBOL"
where "symbol" is the C function identifier of the setter and getter
functions, respectively. The `setter` attribute is only applied to
writable, non-construct-only properties; the `getter` attribute is only
applied to readable properties.
We maintain the ABI compatibility of the typelib data by using 20 bits
of the 25 reserved bits inside the PropertyBlob structure. The data is
exposed through two new GIPropertyInfo methods:
- g_property_info_get_setter()
- g_property_info_get_getter()
which return the GIFunctionInfo for the setter and getter functions,
respectively.
2021-06-17 14:07:35 +02:00
|
|
|
|
|
|
|
if (setter != NULL)
|
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
xml_printf (file, " setter=\"%s\"", gi_base_info_get_name ((GIBaseInfo *) setter));
|
|
|
|
gi_base_info_unref ((GIBaseInfo *) setter);
|
Add introspection data for property accessors
A GObject property can be accessed generically through the GObject API,
e.g. g_object_set_property() and g_object_get_property(). Properties
typically also have public accessor functions, which are (according to
our own best practices) called through the generic API.
The introspection data is currently missing the relation between a
property and its public accessor functions. With this information, a
language binding could, for instance, avoid exposing the C API entirely,
thus minimizing the chances of collisions between property names and
accessor functions; alternatively, a binding could call the C API
directly instead of going through the generic GObject API, thus avoiding
the boxing and unboxing from a native type to a GIArgument and finally
into a GValue, and vice versa.
In the GIR, we add two new attributes to the `property` element:
- setter="SYMBOL"
- getter="SYMBOL"
where "symbol" is the C function identifier of the setter and getter
functions, respectively. The `setter` attribute is only applied to
writable, non-construct-only properties; the `getter` attribute is only
applied to readable properties.
We maintain the ABI compatibility of the typelib data by using 20 bits
of the 25 reserved bits inside the PropertyBlob structure. The data is
exposed through two new GIPropertyInfo methods:
- g_property_info_get_setter()
- g_property_info_get_getter()
which return the GIFunctionInfo for the setter and getter functions,
respectively.
2021-06-17 14:07:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
write_ownership_transfer (gi_property_info_get_ownership_transfer (info), file);
|
2010-06-08 16:40:35 +02:00
|
|
|
|
2010-06-07 15:52:43 +02:00
|
|
|
write_attributes (file, (GIBaseInfo*) info);
|
|
|
|
|
2023-11-28 18:09:26 +01:00
|
|
|
type = gi_property_info_get_type_info (info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 01:23:35 +01:00
|
|
|
write_type_info (ns, type, file);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_end_element (file, "property");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2024-01-15 20:20:47 +01:00
|
|
|
write_object_info (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GIObjectInfo *info,
|
|
|
|
Xml *file)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2024-01-15 20:20:47 +01:00
|
|
|
const char *name;
|
|
|
|
const char *type_name;
|
|
|
|
const char *type_init;
|
|
|
|
const char *func;
|
2010-06-07 15:52:43 +02:00
|
|
|
gboolean deprecated;
|
|
|
|
gboolean is_abstract;
|
2010-06-12 23:08:56 +02:00
|
|
|
gboolean is_fundamental;
|
2021-02-09 12:38:27 +01:00
|
|
|
gboolean is_final;
|
2010-06-07 15:52:43 +02:00
|
|
|
GIObjectInfo *pnode;
|
|
|
|
GIStructInfo *class_struct;
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
name = gi_base_info_get_name ((GIBaseInfo *)info);
|
|
|
|
deprecated = gi_base_info_is_deprecated ((GIBaseInfo *)info);
|
|
|
|
is_abstract = gi_object_info_get_abstract (info);
|
|
|
|
is_fundamental = gi_object_info_get_fundamental (info);
|
|
|
|
is_final = gi_object_info_get_final (info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
type_name = gi_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info);
|
2023-12-12 18:54:19 +01:00
|
|
|
type_init = gi_registered_type_info_get_type_init_function_name ((GIRegisteredTypeInfo*)info);
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_start_element (file, "class");
|
|
|
|
xml_printf (file, " name=\"%s\"", name);
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
pnode = gi_object_info_get_parent (info);
|
2010-06-07 15:52:43 +02:00
|
|
|
if (pnode)
|
|
|
|
{
|
2023-11-08 01:23:35 +01:00
|
|
|
write_type_name_attribute (ns, (GIBaseInfo *)pnode, "parent", file);
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)pnode);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
class_struct = gi_object_info_get_class_struct (info);
|
2010-06-07 15:52:43 +02:00
|
|
|
if (class_struct)
|
|
|
|
{
|
2023-11-08 01:23:35 +01:00
|
|
|
write_type_name_attribute (ns, (GIBaseInfo*) class_struct, "glib:type-struct", file);
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo*)class_struct);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (is_abstract)
|
|
|
|
xml_printf (file, " abstract=\"1\"");
|
|
|
|
|
2021-02-09 12:38:27 +01:00
|
|
|
if (is_final)
|
|
|
|
xml_printf (file, " final=\"1\"");
|
|
|
|
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_printf (file, " glib:type-name=\"%s\" glib:get-type=\"%s\"", type_name, type_init);
|
|
|
|
|
2010-06-12 23:08:56 +02:00
|
|
|
if (is_fundamental)
|
|
|
|
xml_printf (file, " glib:fundamental=\"1\"");
|
|
|
|
|
2023-12-12 19:07:50 +01:00
|
|
|
func = gi_object_info_get_unref_function_name (info);
|
2010-06-12 23:08:56 +02:00
|
|
|
if (func)
|
|
|
|
xml_printf (file, " glib:unref-function=\"%s\"", func);
|
|
|
|
|
2023-12-12 19:07:50 +01:00
|
|
|
func = gi_object_info_get_ref_function_name (info);
|
2010-06-12 23:08:56 +02:00
|
|
|
if (func)
|
|
|
|
xml_printf (file, " glib:ref-function=\"%s\"", func);
|
|
|
|
|
2023-12-12 19:07:50 +01:00
|
|
|
func = gi_object_info_get_set_value_function_name (info);
|
2010-06-12 23:08:56 +02:00
|
|
|
if (func)
|
|
|
|
xml_printf (file, " glib:set-value-function=\"%s\"", func);
|
|
|
|
|
2023-12-12 19:07:50 +01:00
|
|
|
func = gi_object_info_get_get_value_function_name (info);
|
2010-06-12 23:08:56 +02:00
|
|
|
if (func)
|
|
|
|
xml_printf (file, " glib:get-value-function=\"%s\"", func);
|
|
|
|
|
2010-06-07 15:52:43 +02:00
|
|
|
if (deprecated)
|
|
|
|
xml_printf (file, " deprecated=\"1\"");
|
|
|
|
|
|
|
|
write_attributes (file, (GIBaseInfo*) info);
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
if (gi_object_info_get_n_interfaces (info) > 0)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_object_info_get_n_interfaces (info); i++)
|
2024-01-16 17:30:37 +01:00
|
|
|
{
|
|
|
|
GIInterfaceInfo *imp = gi_object_info_get_interface (info, i);
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_start_element (file, "implements");
|
2024-01-16 17:30:37 +01:00
|
|
|
write_type_name_attribute (ns, (GIBaseInfo *)imp, "name", file);
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_end_element (file, "implements");
|
2024-01-16 17:30:37 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo*)imp);
|
|
|
|
}
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_object_info_get_n_fields (info); i++)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GIFieldInfo *field = gi_object_info_get_field (info, i);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_field_info (ns, field, NULL, file);
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)field);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_object_info_get_n_methods (info); i++)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GIFunctionInfo *function = gi_object_info_get_method (info, i);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_function_info (ns, function, file);
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)function);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_object_info_get_n_properties (info); i++)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GIPropertyInfo *prop = gi_object_info_get_property (info, i);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_property_info (ns, prop, file);
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)prop);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_object_info_get_n_signals (info); i++)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GISignalInfo *signal = gi_object_info_get_signal (info, i);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_signal_info (ns, signal, file);
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)signal);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_object_info_get_n_vfuncs (info); i++)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GIVFuncInfo *vfunc = gi_object_info_get_vfunc (info, i);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_vfunc_info (ns, vfunc, file);
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)vfunc);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_object_info_get_n_constants (info); i++)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GIConstantInfo *constant = gi_object_info_get_constant (info, i);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_constant_info (ns, constant, file);
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)constant);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
xml_end_element (file, "class");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2024-01-15 20:20:47 +01:00
|
|
|
write_interface_info (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GIInterfaceInfo *info,
|
|
|
|
Xml *file)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2024-01-15 20:20:47 +01:00
|
|
|
const char *name;
|
|
|
|
const char *type_name;
|
|
|
|
const char *type_init;
|
2010-06-07 15:52:43 +02:00
|
|
|
GIStructInfo *class_struct;
|
|
|
|
gboolean deprecated;
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
name = gi_base_info_get_name ((GIBaseInfo *)info);
|
|
|
|
deprecated = gi_base_info_is_deprecated ((GIBaseInfo *)info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
type_name = gi_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info);
|
2023-12-12 18:54:19 +01:00
|
|
|
type_init = gi_registered_type_info_get_type_init_function_name ((GIRegisteredTypeInfo*)info);
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_start_element (file, "interface");
|
|
|
|
xml_printf (file, " name=\"%s\" glib:type-name=\"%s\" glib:get-type=\"%s\"",
|
2024-01-16 17:30:37 +01:00
|
|
|
name, type_name, type_init);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
class_struct = gi_interface_info_get_iface_struct (info);
|
2010-06-07 15:52:43 +02:00
|
|
|
if (class_struct)
|
|
|
|
{
|
2023-11-08 01:23:35 +01:00
|
|
|
write_type_name_attribute (ns, (GIBaseInfo*) class_struct, "glib:type-struct", file);
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo*)class_struct);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (deprecated)
|
|
|
|
xml_printf (file, " deprecated=\"1\"");
|
|
|
|
|
|
|
|
write_attributes (file, (GIBaseInfo*) info);
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
if (gi_interface_info_get_n_prerequisites (info) > 0)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_interface_info_get_n_prerequisites (info); i++)
|
2024-01-16 17:30:37 +01:00
|
|
|
{
|
|
|
|
GIBaseInfo *req = gi_interface_info_get_prerequisite (info, i);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2024-01-16 17:30:37 +01:00
|
|
|
xml_start_element (file, "prerequisite");
|
|
|
|
write_type_name_attribute (ns, req, "name", file);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_end_element_unchecked (file);
|
2024-01-16 17:30:37 +01:00
|
|
|
gi_base_info_unref (req);
|
|
|
|
}
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_interface_info_get_n_methods (info); i++)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GIFunctionInfo *function = gi_interface_info_get_method (info, i);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_function_info (ns, function, file);
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)function);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_interface_info_get_n_properties (info); i++)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GIPropertyInfo *prop = gi_interface_info_get_property (info, i);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_property_info (ns, prop, file);
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)prop);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_interface_info_get_n_signals (info); i++)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GISignalInfo *signal = gi_interface_info_get_signal (info, i);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_signal_info (ns, signal, file);
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)signal);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_interface_info_get_n_vfuncs (info); i++)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GIVFuncInfo *vfunc = gi_interface_info_get_vfunc (info, i);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_vfunc_info (ns, vfunc, file);
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)vfunc);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_interface_info_get_n_constants (info); i++)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GIConstantInfo *constant = gi_interface_info_get_constant (info, i);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_constant_info (ns, constant, file);
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)constant);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
xml_end_element (file, "interface");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2024-01-15 22:20:02 +01:00
|
|
|
write_union_info (const char *ns,
|
2024-01-16 17:30:37 +01:00
|
|
|
GIUnionInfo *info,
|
|
|
|
Xml *file)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2024-01-15 20:20:47 +01:00
|
|
|
const char *name;
|
|
|
|
const char *type_name;
|
|
|
|
const char *type_init;
|
|
|
|
const char *func;
|
2010-06-07 15:52:43 +02:00
|
|
|
gboolean deprecated;
|
2024-01-16 00:35:23 +01:00
|
|
|
size_t size;
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
name = gi_base_info_get_name ((GIBaseInfo *)info);
|
|
|
|
deprecated = gi_base_info_is_deprecated ((GIBaseInfo *)info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
type_name = gi_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info);
|
2023-12-12 18:54:19 +01:00
|
|
|
type_init = gi_registered_type_info_get_type_init_function_name ((GIRegisteredTypeInfo*)info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_start_element (file, "union");
|
|
|
|
xml_printf (file, " name=\"%s\"", name);
|
|
|
|
|
|
|
|
if (type_name)
|
|
|
|
xml_printf (file, " type-name=\"%s\" get-type=\"%s\"", type_name, type_init);
|
|
|
|
|
|
|
|
if (deprecated)
|
|
|
|
xml_printf (file, " deprecated=\"1\"");
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
size = gi_union_info_get_size (info);
|
2023-12-12 19:39:22 +01:00
|
|
|
if (file->show_all)
|
|
|
|
xml_printf (file, " size=\"%" G_GSIZE_FORMAT "\"", size);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-12-12 19:41:07 +01:00
|
|
|
func = gi_union_info_get_copy_function_name (info);
|
2022-10-29 19:09:23 +02:00
|
|
|
if (func)
|
|
|
|
xml_printf (file, " copy-function=\"%s\"", func);
|
|
|
|
|
2023-12-12 19:41:07 +01:00
|
|
|
func = gi_union_info_get_free_function_name (info);
|
2022-10-29 19:09:23 +02:00
|
|
|
if (func)
|
|
|
|
xml_printf (file, " free-function=\"%s\"", func);
|
|
|
|
|
2010-06-07 15:52:43 +02:00
|
|
|
write_attributes (file, (GIBaseInfo*) info);
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
if (gi_union_info_is_discriminated (info))
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2024-01-16 01:00:07 +01:00
|
|
|
size_t offset;
|
2010-06-07 15:52:43 +02:00
|
|
|
GITypeInfo *type;
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
offset = gi_union_info_get_discriminator_offset (info);
|
|
|
|
type = gi_union_info_get_discriminator_type (info);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_start_element (file, "discriminator");
|
2024-01-16 01:00:07 +01:00
|
|
|
xml_printf (file, " offset=\"%zu\" type=\"", offset);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_type_info (ns, type, file);
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_end_element (file, "discriminator");
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)type);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_union_info_get_n_fields (info); i++)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GIFieldInfo *field = gi_union_info_get_field (info, i);
|
|
|
|
GIConstantInfo *constant = gi_union_info_get_discriminator (info, i);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_field_info (ns, field, constant, file);
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)field);
|
2010-06-07 15:52:43 +02:00
|
|
|
if (constant)
|
2024-01-16 17:30:37 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)constant);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
2024-01-15 22:20:02 +01:00
|
|
|
for (unsigned int i = 0; i < gi_union_info_get_n_methods (info); i++)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
2023-11-08 15:17:52 +01:00
|
|
|
GIFunctionInfo *function = gi_union_info_get_method (info, i);
|
2023-11-08 01:23:35 +01:00
|
|
|
write_function_info (ns, function, file);
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_base_info_unref ((GIBaseInfo *)function);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
xml_end_element (file, "union");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-12-13 14:25:11 +01:00
|
|
|
/**
|
2023-11-08 15:17:52 +01:00
|
|
|
* gi_ir_writer_write:
|
2023-12-13 14:25:11 +01:00
|
|
|
* @filename: (type filename): filename to write to
|
2023-11-08 01:23:35 +01:00
|
|
|
* @ns: GIR namespace to write
|
2010-06-12 02:06:31 +02:00
|
|
|
* @needs_prefix: if the filename needs prefixing
|
|
|
|
* @show_all: if field size calculations should be included
|
2010-06-07 15:52:43 +02:00
|
|
|
*
|
2023-11-08 01:23:35 +01:00
|
|
|
* Writes the output of a typelib represented by @ns
|
2010-06-07 15:52:43 +02:00
|
|
|
* into a GIR xml file named @filename.
|
2023-12-13 14:25:11 +01:00
|
|
|
*
|
|
|
|
* Since: 2.80
|
2010-06-07 15:52:43 +02:00
|
|
|
*/
|
|
|
|
void
|
2023-11-08 15:17:52 +01:00
|
|
|
gi_ir_writer_write (const char *filename,
|
|
|
|
const char *ns,
|
|
|
|
gboolean needs_prefix,
|
|
|
|
gboolean show_all)
|
2010-06-07 15:52:43 +02:00
|
|
|
{
|
|
|
|
FILE *ofile;
|
2024-01-16 01:00:07 +01:00
|
|
|
size_t i, j;
|
2010-06-07 15:52:43 +02:00
|
|
|
char **dependencies;
|
2024-01-26 11:32:52 +01:00
|
|
|
GIRepository *repository = NULL;
|
2010-06-07 15:52:43 +02:00
|
|
|
Xml *xml;
|
|
|
|
|
2024-01-26 11:32:52 +01:00
|
|
|
repository = gi_repository_new ();
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
if (filename == NULL)
|
|
|
|
ofile = stdout;
|
|
|
|
else
|
|
|
|
{
|
2024-01-15 20:20:47 +01:00
|
|
|
char *full_filename;
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
if (needs_prefix)
|
2024-01-16 17:30:37 +01:00
|
|
|
full_filename = g_strdup_printf ("%s-%s", ns, filename);
|
2010-06-07 15:52:43 +02:00
|
|
|
else
|
2024-01-16 17:30:37 +01:00
|
|
|
full_filename = g_strdup (filename);
|
2010-06-07 15:52:43 +02:00
|
|
|
ofile = g_fopen (filename, "w");
|
|
|
|
|
|
|
|
if (ofile == NULL)
|
2024-01-16 17:30:37 +01:00
|
|
|
{
|
|
|
|
g_fprintf (stderr, "failed to open '%s': %s\n",
|
|
|
|
full_filename, g_strerror (errno));
|
|
|
|
g_free (full_filename);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2024-01-16 17:30:37 +01:00
|
|
|
return;
|
|
|
|
}
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
g_free (full_filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
xml = xml_open (ofile);
|
|
|
|
xml->show_all = show_all;
|
|
|
|
xml_printf (xml, "<?xml version=\"1.0\"?>\n");
|
|
|
|
xml_start_element (xml, "repository");
|
|
|
|
xml_printf (xml, " version=\"1.0\"\n"
|
2024-01-16 17:30:37 +01:00
|
|
|
" 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\"");
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
dependencies = gi_repository_get_immediate_dependencies (repository, ns);
|
2010-06-07 15:52:43 +02:00
|
|
|
if (dependencies != NULL)
|
|
|
|
{
|
|
|
|
for (i = 0; dependencies[i]; i++)
|
2024-01-16 17:30:37 +01:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (TRUE)
|
|
|
|
{
|
2024-01-05 13:33:02 +01:00
|
|
|
const char * const *shared_libraries;
|
2024-01-15 20:20:47 +01:00
|
|
|
const char *c_prefix;
|
2023-11-08 01:23:35 +01:00
|
|
|
const char *cur_ns = ns;
|
|
|
|
const char *cur_version;
|
2024-01-16 01:00:07 +01:00
|
|
|
unsigned int n_infos;
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
cur_version = gi_repository_get_version (repository, cur_ns);
|
2010-06-07 15:52:43 +02:00
|
|
|
|
2024-01-05 13:33:02 +01:00
|
|
|
shared_libraries = gi_repository_get_shared_libraries (repository, cur_ns, NULL);
|
2023-11-08 15:17:52 +01:00
|
|
|
c_prefix = gi_repository_get_c_prefix (repository, cur_ns);
|
2010-06-07 15:52:43 +02:00
|
|
|
xml_start_element (xml, "namespace");
|
2023-11-08 01:23:35 +01:00
|
|
|
xml_printf (xml, " name=\"%s\" version=\"%s\"", cur_ns, cur_version);
|
2024-01-05 13:33:02 +01:00
|
|
|
if (shared_libraries != NULL)
|
|
|
|
{
|
|
|
|
char *shared_libraries_str = g_strjoinv (",", (char **) shared_libraries);
|
|
|
|
xml_printf (xml, " shared-library=\"%s\"", shared_libraries_str);
|
|
|
|
g_free (shared_libraries_str);
|
|
|
|
}
|
2010-06-07 15:52:43 +02:00
|
|
|
if (c_prefix)
|
|
|
|
xml_printf (xml, " c:prefix=\"%s\"", c_prefix);
|
|
|
|
|
2023-11-08 15:17:52 +01:00
|
|
|
n_infos = gi_repository_get_n_infos (repository, cur_ns);
|
2010-10-21 20:59:42 +02:00
|
|
|
for (j = 0; j < n_infos; j++)
|
2024-01-16 17:30:37 +01:00
|
|
|
{
|
|
|
|
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_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_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_OBJECT:
|
|
|
|
write_object_info (ns, (GIObjectInfo *)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));
|
|
|
|
}
|
|
|
|
|
|
|
|
gi_base_info_unref (info);
|
|
|
|
}
|
2010-06-07 15:52:43 +02:00
|
|
|
|
|
|
|
xml_end_element (xml, "namespace");
|
|
|
|
}
|
|
|
|
|
|
|
|
xml_end_element (xml, "repository");
|
|
|
|
|
|
|
|
xml_free (xml);
|
2024-01-26 11:32:52 +01:00
|
|
|
|
|
|
|
g_clear_object (&repository);
|
2010-06-07 15:52:43 +02:00
|
|
|
}
|