2012-02-03 19:42:56 +01:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
|
|
|
|
* GObject introspection: IDL generator
|
2005-05-09 16:24:46 +02:00
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Matthias Clasen
|
2009-02-20 03:48:51 +01:00
|
|
|
* Copyright (C) 2008,2009 Red Hat, Inc.
|
2005-05-09 16:24:46 +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.
|
|
|
|
*/
|
|
|
|
|
2016-01-11 06:35:34 +01:00
|
|
|
#include <locale.h>
|
|
|
|
|
2005-05-09 16:24:46 +02:00
|
|
|
#include <glib.h>
|
|
|
|
#include <glib/gstdio.h>
|
2010-06-07 15:52:43 +02:00
|
|
|
#include <gmodule.h>
|
2005-05-09 16:24:46 +02:00
|
|
|
|
2010-06-07 15:52:43 +02:00
|
|
|
#include "girwriter.h"
|
2005-05-09 16:24:46 +02:00
|
|
|
#include "girepository.h"
|
2010-05-31 22:44:46 +02:00
|
|
|
#include "gitypelib-internal.h"
|
2005-05-09 16:24:46 +02:00
|
|
|
|
2010-03-25 13:17:03 +01:00
|
|
|
int
|
2005-05-09 16:24:46 +02:00
|
|
|
main (int argc, char *argv[])
|
2010-03-25 13:17:03 +01:00
|
|
|
{
|
2008-08-22 23:14:31 +02:00
|
|
|
gboolean shlib = FALSE;
|
2010-06-07 15:41:00 +02:00
|
|
|
gchar *output = NULL;
|
|
|
|
gchar **includedirs = NULL;
|
|
|
|
gboolean show_all = FALSE;
|
2008-03-11 15:25:08 +01:00
|
|
|
gchar **input = NULL;
|
2005-05-09 16:24:46 +02:00
|
|
|
GOptionContext *context;
|
|
|
|
GError *error = NULL;
|
|
|
|
gboolean needs_prefix;
|
|
|
|
gint i;
|
2010-03-25 13:17:03 +01:00
|
|
|
GOptionEntry options[] =
|
2008-03-11 15:25:08 +01:00
|
|
|
{
|
2008-08-22 23:14:31 +02:00
|
|
|
{ "shlib", 0, 0, G_OPTION_ARG_NONE, &shlib, "handle typelib embedded in shlib", NULL },
|
2010-03-25 13:17:03 +01:00
|
|
|
{ "output", 'o', 0, G_OPTION_ARG_FILENAME, &output, "output file", "FILE" },
|
2009-02-27 00:17:16 +01:00
|
|
|
{ "includedir", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &includedirs, "include directories in GIR search path", NULL },
|
|
|
|
{ "all", 0, 0, G_OPTION_ARG_NONE, &show_all, "show all available information", NULL, },
|
2008-03-11 15:25:08 +01:00
|
|
|
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &input, NULL, NULL },
|
|
|
|
{ NULL, }
|
|
|
|
};
|
2005-05-09 16:24:46 +02:00
|
|
|
|
2008-08-30 22:31:07 +02:00
|
|
|
g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL);
|
|
|
|
|
2008-06-08 16:37:30 +02:00
|
|
|
g_typelib_check_sanity ();
|
Revert revisions 157,149-148,136-129 and 120. Move back to using
2008-04-22 Johan Dahlin <johan@gnome.org>
* girepository/ginfo.c (g_info_from_entry), (g_type_info_new),
(g_type_info_is_pointer), (g_type_info_get_tag),
(g_type_info_get_param_type), (g_type_info_get_interface),
(g_type_info_get_array_length), (g_type_info_is_zero_terminated),
(g_type_info_get_n_error_domains), (g_type_info_get_error_domain),
(g_error_domain_info_get_codes), (g_enum_info_get_value),
(g_object_info_get_interface), (g_object_info_get_field),
(g_interface_info_get_prerequisite),
(g_signal_info_get_class_closure), (g_constant_info_get_value):
* girepository/ginvoke.c (get_ffi_type):
* girepository/girepository.h:
* girepository/gmetadata.c (g_metadata_get_dir_entry),
(g_metadata_check_sanity), (validate_header),
(validate_array_type_blob), (validate_iface_type_blob),
(validate_param_type_blob), (validate_error_type_blob),
(validate_type_blob), (validate_constant_blob),
(validate_struct_blob), (validate_enum_blob):
* girepository/gmetadata.h:
* tests/Makefile.am:
* tests/invoke/Makefile.am:
* tests/invoke/invoke.c (main):
* tests/roundtrips.sh:
* tools/Makefile.am:
* tools/compiler.c (format_output), (write_out_metadata), (main):
* tools/generate.c (write_type_name), (write_type_info),
(write_constant_value), (write_enum_info), (load_metadata), (main):
* tools/gidlcompilercontext.c:
* tools/gidlcompilercontext.h:
* tools/gidlcompilerentrynode.c:
* tools/gidlcompilerentrynode.h:
* tools/gidlcompilertypenode.c:
* tools/gidlcompilertypenode.h:
* tools/gidlmodule.c (g_idl_module_build_metadata):
* tools/gidlmodule.h:
* tools/gidlnode.c (init_stats), (dump_stats),
(g_idl_node_get_size), (g_idl_node_get_full_size),
(g_idl_node_cmp), (g_idl_node_can_have_member),
(g_idl_node_add_member), (g_idl_node_param_direction_string),
(parse_int_value), (parse_uint_value), (parse_float_value),
(parse_boolean_value), (find_entry_node), (find_entry),
(serialize_type), (g_idl_node_build_metadata), (write_string):
* tools/gidlnode.h:
* tools/gidlparser.c (parse_type_internal):
* tools/quote-file.sh:
Revert revisions 157,149-148,136-129 and 120.
Move back to using g-idl-generate to generate the metadata and
avoids dependency on a c compiler.
svn path=/trunk/; revision=214
2008-04-23 00:48:16 +02:00
|
|
|
|
2016-01-11 06:35:34 +01:00
|
|
|
setlocale (LC_ALL, "");
|
|
|
|
|
2005-05-09 16:24:46 +02:00
|
|
|
context = g_option_context_new ("");
|
|
|
|
g_option_context_add_main_entries (context, options, NULL);
|
2018-07-29 15:40:31 +02:00
|
|
|
if (!g_option_context_parse (context, &argc, &argv, &error))
|
|
|
|
{
|
|
|
|
g_fprintf (stderr, "failed to parse: %s\n", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
return 1;
|
|
|
|
}
|
2005-05-09 16:24:46 +02:00
|
|
|
|
2010-03-25 13:17:03 +01:00
|
|
|
if (!input)
|
|
|
|
{
|
|
|
|
g_fprintf (stderr, "no input files\n");
|
|
|
|
|
2005-05-09 16:24:46 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-08-30 22:31:07 +02:00
|
|
|
if (includedirs != NULL)
|
|
|
|
for (i = 0; includedirs[i]; i++)
|
|
|
|
g_irepository_prepend_search_path (includedirs[i]);
|
|
|
|
|
2005-05-09 16:24:46 +02:00
|
|
|
for (i = 0; input[i]; i++)
|
|
|
|
{
|
2008-08-30 22:31:07 +02:00
|
|
|
const char *namespace;
|
2010-07-14 17:59:11 +02:00
|
|
|
GMappedFile *mfile;
|
2010-08-31 22:36:06 +02:00
|
|
|
GITypelib *typelib;
|
2005-05-09 16:24:46 +02:00
|
|
|
|
2018-07-29 15:56:35 +02:00
|
|
|
error = NULL;
|
2010-07-14 17:59:11 +02:00
|
|
|
mfile = g_mapped_file_new (input[i], FALSE, &error);
|
|
|
|
if (!mfile)
|
|
|
|
g_error ("failed to read '%s': %s", input[i], error->message);
|
2005-05-09 16:24:46 +02:00
|
|
|
|
|
|
|
if (input[i + 1] && output)
|
|
|
|
needs_prefix = TRUE;
|
|
|
|
else
|
|
|
|
needs_prefix = FALSE;
|
|
|
|
|
2010-07-14 17:59:11 +02:00
|
|
|
typelib = g_typelib_new_from_mapped_file (mfile, &error);
|
|
|
|
if (!typelib)
|
|
|
|
g_error ("failed to create typelib '%s': %s", input[i], error->message);
|
|
|
|
|
|
|
|
namespace = g_irepository_load_typelib (g_irepository_get_default (), typelib, 0,
|
2008-08-30 22:31:07 +02:00
|
|
|
&error);
|
|
|
|
if (namespace == NULL)
|
2010-07-14 17:59:11 +02:00
|
|
|
g_error ("failed to load typelib: %s", error->message);
|
|
|
|
|
2010-06-07 15:52:43 +02:00
|
|
|
gir_writer_write (output, namespace, needs_prefix, show_all);
|
2005-05-09 16:24:46 +02:00
|
|
|
|
|
|
|
/* when writing to stdout, stop after the first module */
|
|
|
|
if (input[i + 1] && !output)
|
|
|
|
{
|
|
|
|
g_fprintf (stderr, "warning, %d modules omitted\n",
|
|
|
|
g_strv_length (input) - 1);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-03-25 13:17:03 +01:00
|
|
|
|
2005-05-09 16:24:46 +02:00
|
|
|
return 0;
|
|
|
|
}
|