glib/girepository/tools/generate.c

114 lines
3.3 KiB
C
Raw Normal View History

2010-03-25 13:17:03 +01:00
reviewed by: Johan Dahlin <johan@gnome.org> 2007-12-06 Gustavo J. A. M. Carneiro <gjc@gnome.org> reviewed by: Johan Dahlin <johan@gnome.org> * configure.ac: * gobject-introspection.pc.in: * src/Makefile.am: * src/compiler.c: (format_output), (write_out_metadata), (main): * src/gen-introspect.c: (main): * src/gen-introspect.h: * src/generate.c: (write_callable_info), (write_repository), (load_metadata), (main): * src/gidlmodule.c: (g_idl_module_new), (g_idl_module_build_metadata): * src/gidlmodule.h: * src/gidlparser.c: (start_element_handler): * src/ginfo.c: (g_info_new), (g_info_from_entry), (g_base_info_get_name), (g_base_info_get_namespace), (g_base_info_is_deprecated), (g_base_info_get_annotation), (g_base_info_get_metadata), (g_function_info_get_symbol), (g_function_info_get_flags), (g_function_info_get_property), (g_function_info_get_vfunc), (signature_offset), (g_type_info_new), (g_callable_info_may_return_null), (g_callable_info_get_caller_owns), (g_callable_info_get_n_args), (g_callable_info_get_arg), (g_arg_info_get_direction), (g_arg_info_is_return_value), (g_arg_info_is_dipper), (g_arg_info_is_optional), (g_arg_info_may_be_null), (g_arg_info_get_ownership_transfer), (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_quark), (g_error_domain_info_get_codes), (g_value_info_get_value), (g_field_info_get_flags), (g_field_info_get_size), (g_field_info_get_offset), (g_registered_type_info_get_type_name), (g_registered_type_info_get_type_init), (g_struct_info_get_n_fields), (g_struct_info_get_field), (g_struct_info_get_n_methods), (g_struct_info_get_method), (find_method), (g_struct_info_find_method), (g_enum_info_get_n_values), (g_enum_info_get_value), (g_object_info_get_parent), (g_object_info_get_type_name), (g_object_info_get_type_init), (g_object_info_get_n_interfaces), (g_object_info_get_interface), (g_object_info_get_n_fields), (g_object_info_get_field), (g_object_info_get_n_properties), (g_object_info_get_property), (g_object_info_get_n_methods), (g_object_info_get_method), (g_object_info_find_method), (g_object_info_get_n_signals), (g_object_info_get_signal), (g_object_info_get_n_vfuncs), (g_object_info_get_vfunc), (g_object_info_get_n_constants), (g_object_info_get_constant), (g_interface_info_get_n_prerequisites), (g_interface_info_get_prerequisite), (g_interface_info_get_n_properties), (g_interface_info_get_property), (g_interface_info_get_n_methods), (g_interface_info_get_method), (g_interface_info_find_method), (g_interface_info_get_n_signals), (g_interface_info_get_signal), (g_interface_info_get_n_vfuncs), (g_interface_info_get_vfunc), (g_interface_info_get_n_constants), (g_interface_info_get_constant), (g_property_info_get_flags), (g_signal_info_get_flags), (g_signal_info_get_class_closure), (g_signal_info_true_stops_emit), (g_vfunc_info_get_flags), (g_vfunc_info_get_offset), (g_vfunc_info_get_signal), (g_constant_info_get_value), (g_union_info_get_n_fields), (g_union_info_get_field), (g_union_info_get_n_methods), (g_union_info_get_method), (g_union_info_is_discriminated), (g_union_info_get_discriminator_offset), (g_union_info_get_discriminator): * src/ginvoke.c: (g_function_info_invoke): * src/girepository.c: (g_irepository_register), (g_irepository_unregister), (g_irepository_get_default), (count_interfaces), (g_irepository_get_n_infos), (find_interface), (g_irepository_get_info), (g_irepository_find_by_name), (g_irepository_get_shared_library), (g_irepository_build_search_path), (g_irepository_register_file), (g_irepository_error_quark): * src/girepository.h: * src/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_arg_blob), (validate_signature_blob), (validate_function_blob), (validate_callback_blob), (validate_constant_blob), (validate_value_blob), (validate_field_blob), (validate_property_blob), (validate_signal_blob), (validate_vfunc_blob), (validate_struct_blob), (validate_enum_blob), (validate_object_blob), (validate_interface_blob), (validate_errordomain_blob), (validate_union_blob), (validate_blob), (validate_directory), (validate_annotations), (g_metadata_validate), (_g_metadata_init), (g_metadata_new_from_memory), (g_metadata_new_from_const_memory), (g_metadata_new_from_mapped_file), (g_metadata_free), (g_metadata_set_module), (g_metadata_get_namespace): * src/gmetadata.h: * tests/Makefile.am: * tests/invoke/Makefile.am: * tests/invoke/invoke-namespace-find.sh: * tests/invoke/invoke.c: (main): Add a namespace/shared library mapping. fixes #313268. svn path=/trunk/; revision=66
2007-12-06 01:16:15 +01:00
/* -*- Mode: C; c-file-style: "gnu"; -*- */
2005-05-09 16:24:46 +02:00
/* GObject introspection: IDL generator
*
* Copyright (C) 2005 Matthias Clasen
* 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.
*/
#include <glib.h>
#include <glib/gstdio.h>
#include <gmodule.h>
2005-05-09 16:24:46 +02:00
#include "girwriter.h"
2005-05-09 16:24:46 +02:00
#include "girepository.h"
#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
{
gboolean shlib = FALSE;
gchar *output = NULL;
gchar **includedirs = NULL;
gboolean show_all = FALSE;
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[] =
{
{ "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" },
{ "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, },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &input, NULL, NULL },
{ NULL, }
};
2005-05-09 16:24:46 +02:00
g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL);
2005-05-09 16:24:46 +02:00
g_type_init ();
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
2005-05-09 16:24:46 +02:00
context = g_option_context_new ("");
g_option_context_add_main_entries (context, options, NULL);
g_option_context_parse (context, &argc, &argv, &error);
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;
}
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++)
{
GError *error = NULL;
const char *namespace;
GMappedFile *mfile;
GTypelib *typelib;
2005-05-09 16:24:46 +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;
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,
&error);
if (namespace == NULL)
g_error ("failed to load typelib: %s", error->message);
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;
}