mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 06:56:14 +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
This commit is contained in:
parent
35527e755c
commit
cec833af42
@ -36,23 +36,24 @@ gboolean no_init = FALSE;
|
||||
gchar **input = NULL;
|
||||
gchar *output = NULL;
|
||||
gchar *mname = NULL;
|
||||
gchar *shlib = NULL;
|
||||
gboolean debug = FALSE;
|
||||
gboolean verbose = FALSE;
|
||||
|
||||
static gchar *
|
||||
format_output (guchar *metadata,
|
||||
gsize len)
|
||||
format_output (GMetadata *metadata)
|
||||
{
|
||||
GString *result;
|
||||
gint i;
|
||||
|
||||
result = g_string_sized_new (6 * len);
|
||||
result = g_string_sized_new (6 * metadata->len);
|
||||
|
||||
g_string_append_printf (result, "#include <stdlib.h>\n\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, "const unsigned char _G_METADATA[] = \n{");
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
for (i = 0; i < metadata->len; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
g_string_append (result, ", ");
|
||||
@ -60,10 +61,12 @@ format_output (guchar *metadata,
|
||||
if (i % 10 == 0)
|
||||
g_string_append (result, "\n\t");
|
||||
|
||||
g_string_append_printf (result, "0x%.2x", metadata[i]);
|
||||
g_string_append_printf (result, "0x%.2x", metadata->data[i]);
|
||||
}
|
||||
|
||||
g_string_append_printf (result, "\n};\n\n");
|
||||
g_string_append_printf (result, "const gsize _G_METADATA_SIZE = %u;\n\n",
|
||||
(guint)metadata->len);
|
||||
|
||||
if (!no_init)
|
||||
{
|
||||
@ -71,15 +74,18 @@ format_output (guchar *metadata,
|
||||
"__attribute__((constructor)) void\n"
|
||||
"register_metadata (void)\n"
|
||||
"{\n"
|
||||
"\tg_irepository_register (NULL, _G_METADATA);\n"
|
||||
"\tGMetadata *metadata;\n"
|
||||
"\tmetadata = g_metadata_new_from_const_memory (_G_METADATA, _G_METADATA_SIZE);\n"
|
||||
"\tg_irepository_register (NULL, metadata);\n"
|
||||
"}\n\n");
|
||||
|
||||
g_string_append_printf (result,
|
||||
"__attribute__((destructor)) void\n"
|
||||
"unregister_metadata (void)\n"
|
||||
"{\n"
|
||||
"\tg_irepository_unregister (NULL, _G_METADATA);\n"
|
||||
"}\n");
|
||||
"\tg_irepository_unregister (NULL, \"%s\");\n"
|
||||
"}\n",
|
||||
g_metadata_get_namespace (metadata));
|
||||
}
|
||||
|
||||
return g_string_free (result, FALSE);
|
||||
@ -87,8 +93,7 @@ format_output (guchar *metadata,
|
||||
|
||||
static void
|
||||
write_out_metadata (gchar *prefix,
|
||||
guchar *metadata,
|
||||
gsize len)
|
||||
GMetadata *metadata)
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
@ -117,12 +122,12 @@ write_out_metadata (gchar *prefix,
|
||||
}
|
||||
|
||||
if (raw)
|
||||
fwrite (metadata, 1, len, file);
|
||||
fwrite (metadata->data, 1, metadata->len, file);
|
||||
else
|
||||
{
|
||||
gchar *code;
|
||||
|
||||
code = format_output (metadata, len);
|
||||
code = format_output (metadata);
|
||||
fputs (code, file);
|
||||
g_free (code);
|
||||
}
|
||||
@ -150,6 +155,7 @@ 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" },
|
||||
{ "shared-library", 'l', 0, G_OPTION_ARG_FILENAME, &shlib, "shared library", "FILE" },
|
||||
{ "debug", 0, 0, G_OPTION_ARG_NONE, &debug, "show debug messages", NULL },
|
||||
{ "verbose", 0, 0, G_OPTION_ARG_NONE, &verbose, "show verbose messages", NULL },
|
||||
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &input, NULL, NULL },
|
||||
@ -207,20 +213,24 @@ main (int argc, char ** argv)
|
||||
{
|
||||
GIdlModule *module = m->data;
|
||||
gchar *prefix;
|
||||
guchar *metadata;
|
||||
gsize len;
|
||||
GMetadata *metadata;
|
||||
|
||||
if (mname && strcmp (mname, module->name) != 0)
|
||||
continue;
|
||||
|
||||
g_idl_module_build_metadata (module, modules, &metadata, &len);
|
||||
if (shlib)
|
||||
{
|
||||
if (module->shared_library)
|
||||
g_free (module->shared_library);
|
||||
module->shared_library = g_strdup (shlib);
|
||||
}
|
||||
metadata = g_idl_module_build_metadata (module, modules);
|
||||
if (metadata == NULL)
|
||||
{
|
||||
g_error ("Failed to build metadata for module '%s'\n", module->name);
|
||||
|
||||
continue;
|
||||
}
|
||||
if (!g_metadata_validate (metadata, len, &error))
|
||||
if (!g_metadata_validate (metadata, &error))
|
||||
g_error ("Invalid metadata for module '%s': %s",
|
||||
module->name, error->message);
|
||||
|
||||
@ -230,8 +240,8 @@ main (int argc, char ** argv)
|
||||
else
|
||||
prefix = NULL;
|
||||
|
||||
write_out_metadata (prefix, metadata, len);
|
||||
g_free (metadata);
|
||||
write_out_metadata (prefix, metadata);
|
||||
g_metadata_free (metadata);
|
||||
metadata = NULL;
|
||||
|
||||
/* when writing to stdout, stop after the first module */
|
||||
|
Loading…
Reference in New Issue
Block a user