diff options
author | Olli Salli <olli.salli@collabora.co.uk> | 2008-07-26 15:26:09 +0300 |
---|---|---|
committer | Olli Salli <olli.salli@collabora.co.uk> | 2008-07-26 15:26:09 +0300 |
commit | b312343b31bbbd0ca72d27f998bb35c90629f97e (patch) | |
tree | 9033b22335b0de600ffbad38a33de350335b9f82 /qt4/tools | |
parent | 370516505c488cc21a693a4f302efffbda8a35ff (diff) |
Explicitly qualify custom types used in generated proxies
Diffstat (limited to 'qt4/tools')
-rw-r--r-- | qt4/tools/libqt4codegen.py | 29 | ||||
-rw-r--r-- | qt4/tools/qt4-client-gen.py | 12 | ||||
-rw-r--r-- | qt4/tools/qt4-types-gen.py | 4 |
3 files changed, 26 insertions, 19 deletions
diff --git a/qt4/tools/libqt4codegen.py b/qt4/tools/libqt4codegen.py index c4ca87e7f..77a4dde8e 100644 --- a/qt4/tools/libqt4codegen.py +++ b/qt4/tools/libqt4codegen.py @@ -35,7 +35,7 @@ class _Qt4TypeBinding: self.custom_type = custom_type self.array_of = array_of -def binding_from_usage(sig, tptype, custom_lists, external=False): +def binding_from_usage(sig, tptype, custom_lists, external=False, explicit_own_ns=None): # 'signature' : ('qt-type', 'pass-by-reference') natives = { 'y' : ('uchar', False, None), @@ -67,6 +67,8 @@ def binding_from_usage(sig, tptype, custom_lists, external=False): inarg = (pass_by_ref and ('const %s&' % val)) or val elif sig[0] == 'a' and natives.has_key(sig[1]) and natives[sig[1]][2]: val = natives[sig[1]][2] + if explicit_own_ns: + val = explicit_own_ns + '::' + val inarg = 'const %s&' % val array_of = natives[sig[1]][0] elif tptype: @@ -75,10 +77,12 @@ def binding_from_usage(sig, tptype, custom_lists, external=False): if external: tptype = 'Telepathy::' + tptype + elif explicit_own_ns: + tptype = explicit_own_ns + '::' + tptype if tptype.endswith('[]'): tptype = tptype[:-2] - assert custom_lists.has_key(tptype), ('No array version of custom type %s in the spec, but array version used' % tptype) + str(custom_lists) + assert custom_lists.has_key(tptype), ('No array version of custom type %s in the spec, but array version used' % tptype) val = custom_lists[tptype] else: val = tptype @@ -96,7 +100,7 @@ def binding_from_decl(name, array_name): outarg = '%s&' % val return _Qt4TypeBinding(val, inarg, outarg, array_name.replace('_', ''), True, None) -def extract_arg_or_member_info(els, custom_lists, externals, docstring_indent=' * ', docstring_brackets=None, docstring_maxwidth=80): +def extract_arg_or_member_info(els, custom_lists, externals, typesns, docstring_indent=' * ', docstring_brackets=None, docstring_maxwidth=80): names = [] docstrings = [] bindings = [] @@ -107,7 +111,7 @@ def extract_arg_or_member_info(els, custom_lists, externals, docstring_indent=' sig = el.getAttribute('type') tptype = el.getAttributeNS(NS_TP, 'type') - bindings.append(binding_from_usage(sig, tptype, custom_lists, (sig, tptype) in externals)) + bindings.append(binding_from_usage(sig, tptype, custom_lists, (sig, tptype) in externals, typesns)) return names, docstrings, bindings @@ -183,18 +187,19 @@ def gather_externals(spec): return externals -def gather_custom_lists(spec): +def gather_custom_lists(spec, typesns): custom_lists = {} - structs = spec.getElementsByTagNameNS(NS_TP, 'struct') - mappings = spec.getElementsByTagNameNS(NS_TP, 'mapping') - exts = spec.getElementsByTagNameNS(NS_TP, 'external-type') + structs = [(provider, typesns) for provider in spec.getElementsByTagNameNS(NS_TP, 'struct')] + mappings = [(provider, typesns) for provider in spec.getElementsByTagNameNS(NS_TP, 'mapping')] + exts = [(provider, 'Telepathy') for provider in spec.getElementsByTagNameNS(NS_TP, 'external-type')] - for provider in structs + mappings + exts: + for (provider, ns) in structs + mappings + exts: tptype = provider.getAttribute('name').replace('_', '') - array_name = provider.getAttribute('array-name') + array_val = provider.getAttribute('array-name').replace('_', '') - if array_name: - custom_lists[tptype] = array_name.replace('_', '') + if array_val: + custom_lists[tptype] = array_val + custom_lists[ns + '::' + tptype] = ns + '::' + array_val return custom_lists diff --git a/qt4/tools/qt4-client-gen.py b/qt4/tools/qt4-client-gen.py index e39863199..6f2c78daa 100644 --- a/qt4/tools/qt4-client-gen.py +++ b/qt4/tools/qt4-client-gen.py @@ -32,6 +32,7 @@ class Generator(object): self.headerfile = opts['--headerfile'] self.implfile = opts['--implfile'] self.namespace = opts['--namespace'] + self.typesnamespace = opts['--typesnamespace'] self.realinclude = opts['--realinclude'] self.prettyinclude = opts['--prettyinclude'] self.typesinclude = opts['--typesinclude'] @@ -45,7 +46,7 @@ class Generator(object): self.bs = [] self.ifacenodes = ifacedom.getElementsByTagName('node') self.spec, = get_by_path(specdom, "spec") - self.custom_lists = gather_custom_lists(self.spec) + self.custom_lists = gather_custom_lists(self.spec, self.typesnamespace) self.externals = gather_externals(self.spec) self.mainifacename = self.mainiface and self.mainiface.replace('/', '').replace('_', '') + 'Interface' @@ -261,7 +262,7 @@ Q_SIGNALS:\ sig = prop.getAttribute('type') tptype = prop.getAttributeNS(NS_TP, 'type') - binding = binding_from_usage(sig, tptype, self.custom_lists, (sig, tptype) in self.externals) + binding = binding_from_usage(sig, tptype, self.custom_lists, (sig, tptype) in self.externals, self.typesnamespace) if 'write' in access: settername = 'set' + 'DBus' + qt4name[0].upper() + qt4name[1:] @@ -308,7 +309,7 @@ Q_SIGNALS:\ name = method.getAttribute('name') qt4name = get_qt4_name(method) args = get_by_path(method, 'arg') - argnames, argdocstrings, argbindings = extract_arg_or_member_info(args, self.custom_lists, self.externals, ' * ') + argnames, argdocstrings, argbindings = extract_arg_or_member_info(args, self.custom_lists, self.externals, self.typesnamespace, ' * ') inargs = [] outargs = [] @@ -368,7 +369,7 @@ Q_SIGNALS:\ def do_signal(self, signal): name = signal.getAttribute('name') qt4name = get_qt4_name(signal) - argnames, argdocstrings, argbindings = extract_arg_or_member_info(get_by_path(signal, 'arg'), self.custom_lists, self.externals, ' * ') + argnames, argdocstrings, argbindings = extract_arg_or_member_info(get_by_path(signal, 'arg'), self.custom_lists, self.externals, self.typesnamespace, ' * ') self.h(""" /** @@ -384,7 +385,7 @@ Q_SIGNALS:\ %s\ """ % (argnames[i], argdocstrings[i])) - self.h(""" + self.h("""\ */ void %s(%s); """ % (qt4name, ', '.join(['%s %s' % (binding.inarg, name) for binding, name in zip(argbindings, argnames)]))) @@ -404,6 +405,7 @@ if __name__ == '__main__': options, argv = gnu_getopt(argv[1:], '', ['group=', 'namespace=', + 'typesnamespace=', 'headerfile=', 'implfile=', 'ifacexml=', diff --git a/qt4/tools/qt4-types-gen.py b/qt4/tools/qt4-types-gen.py index e93c1e85d..508d66168 100644 --- a/qt4/tools/qt4-types-gen.py +++ b/qt4/tools/qt4-types-gen.py @@ -66,7 +66,7 @@ class Generator(object): self.impls = [] self.spec = get_by_path(dom, "spec")[0] self.externals = gather_externals(self.spec) - self.custom_lists = gather_custom_lists(self.spec) + self.custom_lists = gather_custom_lists(self.spec, self.namespace) self.required_custom = [] self.required_arrays = [] self.to_declare = [] @@ -292,7 +292,7 @@ void registerTypes() self.required_custom.remove(type) def output_by_depinfo(self, depinfo): - names, docstrings, bindings = extract_arg_or_member_info(get_by_path(depinfo.el, 'member'), self.custom_lists, self.externals, ' * ', (' /**', ' */')) + names, docstrings, bindings = extract_arg_or_member_info(get_by_path(depinfo.el, 'member'), self.custom_lists, self.externals, None, ' * ', (' /**', ' */')) members = len(names) if depinfo.el.localName == 'struct': |