diff options
author | Dylan Baker <baker.dylan.c@gmail.com> | 2015-06-15 14:16:34 -0700 |
---|---|---|
committer | Dylan Baker <baker.dylan.c@gmail.com> | 2015-08-11 14:41:08 -0700 |
commit | 865d023867f44152b965a97bf8e6c7f1447e74f4 (patch) | |
tree | 7c7b44529523945b47b166aa6c726413490db1e4 | |
parent | 5c660febc529d0904e97ebb7d899b18fb8b09076 (diff) |
glapi: glX_proto_size.py: use mako to generate indirect_reqsize.h
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
-rw-r--r-- | src/mapi/glapi/gen/Makefile.am | 2 | ||||
-rw-r--r-- | src/mapi/glapi/gen/glX_proto_size.py | 35 | ||||
-rw-r--r-- | src/mapi/glapi/gen/templates/indirect_reqsize.h.mako | 40 | ||||
-rw-r--r-- | src/mapi/glapi/gen/templates/utils.mako | 12 |
4 files changed, 62 insertions, 27 deletions
diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am index 25d3e1171e..7967a2d121 100644 --- a/src/mapi/glapi/gen/Makefile.am +++ b/src/mapi/glapi/gen/Makefile.am @@ -332,7 +332,7 @@ $(XORG_GLX_DIR)/indirect_size_get.c: glX_proto_size.py $(COMMON_GLX) $(PYTHON_GEN) $< -f $(srcdir)/gl_API.xml -m size_c \ | $(INDENT) $(INDENT_FLAGS) > $@ -$(XORG_GLX_DIR)/indirect_reqsize.h: glX_proto_size.py $(COMMON_GLX) +$(XORG_GLX_DIR)/indirect_reqsize.h: glX_proto_size.py $(COMMON_GLX) tmplates/indirect_reqsize.h.mako $(PYTHON_GEN) $< -f $(srcdir)/gl_API.xml -m reqsize_h \ --only-get -h '_INDIRECT_SIZE_GET_H_' \ | $(INDENT) $(XORG_INDENT_FLAGS) > $@ diff --git a/src/mapi/glapi/gen/glX_proto_size.py b/src/mapi/glapi/gen/glX_proto_size.py index 75fc26f5db..7abda428a1 100644 --- a/src/mapi/glapi/gen/glX_proto_size.py +++ b/src/mapi/glapi/gen/glX_proto_size.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # (C) Copyright IBM Corporation 2004, 2005 +# Copyright (c) 2015 Intel Corporation # All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a @@ -26,10 +27,11 @@ # Ian Romanick <idr@us.ibm.com> import argparse -import sys, string +import string import gl_XML, glX_XML import license +from python.templates import LOOKUP class glx_enum_function(object): @@ -369,7 +371,6 @@ class PrintGlxSizeStubs_c(PrintGlxSizeStubs_common): print 'ALIAS( %s, %s )' % (alias_name, real_name) - class PrintGlxSizeStubs_h(PrintGlxSizeStubs_common): def printRealHeader(self): print """/** @@ -387,7 +388,6 @@ class PrintGlxSizeStubs_h(PrintGlxSizeStubs_common): self.printFastcall(); print '' - def printBody(self, api): for func in api.functionIterateGlx(): ef = glx_enum_function( func.name, api.enums_by_name ) @@ -412,25 +412,6 @@ class PrintGlxReqSize_common(gl_XML.gl_print_base): self.license = license.bsd_license_template % ( "(C) Copyright IBM Corporation 2005", "IBM") -class PrintGlxReqSize_h(PrintGlxReqSize_common): - def __init__(self): - PrintGlxReqSize_common.__init__(self) - self.header_tag = "_INDIRECT_REQSIZE_H_" - - - def printRealHeader(self): - print '#include <X11/Xfuncproto.h>' - print '' - self.printPure() - print '' - - - def printBody(self, api): - for func in api.functionIterateGlx(): - if not func.ignore and func.has_variable_size_request(): - print 'extern PURE _X_HIDDEN int __glX%sReqSize(const GLbyte *pc, Bool swap);' % (func.name) - - class PrintGlxReqSize_c(PrintGlxReqSize_common): """Create the server-side 'request size' functions. @@ -687,6 +668,8 @@ def _parser(): def main(): """Main function.""" args = _parser() + api = gl_XML.parse_GL_API(args.filename, glX_XML.glx_item_factory()) + printer = None if args.mode == "size_c": printer = PrintGlxSizeStubs_c(args.which_functions) @@ -697,11 +680,11 @@ def main(): elif args.mode == "reqsize_c": printer = PrintGlxReqSize_c() elif args.mode == "reqsize_h": - printer = PrintGlxReqSize_h() - - api = gl_XML.parse_GL_API(args.filename, glX_XML.glx_item_factory()) + template = LOOKUP.get_template('indirect_reqsize.h.mako') + print template.render(api=api) - printer.Print(api) + if printer: + printer.Print(api) if __name__ == '__main__': diff --git a/src/mapi/glapi/gen/templates/indirect_reqsize.h.mako b/src/mapi/glapi/gen/templates/indirect_reqsize.h.mako new file mode 100644 index 0000000000..6d43972ea6 --- /dev/null +++ b/src/mapi/glapi/gen/templates/indirect_reqsize.h.mako @@ -0,0 +1,40 @@ +## 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"), to deal +## in the Software without restriction, including without limitation the rights +## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +## copies of the Software, and to permit persons to whom the Software is +## furnished to do so, subject to the following conditions: +## +## The above copyright notice and this permission notice shall be included in +## all copies or substantial portions of the Software. +## +## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +## SOFTWARE. + +<%namespace name="utils" file="utils.mako"/> + +${utils.copyright(['2005 IBM Corporation'], 'glX_proto_size.py')} + +#if !defined( _INDIRECT_REQSIZE_H_ ) +# define _INDIRECT_REQSIZE_H_ + +#include <X11/Xfuncproto.h> + +${utils.pure_init()} + +% for func in api.functionIterateGlx(): + % if not func.ignore and func.has_variable_size_request(): + extern PURE _X_HIDDEN int __glX${func.name}ReqSize(const GLbyte *pc, Bool swap); + % endif +% endfor + +${utils.pure_fin()} + +#endif /* !defined ( _INDIRECT_REQSIZE_H_ ) */ diff --git a/src/mapi/glapi/gen/templates/utils.mako b/src/mapi/glapi/gen/templates/utils.mako index cb1a5fdecc..a66c769592 100644 --- a/src/mapi/glapi/gen/templates/utils.mako +++ b/src/mapi/glapi/gen/templates/utils.mako @@ -76,3 +76,15 @@ things, rather than python functions which should not be doing much printing. <%def name="noinline_fin()"> # undef NOINLINE </%def> + +<%def name="pure_init()"> +# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define PURE __attribute__((pure)) +# else +# define PURE +# endif +</%def> + +<%def name="pure_fin()"> +# undef PURE +</%def> |