diff options
Diffstat (limited to 'src/didl2xml.c')
-rw-r--r-- | src/didl2xml.c | 76 |
1 files changed, 20 insertions, 56 deletions
diff --git a/src/didl2xml.c b/src/didl2xml.c index 35ab8b2..aa0caf5 100644 --- a/src/didl2xml.c +++ b/src/didl2xml.c @@ -26,40 +26,15 @@ static gchar **opt_input_files; static gchar *opt_output_dir; -static gchar **opt_namespaces; static GOptionEntry entries[] = { { "idl", 'i', 0, G_OPTION_ARG_FILENAME_ARRAY, &opt_input_files, "IDL files (may be used several times)", NULL }, { "output", 'o', 0, G_OPTION_ARG_FILENAME, &opt_output_dir, "Directory for output", NULL }, - { "namespaces", 'n', 0, G_OPTION_ARG_STRING_ARRAY, &opt_namespaces, "Namespaces to consider (may be used several times)", NULL }, { NULL } }; /* ---------------------------------------------------------------------------------------------------- */ -static gboolean -check_ignore_namespace (DINamespace *namespace, - gchar **namespaces_to_consider) -{ - guint n; - gboolean ret; - - ret = FALSE; - - for (n = 0; namespaces_to_consider[n] != NULL; n++) - { - if (g_strcmp0 (di_namespace_get_name (namespace), namespaces_to_consider[n]) == 0) - goto out; - } - - ret = TRUE; - - out: - return ret; -} - -/* ---------------------------------------------------------------------------------------------------- */ - static void print_annotations (DIBase *base, guint indent, @@ -239,7 +214,7 @@ print_interface (DIInterface *iface, g_string_append_printf (s, "%*s<interface name=\"%s\">\n", indent, "", - di_interface_get_fully_qualified_name (iface)); + di_interface_get_name (iface)); print_annotations ((DIBase *) iface, indent + 2, s); g_string_append (s, "\n"); @@ -288,7 +263,7 @@ print_struct (DIStruct *struct_, g_string_append_printf (s, "%*s<struct name=\"%s\">\n", indent, "", - di_struct_get_fully_qualified_name (struct_)); + di_struct_get_name (struct_)); print_annotations ((DIBase *) struct_, indent + 2, s); g_string_append (s, "\n"); @@ -324,7 +299,7 @@ print_enum (DIEnum *enum_, g_string_append_printf (s, "%*s<enum name=\"%s\">\n", indent, "", - di_enum_get_fully_qualified_name (enum_)); + di_enum_get_name (enum_)); print_annotations ((DIBase *) enum_, indent + 2, s); g_string_append (s, "\n"); @@ -358,7 +333,7 @@ print_error_domain (DIErrorDomain *error_domain, g_string_append_printf (s, "%*s<error_domain name=\"%s\">\n", indent, "", - di_error_domain_get_fully_qualified_name (error_domain)); + di_error_domain_get_name (error_domain)); print_annotations ((DIBase *) error_domain, indent + 2, s); g_string_append (s, "\n"); @@ -421,8 +396,8 @@ write_file (const gchar *filename, } static gboolean -print_namespace (DINamespace *namespace, - GError **error) +print_all (DIParser *parser, + GError **error) { GList *l; gboolean ret; @@ -432,7 +407,7 @@ print_namespace (DINamespace *namespace, /* ---------------------------------------------------------------------------------------------------- */ /* Print all interfaces in separate files */ - for (l = di_namespace_get_interfaces (namespace); l != NULL; l = l->next) + for (l = di_parser_get_interfaces (parser); l != NULL; l = l->next) { DIInterface *iface = l->data; GString *s; @@ -446,7 +421,7 @@ print_namespace (DINamespace *namespace, g_string_append (s, "</typelib>\n"); filename = g_strdup_printf ("%s.xml", - di_interface_get_fully_qualified_name (iface)); + di_interface_get_name (iface)); if (!write_file (filename, s, error)) { g_free (filename); @@ -459,7 +434,7 @@ print_namespace (DINamespace *namespace, /* ---------------------------------------------------------------------------------------------------- */ /* Print all structs in separate files */ - for (l = di_namespace_get_structs (namespace); l != NULL; l = l->next) + for (l = di_parser_get_structs (parser); l != NULL; l = l->next) { DIStruct *struct_ = l->data; GString *s; @@ -473,7 +448,7 @@ print_namespace (DINamespace *namespace, g_string_append (s, "</typelib>\n"); filename = g_strdup_printf ("%s.xml", - di_struct_get_fully_qualified_name (struct_)); + di_struct_get_name (struct_)); if (!write_file (filename, s, error)) { g_free (filename); @@ -486,7 +461,7 @@ print_namespace (DINamespace *namespace, /* ---------------------------------------------------------------------------------------------------- */ /* Print all enums in separate files */ - for (l = di_namespace_get_enums (namespace); l != NULL; l = l->next) + for (l = di_parser_get_enums (parser); l != NULL; l = l->next) { DIEnum *enum_ = l->data; GString *s; @@ -502,7 +477,7 @@ print_namespace (DINamespace *namespace, g_string_append (s, "</typelib>\n"); filename = g_strdup_printf ("%s.xml", - di_enum_get_fully_qualified_name (enum_)); + di_enum_get_name (enum_)); if (!write_file (filename, s, error)) { g_free (filename); @@ -516,7 +491,7 @@ print_namespace (DINamespace *namespace, /* ---------------------------------------------------------------------------------------------------- */ /* Print all error domains in separate files */ - for (l = di_namespace_get_error_domains (namespace); l != NULL; l = l->next) + for (l = di_parser_get_error_domains (parser); l != NULL; l = l->next) { DIErrorDomain *error_domain = l->data; GString *s; @@ -531,7 +506,7 @@ print_namespace (DINamespace *namespace, g_string_append (s, "</typelib>\n"); filename = g_strdup_printf ("%s.xml", - di_error_domain_get_fully_qualified_name (error_domain)); + di_error_domain_get_name (error_domain)); if (!write_file (filename, s, error)) { g_free (filename); @@ -564,7 +539,6 @@ main (int argc, char *argv[]) opt_input_files = NULL; opt_output_dir = NULL; - opt_namespaces = NULL; ret = 1; @@ -585,7 +559,7 @@ main (int argc, char *argv[]) goto out; } - parser = di_parser_new (opt_input_files[0]); + parser = di_parser_new (opt_input_files); for (l = di_parser_get_errors (parser); l != NULL; l = l->next) { g_printerr ("%s\n", (const gchar *) l->data); @@ -597,21 +571,12 @@ main (int argc, char *argv[]) if (di_parser_get_errors (parser) != NULL) goto out; - for (l = di_parser_get_namespaces (parser); l != NULL; l = l->next) + error = NULL; + if (!print_all (parser, &error)) { - DINamespace *namespace = l->data; - - if (opt_namespaces != NULL) - if (check_ignore_namespace (namespace, opt_namespaces)) - continue; - - error = NULL; - if (!print_namespace (namespace, &error)) - { - g_printerr ("Error writing file: %s", error->message); - g_error_free (error); - goto out; - } + g_printerr ("Error writing file: %s", error->message); + g_error_free (error); + goto out; } ret = 0; @@ -623,6 +588,5 @@ main (int argc, char *argv[]) g_option_context_free (context); g_strfreev (opt_input_files); g_free (opt_output_dir); - g_strfreev (opt_namespaces); return ret;; } |