diff options
author | Dylan Baker <baker.dylan.c@gmail.com> | 2015-02-10 15:20:18 -0800 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2015-05-22 11:31:28 -0700 |
commit | 9eed4e6232b9ca936ad8e87aa21f97ffb81981ce (patch) | |
tree | 1de67c1216b872bdf4ea725b93bdb32a13defae0 /src | |
parent | dddac8cac3ab883b6beeb4af9ca27bb2f3b4ebec (diff) | |
download | external_mesa3d-9eed4e6232b9ca936ad8e87aa21f97ffb81981ce.zip external_mesa3d-9eed4e6232b9ca936ad8e87aa21f97ffb81981ce.tar.gz external_mesa3d-9eed4e6232b9ca936ad8e87aa21f97ffb81981ce.tar.bz2 |
glapi: glX_proto_send.py: use argparse instead of getopt
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
Acked-by: Matt Turner <mattst88@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/mapi/glapi/gen/glX_proto_send.py | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/src/mapi/glapi/gen/glX_proto_send.py b/src/mapi/glapi/gen/glX_proto_send.py index b93989f..ea766af 100644 --- a/src/mapi/glapi/gen/glX_proto_send.py +++ b/src/mapi/glapi/gen/glX_proto_send.py @@ -2,6 +2,7 @@ # (C) Copyright IBM Corporation 2004, 2005 # All Rights Reserved. +# Copyright (c) 2015 Intel Corporation # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -26,8 +27,10 @@ # Ian Romanick <idr@us.ibm.com> # Jeremy Kolb <jkolb@brandeis.edu> +import argparse + import gl_XML, glX_XML, glX_proto_common, license -import sys, getopt, copy, string +import copy, string def convertStringForXCB(str): tmp = "" @@ -1085,42 +1088,36 @@ extern _X_HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupVendorRequest( print '#endif' -def show_usage(): - print "Usage: %s [-f input_file_name] [-m output_mode] [-d]" % sys.argv[0] - print " -m output_mode Output mode can be one of 'proto', 'init_c' or 'init_h'." - print " -d Enable extra debug information in the generated code." - sys.exit(1) +def _parser(): + """Parse input and returned a parsed namespace.""" + parser = argparse.ArgumentParser() + parser.add_argument('-f', + default='gl_API.xml', + dest='filename', + help='An XML file describing an API') + parser.add_argument('-m', + required=True, + dest='mode', + choices=frozenset(['proto', 'init_c', 'init_h']), + help='which file to generate') + parser.add_argument('-d', + action='store_true', + dest='debug', + help='turn debug mode on.') + return parser.parse_args() if __name__ == '__main__': - file_name = "gl_API.xml" - - try: - (args, trail) = getopt.getopt(sys.argv[1:], "f:m:d") - except Exception,e: - show_usage() - - debug = 0 - mode = "proto" - for (arg,val) in args: - if arg == "-f": - file_name = val - elif arg == "-m": - mode = val - elif arg == "-d": - debug = 1 - - if mode == "proto": + args = _parser() + + if args.mode == "proto": printer = PrintGlxProtoStubs() - elif mode == "init_c": + elif args.mode == "init_c": printer = PrintGlxProtoInit_c() - elif mode == "init_h": + elif args.mode == "init_h": printer = PrintGlxProtoInit_h() - else: - show_usage() - - printer.debug = debug - api = gl_XML.parse_GL_API( file_name, glX_XML.glx_item_factory() ) + printer.debug = args.debug + api = gl_XML.parse_GL_API(args.filename, glX_XML.glx_item_factory()) printer.Print( api ) |