mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
Don't require c:type. Test boxed.gir Update, remove parts we don't support
2008-08-14 Johan Dahlin <johan@gnome.org> * girepository/girparser.c (start_type): Don't require c:type. * tests/Makefile.am: Test boxed.gir * tests/boxed.gir: Update, remove parts we don't support yet * tests/roundtrips.sh: Remove * tools/generate.c (write_type_info), (write_field_info), (write_callable_info), (write_struct_info): Make it emit proper gir. svn path=/trunk/; revision=376
This commit is contained in:
parent
c2bbd6ecba
commit
8ed19c3d86
@ -54,24 +54,24 @@ write_type_info (const gchar *namespace,
|
|||||||
GITypeInfo *type;
|
GITypeInfo *type;
|
||||||
|
|
||||||
const gchar* basic[] = {
|
const gchar* basic[] = {
|
||||||
"void",
|
"none",
|
||||||
"gboolean",
|
"boolean",
|
||||||
"gint8",
|
"int8",
|
||||||
"guint8",
|
"uint8",
|
||||||
"gint16",
|
"int16",
|
||||||
"guint16",
|
"uint16",
|
||||||
"gint32",
|
"int32",
|
||||||
"guint32",
|
"uint32",
|
||||||
"gint64",
|
"int64",
|
||||||
"guint64",
|
"uint64",
|
||||||
"gint",
|
"int",
|
||||||
"guint",
|
"uint",
|
||||||
"glong",
|
"long",
|
||||||
"gulong",
|
"ulong",
|
||||||
"gssize",
|
"ssize",
|
||||||
"gsize",
|
"size",
|
||||||
"gfloat",
|
"float",
|
||||||
"gdouble",
|
"double",
|
||||||
"utf8",
|
"utf8",
|
||||||
"filename"
|
"filename"
|
||||||
};
|
};
|
||||||
@ -200,21 +200,16 @@ write_field_info (const gchar *namespace,
|
|||||||
offset = g_field_info_get_offset (info);
|
offset = g_field_info_get_offset (info);
|
||||||
|
|
||||||
g_fprintf (file,
|
g_fprintf (file,
|
||||||
" <field name=\"%s\" readable=\"%s\" writable=\"%s\" ",
|
" <field name=\"%s\" readable=\"%s\" writable=\"%s\"",
|
||||||
name,
|
name,
|
||||||
flags & GI_FIELD_IS_READABLE ? "1" : "0",
|
flags & GI_FIELD_IS_READABLE ? "1" : "0",
|
||||||
flags & GI_FIELD_IS_WRITABLE ? "1" : "0");
|
flags & GI_FIELD_IS_WRITABLE ? "1" : "0");
|
||||||
if (size)
|
if (size)
|
||||||
g_fprintf (file, "bits=\"%d\" ", size);
|
g_fprintf (file, " bits=\"%d\"", size);
|
||||||
g_fprintf (file, "offset=\"%d\" ", offset);
|
|
||||||
|
|
||||||
g_fprintf (file, "type=\"");
|
g_fprintf (file, " offset=\"%d\"", offset);
|
||||||
|
|
||||||
type = g_field_info_get_type (info);
|
type = g_field_info_get_type (info);
|
||||||
write_type_info (namespace, type, file);
|
|
||||||
g_base_info_unref ((GIBaseInfo *)type);
|
|
||||||
|
|
||||||
g_fprintf (file, "\"");
|
|
||||||
|
|
||||||
if (branch)
|
if (branch)
|
||||||
{
|
{
|
||||||
@ -225,7 +220,17 @@ write_field_info (const gchar *namespace,
|
|||||||
g_fprintf (file, "\"");
|
g_fprintf (file, "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
g_fprintf (file," />\n");
|
g_fprintf (file,">\n");
|
||||||
|
|
||||||
|
g_fprintf (file, " <type name=\"");
|
||||||
|
|
||||||
|
write_type_info (namespace, type, file);
|
||||||
|
g_base_info_unref ((GIBaseInfo *)type);
|
||||||
|
|
||||||
|
g_fprintf (file, "\"/>\n");
|
||||||
|
|
||||||
|
g_fprintf (file, " </field>\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -237,12 +242,9 @@ write_callable_info (const gchar *namespace,
|
|||||||
GITypeInfo *type;
|
GITypeInfo *type;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
g_fprintf (file, "%*s <return-type c:type=\"", indent, "");
|
g_fprintf (file, "%*s <return-value>\n", indent, "");
|
||||||
|
|
||||||
type = g_callable_info_get_return_type (info);
|
type = g_callable_info_get_return_type (info);
|
||||||
write_type_info (namespace, type, file);
|
|
||||||
|
|
||||||
g_fprintf (file, "\"");
|
|
||||||
|
|
||||||
if (g_type_info_is_pointer (type))
|
if (g_type_info_is_pointer (type))
|
||||||
{
|
{
|
||||||
@ -265,75 +267,86 @@ write_callable_info (const gchar *namespace,
|
|||||||
if (g_callable_info_may_return_null (info))
|
if (g_callable_info_may_return_null (info))
|
||||||
g_fprintf (file, " null-ok=\"1\"");
|
g_fprintf (file, " null-ok=\"1\"");
|
||||||
|
|
||||||
g_fprintf (file, " />\n");
|
g_fprintf (file, "%*s <type name=\"", indent + 2, "");
|
||||||
|
|
||||||
|
write_type_info (namespace, type, file);
|
||||||
|
|
||||||
|
g_fprintf (file, "\"/>\n");
|
||||||
|
|
||||||
|
g_fprintf (file, "%*s </return-value>\n", indent, "");
|
||||||
|
|
||||||
if (g_callable_info_get_n_args (info) > 0)
|
if (g_callable_info_get_n_args (info) <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_fprintf (file, "%*s <parameters>\n", indent, "");
|
||||||
|
for (i = 0; i < g_callable_info_get_n_args (info); i++)
|
||||||
{
|
{
|
||||||
g_fprintf (file, "%*s <parameters>\n", indent, "");
|
GIArgInfo *arg = g_callable_info_get_arg (info, i);
|
||||||
for (i = 0; i < g_callable_info_get_n_args (info); i++)
|
|
||||||
|
g_fprintf (file, "%*s <parameter name=\"%s\"",
|
||||||
|
indent, "", g_base_info_get_name ((GIBaseInfo *) arg));
|
||||||
|
|
||||||
|
if (g_type_info_is_pointer (type))
|
||||||
{
|
{
|
||||||
GIArgInfo *arg = g_callable_info_get_arg (info, i);
|
switch (g_arg_info_get_ownership_transfer (arg))
|
||||||
|
|
||||||
g_fprintf (file, "%*s <parameter name=\"%s\" c:type=\"",
|
|
||||||
indent, "", g_base_info_get_name ((GIBaseInfo *) arg));
|
|
||||||
|
|
||||||
type = g_arg_info_get_type (arg);
|
|
||||||
write_type_info (namespace, type, file);
|
|
||||||
g_fprintf (file, "\"");
|
|
||||||
|
|
||||||
if (g_type_info_is_pointer (type))
|
|
||||||
{
|
{
|
||||||
switch (g_arg_info_get_ownership_transfer (arg))
|
case GI_TRANSFER_NOTHING:
|
||||||
{
|
g_fprintf (file, " transfer=\"none\"");
|
||||||
case GI_TRANSFER_NOTHING:
|
|
||||||
g_fprintf (file, " transfer=\"none\"");
|
|
||||||
break;
|
|
||||||
case GI_TRANSFER_CONTAINER:
|
|
||||||
g_fprintf (file, " transfer=\"shallow\"");
|
|
||||||
break;
|
|
||||||
case GI_TRANSFER_EVERYTHING:
|
|
||||||
g_fprintf (file, " transfer=\"full\"");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_base_info_unref ((GIBaseInfo *)type);
|
|
||||||
|
|
||||||
g_fprintf (file, " direction=\"");
|
|
||||||
switch (g_arg_info_get_direction (arg))
|
|
||||||
{
|
|
||||||
case GI_DIRECTION_IN:
|
|
||||||
g_fprintf (file, "in");
|
|
||||||
break;
|
break;
|
||||||
case GI_DIRECTION_OUT:
|
case GI_TRANSFER_CONTAINER:
|
||||||
g_fprintf (file, "out");
|
g_fprintf (file, " transfer=\"shallow\"");
|
||||||
break;
|
break;
|
||||||
case GI_DIRECTION_INOUT:
|
case GI_TRANSFER_EVERYTHING:
|
||||||
g_fprintf (file, "inout");
|
g_fprintf (file, " transfer=\"full\"");
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
g_fprintf (file, "\"");
|
}
|
||||||
|
g_base_info_unref ((GIBaseInfo *)type);
|
||||||
if (g_arg_info_may_be_null (arg))
|
|
||||||
g_fprintf (file, " null-ok=\"1\"");
|
g_fprintf (file, " direction=\"");
|
||||||
|
switch (g_arg_info_get_direction (arg))
|
||||||
if (g_arg_info_is_dipper (arg))
|
{
|
||||||
g_fprintf (file, " dipper=\"1\"");
|
case GI_DIRECTION_IN:
|
||||||
|
g_fprintf (file, "in");
|
||||||
if (g_arg_info_is_return_value (arg))
|
break;
|
||||||
g_fprintf (file, " retval=\"1\"");
|
case GI_DIRECTION_OUT:
|
||||||
|
g_fprintf (file, "out");
|
||||||
if (g_arg_info_is_optional (arg))
|
break;
|
||||||
g_fprintf (file, " optional=\"1\"");
|
case GI_DIRECTION_INOUT:
|
||||||
|
g_fprintf (file, "inout");
|
||||||
g_fprintf (file, " />\n");
|
break;
|
||||||
|
|
||||||
g_base_info_unref ((GIBaseInfo *)arg);
|
|
||||||
}
|
}
|
||||||
|
g_fprintf (file, "\"");
|
||||||
g_fprintf (file, "%*s </parameters>\n", indent, "");
|
|
||||||
|
if (g_arg_info_may_be_null (arg))
|
||||||
|
g_fprintf (file, " null-ok=\"1\"");
|
||||||
|
|
||||||
|
if (g_arg_info_is_dipper (arg))
|
||||||
|
g_fprintf (file, " dipper=\"1\"");
|
||||||
|
|
||||||
|
if (g_arg_info_is_return_value (arg))
|
||||||
|
g_fprintf (file, " retval=\"1\"");
|
||||||
|
|
||||||
|
if (g_arg_info_is_optional (arg))
|
||||||
|
g_fprintf (file, " optional=\"1\"");
|
||||||
|
|
||||||
|
g_fprintf (file, ">\n");
|
||||||
|
|
||||||
|
g_fprintf (file, "%*s <type name=\"", indent+2, "");
|
||||||
|
|
||||||
|
type = g_arg_info_get_type (arg);
|
||||||
|
write_type_info (namespace, type, file);
|
||||||
|
|
||||||
|
g_fprintf (file, "\"/>\n");
|
||||||
|
|
||||||
|
g_fprintf (file, "%*s </parameter>\n", indent, "");
|
||||||
|
|
||||||
|
g_base_info_unref ((GIBaseInfo *)arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_fprintf (file, "%*s </parameters>\n", indent, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -417,7 +430,7 @@ write_struct_info (const gchar *namespace,
|
|||||||
type_name = g_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info);
|
type_name = g_registered_type_info_get_type_name ((GIRegisteredTypeInfo*)info);
|
||||||
type_init = g_registered_type_info_get_type_init ((GIRegisteredTypeInfo*)info);
|
type_init = g_registered_type_info_get_type_init ((GIRegisteredTypeInfo*)info);
|
||||||
|
|
||||||
g_fprintf (file, " <boxed name=\"%s\" type-name=\"%s\" get-type=\"%s\"", name, type_name, type_init);
|
g_fprintf (file, " <glib:boxed glib:name=\"%s\" glib:type-name=\"%s\" glib:get-type=\"%s\"", name, type_name, type_init);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
g_fprintf (file, " <struct name=\"%s\"", name);
|
g_fprintf (file, " <struct name=\"%s\"", name);
|
||||||
@ -442,7 +455,7 @@ write_struct_info (const gchar *namespace,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (g_base_info_get_type ((GIBaseInfo *)info) == GI_INFO_TYPE_BOXED)
|
if (g_base_info_get_type ((GIBaseInfo *)info) == GI_INFO_TYPE_BOXED)
|
||||||
g_fprintf (file, " </boxed>\n");
|
g_fprintf (file, " </glib:boxed>\n");
|
||||||
else
|
else
|
||||||
g_fprintf (file, " </struct>\n");
|
g_fprintf (file, " </struct>\n");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user