summaryrefslogtreecommitdiffstats
path: root/src/mapi
diff options
context:
space:
mode:
authorJose Fonseca <[email protected]>2015-05-26 11:01:57 +0100
committerJose Fonseca <[email protected]>2015-05-26 15:26:03 +0100
commitb787f48ed2a7e1855100afd943ae6b407abb401f (patch)
treee039bdbce98690ebe65960f5acb2443bbdef56b5 /src/mapi
parent224a77cc60cc0e7f8a14e35ebca6e42544af39b1 (diff)
glapi: Avoid argparse type argument for API XML input files.
argparse type is a nice type saver for simple data types, but it doesn't look a good fit for the input XML file: - Certain implementations of argparse (particularly python 2.7.3's) invoke the type constructor for the default argument even when an option is passed in the command line. Causing `No such file or directory: 'gl_API.xml'` when the current dir is not src/mapi/glapi/gen. - The parser takes multiple arguments. This is currently worked around using lambdas, but that unnecessarily complex and hard to read. Furthermore it's odd to have a side-effect as heavy as parsing XML happening deep inside the argument parsing. https://bugs.freedesktop.org/show_bug.cgi?id=90600 Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mapi')
-rw-r--r--src/mapi/glapi/gen/gl_procs.py7
-rw-r--r--src/mapi/glapi/gen/gl_table.py9
-rw-r--r--src/mapi/glapi/gen/remap_helper.py8
3 files changed, 12 insertions, 12 deletions
diff --git a/src/mapi/glapi/gen/gl_procs.py b/src/mapi/glapi/gen/gl_procs.py
index cf6d2de8a4b..685e2fac345 100644
--- a/src/mapi/glapi/gen/gl_procs.py
+++ b/src/mapi/glapi/gen/gl_procs.py
@@ -165,14 +165,12 @@ typedef struct {
def _parser():
"""Parse arguments and return a namepsace."""
- api_type = lambda x: gl_XML.parse_GL_API(x, glX_XML.glx_item_factory())
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--filename',
- type=api_type,
default='gl_API.xml',
metavar="input_file_name",
- dest='api',
+ dest='file_name',
help="Path to an XML description of OpenGL API.")
parser.add_argument('-c', '--es-version',
dest='es',
@@ -184,7 +182,8 @@ def _parser():
def main():
"""Main function."""
args = _parser()
- PrintGlProcs(args.es).Print(args.api)
+ api = gl_XML.parse_GL_API(args.file_name, glX_XML.glx_item_factory())
+ PrintGlProcs(args.es).Print(api)
if __name__ == '__main__':
diff --git a/src/mapi/glapi/gen/gl_table.py b/src/mapi/glapi/gen/gl_table.py
index 30903fd8f60..3f029023087 100644
--- a/src/mapi/glapi/gen/gl_table.py
+++ b/src/mapi/glapi/gen/gl_table.py
@@ -206,10 +206,9 @@ def _parser():
"""Parse arguments and return a namespace."""
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--filename',
- type=gl_XML.parse_GL_API,
default='gl_API.xml',
metavar="input_file_name",
- dest='api',
+ dest='file_name',
help="Path to an XML description of OpenGL API.")
parser.add_argument('-m', '--mode',
choices=['table', 'remap_table'],
@@ -229,15 +228,17 @@ def main():
"""Main function."""
args = _parser()
+ api = gl_XML.parse_GL_API(args.file_name)
+
if args.mode == "table":
printer = PrintGlTable(args.es)
elif args.mode == "remap_table":
printer = PrintRemapTable(args.es)
if args.es is not None:
- args.api.filter_functions_by_api(args.es)
+ api.filter_functions_by_api(args.es)
- printer.Print(args.api)
+ printer.Print(api)
if __name__ == '__main__':
diff --git a/src/mapi/glapi/gen/remap_helper.py b/src/mapi/glapi/gen/remap_helper.py
index 9e3c3908d8c..94ae1936d21 100644
--- a/src/mapi/glapi/gen/remap_helper.py
+++ b/src/mapi/glapi/gen/remap_helper.py
@@ -170,10 +170,9 @@ def _parser():
"""Parse input options and return a namsepace."""
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--filename',
- type=gl_XML.parse_GL_API,
default="gl_API.xml",
metavar="input_file_name",
- dest='api',
+ dest='file_name',
help="An xml description file.")
parser.add_argument('-c', '--es-version',
choices=[None, 'es1', 'es2'],
@@ -188,11 +187,12 @@ def main():
"""Main function."""
args = _parser()
+ api = gl_XML.parse_GL_API(args.file_name)
if args.es is not None:
- args.api.filter_functions_by_api(args.es)
+ api.filter_functions_by_api(args.es)
printer = PrintGlRemap()
- printer.Print(args.api)
+ printer.Print(api)
if __name__ == '__main__':