fclose (fp);
}
+static int
+compare_types (const void *a, const void *b)
+{
+ const char *na = g_type_name (*((GType *)a));
+ const char *nb = g_type_name (*((GType *)b));
+
+ return g_strcmp0 (na, nb);
+}
+
+
/* This is called recursively to output the hierarchy of a object. */
static void
output_hierarchy (FILE *fp,
fprintf (fp, "%s\\n", g_type_name (type));
children = g_type_children (type, &n_children);
+ qsort (children, n_children, sizeof (GType), compare_types);
+
for (i=0; i < n_children; i++)
output_hierarchy (fp, children[i], level + 1);
}
&UpdateFileIfChanged ($old_hierarchy_filename, $new_hierarchy_filename, 0);
-&UpdateFileIfChanged ($old_interfaces_filename, $new_interfaces_filename, 0);
-&UpdateFileIfChanged ($old_prerequisites_filename, $new_prerequisites_filename, 0);
# we will merge these in scangobj-merge.py
+#&UpdateFileIfChanged ($old_interfaces_filename, $new_interfaces_filename, 0);
+#&UpdateFileIfChanged ($old_prerequisites_filename, $new_prerequisites_filename, 0);
#&UpdateFileIfChanged ($old_signals_filename, $new_signals_filename, 0);
#&UpdateFileIfChanged ($old_args_filename, $new_args_filename, 0);
# gstdoc-scanobj produces 5 output files (.new)
# scangobj-merge.py merges them into the file which we commit later
-# TODO: scangobj-merge.py only merges signals and args
-# - for interfaces and prerequisites do:
-# 'sort -du file file.new' and update file if changed
-# - do that either in gstdoc-scanobj (which we change already) or in
-# scangobj-merge.py
+# TODO: also merge the hierarchy
scanobj-build.stamp: $(SCANOBJ_DEPS) $(basefiles)
@echo " DOC Introspecting gobjects"
@if test x"$(srcdir)" != x. ; then \
# vi:si:et:sw=4:sts=4:ts=4
"""
-parse, update and write .signals and .args files
+parse, merge and write gstdoc-scanobj files
"""
import sys
def save_file(self, filename, backup=False):
"""
- Save the signals information to the given .signals file if the
- file content changed.
+ Save the information to the given file if the file content changed.
"""
olddata = None
try:
return "\n".join(lines) + '\n'
+class SingleLine(GDoc):
+ def __init__(self):
+ self._objects = []
+
+ def load_data(self, data):
+ """
+ Load the .interfaces/.prerequisites lines, merge duplicates
+ """
+ # split data on '\n'
+ lines = data.splitlines();
+ # merge them into self._objects
+ for line in lines:
+ if line not in self._objects:
+ self._objects.append(line)
+
+ def get_data(self):
+ lines = sorted(self._objects)
+ return "\n".join(lines) + '\n'
+
def main(argv):
modulename = None
try:
args.save_file(modulename + '.args', backup=True)
os.unlink(modulename + '.args.new')
+ ifaces = SingleLine()
+ ifaces.load_file(modulename + '.interfaces')
+ ifaces.load_file(modulename + '.interfaces.new')
+ ifaces.save_file(modulename + '.interfaces', backup=True)
+ os.unlink(modulename + '.interfaces.new')
+
+ prereq = SingleLine()
+ prereq.load_file(modulename + '.prerequisites')
+ prereq.load_file(modulename + '.prerequisites.new')
+ prereq.save_file(modulename + '.prerequisites', backup=True)
+ os.unlink(modulename + '.prerequisites.new')
+
main(sys.argv)