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
This commit is contained in:
Gustavo J. A. M. Carneiro 2007-12-06 00:16:15 +00:00 committed by Philip Withnall
parent 00a6f8ada0
commit 2b0304b865

View File

@ -1,3 +1,4 @@
/* -*- Mode: C; c-file-style: "gnu"; -*- */
/* GObject introspection: IDL generator /* GObject introspection: IDL generator
* *
* Copyright (C) 2005 Matthias Clasen * Copyright (C) 2005 Matthias Clasen
@ -241,7 +242,6 @@ write_callable_info (const gchar *namespace,
type = g_callable_info_get_return_type (info); type = g_callable_info_get_return_type (info);
write_type_info (namespace, type, file); write_type_info (namespace, type, file);
g_base_info_unref ((GIBaseInfo *)type);
g_fprintf (file, "\""); g_fprintf (file, "\"");
@ -262,6 +262,7 @@ write_callable_info (const gchar *namespace,
g_assert_not_reached (); g_assert_not_reached ();
} }
} }
g_base_info_unref ((GIBaseInfo *)type);
if (g_callable_info_may_return_null (info)) if (g_callable_info_may_return_null (info))
g_fprintf (file, " null-ok=\"1\""); g_fprintf (file, " null-ok=\"1\"");
@ -1023,7 +1024,13 @@ write_repository (GIRepository *repository,
for (i = 0; namespaces[i]; i++) for (i = 0; namespaces[i]; i++)
{ {
const gchar *shared_library;
ns = namespaces[i]; ns = namespaces[i];
shared_library = g_irepository_get_shared_library (repository, ns);
if (shared_library)
g_fprintf (file, " <namespace name=\"%s\" shared-library=\"%s\">\n",
ns, shared_library);
else
g_fprintf (file, " <namespace name=\"%s\">\n", ns); g_fprintf (file, " <namespace name=\"%s\">\n", ns);
for (j = 0; j < g_irepository_get_n_infos (repository, ns); j++) for (j = 0; j < g_irepository_get_n_infos (repository, ns); j++)
@ -1097,29 +1104,33 @@ static GOptionEntry options[] =
static const guchar * static const guchar *
load_metadata (const gchar *filename, load_metadata (const gchar *filename,
void **dlhandle) GModule **dlhandle,
gsize *len)
{ {
guchar *metadata; guchar *metadata;
void *handle; gsize *metadata_size;
char *error; GModule *handle;
handle = dlopen (filename, RTLD_LAZY); handle = g_module_open (filename, G_MODULE_BIND_LOCAL|G_MODULE_BIND_LAZY);
metadata = dlsym (handle, "_G_METADATA"); if (!g_module_symbol (handle, "_G_METADATA", (gpointer *) &metadata))
{
g_printerr ("Could not load metadata from '%s': %s\n",
filename, g_module_error ());
return NULL;
}
error = dlerror (); if (!g_module_symbol (handle, "_G_METADATA_SIZE", (gpointer *) &metadata_size))
{
g_printerr ("Could not load metadata from '%s': %s\n",
filename, g_module_error ());
return NULL;
}
*len = *metadata_size;
if (dlhandle) if (dlhandle)
*dlhandle = handle; *dlhandle = handle;
if (error)
{
g_fprintf (stderr,
"Could not load metadata from '%s': %s\n",
filename, error);
return NULL;
}
return metadata; return metadata;
} }
@ -1130,6 +1141,7 @@ main (int argc, char *argv[])
GError *error = NULL; GError *error = NULL;
gboolean needs_prefix; gboolean needs_prefix;
gint i; gint i;
GMetadata *data;
g_type_init (); g_type_init ();
@ -1148,12 +1160,13 @@ main (int argc, char *argv[])
for (i = 0; input[i]; i++) for (i = 0; input[i]; i++)
{ {
void *dlhandle = NULL; GModule *dlhandle = NULL;
const guchar *metadata; const guchar *metadata;
gsize len;
if (raw) if (raw)
{ {
if (!g_file_get_contents (input[i], (gchar **)&metadata, NULL, &error)) if (!g_file_get_contents (input[i], (gchar **)&metadata, &len, &error))
{ {
g_fprintf (stderr, "failed to read '%s': %s\n", g_fprintf (stderr, "failed to read '%s': %s\n",
input[i], error->message); input[i], error->message);
@ -1163,7 +1176,7 @@ main (int argc, char *argv[])
} }
else else
{ {
metadata = load_metadata (input[i], &dlhandle); metadata = load_metadata (input[i], &dlhandle, &len);
if (!metadata) if (!metadata)
{ {
g_fprintf (stderr, "failed to load metadata from '%s'\n", g_fprintf (stderr, "failed to load metadata from '%s'\n",
@ -1177,13 +1190,22 @@ main (int argc, char *argv[])
else else
needs_prefix = FALSE; needs_prefix = FALSE;
g_irepository_register (g_irepository_get_default (), metadata); data = g_metadata_new_from_const_memory (metadata, len);
{
GError *error = NULL;
if (!g_metadata_validate (data, &error)) {
g_printerr ("metadata not valid: %s\n", error->message);
g_clear_error (&error);
}
}
g_irepository_register (g_irepository_get_default (), data);
write_repository (g_irepository_get_default (), needs_prefix); write_repository (g_irepository_get_default (), needs_prefix);
g_irepository_unregister (g_irepository_get_default (), metadata); g_irepository_unregister (g_irepository_get_default (),
g_metadata_get_namespace (data));
if (dlhandle) if (dlhandle)
{ {
dlclose (dlhandle); g_module_close (dlhandle);
dlhandle = NULL; dlhandle = NULL;
} }