diff options
author | Dylan Baker <[email protected]> | 2015-05-20 15:19:28 -0700 |
---|---|---|
committer | Matt Turner <[email protected]> | 2015-05-22 11:31:28 -0700 |
commit | d986cb7c70db3b512f6ee0bbc95ba2565606c222 (patch) | |
tree | 378757f6dec0a375daabc82fad7c175b3dfd7bbb /src/mapi/glapi/gen | |
parent | 67d3ec0bb8f6a8c918b371ed03ef21814899f07d (diff) |
glapi: glX_proto_recv.py: use argparse instead of getopt
Signed-off-by: Dylan Baker <[email protected]>
Acked-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/mapi/glapi/gen')
-rw-r--r-- | src/mapi/glapi/gen/glX_proto_recv.py | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/src/mapi/glapi/gen/glX_proto_recv.py b/src/mapi/glapi/gen/glX_proto_recv.py index d076409c2fa..dbc26a8eb03 100644 --- a/src/mapi/glapi/gen/glX_proto_recv.py +++ b/src/mapi/glapi/gen/glX_proto_recv.py @@ -25,8 +25,10 @@ # Authors: # Ian Romanick <[email protected]> +import argparse +import string + import gl_XML, glX_XML, glX_proto_common, license -import sys, getopt, string class PrintGlxDispatch_h(gl_XML.gl_print_base): @@ -524,31 +526,34 @@ class PrintGlxDispatchFunctions(glX_proto_common.glx_print_proto): return +def _parser(): + """Parse any arguments passed and return a namespace.""" + parser = argparse.ArgumentParser() + parser.add_argument('-f', + dest='filename', + default='gl_API.xml', + help='an xml file describing an OpenGL API') + parser.add_argument('-m', + dest='mode', + default='dispatch_c', + choices=['dispatch_c', 'dispatch_h'], + help='what file to generate') + parser.add_argument('-s', + dest='swap', + action='store_true', + help='emit swap in GlXDispatchFunctions') + return parser.parse_args() + + if __name__ == '__main__': - file_name = "gl_API.xml" - - try: - (args, trail) = getopt.getopt(sys.argv[1:], "f:m:s") - except Exception,e: - show_usage() - - mode = "dispatch_c" - do_swap = 0 - for (arg,val) in args: - if arg == "-f": - file_name = val - elif arg == "-m": - mode = val - elif arg == "-s": - do_swap = 1 - - if mode == "dispatch_c": - printer = PrintGlxDispatchFunctions(do_swap) - elif mode == "dispatch_h": + args = _parser() + + if args._mode == "dispatch_c": + printer = PrintGlxDispatchFunctions(args.swap) + elif args._mode == "dispatch_h": printer = PrintGlxDispatch_h() - else: - show_usage() - api = gl_XML.parse_GL_API( file_name, glX_proto_common.glx_proto_item_factory() ) + api = gl_XML.parse_GL_API( + args.filename, glX_proto_common.glx_proto_item_factory()) - printer.Print( api ) + printer.Print(api) |