diff options
author | Dylan Baker <baker.dylan.c@gmail.com> | 2015-06-22 15:36:26 -0700 |
---|---|---|
committer | Dylan Baker <baker.dylan.c@gmail.com> | 2015-08-11 14:41:32 -0700 |
commit | 462f8428d1961c54f133c9389f2be53b31097540 (patch) | |
tree | 93106fcb24b9d1b842b8bbb0365778a8e2f86cb3 | |
parent | 274ad33c5f3c3f4ba5e0158c652aed17ce9095de (diff) |
glapi: generate indirect_dispatch.h with makosubmit/generator-mako
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
-rw-r--r-- | src/mapi/glapi/gen/Makefile.am | 4 | ||||
-rw-r--r-- | src/mapi/glapi/gen/glX_proto_recv.py | 54 | ||||
-rw-r--r-- | src/mapi/glapi/gen/templates/indirect_dispatch.h.mako | 49 |
3 files changed, 60 insertions, 47 deletions
diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am index 387c087615..cbb7bc859f 100644 --- a/src/mapi/glapi/gen/Makefile.am +++ b/src/mapi/glapi/gen/Makefile.am @@ -319,8 +319,8 @@ $(XORG_GLX_DIR)/indirect_dispatch_swap.c: glX_proto_recv.py $(COMMON_GLX) $(PYTHON_GEN) $< -f $(srcdir)/gl_API.xml -m dispatch_c -s \ | $(INDENT) $(XORG_INDENT_FLAGS) > $@ -$(XORG_GLX_DIR)/indirect_dispatch.h: glX_proto_recv.py gl_and_glX_API.xml $(COMMON_GLX) - $(PYTHON_GEN) $< -m dispatch_h -f $(srcdir)/gl_and_glX_API.xml -s \ +$(XORG_GLX_DIR)/indirect_dispatch.h: glX_proto_recv.py $(COMMON_GLX) templates/indirect_dispatch.h.mako + $(PYTHON_GEN) $< -m dispatch_h -f $(srcdir)/gl_and_glX_API.xml \ | $(INDENT) $(XORG_INDENT_FLAGS) > $@ $(XORG_GLX_DIR)/indirect_size_get.h: glX_proto_size.py $(COMMON_GLX) templates/indirect_size_get.h.mako diff --git a/src/mapi/glapi/gen/glX_proto_recv.py b/src/mapi/glapi/gen/glX_proto_recv.py index 5d95f278a9..d47f556b83 100644 --- a/src/mapi/glapi/gen/glX_proto_recv.py +++ b/src/mapi/glapi/gen/glX_proto_recv.py @@ -28,44 +28,10 @@ import argparse import string -import gl_XML, glX_XML, glX_proto_common, license - - -class PrintGlxDispatch_h(gl_XML.gl_print_base): - def __init__(self): - gl_XML.gl_print_base.__init__(self) - - self.name = "glX_proto_recv.py (from Mesa)" - self.license = license.bsd_license_template % ( "(C) Copyright IBM Corporation 2005", "IBM") - - self.header_tag = "_INDIRECT_DISPATCH_H_" - return - - - def printRealHeader(self): - print '# include <X11/Xfuncproto.h>' - print '' - print 'struct __GLXclientStateRec;' - print '' - return - - - def printBody(self, api): - for func in api.functionIterateAll(): - if not func.ignore and not func.vectorequiv: - if func.glx_rop: - print 'extern _X_HIDDEN void __glXDisp_%s(GLbyte * pc);' % (func.name) - print 'extern _X_HIDDEN void __glXDispSwap_%s(GLbyte * pc);' % (func.name) - elif func.glx_sop or func.glx_vendorpriv: - print 'extern _X_HIDDEN int __glXDisp_%s(struct __GLXclientStateRec *, GLbyte *);' % (func.name) - print 'extern _X_HIDDEN int __glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (func.name) - - if func.glx_sop and func.glx_vendorpriv: - n = func.glx_vendorpriv_names[0] - print 'extern _X_HIDDEN int __glXDisp_%s(struct __GLXclientStateRec *, GLbyte *);' % (n) - print 'extern _X_HIDDEN int __glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (n) - - return +from python.templates import LOOKUP +import gl_XML +import glX_proto_common +import license class PrintGlxDispatchFunctions(glX_proto_common.glx_print_proto): @@ -548,16 +514,14 @@ def _parser(): def main(): """Main function.""" args = _parser() - - if args.mode == "dispatch_c": - printer = PrintGlxDispatchFunctions(args.swap) - elif args.mode == "dispatch_h": - printer = PrintGlxDispatch_h() - api = gl_XML.parse_GL_API( args.filename, glX_proto_common.glx_proto_item_factory()) - printer.Print(api) + if args.mode == "dispatch_c": + PrintGlxDispatchFunctions(args.swap).Print(api) + elif args.mode == "dispatch_h": + template = LOOKUP.get_template('indirect_dispatch.h.mako') + print template.render(api=api) if __name__ == '__main__': diff --git a/src/mapi/glapi/gen/templates/indirect_dispatch.h.mako b/src/mapi/glapi/gen/templates/indirect_dispatch.h.mako new file mode 100644 index 0000000000..426f094c8a --- /dev/null +++ b/src/mapi/glapi/gen/templates/indirect_dispatch.h.mako @@ -0,0 +1,49 @@ +## 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_recv.py')} + + +#if !defined( _INDIRECT_DISPATCH_H_ ) +# define _INDIRECT_DISPATCH_H_ + +#include <X11/Xfuncproto.h> + +struct __GLXclientStateRec; + +% for func in api.functionIterateAll(): + % if not func.ignore and not func.vectorequiv: + % if func.glx_rop: + extern _X_HIDDEN void __glXDisp_${func.name}(GLbyte * pc); + extern _X_HIDDEN void __glXDispSwap_${func.name}(GLbyte * pc); + % elif func.glx_sop or func.glx_vendorpriv: + extern _X_HIDDEN int __glXDisp_${func.name}(struct __GLXclientStateRec *, GLbyte *); + extern _X_HIDDEN int __glXDispSwap_${func.name}(struct __GLXclientStateRec *, GLbyte *); + % if func.glx_sop and func.glx_vendorpriv: + extern _X_HIDDEN int __glXDisp_${func.glx_vendorpriv_names[0]}(struct __GLXclientStateRec *, GLbyte *); + extern _X_HIDDEN int __glXDispSwap_${func.glx_vendorpriv_names[0]}(struct __GLXclientStateRec *, GLbyte *); + % endif + % endif + % endif +% endfor + +#endif /* !defined( _INDIRECT_DISPATCH_H_ ) */ |