Refactor the code to emit multiple-inclusion protection to
authorIan Romanick <idr@us.ibm.com>
Fri, 28 Jan 2005 19:00:54 +0000 (19:00 +0000)
committerIan Romanick <idr@us.ibm.com>
Fri, 28 Jan 2005 19:00:54 +0000 (19:00 +0000)
FilterGLAPISpecBase.  Since the size_h mode of glX_proto_size.py will be
used to generate multiple header files, add an option to specify the define
that is used for multiple-inclusion protection.

The changes to the header files in this commit are just a side-effect of the
changes to the Python scripts.

src/glx/x11/indirect.h
src/glx/x11/indirect_size.h
src/mesa/glapi/Makefile
src/mesa/glapi/glX_proto_send.py
src/mesa/glapi/glX_proto_size.py
src/mesa/glapi/gl_XML.py
src/mesa/glapi/gl_offsets.py
src/mesa/glapi/gl_table.py
src/mesa/glapi/glapioffsets.h
src/mesa/glapi/glapitable.h

index f5ffe1c483bacfafe07ef0f173fc0b89dc6a6839..cb14dbc75e88c258c768733bafad55435fbd24ff 100644 (file)
@@ -26,6 +26,8 @@
  * SOFTWARE.
  */
 
+#if !defined( _INDIRECT_H_ )
+#  define _INDIRECT_H_
 
 /**
  * \file
  * \author Ian Romanick <idr@us.ibm.com>
  */
 
-#if !defined( _INDIRECT_H_ )
-#  define _INDIRECT_H_
-
-
 #  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
 #    define HIDDEN  __attribute__((visibility("hidden")))
 #  else
