From c2803587b6f2533514e1cfa9793d0a448e9c2c85 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 1 Feb 2005 00:28:47 +0000 Subject: Small refactor. Move several utility functions from glX_XML.py to FilterGLAPISpecBase (in gl_XML.py). When these functions are used to emit common #define lines, the will automatically be undefined in FilterGLAPISpecBase::printFooter if header_tag is set (i.e., the file is a header file). These changes do not modify the generated code. --- src/mesa/glapi/gl_XML.py | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'src/mesa/glapi/gl_XML.py') diff --git a/src/mesa/glapi/gl_XML.py b/src/mesa/glapi/gl_XML.py index 086133cdf1..1771975e84 100644 --- a/src/mesa/glapi/gl_XML.py +++ b/src/mesa/glapi/gl_XML.py @@ -509,6 +509,7 @@ class FilterGLAPISpecBase(saxutils.XMLFilterBase): self.xref = {} self.factory = glItemFactory() self.header_tag = None + self.undef_list = [] def find_type(self,type_name): @@ -558,8 +559,12 @@ class FilterGLAPISpecBase(saxutils.XMLFilterBase): self.printFunctions() self.printRealFooter() if self.header_tag: - print '' - print '#endif /* !defined( %s ) */' % (self.header_tag) + if self.undef_list: + print '' + for u in self.undef_list: + print "# undef %s" % (u) + print '' + print '#endif /* !defined( %s ) */' % (self.header_tag) def get_category_define(self): @@ -625,6 +630,44 @@ class FilterGLAPISpecBase(saxutils.XMLFilterBase): return + def printPure(self): + self.undef_list.append("PURE") + print """# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +# define PURE __attribute__((pure)) +# else +# define PURE +# endif""" + + def printFastcall(self): + self.undef_list.append("FASTCALL") + print """# if defined(__i386__) && defined(__GNUC__) +# define FASTCALL __attribute__((fastcall)) +# else +# define FASTCALL +# endif""" + + def printVisibility(self, S, s): + self.undef_list.append(S) + print """# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) +# define %s __attribute__((visibility("%s"))) +# else +# define %s +# endif""" % (S, s, S) + + def printNoinline(self): + self.undef_list.append("NOINLINE") + print """# if defined(__GNUC__) +# define NOINLINE __attribute__((noinline)) +# else +# define NOINLINE +# endif""" + + def printHaveAlias(self): + self.undef_list.append("HAVE_ALIAS") + print """# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) +# define HAVE_ALIAS +# endif""" + def printFunction(self,offset): """Print a single function. -- cgit v1.2.3