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>
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
# (C) Copyright IBM Corporation 2004, 2005
|
# (C) Copyright IBM Corporation 2004, 2005
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
|
# Copyright (c) 2015 Intel Corporation
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
# copy of this software and associated documentation files (the "Software"),
|
# copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -26,8 +27,10 @@
|
|||||||
# Ian Romanick <idr@us.ibm.com>
|
# Ian Romanick <idr@us.ibm.com>
|
||||||
# Jeremy Kolb <jkolb@brandeis.edu>
|
# Jeremy Kolb <jkolb@brandeis.edu>
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
import gl_XML, glX_XML, glX_proto_common, license
|
import gl_XML, glX_XML, glX_proto_common, license
|
||||||
import sys, getopt, copy, string
|
import copy, string
|
||||||
|
|
||||||
def convertStringForXCB(str):
|
def convertStringForXCB(str):
|
||||||
tmp = ""
|
tmp = ""
|
||||||
@@ -1085,42 +1088,36 @@ extern _X_HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupVendorRequest(
|
|||||||
print '#endif'
|
print '#endif'
|
||||||
|
|
||||||
|
|
||||||
def show_usage():
|
def _parser():
|
||||||
print "Usage: %s [-f input_file_name] [-m output_mode] [-d]" % sys.argv[0]
|
"""Parse input and returned a parsed namespace."""
|
||||||
print " -m output_mode Output mode can be one of 'proto', 'init_c' or 'init_h'."
|
parser = argparse.ArgumentParser()
|
||||||
print " -d Enable extra debug information in the generated code."
|
parser.add_argument('-f',
|
||||||
sys.exit(1)
|
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__':
|
if __name__ == '__main__':
|
||||||
file_name = "gl_API.xml"
|
args = _parser()
|
||||||
|
|
||||||
try:
|
if args.mode == "proto":
|
||||||
(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":
|
|
||||||
printer = PrintGlxProtoStubs()
|
printer = PrintGlxProtoStubs()
|
||||||
elif mode == "init_c":
|
elif args.mode == "init_c":
|
||||||
printer = PrintGlxProtoInit_c()
|
printer = PrintGlxProtoInit_c()
|
||||||
elif mode == "init_h":
|
elif args.mode == "init_h":
|
||||||
printer = PrintGlxProtoInit_h()
|
printer = PrintGlxProtoInit_h()
|
||||||
else:
|
|
||||||
show_usage()
|
|
||||||
|
|
||||||
|
printer.debug = args.debug
|
||||||
printer.debug = debug
|
api = gl_XML.parse_GL_API(args.filename, glX_XML.glx_item_factory())
|
||||||
api = gl_XML.parse_GL_API( file_name, glX_XML.glx_item_factory() )
|
|
||||||
|
|
||||||
printer.Print( api )
|
printer.Print( api )
|
||||||
|
Reference in New Issue
Block a user