Rename metadata to typelib in variable names, comments and apis.

2008-08-09  Johan Dahlin  <johan@gnome.org>

    * *.[ch]:
    Rename metadata to typelib in variable names,
    comments and apis.


svn path=/trunk/; revision=339
This commit is contained in:
Johan Dahlin 2008-08-09 12:55:32 +00:00 committed by Evan Welsh
parent 04a5cdf05d
commit b1039a6dc9

View File

@ -1,4 +1,4 @@
/* GObject introspection: Metadata compiler /* GObject introspection: Typelib compiler
* *
* Copyright (C) 2005 Matthias Clasen * Copyright (C) 2005 Matthias Clasen
* *
@ -39,19 +39,19 @@ gboolean debug = FALSE;
gboolean verbose = FALSE; gboolean verbose = FALSE;
static gchar * static gchar *
format_output (GTypelib *metadata) format_output (GTypelib *typelib)
{ {
GString *result; GString *result;
gint i; gint i;
result = g_string_sized_new (6 * metadata->len); result = g_string_sized_new (6 * typelib->len);
g_string_append_printf (result, "#include <stdlib.h>\n"); g_string_append_printf (result, "#include <stdlib.h>\n");
g_string_append_printf (result, "#include <girepository.h>\n\n"); g_string_append_printf (result, "#include <girepository.h>\n\n");
g_string_append_printf (result, "const unsigned char _G_TYPELIB[] = \n{"); g_string_append_printf (result, "const unsigned char _G_TYPELIB[] = \n{");
for (i = 0; i < metadata->len; i++) for (i = 0; i < typelib->len; i++)
{ {
if (i > 0) if (i > 0)
g_string_append (result, ", "); g_string_append (result, ", ");
@ -59,39 +59,39 @@ format_output (GTypelib *metadata)
if (i % 10 == 0) if (i % 10 == 0)
g_string_append (result, "\n\t"); g_string_append (result, "\n\t");
g_string_append_printf (result, "0x%.2x", metadata->data[i]); g_string_append_printf (result, "0x%.2x", typelib->data[i]);
} }
g_string_append_printf (result, "\n};\n\n"); g_string_append_printf (result, "\n};\n\n");
g_string_append_printf (result, "const gsize _G_TYPELIB_SIZE = %u;\n\n", g_string_append_printf (result, "const gsize _G_TYPELIB_SIZE = %u;\n\n",
(guint)metadata->len); (guint)typelib->len);
if (!no_init) if (!no_init)
{ {
g_string_append_printf (result, g_string_append_printf (result,
"__attribute__((constructor)) void\n" "__attribute__((constructor)) void\n"
"register_metadata (void)\n" "register_typelib (void)\n"
"{\n" "{\n"
"\tGTypelib *metadata;\n" "\tGTypelib *typelib;\n"
"\tmetadata = g_typelib_new_from_const_memory (_G_TYPELIB, _G_TYPELIB_SIZE);\n" "\ttypelib = g_typelib_new_from_const_memory (_G_TYPELIB, _G_TYPELIB_SIZE);\n"
"\tg_irepository_register (NULL, metadata);\n" "\tg_irepository_register (NULL, typelib);\n"
"}\n\n"); "}\n\n");
g_string_append_printf (result, g_string_append_printf (result,
"__attribute__((destructor)) void\n" "__attribute__((destructor)) void\n"
"unregister_metadata (void)\n" "unregister_typelib (void)\n"
"{\n" "{\n"
"\tg_irepository_unregister (NULL, \"%s\");\n" "\tg_irepository_unregister (NULL, \"%s\");\n"
"}\n", "}\n",
g_typelib_get_namespace (metadata)); g_typelib_get_namespace (typelib));
} }
return g_string_free (result, FALSE); return g_string_free (result, FALSE);
} }
static void static void
write_out_metadata (gchar *prefix, write_out_typelib (gchar *prefix,
GTypelib *metadata) GTypelib *typelib)
{ {
FILE *file; FILE *file;
@ -120,12 +120,12 @@ write_out_metadata (gchar *prefix,
} }
if (raw) if (raw)
fwrite (metadata->data, 1, metadata->len, file); fwrite (typelib->data, 1, typelib->len, file);
else else
{ {
gchar *code; gchar *code;
code = format_output (metadata); code = format_output (typelib);
fputs (code, file); fputs (code, file);
g_free (code); g_free (code);
} }
@ -148,7 +148,7 @@ static void log_handler (const gchar *log_domain,
static GOptionEntry options[] = static GOptionEntry options[] =
{ {
{ "raw", 0, 0, G_OPTION_ARG_NONE, &raw, "emit raw metadata", NULL }, { "raw", 0, 0, G_OPTION_ARG_NONE, &raw, "emit raw typelib", NULL },
{ "code", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &raw, "emit C code", NULL }, { "code", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &raw, "emit C code", NULL },
{ "no-init", 0, 0, G_OPTION_ARG_NONE, &no_init, "do not create _init() function", NULL }, { "no-init", 0, 0, G_OPTION_ARG_NONE, &no_init, "do not create _init() function", NULL },
{ "output", 'o', 0, G_OPTION_ARG_FILENAME, &output, "output file", "FILE" }, { "output", 'o', 0, G_OPTION_ARG_FILENAME, &output, "output file", "FILE" },
@ -217,7 +217,7 @@ main (int argc, char ** argv)
{ {
GIrModule *module = m->data; GIrModule *module = m->data;
gchar *prefix; gchar *prefix;
GTypelib *metadata; GTypelib *typelib;
if (mname && strcmp (mname, module->name) != 0) if (mname && strcmp (mname, module->name) != 0)
continue; continue;
@ -230,15 +230,15 @@ main (int argc, char ** argv)
g_debug ("[building] module %s", module->name); g_debug ("[building] module %s", module->name);
metadata = g_ir_module_build_metadata (module, modules); typelib = g_ir_module_build_typelib (module, modules);
if (metadata == NULL) if (typelib == NULL)
{ {
g_error ("Failed to build metadata for module '%s'\n", module->name); g_error ("Failed to build typelib for module '%s'\n", module->name);
continue; continue;
} }
if (!g_typelib_validate (metadata, &error)) if (!g_typelib_validate (typelib, &error))
g_error ("Invalid metadata for module '%s': %s", g_error ("Invalid typelib for module '%s': %s",
module->name, error->message); module->name, error->message);
if (!mname && (m->next || m->prev) && output) if (!mname && (m->next || m->prev) && output)
@ -246,9 +246,9 @@ main (int argc, char ** argv)
else else
prefix = NULL; prefix = NULL;
write_out_metadata (prefix, metadata); write_out_typelib (prefix, typelib);
g_typelib_free (metadata); g_typelib_free (typelib);
metadata = NULL; typelib = NULL;
/* when writing to stdout, stop after the first module */ /* when writing to stdout, stop after the first module */
if (m->next && !output && !mname) if (m->next && !output && !mname)