Use GLib types consistently

Rather than have the scanner/parser handle both e.g. "glong" and
"long", simply use the GLib types everywhere.

This commit adds TYPE_LONG_LONG and TYPE_LONG_DOUBLE to the
scanner types; however, rather than add them to the typelib,
they're just marked as not-introspectable.
This commit is contained in:
Colin Walters 2010-07-21 21:06:17 -04:00
parent d853f196c1
commit f5ec6f6698
3 changed files with 40 additions and 66 deletions

View File

@ -1445,27 +1445,27 @@ g_type_tag_to_string (GITypeTag type)
case GI_TYPE_TAG_VOID:
return "void";
case GI_TYPE_TAG_BOOLEAN:
return "boolean";
return "gboolean";
case GI_TYPE_TAG_INT8:
return "int8";
return "gint8";
case GI_TYPE_TAG_UINT8:
return "uint8";
return "guint8";
case GI_TYPE_TAG_INT16:
return "int16";
return "gint16";
case GI_TYPE_TAG_UINT16:
return "uint16";
return "guint16";
case GI_TYPE_TAG_INT32:
return "int32";
return "gint32";
case GI_TYPE_TAG_UINT32:
return "uint32";
return "guint32";
case GI_TYPE_TAG_INT64:
return "int64";
return "gint64";
case GI_TYPE_TAG_UINT64:
return "uint64";
return "guint64";
case GI_TYPE_TAG_FLOAT:
return "float";
return "gfloat";
case GI_TYPE_TAG_DOUBLE:
return "double";
return "gdouble";
case GI_TYPE_TAG_GTYPE:
return "GType";
case GI_TYPE_TAG_UTF8:

View File

@ -1219,36 +1219,10 @@ serialize_type (GIrTypelibBuild *build,
GString *str)
{
gint i;
const gchar* basic[] = {
"void",
"boolean",
"int8",
"uint8",
"int16",
"uint16",
"int32",
"uint32",
"int64",
"uint64",
"short",
"ushort",
"int",
"uint",
"long",
"ulong",
"ssize",
"size",
"float",
"double",
"time_t",
"GType",
"utf8",
"filename",
};
if (node->tag < GI_TYPE_TAG_ARRAY)
{
g_string_append_printf (str, "%s%s", basic[node->tag],
g_string_append_printf (str, "%s%s", g_type_tag_to_string (node->tag),
node->is_pointer ? "*" : "");
}
else if (node->tag == GI_TYPE_TAG_ARRAY)

View File

@ -359,13 +359,13 @@ typedef struct {
} IntegerAliasInfo;
static IntegerAliasInfo integer_aliases[] = {
{ "char", SIZEOF_CHAR, 0 },
{ "short", SIZEOF_SHORT, 1 },
{ "ushort", SIZEOF_SHORT, 0 },
{ "int", SIZEOF_INT, 1 },
{ "uint", SIZEOF_INT, 0 },
{ "long", SIZEOF_LONG, 1 },
{ "ulong", SIZEOF_LONG, 0 },
{ "gchar", SIZEOF_CHAR, 0 },
{ "gshort", SIZEOF_SHORT, 1 },
{ "gushort", SIZEOF_SHORT, 0 },
{ "gint", SIZEOF_INT, 1 },
{ "guint", SIZEOF_INT, 0 },
{ "glong", SIZEOF_LONG, 1 },
{ "gulong", SIZEOF_LONG, 0 },
{ "gsize", GLIB_SIZEOF_SIZE_T, 0 },
{ "gssize", GLIB_SIZEOF_SIZE_T, 1 },
};
@ -379,30 +379,30 @@ typedef struct {
#define BASIC_TYPE_FIXED_OFFSET 3
static BasicTypeInfo basic_types[] = {
{ "none", GI_TYPE_TAG_VOID, 0 },
{ "any", GI_TYPE_TAG_VOID, 1 },
{ "none", GI_TYPE_TAG_VOID, 0 },
{ "gpointer", GI_TYPE_TAG_VOID, 1 },
{ "bool", GI_TYPE_TAG_BOOLEAN, 0 },
{ "int8", GI_TYPE_TAG_INT8, 0 }, /* Start of BASIC_TYPE_FIXED_OFFSET */
{ "uint8", GI_TYPE_TAG_UINT8, 0 },
{ "int16", GI_TYPE_TAG_INT16, 0 },
{ "uint16", GI_TYPE_TAG_UINT16, 0 },
{ "int32", GI_TYPE_TAG_INT32, 0 },
{ "uint32", GI_TYPE_TAG_UINT32, 0 },
{ "int64", GI_TYPE_TAG_INT64, 0 },
{ "uint64", GI_TYPE_TAG_UINT64, 0 },
{ "float", GI_TYPE_TAG_FLOAT, 0 },
{ "double", GI_TYPE_TAG_DOUBLE, 0 },
{ "GType", GI_TYPE_TAG_GTYPE, 0 },
{ "utf8", GI_TYPE_TAG_UTF8, 1 },
{ "filename", GI_TYPE_TAG_FILENAME,1 },
{ "gboolean", GI_TYPE_TAG_BOOLEAN, 0 },
{ "gint8", GI_TYPE_TAG_INT8, 0 }, /* Start of BASIC_TYPE_FIXED_OFFSET */
{ "guint8", GI_TYPE_TAG_UINT8, 0 },
{ "gint16", GI_TYPE_TAG_INT16, 0 },
{ "guint16", GI_TYPE_TAG_UINT16, 0 },
{ "gint32", GI_TYPE_TAG_INT32, 0 },
{ "guint32", GI_TYPE_TAG_UINT32, 0 },
{ "gint64", GI_TYPE_TAG_INT64, 0 },
{ "guint64", GI_TYPE_TAG_UINT64, 0 },
{ "gfloat", GI_TYPE_TAG_FLOAT, 0 },
{ "gdouble", GI_TYPE_TAG_DOUBLE, 0 },
{ "GType", GI_TYPE_TAG_GTYPE, 0 },
{ "utf8", GI_TYPE_TAG_UTF8, 1 },
{ "filename", GI_TYPE_TAG_FILENAME,1 },
};
static const BasicTypeInfo *
parse_basic (const char *str)
{
gint i;
gint n_basic = G_N_ELEMENTS (basic_types);
guint i;
guint n_basic = G_N_ELEMENTS (basic_types);
for (i = 0; i < n_basic; i++)
{
@ -1981,14 +1981,14 @@ end_type_top (ParseContext *ctx)
typenode->tag == GI_TYPE_TAG_GSLIST)
{
if (typenode->parameter_type1 == NULL)
typenode->parameter_type1 = parse_type (ctx, "any");
typenode->parameter_type1 = parse_type (ctx, "gpointer");
}
else if (typenode->tag == GI_TYPE_TAG_GHASH)
{
if (typenode->parameter_type1 == NULL)
{
typenode->parameter_type1 = parse_type (ctx, "any");
typenode->parameter_type2 = parse_type (ctx, "any");
typenode->parameter_type1 = parse_type (ctx, "gpointer");
typenode->parameter_type2 = parse_type (ctx, "gpointer");
}
}