コード例 #1
0
		ty = getType(output, ty)

		assert ty is not None

		if is_arg:
			return '%s: %s' % (name, ty)
		else:
			return '%s' % ty

	out = ', '.join(filter(None, map(partial(sub, is_output, is_arg), enumerate(elems))))
	if not is_arg and len(list(elems)) != 1:
		return '(%s)' % out
	else:
		return out

types, ifaces, services = idparser.getAll()
invServices = {svc : ifname for ifname, svcs in services.items() for svc in svcs}
returnedBy = {}
takenBy = {}

for name, cmds in ifaces.items():
	for cmd in cmds['cmds']:
		for _, elem in cmd['inputs']:
			if elem[0] == 'object':
				c = elem[1][0]
				if c not in takenBy:
					takenBy[c] = []
				takenBy[c].append((name, cmd['cmdId']))
		for _, elem in cmd['outputs']:
			if elem[0] == 'object':
				c = elem[1][0]
コード例 #2
0
def main():
    global allTypes

    types, ifaces, services = idparser.getAll()

    allTypes = types

    typesByNs = splitByNs(types)
    ifacesByNs = splitByNs(ifaces)

    namespaces = {x: [] for x in typesByNs.keys() + ifacesByNs.keys()}

    for ns, types in typesByNs.items():
        for name, spec in sorted(types.items(), key=lambda x: x[0]):
            retyped, plain = retype(spec, noIndex=True), retype(spec)
            namespaces[ns].append(
                'using %s = %s;%s' %
                (name, retyped, ' // ' + plain if retyped != plain else ''))

    for ns, ifaces in ifacesByNs.items():
        for name in sorted(ifaces.keys()):
            namespaces[ns].append('class %s;' % name)

    with file('lib/ipcClients.h', 'w') as fp:
        print >> fp, '#pragma once'
        print >> fp, '#include<libtransistor/ipc.h>'
        print >> fp

        for ns, elems in sorted(namespaces.items(), key=lambda x: x[0]):
            if ns is not None:
                print >> fp, 'namespace %s {' % ns
            hasUsing = False
            for elem in elems:
                if not hasUsing and elem.startswith('using'):
                    hasUsing = True
                elif hasUsing and elem.startswith('class'):
                    print >> fp
                    hasUsing = False
                print >> fp, ('\t' if ns is not None else '') + elem
            if ns is not None:
                print >> fp, '}'

        print >> fp

        for ns, ifaces in sorted(ifacesByNs.items(), key=lambda x: x[0]):
            print >> fp, '%snamespace %s {' % ('//// ' if ns is None else '',
                                               ns)
            for name, funcs in sorted(ifaces.items(), key=lambda x: x[0]):
                qname = '%s::%s' % (ns, name) if ns else name
                print >> fp, '\tclass %s {' % name
                print >> fp, '\tpublic:'
                print >> fp, '\t\t%s();' % name
                for fname, func in sorted(funcs.items(), key=lambda x: x[0]):
                    print >> fp, '\t\tuint32_t %s(%s);' % (
                        fname, generatePrototype(func))
                print >> fp, '\t};'
            print >> fp, '%s}' % ('//// ' if ns is None else '')

            print >> fp, '#ifdef DEFINE_CALLERS'
            for name, funcs in sorted(ifaces.items(), key=lambda x: x[0]):
                qname = '%s::%s' % (ns, name) if ns else name
                for fname, func in sorted(funcs.items(), key=lambda x: x[0]):
                    print >> fp, 'uint32_t %s::%s(%s) {' % (
                        qname, fname, generatePrototype(func))
                    print >> fp, '\tipc_request_t req;'
                    print >> fp, '\tipc_response_t resp;'
                    print >> fp, '\tmemset(&req, 0, sizeof(ipc_request_t));'
                    print >> fp, '\n'.join(
                        '\t' + x
                        for x in reorder(generateCaller(qname, fname, func)))
                    print >> fp, '}'
            print >> fp, '#endif // DEFINE_CALLERS'