From e3c75cfc78e07e77172e12cbcc41aa25e3976dd7 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 1 Aug 2014 15:30:31 +0800 Subject: xgl-generate: add pretty-dummy subcommand --- xgl-generate.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/xgl-generate.py b/xgl-generate.py index 660d2278..eb27f0f5 100755 --- a/xgl-generate.py +++ b/xgl-generate.py @@ -81,6 +81,38 @@ class Subcommand(object): %s; };""" % ";\n ".join(entries) +class PrettyDummySubcommand(Subcommand): + def generate_header(self): + return "\n".join([ + "#include ", + "#include "]) + + def generate_body(self): + funcs = [] + for proto in self.protos: + plist = [] + for param in proto.params: + idx = param.ty.find("[") + if idx < 0: + idx = len(param.ty) + + pad = 44 - idx + if pad <= 0: + pad = 1 + + plist.append(" %s%s%s%s" % (param.ty[:idx], + " " * pad, param.name, param.ty[idx:])) + + if proto.ret != "XGL_VOID": + stmt = " return XGL_ERROR_UNAVAILABLE;\n" + else: + stmt = "" + + funcs.append("%s XGLAPI xgl%s(\n%s)\n{\n%s}" % (proto.ret, + proto.name, ",\n".join(plist), stmt)) + + return "\n\n".join(funcs) + class LoaderSubcommand(Subcommand): def generate_header(self): return "\n".join([ @@ -115,6 +147,7 @@ class LoaderSubcommand(Subcommand): def main(): subcommands = { + "pretty-dummy": PrettyDummySubcommand, "loader": LoaderSubcommand, } -- cgit v1.2.3