2005-05-09 16:24:46 +02:00
|
|
|
/* GObject introspection: Metadata compiler
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Matthias Clasen
|
|
|
|
*
|
|
|
|
* 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 <errno.h>
|
Hush compiler warnings about return values, signedness mismatches, unused
* src/compiler.c, src/generate.c, src/gidlnode.c,
src/gidlparser.c, src/ginfo.c, src/girepository.c,
tests/invoke/invoke.c, test/invoke/testfns.c: Hush compiler
warnings about return values, signedness mismatches, unused
variables, and unhandles enum values in switch statements.
* tests/invoke/Makefile.am: Don't install the invoke test program.
Add -I ../../src to the cflags used for the test functions files.
2006-10-03 16:38:07 +02:00
|
|
|
#include <string.h>
|
2005-05-09 16:24:46 +02:00
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <glib/gstdio.h>
|
|
|
|
|
|
|
|
#include "gidlmodule.h"
|
|
|
|
#include "gidlnode.h"
|
|
|
|
#include "gidlparser.h"
|
Hush compiler warnings about return values, signedness mismatches, unused
* src/compiler.c, src/generate.c, src/gidlnode.c,
src/gidlparser.c, src/ginfo.c, src/girepository.c,
tests/invoke/invoke.c, test/invoke/testfns.c: Hush compiler
warnings about return values, signedness mismatches, unused
variables, and unhandles enum values in switch statements.
* tests/invoke/Makefile.am: Don't install the invoke test program.
Add -I ../../src to the cflags used for the test functions files.
2006-10-03 16:38:07 +02:00
|
|
|
#include "gmetadata.h"
|
2008-03-10 18:47:29 +01:00
|
|
|
#include "gidlcompilercontext.h"
|
2005-05-09 16:24:46 +02:00
|
|
|
|
|
|
|
gboolean no_init = FALSE;
|
|
|
|
gchar **input = NULL;
|
|
|
|
gchar *output = NULL;
|
|
|
|
gchar *mname = NULL;
|
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
|
|
|
gchar *shlib = NULL;
|
2005-05-11 21:31:37 +02:00
|
|
|
gboolean debug = FALSE;
|
|
|
|
gboolean verbose = FALSE;
|
2005-05-09 16:24:46 +02:00
|
|
|
|
2005-05-11 21:31:37 +02:00
|
|
|
GLogLevelFlags logged_levels;
|
|
|
|
|
|
|
|
static void log_handler (const gchar *log_domain,
|
|
|
|
GLogLevelFlags log_level,
|
|
|
|
const gchar *message,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (log_level & logged_levels)
|
|
|
|
g_log_default_handler (log_domain, log_level, message, user_data);
|
|
|
|
}
|
|
|
|
|
2005-05-09 16:24:46 +02:00
|
|
|
static GOptionEntry options[] =
|
|
|
|
{
|
|
|
|
{ "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" },
|
|
|
|
{ "module", 'm', 0, G_OPTION_ARG_STRING, &mname, "module to compile", "NAME" },
|
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
|
|
|
{ "shared-library", 'l', 0, G_OPTION_ARG_FILENAME, &shlib, "shared library", "FILE" },
|
2005-05-10 19:43:21 +02:00
|
|
|
{ "debug", 0, 0, G_OPTION_ARG_NONE, &debug, "show debug messages", NULL },
|
2005-05-11 21:31:37 +02:00
|
|
|
{ "verbose", 0, 0, G_OPTION_ARG_NONE, &verbose, "show verbose messages", NULL },
|
2005-05-09 16:24:46 +02:00
|
|
|
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &input, NULL, NULL },
|
|
|
|
{ NULL, }
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char ** argv)
|
|
|
|
{
|
|
|
|
GOptionContext *context;
|
|
|
|
GError *error = NULL;
|
|
|
|
GList *m, *modules;
|
|
|
|
gint i;
|
2008-03-10 18:47:29 +01:00
|
|
|
GList *c;
|
|
|
|
gint entry_id;
|
2005-05-09 16:24:46 +02:00
|
|
|
|
2008-03-10 18:47:29 +01:00
|
|
|
FILE *file;
|
|
|
|
GIdlCompilerContext *ctx;
|
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);
|
2005-05-10 05:52:16 +02:00
|
|
|
g_option_context_free (context);
|
2005-05-09 16:24:46 +02:00
|
|
|
|
2005-05-11 21:31:37 +02:00
|
|
|
logged_levels = G_LOG_LEVEL_MASK & ~(G_LOG_LEVEL_MESSAGE|G_LOG_LEVEL_DEBUG);
|
|
|
|
if (debug)
|
|
|
|
logged_levels = logged_levels | G_LOG_LEVEL_DEBUG;
|
|
|
|
if (verbose)
|
|
|
|
logged_levels = logged_levels | G_LOG_LEVEL_MESSAGE;
|
|
|
|
|
2005-05-10 19:43:21 +02:00
|
|
|
g_log_set_default_handler (log_handler, NULL);
|
|
|
|
|
2005-05-09 16:24:46 +02:00
|
|
|
if (!input)
|
|
|
|
{
|
|
|
|
g_fprintf (stderr, "no input files\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
modules = NULL;
|
|
|
|
for (i = 0; input[i]; i++)
|
|
|
|
{
|
|
|
|
GList *mods;
|
|
|
|
mods = g_idl_parse_file (input[i], &error);
|
|
|
|
|
|
|
|
if (mods == NULL)
|
|
|
|
{
|
|
|
|
g_fprintf (stderr, "error parsing file %s: %s\n",
|
|
|
|
input[i], error->message);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
modules = g_list_concat (modules, mods);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (m = modules; m; m = m->next)
|
|
|
|
{
|
|
|
|
GIdlModule *module = m->data;
|
|
|
|
gchar *prefix;
|
2008-03-10 18:47:29 +01:00
|
|
|
GError *err = NULL;
|
|
|
|
|
2005-05-09 16:24:46 +02:00
|
|
|
|
|
|
|
if (mname && strcmp (mname, module->name) != 0)
|
|
|
|
continue;
|
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
|
|
|
if (shlib)
|
|
|
|
{
|
|
|
|
if (module->shared_library)
|
|
|
|
g_free (module->shared_library);
|
|
|
|
module->shared_library = g_strdup (shlib);
|
|
|
|
}
|
2008-03-10 18:47:29 +01:00
|
|
|
|
|
|
|
if (!mname && (m->next || m->prev) && output)
|
|
|
|
prefix = module->name;
|
|
|
|
else
|
|
|
|
prefix = NULL;
|
|
|
|
|
|
|
|
ctx = g_idl_compiler_context_new (module->name, &err);
|
|
|
|
if (err != NULL)
|
2005-05-09 16:24:46 +02:00
|
|
|
{
|
2008-03-10 18:47:29 +01:00
|
|
|
g_fprintf (stderr, "Error creating new compiler context: %s",
|
|
|
|
err->message);
|
2005-05-09 16:24:46 +02:00
|
|
|
|
2008-03-10 18:47:29 +01:00
|
|
|
return 1;
|
2005-05-09 16:24:46 +02:00
|
|
|
}
|
2005-05-24 17:36:42 +02:00
|
|
|
|
2008-03-10 18:47:29 +01:00
|
|
|
/* This is making sure all the types
|
|
|
|
* that have local directory entries are already
|
|
|
|
* in the entries database.
|
|
|
|
*
|
|
|
|
* A method of finding out if an external reference is
|
|
|
|
* needed
|
|
|
|
*/
|
2008-03-11 09:59:16 +01:00
|
|
|
for (c = module->entries; c; c = c->next)
|
2008-03-10 18:47:29 +01:00
|
|
|
{
|
|
|
|
GIdlNode *node = (GIdlNode*) c->data;
|
2005-05-09 16:24:46 +02:00
|
|
|
|
2008-03-11 09:59:16 +01:00
|
|
|
g_idl_compiler_add_entry (ctx, node);
|
2008-03-10 18:47:29 +01:00
|
|
|
}
|
|
|
|
|
2008-03-11 09:59:16 +01:00
|
|
|
for (c = module->entries; c; c = c->next)
|
2008-03-10 18:47:29 +01:00
|
|
|
{
|
|
|
|
GIdlNode *node = (GIdlNode*) c->data;
|
|
|
|
|
2008-03-11 09:59:16 +01:00
|
|
|
entry_id = g_idl_compiler_get_entry_id (ctx, node->name);
|
2008-03-10 18:47:29 +01:00
|
|
|
|
2008-03-11 09:59:16 +01:00
|
|
|
g_idl_compiler_write_node (node, entry_id, ctx);
|
2008-03-10 18:47:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (output == NULL)
|
|
|
|
file = stdout;
|
2005-05-09 16:24:46 +02:00
|
|
|
else
|
2008-03-10 18:47:29 +01:00
|
|
|
{
|
|
|
|
gchar *filename;
|
|
|
|
|
|
|
|
if (prefix)
|
|
|
|
filename = g_strdup_printf ("%s-%s", prefix, output);
|
|
|
|
else
|
|
|
|
filename = g_strdup (output);
|
|
|
|
file = g_fopen (filename, "w");
|
|
|
|
|
|
|
|
if (file == NULL)
|
|
|
|
{
|
|
|
|
g_fprintf (stderr, "failed to open '%s': %s\n",
|
|
|
|
filename, g_strerror (errno));
|
|
|
|
g_free (filename);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (filename);
|
|
|
|
}
|
|
|
|
|
2008-03-11 09:59:16 +01:00
|
|
|
g_idl_compiler_context_finalize (ctx, file, module->shared_library, &err);
|
2005-05-09 16:24:46 +02:00
|
|
|
|
2008-03-11 09:59:16 +01:00
|
|
|
g_idl_compiler_context_destroy (ctx);
|
2005-05-09 16:24:46 +02:00
|
|
|
|
|
|
|
/* when writing to stdout, stop after the first module */
|
|
|
|
if (m->next && !output && !mname)
|
|
|
|
{
|
|
|
|
g_warning ("%d modules omitted\n", g_list_length (modules) - 1);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|