[Telepathy-commits] [telepathy-qt4/master] Make prettyinclude optional in types-gen and client-gen, extensions don't usually care about pretty includes

Olli Salli olli.salli at collabora.co.uk
Mon Sep 29 13:05:11 PDT 2008


---
 tools/libqt4codegen.py  |    7 +++++++
 tools/qt4-client-gen.py |    9 ++++-----
 tools/qt4-types-gen.py  |   27 ++++++++++++++-------------
 3 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/tools/libqt4codegen.py b/tools/libqt4codegen.py
index 77a4dde..62700a2 100644
--- a/tools/libqt4codegen.py
+++ b/tools/libqt4codegen.py
@@ -203,6 +203,13 @@ def gather_custom_lists(spec, typesns):
 
     return custom_lists
 
+def get_headerfile_cmd(realinclude, prettyinclude, indent=' * '):
+    prettyinclude = prettyinclude or realinclude
+    if realinclude:
+        return indent + ('\\headerfile %s <%s>\n' % (realinclude, prettyinclude))
+    else:
+        return ''
+
 def get_qt4_name(el):
     name = el.getAttribute('name')
 
diff --git a/tools/qt4-client-gen.py b/tools/qt4-client-gen.py
index 3f928d2..1596c98 100644
--- a/tools/qt4-client-gen.py
+++ b/tools/qt4-client-gen.py
@@ -23,7 +23,7 @@ import codecs
 from getopt import gnu_getopt
 
 from libtpcodegen import NS_TP, get_descendant_text, get_by_path
-from libqt4codegen import binding_from_usage, extract_arg_or_member_info, format_docstring, gather_externals, gather_custom_lists, get_qt4_name, qt4_identifier_escape
+from libqt4codegen import binding_from_usage, extract_arg_or_member_info, format_docstring, gather_externals, gather_custom_lists, get_headerfile_cmd, get_qt4_name, qt4_identifier_escape
 
 class Generator(object):
     def __init__(self, opts):
@@ -34,7 +34,7 @@ class Generator(object):
             self.namespace = opts['--namespace']
             self.typesnamespace = opts['--typesnamespace']
             self.realinclude = opts['--realinclude']
-            self.prettyinclude = opts['--prettyinclude']
+            self.prettyinclude = opts.get('--prettyinclude')
             self.extraincludes = opts.get('--extraincludes', None)
             self.mainiface = opts.get('--mainiface', None)
             ifacedom = xml.dom.minidom.parse(opts['--ifacexml'])
@@ -121,7 +121,7 @@ namespace %s
         self.h("""
 /**
  * \\class %(name)s
- * \\headerfile %(realinclude)s <%(prettyinclude)s>
+%(headercmd)s\
  * \\ingroup %(group)s
  *
  * Proxy class providing a 1:1 mapping of the D-Bus interface "%(dbusname)s."
@@ -170,8 +170,7 @@ public:
         QObject* parent = 0
     );
 """ % {'name' : name,
-       'realinclude' : self.realinclude,
-       'prettyinclude' : self.prettyinclude,
+       'headercmd' : get_headerfile_cmd(self.realinclude, self.prettyinclude),
        'group' : self.group,
        'dbusname' : dbusname})
 
diff --git a/tools/qt4-types-gen.py b/tools/qt4-types-gen.py
index 727e802..089e17e 100644
--- a/tools/qt4-types-gen.py
+++ b/tools/qt4-types-gen.py
@@ -22,7 +22,7 @@ import xml.dom.minidom
 from getopt import gnu_getopt
 
 from libtpcodegen import NS_TP, get_descendant_text, get_by_path
-from libqt4codegen import binding_from_usage, binding_from_decl, extract_arg_or_member_info, format_docstring, gather_externals, gather_custom_lists, get_qt4_name
+from libqt4codegen import binding_from_usage, binding_from_decl, extract_arg_or_member_info, format_docstring, gather_externals, gather_custom_lists, get_qt4_name, get_headerfile_cmd
 
 class DepInfo:
     def __init__(self, el, externals, custom_lists):
@@ -137,8 +137,8 @@ class Generator(object):
 
 """)
         self.impl("""
-#include <%s>
-""" % self.prettyinclude)
+#include "%s"
+""" % self.realinclude)
         self.both("""
 namespace %s
 {
@@ -153,7 +153,7 @@ namespace %s
         self.decl("""\
 /**
  * \\ingroup types
- * \\headerfile %s <%s>
+%s\
  *
  * Register the types used by the library with the QtDBus type system.
  *
@@ -163,7 +163,8 @@ namespace %s
 void registerTypes();
 }
 
-""" % (self.realinclude, self.prettyinclude))
+""" % get_headerfile_cmd(self.realinclude, self.prettyinclude))
+
         self.impl("""\
 void registerTypes()
 {
@@ -228,12 +229,12 @@ void registerTypes()
  /**
   * \\struct %s
   * \\ingroup list
-  * \\headerfile %s <%s>
+%s\
   * 
   * Generic list type with %s elements. Convertible with
   * %s, but needed to have a discrete type in the Qt4 type system.
   */
-""" % (val, self.realinclude, self.prettyinclude, array_of, real))
+""" % (val, get_headerfile_cmd(self.realinclude, self.prettyinclude), array_of, real))
             self.decl(self.faketype(val, real))
             self.to_declare.append(self.namespace + '::' + val)
 
@@ -301,14 +302,14 @@ void registerTypes()
 /**
  * \\struct %(name)s
  * \\ingroup struct
- * \\headerfile %(realinclude)s <%(prettyinclude)s>
+%(headercmd)s\
  *
  * Structure type generated from the specification.
 %(docstring)s\
  */
 struct %(name)s
 {
-""" % {'name' : depinfo.binding.val, 'realinclude' : self.realinclude, 'prettyinclude' : self.prettyinclude, 'docstring' : format_docstring(depinfo.el)})
+""" % {'name' : depinfo.binding.val, 'headercmd': get_headerfile_cmd(self.realinclude, self.prettyinclude), 'docstring' : format_docstring(depinfo.el)})
 
             for i in xrange(members):
                 self.decl("""\
@@ -351,13 +352,13 @@ struct %(name)s
 /**
  * \\struct %s
  * \\ingroup mapping
- * \\headerfile %s <%s>
+%s\
  *
  * Mapping type generated from the specification. Convertible with
  * %s, but needed to have a discrete type in the Qt4 type system.
 %s\
  */
-""" % (depinfo.binding.val, self.realinclude, self.prettyinclude, realtype, format_docstring(depinfo.el)))
+""" % (depinfo.binding.val, get_headerfile_cmd(self.realinclude, self.prettyinclude), realtype, format_docstring(depinfo.el)))
             self.decl(self.faketype(depinfo.binding.val, realtype))
         else:
             assert False
@@ -369,13 +370,13 @@ struct %(name)s
             self.decl("""\
 /**
  * \\ingroup list
- * \\headerfile %s <%s>
+%s\
  *
  * Array of %s values.
  */
 typedef %s %s;
 
-""" % (self.realinclude, self.prettyinclude, depinfo.binding.val, 'QList<%s>' % depinfo.binding.val, depinfo.binding.array_val))
+""" % (get_headerfile_cmd(self.realinclude, self.prettyinclude), depinfo.binding.val, 'QList<%s>' % depinfo.binding.val, depinfo.binding.array_val))
 
     def faketype(self, fake, real):
         return """\
-- 
1.5.6.5




More information about the Telepathy-commits mailing list