summaryrefslogtreecommitdiff
path: root/src/didl2docbook.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/didl2docbook.c')
-rw-r--r--src/didl2docbook.c185
1 files changed, 38 insertions, 147 deletions
diff --git a/src/didl2docbook.c b/src/didl2docbook.c
index 3d531b5..9f26a82 100644
--- a/src/didl2docbook.c
+++ b/src/didl2docbook.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_type (DIType *type,
GString *s,
@@ -365,9 +340,9 @@ print_interface (DIInterface *iface,
" <refname>Interface %s</refname>\n"
" <refpurpose>%s</refpurpose>\n"
" </refnamediv>\n",
- di_interface_get_fully_qualified_name (iface),
- di_interface_get_fully_qualified_name (iface),
- di_interface_get_fully_qualified_name (iface),
+ di_interface_get_name (iface),
+ di_interface_get_name (iface),
+ di_interface_get_name (iface),
get_doc (iface, TRUE));
/* Synopsis for methods */
@@ -502,7 +477,7 @@ print_interface (DIInterface *iface,
g_string_append_printf (s, " <refsect2 role=\"function\" id=\"didl-%s\">\n"
" <title>%s ()</title>\n",
- di_method_get_fully_qualified_name (method),
+ di_method_get_name (method),
di_method_get_name (method));
g_string_append_printf (s, " <programlisting>\n");
@@ -539,7 +514,7 @@ print_interface (DIInterface *iface,
g_string_append_printf (s, " <refsect2 role=\"function\" id=\"didl-%s\">\n"
" <title>%s ()</title>\n",
- di_signal_get_fully_qualified_name (signal),
+ di_signal_get_name (signal),
di_signal_get_name (signal));
g_string_append_printf (s, " <programlisting>\n");
@@ -575,7 +550,7 @@ print_interface (DIInterface *iface,
g_string_append_printf (s, " <refsect2 role=\"function\" id=\"didl-%s\">\n"
" <title>%s ()</title>\n",
- di_property_get_fully_qualified_name (property),
+ di_property_get_name (property),
di_property_get_name (property));
g_string_append_printf (s, " <programlisting>\n");
@@ -686,14 +661,14 @@ print_struct (DIStruct *struct_,
" <refname>Struct %s</refname>\n"
" <refpurpose>%s</refpurpose>\n"
" </refnamediv>\n",
- di_struct_get_fully_qualified_name (struct_),
- di_struct_get_fully_qualified_name (struct_),
- di_struct_get_fully_qualified_name (struct_),
+ di_struct_get_name (struct_),
+ di_struct_get_name (struct_),
+ di_struct_get_name (struct_),
get_doc (struct_, TRUE));
print_struct_members (di_struct_get_members (struct_),
"struct",
- di_struct_get_fully_qualified_name (struct_),
+ di_struct_get_name (struct_),
get_doc (struct_, FALSE),
s);
}
@@ -713,9 +688,9 @@ print_enum (DIEnum *enum_,
" <refname>Enum %s</refname>\n"
" <refpurpose>%s</refpurpose>\n"
" </refnamediv>\n",
- di_enum_get_fully_qualified_name (enum_),
- di_enum_get_fully_qualified_name (enum_),
- di_enum_get_fully_qualified_name (enum_),
+ di_enum_get_name (enum_),
+ di_enum_get_name (enum_),
+ di_enum_get_name (enum_),
get_doc (enum_, TRUE));
@@ -741,7 +716,7 @@ print_enum (DIEnum *enum_,
g_string_append_printf (s,
"enum %s\n"
"{\n",
- di_enum_get_fully_qualified_name (enum_));
+ di_enum_get_name (enum_));
for (l = di_enum_get_members (enum_); l != NULL; l = l->next)
{
@@ -801,9 +776,9 @@ print_error_domain (DIErrorDomain *error_domain,
" <refname>Error Domain %s</refname>\n"
" <refpurpose>%s</refpurpose>\n"
" </refnamediv>\n",
- di_error_domain_get_fully_qualified_name (error_domain),
- di_error_domain_get_fully_qualified_name (error_domain),
- di_error_domain_get_fully_qualified_name (error_domain),
+ di_error_domain_get_name (error_domain),
+ di_error_domain_get_name (error_domain),
+ di_error_domain_get_name (error_domain),
get_doc (error_domain, TRUE));
@@ -817,7 +792,7 @@ print_error_domain (DIErrorDomain *error_domain,
g_string_append_printf (s,
"error_domain %s\n"
"{\n",
- di_error_domain_get_fully_qualified_name (error_domain));
+ di_error_domain_get_name (error_domain));
for (l = di_error_domain_get_members (error_domain); l != NULL; l = l->next)
{
@@ -885,38 +860,18 @@ write_file (const gchar *filename,
}
static gboolean
-print_namespace (DINamespace *namespace,
- GError **error)
+print_all (DIParser *parser,
+ GError **error)
{
GList *l;
gboolean ret;
gchar *filename;
- GString *sn;
ret = FALSE;
-
- sn = g_string_new (NULL);
- g_string_append (sn,
- "<?xml version=\"1.0\"?>\n"
- "<!DOCTYPE book PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2 //EN\"\n"
- "\"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\">\n");
-
- g_string_append_printf (sn,
- "<book id=\"didl-%s\" xmlns:xi=\"http://www.w3.org/2003/XInclude\">\n",
- di_namespace_get_name (namespace));
-
- g_string_append_printf (sn,
- " <reference>\n"
- " <title>Foo</title>\n");
-
/* ---------------------------------------------------------------------------------------------------- */
-
- /* Print all interfaces in separate files */
- g_string_append_printf (sn,
- " <chapter id=\"bar\">\n"
- " <title>D-Bus interfaces</title>\n");
- for (l = di_namespace_get_interfaces (namespace); l != NULL; l = l->next)
+ /* Print all interfaces */
+ for (l = di_parser_get_interfaces (parser); l != NULL; l = l->next)
{
DIInterface *iface = l->data;
GString *s;
@@ -929,7 +884,7 @@ print_namespace (DINamespace *namespace,
print_interface (iface, s);
filename = g_strdup_printf ("didl-%s.xml",
- di_interface_get_fully_qualified_name (iface));
+ di_interface_get_name (iface));
if (!write_file (filename, s, error))
{
g_free (filename);
@@ -937,23 +892,12 @@ print_namespace (DINamespace *namespace,
goto out;
}
g_string_free (s, TRUE);
-
- g_string_append_printf (sn,
- " <xi:include href=\"%s\"/>\n",
- filename);
-
g_free (filename);
}
- g_string_append_printf (sn,
- " </chapter>\n");
/* ---------------------------------------------------------------------------------------------------- */
-
- /* Print all structs in separate files */
- g_string_append_printf (sn,
- " <chapter>\n"
- " <title>Structs</title>\n");
- for (l = di_namespace_get_structs (namespace); l != NULL; l = l->next)
+ /* Print all structs */
+ for (l = di_parser_get_structs (parser); l != NULL; l = l->next)
{
DIStruct *struct_ = l->data;
GString *s;
@@ -966,7 +910,7 @@ print_namespace (DINamespace *namespace,
print_struct (struct_, s);
filename = g_strdup_printf ("didl-%s.xml",
- di_struct_get_fully_qualified_name (struct_));
+ di_struct_get_name (struct_));
if (!write_file (filename, s, error))
{
g_free (filename);
@@ -975,22 +919,12 @@ print_namespace (DINamespace *namespace,
}
g_string_free (s, TRUE);
- g_string_append_printf (sn,
- " <xi:include href=\"%s\"/>\n",
- filename);
-
g_free (filename);
}
- g_string_append_printf (sn,
- " </chapter>\n");
/* ---------------------------------------------------------------------------------------------------- */
-
- /* Print all enums in separate files */
- g_string_append_printf (sn,
- " <chapter>\n"
- " <title>Enumerations</title>\n");
- for (l = di_namespace_get_enums (namespace); l != NULL; l = l->next)
+ /* Print all enums */
+ for (l = di_parser_get_enums (parser); l != NULL; l = l->next)
{
DIEnum *enum_ = l->data;
GString *s;
@@ -1003,7 +937,7 @@ print_namespace (DINamespace *namespace,
print_enum (enum_, s);
filename = g_strdup_printf ("didl-%s.xml",
- di_enum_get_fully_qualified_name (enum_));
+ di_enum_get_name (enum_));
if (!write_file (filename, s, error))
{
g_free (filename);
@@ -1012,22 +946,12 @@ print_namespace (DINamespace *namespace,
}
g_string_free (s, TRUE);
- g_string_append_printf (sn,
- " <xi:include href=\"%s\"/>\n",
- filename);
-
g_free (filename);
}
- g_string_append_printf (sn,
- " </chapter>\n");
/* ---------------------------------------------------------------------------------------------------- */
-
- /* Print all error domains in separate files */
- g_string_append_printf (sn,
- " <chapter>\n"
- " <title>Error domains</title>\n");
- for (l = di_namespace_get_error_domains (namespace); l != NULL; l = l->next)
+ /* Print all error domains */
+ for (l = di_parser_get_error_domains (parser); l != NULL; l = l->next)
{
DIErrorDomain *error_domain = l->data;
GString *s;
@@ -1040,7 +964,7 @@ print_namespace (DINamespace *namespace,
print_error_domain (error_domain, s);
filename = g_strdup_printf ("didl-%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);
@@ -1049,36 +973,14 @@ print_namespace (DINamespace *namespace,
}
g_string_free (s, TRUE);
- g_string_append_printf (sn,
- " <xi:include href=\"%s\"/>\n",
- filename);
-
g_free (filename);
}
- g_string_append_printf (sn,
- " </chapter>\n");
-
/* ---------------------------------------------------------------------------------------------------- */
- g_string_append_printf (sn,
- " </reference>\n");
- g_string_append_printf (sn, "</book>\n");
-
- filename = g_strdup_printf ("didl-%s.xml",
- di_namespace_get_name (namespace));
- if (!write_file (filename, sn, error))
- {
- g_free (filename);
- goto out;
- }
- g_free (filename);
-
ret = TRUE;
out:
- if (sn != NULL)
- g_string_free (sn, TRUE);
return ret;
}
@@ -1097,7 +999,6 @@ main (int argc, char *argv[])
opt_input_files = NULL;
opt_output_dir = NULL;
- opt_namespaces = NULL;
ret = 1;
@@ -1118,7 +1019,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);
@@ -1130,21 +1031,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;
@@ -1156,6 +1048,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;;
}