@@ -522,4 +520,5 @@ extern HIDDEN void __indirect_glMultiDrawArraysEXT(GLenum mode, GLint * first, G
 extern HIDDEN void __indirect_glMultiDrawElementsEXT(GLenum mode, const GLsizei * count, GLenum type, const GLvoid ** indices, GLsizei primcount);
 extern HIDDEN void __indirect_glActiveStencilFaceEXT(GLenum face);
 #  undef HIDDEN
+
 #endif /* !defined( _INDIRECT_H_ ) */
index 833e95b2413efd062bf66dbc11857e893830aab8..2001c56c4ed638dc3adeea4253e73b5ac41ce7b2 100644 (file)
@@ -25,6 +25,8 @@
  * SOFTWARE.
  */
 
+#if !defined( _INDIRECT_SIZE_H_ )
+#  define _INDIRECT_SIZE_H_
 
 /**
  * \file
  * \author Ian Romanick <idr@us.ibm.com>
  */
 
-#if !defined( _GLXSIZE_H_ )
-#  define _GLXSIZE_H_
-
-
 #  if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
 #    define PURE __attribute__((pure))
 #  else
@@ -86,4 +84,5 @@ extern INTERNAL PURE FASTCALL GLint __glPointParameterivNV_size(GLenum);
 #  undef INTERNAL
 #  undef PURE
 #  undef FASTCALL
-#endif /* !defined( _GLXSIZE_H_ ) */
+
+#endif /* !defined( _INDIRECT_SIZE_H_ ) */
index ba89550edadc366dd0caaac5b47e72dbb5d34ac0..9fad47e00a4a560637eb4525111d9edab0d170ad 100644 (file)
@@ -57,7 +57,7 @@ glapitable.h: $(COMMON) gl_table.py
        $(PYTHON2) $(PYTHON_FLAGS) glX_proto_send.py -m init_c > ../../glx/x11/indirect_init.c
 
 ../../glx/x11/indirect_size.h: $(COMMON_GLX) glX_proto_size.py
-       $(PYTHON2) $(PYTHON_FLAGS) glX_proto_size.py -m size_h --only-set > ../../glx/x11/indirect_size.h
+       $(PYTHON2) $(PYTHON_FLAGS) glX_proto_size.py -m size_h --only-set -h _INDIRECT_SIZE_H_ > ../../glx/x11/indirect_size.h
 
 ../../glx/x11/indirect_size.c: $(COMMON_GLX) glX_proto_size.py
        $(PYTHON2) $(PYTHON_FLAGS) glX_proto_size.py -m size_c --only-set > ../../glx/x11/indirect_size.c
index 7216b699720d52aef182ca4e3cb40066b452ec54..146d6620790e878faba669f74e9fb443697eab1b 100644 (file)
@@ -758,28 +758,23 @@ class PrintGlxProtoInit_h(glX_XML.GlxProto):
                self.license = license.bsd_license_template % ( \
 """Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
 (C) Copyright IBM Corporation 2004""", "PRECISION INSIGHT, IBM")
-
+               self.header_tag = "_INDIRECT_H_"
 
        def printRealHeader(self):
-               print """
-/**
+               print """/**
  * \\file
  * Prototypes for indirect rendering functions.
  *
  * \\author Kevin E. Martin <kevin@precisioninsight.com>
  * \\author Ian Romanick <idr@us.ibm.com>
  */
-
-#if !defined( _INDIRECT_H_ )
-#  define _INDIRECT_H_
-
 """
                glX_XML.printVisibility( "HIDDEN", "hidden" )
 
 
        def printRealFooter(self):
                print "#  undef HIDDEN"
-               print "#endif /* !defined( _INDIRECT_H_ ) */"
+
 
        def printFunction(self, f):
                if f.fn_offset < 0 or f.ignore: return
index ecab65d3f0c077915638eeeb17c127bd35d28a0d..cf0885a5a6f40827cab581b5f6bfc4edd7145d32 100644 (file)
@@ -166,18 +166,13 @@ class PrintGlxSizeStubs_c(PrintGlxSizeStubs_common):
                                
 class PrintGlxSizeStubs_h(PrintGlxSizeStubs_common):
        def printRealHeader(self):
-               print """
-/**
+               print """/**
  * \\file
  * Prototypes for functions used to determine the number of data elements in
  * various GLX protocol messages.
  *
  * \\author Ian Romanick <idr@us.ibm.com>
  */
-
-#if !defined( _GLXSIZE_H_ )
-#  define _GLXSIZE_H_
-
 """
                glX_XML.printPure();
                print ''
@@ -191,7 +186,6 @@ class PrintGlxSizeStubs_h(PrintGlxSizeStubs_common):
                print "#  undef INTERNAL"
                print "#  undef PURE"
                print "#  undef FASTCALL"
-               print "#endif /* !defined( _GLXSIZE_H_ ) */"
 
 
        def printFunction(self, f):
@@ -215,11 +209,12 @@ if __name__ == '__main__':
        file_name = "gl_API.xml"
 
        try:
-               (args, trail) = getopt.getopt(sys.argv[1:], "f:m:", ["only-get", "only-set", "get-alias-set"])
+               (args, trail) = getopt.getopt(sys.argv[1:], "f:m:h:", ["only-get", "only-set", "get-alias-set", "header-tag"])
        except Exception,e:
                show_usage()
 
        mode = None
+       header_tag = None
        which_functions = PrintGlxSizeStubs_common.do_get | PrintGlxSizeStubs_common.do_set
 
        for (arg,val) in args:
@@ -233,11 +228,15 @@ if __name__ == '__main__':
                        which_functions = PrintGlxSizeStubs_common.do_set
                elif arg == "--get-alias-set":
                        which_functions |= PrintGlxSizeStubs_common.do_get_alias_set
+               elif (arg == '-h') or (arg == "--header-tag"):
+                       header_tag = val
 
        if mode == "size_c":
                dh = PrintGlxSizeStubs_c( which_functions )
        elif mode == "size_h":
                dh = PrintGlxSizeStubs_h( which_functions )
+               if header_tag:
+                       dh.header_tag = header_tag
        else:
                show_usage()
 
index 16499df0946481c5d4c03abbb5788a793bb3c80c..21f6dc0e62d9a1c3f57c98bb21e8ba99b25effed 100644 (file)
@@ -494,6 +494,7 @@ class FilterGLAPISpecBase(saxutils.XMLFilterBase):
                self.types = {}
                self.xref = {}
                self.factory = glItemFactory()
+               self.header_tag = None
 
 
        def find_type(self,type_name):
@@ -529,6 +530,10 @@ class FilterGLAPISpecBase(saxutils.XMLFilterBase):
                print ' * ' + self.license.replace('\n', '\n * ')
                print ' */'
                print ''
+               if self.header_tag:
+                   print '#if !defined( %s )' % (self.header_tag)
+                   print '#  define %s' % (self.header_tag)
+                   print ''
                self.printRealHeader();
                return
 
@@ -538,6 +543,9 @@ class FilterGLAPISpecBase(saxutils.XMLFilterBase):
 
                self.printFunctions()
                self.printRealFooter()
+               if self.header_tag:
+                   print ''
+                   print '#endif /* !defined( %s ) */' % (self.header_tag)
 
 
        def get_category_define(self):
index 3ff27e7d2ad6d3ccf3085ca42d698929a132f6b5..f5bd7f40ed75e135469b048a7a6905d0a1e101aa 100644 (file)
@@ -38,6 +38,7 @@ class PrintGlOffsets(gl_XML.FilterGLAPISpecBase):
 
        def __init__(self):
                gl_XML.FilterGLAPISpecBase.__init__(self)
+               self.header_tag = '_GLAPI_OFFSETS_H_'
                self.license = license.bsd_license_template % ( \
 """Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
 (C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM")
@@ -46,16 +47,6 @@ class PrintGlOffsets(gl_XML.FilterGLAPISpecBase):
                if f.fn_offset < 0: return
                print '#define _gloffset_%s %d' % (f.name, f.fn_offset)
 
-       def printRealHeader(self):
-               print '#ifndef _GLAPI_OFFSETS_H_'
-               print '#define _GLAPI_OFFSETS_H_'
-               print ''
-               return
-
-       def printRealFooter(self):
-               print ''
-               print '#endif'
-               return
 
 def show_usage():
        print "Usage: %s [-f input_file_name]" % sys.argv[0]
index d59d3de42a2bf6326183b6d6564f1bf0878322a6..49a8af7da4c729ba463d324e9d9a1ad407dd9ca6 100644 (file)
@@ -38,6 +38,7 @@ class PrintGlTable(gl_XML.FilterGLAPISpecBase):
 
        def __init__(self):
                gl_XML.FilterGLAPISpecBase.__init__(self)
+               self.header_tag = '_GLAPI_TABLE_H_'
                self.license = license.bsd_license_template % ( \
 """Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
 (C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM")
@@ -51,9 +52,6 @@ class PrintGlTable(gl_XML.FilterGLAPISpecBase):
                        (f.fn_return_type, f.name, arg_string, f.fn_offset)
 
        def printRealHeader(self):
-               print '#ifndef _GLAPI_TABLE_H_'
-               print '#define _GLAPI_TABLE_H_'
-               print ''
                print '#ifndef GLAPIENTRYP'
                print '#define GLAPIENTRYP'
                print '#endif'
@@ -64,8 +62,6 @@ class PrintGlTable(gl_XML.FilterGLAPISpecBase):
 
        def printRealFooter(self):
                print '};'
-               print ''
-               print '#endif'
                return
 
 
index c4431a79a5855a0ffc9f8c985983961080edcc6f..4bb255ee5c0cc1798c58750a2a4e19b4213609aa 100644 (file)
@@ -26,8 +26,8 @@
  * SOFTWARE.
  */
 
-#ifndef _GLAPI_OFFSETS_H_
-#define _GLAPI_OFFSETS_H_
+#if !defined( _GLAPI_OFFSETS_H_ )
+#  define _GLAPI_OFFSETS_H_
 
 #define _gloffset_NewList 0
 #define _gloffset_EndList 1
 #define _gloffset_StencilOpSeparate 797
 #define _gloffset_StencilMaskSeparate 798
 
-#endif
+#endif /* !defined( _GLAPI_OFFSETS_H_ ) */
index 48692540d58152a5df9dd609d823512a925ec249..be6ca81acbbb17a9e642a8c7798196d8f7d1355d 100644 (file)
@@ -26,8 +26,8 @@
  * SOFTWARE.
  */
 
-#ifndef _GLAPI_TABLE_H_
-#define _GLAPI_TABLE_H_
+#if !defined( _GLAPI_TABLE_H_ )
+#  define _GLAPI_TABLE_H_
 
 #ifndef GLAPIENTRYP
 #define GLAPIENTRYP
@@ -836,4 +836,4 @@ struct _glapi_table
    void (GLAPIENTRYP StencilMaskSeparate)(GLenum face, GLuint mask); /* 798 */
 };
 
-#endif
+#endif /* !defined( _GLAPI_TABLE_H_ ) */