summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorIan Romanick <idr@us.ibm.com>2005-01-27 01:08:48 +0000
committerIan Romanick <idr@us.ibm.com>2005-01-27 01:08:48 +0000
commit5aa6dc329b983b95071700c3af9353e3b35454d9 (patch)
tree89506c88a9668aca519aa79d1654a1144d724f71 /src/mesa
parent5b0dd893704157cb8f9c42ce4a32a9d3e2a7edef (diff)
The 'mode' setting of a function within an 'enum' element is now used.
Parameters to glX_proto_size.py are now used to determine whether to emit either get-type function, set-type functions, or both. When only get-type functions are emitted, they can optionally alias set-type functions. This would be useful if, for example, the two types were in different source files. The real work to implement this is in SizeStubFunctionIterator class. All of the logic for which functions to iterate and in which order is implemented there.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/glapi/Makefile4
-rw-r--r--src/mesa/glapi/glX_XML.py26
-rw-r--r--src/mesa/glapi/glX_proto_size.py137
3 files changed, 131 insertions, 36 deletions
diff --git a/src/mesa/glapi/Makefile b/src/mesa/glapi/Makefile
index 35d8951c2d..ba89550eda 100644
--- a/src/mesa/glapi/Makefile
+++ b/src/mesa/glapi/Makefile
@@ -57,10 +57,10 @@ 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 > ../../glx/x11/indirect_size.h
+ $(PYTHON2) $(PYTHON_FLAGS) glX_proto_size.py -m size_h --only-set > ../../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 > ../../glx/x11/indirect_size.c
+ $(PYTHON2) $(PYTHON_FLAGS) glX_proto_size.py -m size_c --only-set > ../../glx/x11/indirect_size.c
clean:
rm -f *~ *.pyo
diff --git a/src/mesa/glapi/glX_XML.py b/src/mesa/glapi/glX_XML.py
index 9d8fe00096..dcfb015623 100644
--- a/src/mesa/glapi/glX_XML.py
+++ b/src/mesa/glapi/glX_XML.py
@@ -83,7 +83,9 @@ class glXItemFactory(gl_XML.glItemFactory):
class glXEnumFunction:
def __init__(self, name):
self.name = name
-
+ self.mode = 0
+ self.sig = None
+
# "enums" is a set of lists. The element in the set is the
# value of the enum. The list is the list of names for that
# value. For example, [0x8126] = {"POINT_SIZE_MIN",
@@ -115,12 +117,23 @@ class glXEnumFunction:
def signature( self ):
- sig = ""
- for i in self.count:
- for e in self.count[i]:
- sig += "%04x,%u," % (e, i)
+ if self.sig == None:
+ self.sig = ""
+ for i in self.count:
+ for e in self.count[i]:
+ self.sig += "%04x,%u," % (e, i)
- return sig;
+ return self.sig
+
+
+ def set_mode( self, mode ):
+ """Mark an enum-function as a 'set' function."""
+
+ self.mode = mode
+
+
+ def is_set( self ):
+ return self.mode
def PrintUsingTable(self):
@@ -248,6 +261,7 @@ class glXEnum(gl_XML.glEnum):
if not self.context.glx_enum_functions.has_key( n ):
f = glXEnumFunction( n )
+ f.set_mode( mode )
self.context.glx_enum_functions[ f.name ] = f
self.context.glx_enum_functions[ n ].append( c, self.value, self.name )
diff --git a/src/mesa/glapi/glX_proto_size.py b/src/mesa/glapi/glX_proto_size.py
index 883f4827e1..ecab65d3f0 100644
--- a/src/mesa/glapi/glX_proto_size.py
+++ b/src/mesa/glapi/glX_proto_size.py
@@ -35,14 +35,89 @@ import license
import sys, getopt, copy
-class PrintGlxSizeStubs_c(glX_XML.GlxProto):
- def __init__(self):
+class SizeStubFunctionIterator:
+ """Iterate over functions that need "size" information.
+
+ Iterate over the functions that have variable sized data. First the
+ "set"-type functions are iterated followed by the "get"-type
+ functions.
+ """
+
+ def __init__(self, context):
+ self.data = []
+ self.index = 0
+
+ set_functions = []
+ get_functions = []
+ extra_data = []
+
+ for f in gl_XML.glFunctionIterator(context):
+ if f.fn_offset < 0: break
+
+ if context.glx_enum_functions.has_key(f.name):
+ ef = context.glx_enum_functions[f.name]
+ if ef.is_set():
+ set_functions.append(f)
+ else:
+ get_functions.append(f)
+
+
+ if (context.which_functions & PrintGlxSizeStubs_c.do_set) != 0:
+ self.data += set_functions
+ elif context.get_alias_set:
+ extra_data = set_functions
+
+ if (context.which_functions & PrintGlxSizeStubs_c.do_get) != 0:
+ self.data += get_functions
+
+
+ for f in extra_data + self.data:
+ sig = context.glx_enum_functions[f.name].signature()
+
+ if not context.glx_enum_sigs.has_key(sig):
+ context.glx_enum_sigs[sig] = f.name;
+
+ return
+
+
+ def __iter__(self):
+ return self
+
+
+ def next(self):
+ if self.index == len(self.data):
+ raise StopIteration
+
+ f = self.data[ self.index ]
+ self.index += 1
+
+ return f
+
+
+class PrintGlxSizeStubs_common(glX_XML.GlxProto):
+ do_get = (1 << 0)
+ do_set = (1 << 1)
+ do_get_alias_set = (1 << 2)
+
+ def __init__(self, which_functions):
glX_XML.GlxProto.__init__(self)
self.license = license.bsd_license_template % ( "(C) Copyright IBM Corporation 2004", "IBM")
self.aliases = []
self.glx_enum_sigs = {}
self.name = "glX_proto_size.py (from Mesa)"
+ self.which_functions = which_functions
+
+ if (((which_functions & PrintGlxSizeStubs_common.do_set) != 0) and ((which_functions & PrintGlxSizeStubs_common.do_get) != 0)) or ((which_functions & PrintGlxSizeStubs_common.do_get_alias_set) != 0):
+ self.get_alias_set = 1
+ else:
+ self.get_alias_set = 0
+
+ def functionIterator(self):
+ return SizeStubFunctionIterator(self)
+
+
+class PrintGlxSizeStubs_c(PrintGlxSizeStubs_common):
def printRealHeader(self):
print ''
print '#include <GL/gl.h>'
@@ -71,33 +146,25 @@ class PrintGlxSizeStubs_c(glX_XML.GlxProto):
print ''
print ''
+
def printRealFooter(self):
for a in self.aliases:
print a
+
def printFunction(self, f):
- if self.glx_enum_functions.has_key(f.name):
- ef = self.glx_enum_functions[f.name]
+ ef = self.glx_enum_functions[f.name]
+ n = self.glx_enum_sigs[ ef.signature() ];
- sig = ef.signature();
- if self.glx_enum_sigs.has_key(sig):
- n = self.glx_enum_sigs[sig];
- a = 'ALIAS( %s, %s )' % (f.name, n)
- self.aliases.append(a)
- else:
- ef.Print( f.name )
- self.glx_enum_sigs[sig] = f.name;
+ if n != f.name:
+ a = 'ALIAS( %s, %s )' % (f.name, n)
+ self.aliases.append(a)
+ else:
+ ef.Print( f.name )
-class PrintGlxSizeStubs_h(glX_XML.GlxProto):
- def __init__(self):
- glX_XML.GlxProto.__init__(self)
- self.license = license.bsd_license_template % ( "(C) Copyright IBM Corporation 2004", "IBM")
- self.aliases = []
- self.glx_enum_sigs = {}
- self.name = "glX_proto_size.py (from Mesa)"
-
+class PrintGlxSizeStubs_h(PrintGlxSizeStubs_common):
def printRealHeader(self):
print """
/**
@@ -128,13 +195,19 @@ class PrintGlxSizeStubs_h(glX_XML.GlxProto):
def printFunction(self, f):
- if self.glx_enum_functions.has_key(f.name):
- ef = self.glx_enum_functions[f.name]
- print 'extern INTERNAL PURE FASTCALL GLint __gl%s_size(GLenum);' % (f.name)
+ ef = self.glx_enum_functions[f.name]
+ print 'extern INTERNAL PURE FASTCALL GLint __gl%s_size(GLenum);' % (f.name)
def show_usage():
- print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]
+ print "Usage: %s [-f input_file_name] -m output_mode [--only-get | --only-set] [--get-alias-set]" % sys.argv[0]
+ print " -m output_mode Output mode can be one of 'size_c' or 'size_h'."
+ print " --only-get Only emit 'get'-type functions."
+ print " --only-set Only emit 'set'-type functions."
+ print " --get-alias-set When only 'get'-type functions are emitted, allow them"
+ print " to be aliases to 'set'-type funcitons."
+ print ""
+ print "By default, both 'get' and 'set'-type functions are emitted."
sys.exit(1)
@@ -142,21 +215,29 @@ if __name__ == '__main__':
file_name = "gl_API.xml"
try:
- (args, trail) = getopt.getopt(sys.argv[1:], "f:m:")
+ (args, trail) = getopt.getopt(sys.argv[1:], "f:m:", ["only-get", "only-set", "get-alias-set"])
except Exception,e:
show_usage()
- mode = "proto"
+ mode = None
+ which_functions = PrintGlxSizeStubs_common.do_get | PrintGlxSizeStubs_common.do_set
+
for (arg,val) in args:
if arg == "-f":
file_name = val
elif arg == "-m":
mode = val
+ elif arg == "--only-get":
+ which_functions = PrintGlxSizeStubs_common.do_get
+ elif arg == "--only-set":
+ which_functions = PrintGlxSizeStubs_common.do_set
+ elif arg == "--get-alias-set":
+ which_functions |= PrintGlxSizeStubs_common.do_get_alias_set
if mode == "size_c":
- dh = PrintGlxSizeStubs_c()
+ dh = PrintGlxSizeStubs_c( which_functions )
elif mode == "size_h":
- dh = PrintGlxSizeStubs_h()
+ dh = PrintGlxSizeStubs_h( which_functions )
else:
show_usage()