def __init__(self, el, externals, custom_lists): self.el = el name = get_by_path(el, '@name') array_name = get_by_path(el, '@array-name') array_depth = get_by_path(el, '@array-depth') if array_depth: array_depth = int(array_depth) else: array_depth = None self.binding = binding_from_decl(name, array_name, array_depth) self.deps = [] for member in get_by_path(el, 'member'): sig = member.getAttribute('type') tptype = member.getAttributeNS(NS_TP, 'type') if (sig, tptype) in externals: continue if tptype.endswith('[]'): tptype = tptype[:-2] binding = binding_from_usage(sig, tptype, custom_lists) if binding.custom_type: self.deps.append(binding.val) self.revdeps = []
def provide_all(self): self.required_arrays.sort() for (val, array_of) in self.required_arrays: real = 'QList<%s>' % array_of self.decl("""\ /** * \\struct %s * \\ingroup list %s\ * * Generic list type with %s elements. Convertible with * %s, but needed to have a discrete type in the Qt type system. */ """ % (val, get_headerfile_cmd(self.realinclude, self.prettyinclude), array_of, real)) self.decl(self.faketype(val, real)) self.to_declare.append(self.namespace + '::' + val) structs = self.spec.getElementsByTagNameNS(NS_TP, 'struct') mappings = self.spec.getElementsByTagNameNS(NS_TP, 'mapping') exts = self.spec.getElementsByTagNameNS(NS_TP, 'external-type') for deptype in structs + mappings: info = DepInfo(deptype, self.externals, self.custom_lists) self.depinfos[info.binding.val] = info leaves = [] next_leaves = [] for val, depinfo in self.depinfos.iteritems(): leaf = True for dep in depinfo.deps: if not self.depinfos.has_key(dep): raise UnresolvedDependency(val, dep) leaf = False self.depinfos[dep].revdeps.append(val) if leaf: next_leaves.append(val) while leaves or next_leaves: if not leaves: leaves = next_leaves leaves.sort() next_leaves = [] val = leaves.pop(0) depinfo = self.depinfos[val] self.output_by_depinfo(depinfo) for revdep in depinfo.revdeps: revdepinfo = self.depinfos[revdep] revdepinfo.deps.remove(val) if not revdepinfo.deps: next_leaves.append(revdep) del self.depinfos[val] for provider in structs + mappings + exts: name = get_by_path(provider, '@name') array_name = get_by_path(provider, '@array-name') array_depth = get_by_path(provider, '@array-depth') if array_depth: array_depth = int(array_depth) else: array_depth = None sig = provider.getAttribute('type') tptype = provider.getAttribute('name') external = (sig, tptype) in self.externals binding = binding_from_decl(name, array_name, array_depth, external) self.provide(binding.val) if binding.array_val: self.provide(binding.array_val) d = binding.array_depth while d > 1: d -= 1 self.provide(binding.array_val + ('List' * d)) if self.required_custom: raise MissingTypes(self.required_custom)
def provide_all(self): self.required_arrays.sort() for (val, array_of) in self.required_arrays: init_list_type = array_of real = 'QList<%s>' % init_list_type self.decl("""\ /** * \\struct %s * \\ingroup list %s\ * * Generic list type with %s elements. Convertible with * %s, but needed to have a discrete type in the Qt type system. */ """ % (val, get_headerfile_cmd(self.realinclude, self.prettyinclude), array_of, real)) self.decl(self.faketype(val, real, init_list_type)) self.to_declare.append(self.namespace + '::' + val) self.both('%s QDBusArgument& operator<<(QDBusArgument& arg, const %s &list)' % (self.visibility, val)) self.decl(';\n') self.impl(""" { int id = qMetaTypeId<%s>(); arg.beginArray(id); for (int i = 0; i < list.count(); ++i) { arg << list.at(i); } arg.endArray(); return arg; } """ % (array_of)) self.both('%s const QDBusArgument& operator>>(const QDBusArgument& arg, %s &list)' % (self.visibility, val)) self.decl(';\n\n') self.impl(""" { arg.beginArray(); list.clear(); while (!arg.atEnd()) { %s item; arg >> item; list.append(item); } arg.endArray(); return arg; } """ % (array_of)) structs = self.spec.getElementsByTagNameNS(NS_TP, 'struct') mappings = self.spec.getElementsByTagNameNS(NS_TP, 'mapping') exts = self.spec.getElementsByTagNameNS(NS_TP, 'external-type') for deptype in structs + mappings: info = DepInfo(deptype, self.externals, self.custom_lists) self.depinfos[info.binding.val] = info leaves = [] next_leaves = [] for val, depinfo in self.depinfos.iteritems(): leaf = True for dep in depinfo.deps: if not self.depinfos.has_key(dep): raise UnresolvedDependency(val, dep) leaf = False self.depinfos[dep].revdeps.append(val) if leaf: next_leaves.append(val) while leaves or next_leaves: if not leaves: leaves = next_leaves leaves.sort() next_leaves = [] val = leaves.pop(0) depinfo = self.depinfos[val] self.output_by_depinfo(depinfo) for revdep in depinfo.revdeps: revdepinfo = self.depinfos[revdep] revdepinfo.deps.remove(val) if not revdepinfo.deps: next_leaves.append(revdep) del self.depinfos[val] for provider in structs + mappings + exts: name = get_by_path(provider, '@name') array_name = get_by_path(provider, '@array-name') array_depth = get_by_path(provider, '@array-depth') if array_depth: array_depth = int(array_depth) else: array_depth = None sig = provider.getAttribute('type') tptype = provider.getAttribute('name') external = (sig, tptype) in self.externals binding = binding_from_decl(name, array_name, array_depth, external) self.provide(binding.val) if binding.array_val: self.provide(binding.array_val) d = binding.array_depth while d > 1: d -= 1 self.provide(binding.array_val + ('List' * d)) if self.required_custom: raise MissingTypes(self.required_custom)
def provide_all(self): self.required_arrays.sort() for (val, array_of) in self.required_arrays: real = 'QList<%s>' % array_of self.decl("""\ /** * \\struct %s * \\ingroup list %s\ * * Generic list type with %s elements. Convertible with * %s, but needed to have a discrete type in the Qt type system. */ """ % (val, get_headerfile_cmd(self.realinclude, self.prettyinclude), array_of, real)) self.decl(self.faketype(val, real)) self.to_declare.append(self.namespace + '::' + val) self.both('%s QDBusArgument& operator<<(QDBusArgument& arg, const %s &list)' % (self.visibility, val)) self.decl(';\n') self.impl(""" { int id = qMetaTypeId<%s>(); arg.beginArray(id); for (int i = 0; i < list.count(); ++i) { arg << list.at(i); } arg.endArray(); return arg; } """ % (array_of)) self.both('%s const QDBusArgument& operator>>(const QDBusArgument& arg, %s &list)' % (self.visibility, val)) self.decl(';\n\n') self.impl(""" { arg.beginArray(); list.clear(); while (!arg.atEnd()) { %s item; arg >> item; list.append(item); } arg.endArray(); return arg; } """ % (array_of)) structs = self.spec.getElementsByTagNameNS(NS_TP, 'struct') mappings = self.spec.getElementsByTagNameNS(NS_TP, 'mapping') exts = self.spec.getElementsByTagNameNS(NS_TP, 'external-type') for deptype in structs + mappings: info = DepInfo(deptype, self.externals, self.custom_lists) self.depinfos[info.binding.val] = info leaves = [] next_leaves = [] for val, depinfo in self.depinfos.iteritems(): leaf = True for dep in depinfo.deps: if not self.depinfos.has_key(dep): raise UnresolvedDependency(val, dep) leaf = False self.depinfos[dep].revdeps.append(val) if leaf: next_leaves.append(val) while leaves or next_leaves: if not leaves: leaves = next_leaves leaves.sort() next_leaves = [] val = leaves.pop(0) depinfo = self.depinfos[val] self.output_by_depinfo(depinfo) for revdep in depinfo.revdeps: revdepinfo = self.depinfos[revdep] revdepinfo.deps.remove(val) if not revdepinfo.deps: next_leaves.append(revdep) del self.depinfos[val] for provider in structs + mappings + exts: name = get_by_path(provider, '@name') array_name = get_by_path(provider, '@array-name') array_depth = get_by_path(provider, '@array-depth') if array_depth: array_depth = int(array_depth) else: array_depth = None sig = provider.getAttribute('type') tptype = provider.getAttribute('name') external = (sig, tptype) in self.externals binding = binding_from_decl(name, array_name, array_depth, external) self.provide(binding.val) if binding.array_val: self.provide(binding.array_val) d = binding.array_depth while d > 1: d -= 1 self.provide(binding.array_val + ('List' * d)) if self.required_custom: raise MissingTypes(self.required_custom)