diff options
author | Ian Romanick <idr@us.ibm.com> | 2005-04-18 19:42:23 +0000 |
---|---|---|
committer | Ian Romanick <idr@us.ibm.com> | 2005-04-18 19:42:23 +0000 |
commit | 93d2d54e7a11cf1a01c976ede37db2320ccc2dff (patch) | |
tree | 7918b8232796a7480f63e9b57dfd34f87f3a6327 | |
parent | 8ea22650bd2f791f72b9b2970b88236d59234d61 (diff) |
Refactor a bunch of common code from the "leaf" scripts to a new functions,
parse_GL_API, in gl_XML.py.
-rw-r--r-- | src/mesa/glapi/glX_XML.py | 4 | ||||
-rw-r--r-- | src/mesa/glapi/glX_doc.py | 15 | ||||
-rw-r--r-- | src/mesa/glapi/glX_proto_send.py | 13 | ||||
-rw-r--r-- | src/mesa/glapi/glX_proto_size.py | 14 | ||||
-rw-r--r-- | src/mesa/glapi/gl_SPARC_asm.py | 14 | ||||
-rw-r--r-- | src/mesa/glapi/gl_XML.py | 18 | ||||
-rw-r--r-- | src/mesa/glapi/gl_apitemp.py | 16 | ||||
-rw-r--r-- | src/mesa/glapi/gl_enums.py | 15 | ||||
-rw-r--r-- | src/mesa/glapi/gl_offsets.py | 15 | ||||
-rw-r--r-- | src/mesa/glapi/gl_procs.py | 17 | ||||
-rw-r--r-- | src/mesa/glapi/gl_table.py | 15 | ||||
-rw-r--r-- | src/mesa/glapi/gl_x86_asm.py | 14 |
12 files changed, 29 insertions, 141 deletions
diff --git a/src/mesa/glapi/glX_XML.py b/src/mesa/glapi/glX_XML.py index 81c94a5223..53f89b31bd 100644 --- a/src/mesa/glapi/glX_XML.py +++ b/src/mesa/glapi/glX_XML.py @@ -25,10 +25,6 @@ # Authors: # Ian Romanick <idr@us.ibm.com> -from xml.sax import saxutils -from xml.sax import make_parser -from xml.sax.handler import feature_namespaces - import gl_XML import license import sys, getopt, string diff --git a/src/mesa/glapi/glX_doc.py b/src/mesa/glapi/glX_doc.py index ea90d53f71..fa2d812974 100644 --- a/src/mesa/glapi/glX_doc.py +++ b/src/mesa/glapi/glX_doc.py @@ -25,10 +25,6 @@ # Authors: # Ian Romanick <idr@us.ibm.com> -from xml.sax import saxutils -from xml.sax import make_parser -from xml.sax.handler import feature_namespaces - import gl_XML import glX_XML import license @@ -266,13 +262,4 @@ if __name__ == '__main__': file_name = val dh = PrintGlxProtoText() - - parser = make_parser() - parser.setFeature(feature_namespaces, 1) - parser.setContentHandler(dh) - - f = open(file_name) - - dh.printHeader() - parser.parse(f) - dh.printFooter() + gl_XML.parse_GL_API( dh, file_name ) diff --git a/src/mesa/glapi/glX_proto_send.py b/src/mesa/glapi/glX_proto_send.py index d78e07ee5e..1ac46c3b4c 100644 --- a/src/mesa/glapi/glX_proto_send.py +++ b/src/mesa/glapi/glX_proto_send.py @@ -25,10 +25,6 @@ # Authors: # Ian Romanick <idr@us.ibm.com> -from xml.sax import saxutils -from xml.sax import make_parser -from xml.sax.handler import feature_namespaces - import gl_XML import glX_XML import license @@ -889,13 +885,6 @@ if __name__ == '__main__': else: show_usage() - parser = make_parser() - parser.setFeature(feature_namespaces, 1) - parser.setContentHandler(dh) - - f = open(file_name) dh.debug = debug - dh.printHeader() - parser.parse(f) - dh.printFooter() + gl_XML.parse_GL_API( dh, file_name ) diff --git a/src/mesa/glapi/glX_proto_size.py b/src/mesa/glapi/glX_proto_size.py index 5049545222..a1c0497ae7 100644 --- a/src/mesa/glapi/glX_proto_size.py +++ b/src/mesa/glapi/glX_proto_size.py @@ -25,10 +25,6 @@ # Authors: # Ian Romanick <idr@us.ibm.com> -from xml.sax import saxutils -from xml.sax import make_parser -from xml.sax.handler import feature_namespaces - import gl_XML import glX_XML import license @@ -533,12 +529,4 @@ if __name__ == '__main__': else: show_usage() - parser = make_parser() - parser.setFeature(feature_namespaces, 1) - parser.setContentHandler(dh) - - f = open(file_name) - - dh.printHeader() - parser.parse(f) - dh.printFooter() + gl_XML.parse_GL_API( dh, file_name ) diff --git a/src/mesa/glapi/gl_SPARC_asm.py b/src/mesa/glapi/gl_SPARC_asm.py index 2623e1beea..76a545d90c 100644 --- a/src/mesa/glapi/gl_SPARC_asm.py +++ b/src/mesa/glapi/gl_SPARC_asm.py @@ -25,10 +25,6 @@ # Authors: # Ian Romanick <idr@us.ibm.com> -from xml.sax import saxutils -from xml.sax import make_parser -from xml.sax.handler import feature_namespaces - import gl_XML import license import sys, getopt @@ -123,12 +119,4 @@ if __name__ == '__main__': print "ERROR: Invalid mode \"%s\" specified." % mode show_usage() - parser = make_parser() - parser.setFeature(feature_namespaces, 1) - parser.setContentHandler(dh) - - f = open(file_name) - - dh.printHeader() - parser.parse(f) - dh.printFooter() + gl_XML.parse_GL_API( dh, file_name ) diff --git a/src/mesa/glapi/gl_XML.py b/src/mesa/glapi/gl_XML.py index 38ccc53465..64422be913 100644 --- a/src/mesa/glapi/gl_XML.py +++ b/src/mesa/glapi/gl_XML.py @@ -48,6 +48,24 @@ def is_attr_true( attrs, name ): raise RuntimeError('Invalid value "%s" for boolean "%s".' % (value, name)) +def parse_GL_API( handler, file_name ): + """Boiler-plate code to create an XML parser and use it. + + Creates an XML parser and uses that parser with the application + supplied SAX callback, which should be derived from + FilterGLAPISpecBase. + """ + parser = make_parser() + parser.setFeature(feature_namespaces, 1) + parser.setContentHandler( handler ) + + handler.printHeader() + parser.parse( file_name ) + + handler.printFooter() + return + + class glItem: """Generic class on which all other API entity types are based.""" diff --git a/src/mesa/glapi/gl_apitemp.py b/src/mesa/glapi/gl_apitemp.py index 4c4bcd40ff..6f30a16d99 100644 --- a/src/mesa/glapi/gl_apitemp.py +++ b/src/mesa/glapi/gl_apitemp.py @@ -25,10 +25,6 @@ # Authors: # Ian Romanick <idr@us.ibm.com> -from xml.sax import saxutils -from xml.sax import make_parser -from xml.sax.handler import feature_namespaces - import gl_XML import license import sys, getopt @@ -216,14 +212,4 @@ if __name__ == '__main__': file_name = val dh = PrintGlOffsets() - - parser = make_parser() - parser.setFeature(feature_namespaces, 1) - parser.setContentHandler(dh) - - f = open(file_name) - - dh.printHeader() - parser.parse(f) - dh.printFooter() - + gl_XML.parse_GL_API( dh, file_name ) diff --git a/src/mesa/glapi/gl_enums.py b/src/mesa/glapi/gl_enums.py index 177c95f6ed..615f79729c 100644 --- a/src/mesa/glapi/gl_enums.py +++ b/src/mesa/glapi/gl_enums.py @@ -26,10 +26,6 @@ # Authors: # Zack Rusin <zack@kde.org> -from xml.sax import saxutils -from xml.sax import make_parser -from xml.sax.handler import feature_namespaces - import license import gl_XML import sys, getopt @@ -235,13 +231,4 @@ if __name__ == '__main__': file_name = val dh = PrintGlEnums() - - parser = make_parser() - parser.setFeature(feature_namespaces, 1) - parser.setContentHandler(dh) - - f = open(file_name) - - dh.printHeader() - parser.parse(f) - dh.printFooter() + gl_XML.parse_GL_API( dh, file_name ) diff --git a/src/mesa/glapi/gl_offsets.py b/src/mesa/glapi/gl_offsets.py index 95657b80e0..f47eaa26b3 100644 --- a/src/mesa/glapi/gl_offsets.py +++ b/src/mesa/glapi/gl_offsets.py @@ -25,10 +25,6 @@ # Authors: # Ian Romanick <idr@us.ibm.com> -from xml.sax import saxutils -from xml.sax import make_parser -from xml.sax.handler import feature_namespaces - import gl_XML import license import sys, getopt @@ -65,13 +61,4 @@ if __name__ == '__main__': file_name = val dh = PrintGlOffsets() - - parser = make_parser() - parser.setFeature(feature_namespaces, 1) - parser.setContentHandler(dh) - - f = open(file_name) - - dh.printHeader() - parser.parse(f) - dh.printFooter() + gl_XML.parse_GL_API( dh, file_name ) diff --git a/src/mesa/glapi/gl_procs.py b/src/mesa/glapi/gl_procs.py index b5d51b0b40..75bb844a33 100644 --- a/src/mesa/glapi/gl_procs.py +++ b/src/mesa/glapi/gl_procs.py @@ -25,10 +25,6 @@ # Authors: # Ian Romanick <idr@us.ibm.com> -from xml.sax import saxutils -from xml.sax import make_parser -from xml.sax.handler import feature_namespaces - import license import gl_XML import sys, getopt @@ -128,7 +124,7 @@ def show_usage(): if __name__ == '__main__': file_name = "gl_API.xml" - + try: (args, trail) = getopt.getopt(sys.argv[1:], "f:m:") except Exception,e: @@ -147,13 +143,4 @@ if __name__ == '__main__': show_usage() dh = PrintGlProcs( long_string ) - - parser = make_parser() - parser.setFeature(feature_namespaces, 1) - parser.setContentHandler(dh) - - f = open(file_name) - - dh.printHeader() - parser.parse(f) - dh.printFooter() + gl_XML.parse_GL_API( dh, file_name ) diff --git a/src/mesa/glapi/gl_table.py b/src/mesa/glapi/gl_table.py index 30dcd4149f..3b8f1ca411 100644 --- a/src/mesa/glapi/gl_table.py +++ b/src/mesa/glapi/gl_table.py @@ -25,10 +25,6 @@ # Authors: # Ian Romanick <idr@us.ibm.com> -from xml.sax import saxutils -from xml.sax import make_parser -from xml.sax.handler import feature_namespaces - import gl_XML import license import sys, getopt @@ -82,13 +78,4 @@ if __name__ == '__main__': file_name = val dh = PrintGlTable() - - parser = make_parser() - parser.setFeature(feature_namespaces, 1) - parser.setContentHandler(dh) - - f = open(file_name) - - dh.printHeader() - parser.parse(f) - dh.printFooter() + gl_XML.parse_GL_API( dh, file_name ) diff --git a/src/mesa/glapi/gl_x86_asm.py b/src/mesa/glapi/gl_x86_asm.py index 02dafa5c62..85a5c2be05 100644 --- a/src/mesa/glapi/gl_x86_asm.py +++ b/src/mesa/glapi/gl_x86_asm.py @@ -25,10 +25,6 @@ # Authors: # Ian Romanick <idr@us.ibm.com> -from xml.sax import saxutils -from xml.sax import make_parser -from xml.sax.handler import feature_namespaces - import gl_XML import license import sys, getopt @@ -247,12 +243,4 @@ if __name__ == '__main__': print "ERROR: Invalid mode \"%s\" specified." % mode show_usage() - parser = make_parser() - parser.setFeature(feature_namespaces, 1) - parser.setContentHandler(dh) - - f = open(file_name) - - dh.printHeader() - parser.parse(f) - dh.printFooter() + gl_XML.parse_GL_API( dh, file_name ) |