OSDN Git Service

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 f5ffe1c..cb14dbc 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 833e95b..2001c56 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 ba89550..9fad47e 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 7216b69..146d662 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 ecab65d..cf0885a 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 16499df..21f6dc0 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 3ff27e7..f5bd7f4 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 d59d3de..49a8af7 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 c4431a7..4bb255e 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 4869254..be6ca81 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_ ) */