Commit 9aed1d7a authored by Stefan Sauer's avatar Stefan Sauer
Browse files

gstdoc-scangobj: generate -sections.txt

Generate a sections file. We don't merge it yet until we cleaned all the modules.
parent f74b2df7
......@@ -110,6 +110,8 @@ my $old_prerequisites_filename = "$OUTPUT_DIR/$MODULE.prerequisites";
my $new_prerequisites_filename = "$OUTPUT_DIR/$MODULE.prerequisites.new";
my $old_args_filename = "$OUTPUT_DIR/$MODULE.args";
my $new_args_filename = "$OUTPUT_DIR/$MODULE.args.new";
my $old_sections_filename = "$OUTPUT_DIR/$MODULE-sections";
my $new_sections_filename = "$OUTPUT_DIR/$MODULE-sections.new";
my $debug_log="g_message";
if (!defined($VERBOSE) or $VERBOSE eq "0") {
......@@ -437,32 +439,30 @@ const gchar *hierarchy_filename = "$new_hierarchy_filename";
const gchar *interfaces_filename = "$new_interfaces_filename";
const gchar *prerequisites_filename = "$new_prerequisites_filename";
const gchar *args_filename = "$new_args_filename";
const gchar *sections_filename = "$new_sections_filename";
static void output_signals (void);
static void output_object_signals (FILE *fp,
GType object_type);
static void output_object_signal (FILE *fp,
const gchar *object_class_name,
static void output_object_signals (FILE *fp, GType object_type);
static void output_object_signal (FILE *fp, const gchar *object_class_name,
guint signal_id);
static const gchar * get_type_name (GType type,
gboolean * is_pointer);
static const gchar * get_type_name (GType type, gboolean * is_pointer);
static void output_object_hierarchy (void);
static void output_hierarchy (FILE *fp,
GType type,
guint level);
static void output_hierarchy (FILE *fp, GType type, guint level);
static void output_object_interfaces (void);
static void output_interfaces (FILE *fp,
GType type);
static void output_interfaces (FILE *fp, GType type);
static void output_interface_prerequisites (void);
static void output_prerequisites (FILE *fp,
GType type);
static void output_prerequisites (FILE *fp, GType type);
static void output_args (void);
static void output_object_args (FILE *fp, GType object_type);
static void output_sections (void);
static void output_object_section (FILE *fp, GType object_type);
int
main (G_GNUC_UNUSED int argc, G_GNUC_UNUSED char *argv[])
{
......@@ -475,6 +475,8 @@ main (G_GNUC_UNUSED int argc, G_GNUC_UNUSED char *argv[])
output_object_interfaces ();
output_interface_prerequisites ();
output_args ();
output_sections ();
return 0;
}
......@@ -1570,6 +1572,139 @@ output_object_args (FILE *fp, GType object_type)
break;
}
}
static void
output_sections (void)
{
FILE *fp;
gint i;
fp = fopen (sections_filename, "w");
if (fp == NULL)
{
g_warning ("Couldn't open output file: %s : %s", sections_filename, g_strerror(errno));
return;
}
for (i = 0; object_types[i]; i++) { }
qsort (object_types, i, sizeof (GType), compare_types);
for (i = 0; object_types[i]; i++) {
output_object_section (fp, object_types[i]);
}
fclose (fp);
}
static gboolean
find_by_type (GstPluginFeature *f, gpointer data) {
return (GST_IS_ELEMENT_FACTORY(f) &&
((GType)data == gst_element_factory_get_element_type (GST_ELEMENT_FACTORY(f))));
}
static void
output_object_section (FILE *fp, GType object_type)
{
/* e.g. GstFakeSink */
const gchar *tn = g_type_name (object_type);
const gchar *cct = &tn[3]; /* cut 'Gst' */
gchar *title, *lct, *uct;
gint i, j, l = strlen(cct);
gpointer class;
GParamSpec **properties;
guint n_properties;
const gchar *ptn;
gchar *ptns;
GString *strbuf = g_string_new (NULL);
GList *fl;
GstPluginFeature *f = NULL;
gboolean need_unserscore = TRUE, have_abbrev = FALSE;
fl = gst_registry_feature_filter (gst_registry_get(), find_by_type, TRUE,
(gpointer)object_type);
if (fl) {
f = fl->data;
g_list_free(fl);
}
if (f) {
title = g_strdup (gst_plugin_feature_get_name(f));
g_object_unref (f);
} else {
title = g_ascii_strdown(cct, -1);
}
/* turn CamelCase into '_' separated all lower, resulting string is atmost
* twice as long, special casing for abbevs like GstTCPClientSink */
lct = g_malloc(2*l);
for (i = 0, j = 0; i < l; i++) {
if (g_ascii_isupper (cct[i])) {
if (need_unserscore) {
if (i > 0) {
lct[j++] = '_';
}
} else {
have_abbrev = TRUE;
}
lct[j++] = g_ascii_tolower(cct[i]);
need_unserscore = FALSE;
} else {
if (have_abbrev) {
lct[j] = lct[j-1];
lct[j-1] = '_';
j++;
have_abbrev = FALSE;
}
lct[j++] = cct[i];
need_unserscore = TRUE;
}
}
lct[j] = '\\0';
uct = g_ascii_strup(lct, -1);
/* scan properties and find local enums */
class = g_type_class_peek (object_type);
properties = g_object_class_list_properties (class, &n_properties);
qsort (properties, n_properties, sizeof (GParamSpec *), compare_param_specs);
for (i = 0; i < n_properties; i++) {
GParamSpec *spec = properties[i];
if (!(G_IS_PARAM_SPEC_ENUM (spec) || G_IS_PARAM_SPEC_FLAGS (spec))) {
continue;
}
ptn = g_type_name(spec->value_type);
// does it start with tn?
if (strncmp(tn, ptn, strlen(tn))) {
continue;
}
g_string_append_c(strbuf, '\\n');
g_string_append(strbuf, ptn);
}
ptns = g_string_free (strbuf, FALSE);
/* later we can remove the SUBSECTION Standart/Private, since we only need to
* highlight what is public API */
fprintf (fp, "<SECTION>\\n"
"<FILE>element-%s</FILE>\\n"
"<TITLE>%s</TITLE>\\n"
"Gst%s%s\\n"
"<SUBSECTION Standard>\\n"
"Gst%sClass\\n"
"GST_%s\\n"
"GST_%s_CAST\\n"
"GST_IS_%s\\n"
"GST_%s_CLASS\\n"
"GST_IS_%s_CLASS\\n"
"GST_TYPE_%s\\n"
"<SUBSECTION Private>\\n"
"gst_%s_get_type\\n"
"</SECTION>\\n\\n",
title, title, cct, ptns,
cct, uct, uct, uct, uct, uct, uct, lct);
g_free (title);
g_free (lct);
g_free (uct);
g_free (ptns);
}
EOT
close OUTPUT;
......@@ -1614,4 +1749,4 @@ if (!defined($ENV{"GTK_DOC_KEEP_INTERMEDIATE"})) {
#&UpdateFileIfChanged ($old_prerequisites_filename, $new_prerequisites_filename, 0);
#&UpdateFileIfChanged ($old_signals_filename, $new_signals_filename, 0);
#&UpdateFileIfChanged ($old_args_filename, $new_args_filename, 0);
#&UpdateFileIfChanged ($old_sections_filename, $new_sections_filename, 0);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment