import gl_XML
import license
-import sys, getopt
+import sys, getopt, string
class glXItemFactory(gl_XML.glItemFactory):
def __init__(self, context, name, attrs):
self.vectorequiv = attrs.get('vectorequiv', None)
- self.count_parameters = None
self.counter = None
self.output = None
self.can_be_large = 0
elif not self.glx_doubles_in_order and p.p_type.size == 8:
p.order = 0;
- if p.p_count_parameters != None:
- self.count_parameters = p.p_count_parameters
-
if p.is_counter:
self.counter = p.name
elif self.glx_vendorpriv != 0:
return "X_GLvop_%s" % (self.name)
else:
- return "ERROR"
+ raise RuntimeError('Function "%s" has no opcode.' % (self.name))
+
def opcode_real_name(self):
"""Get the true protocol enum name for the GLX opcode
return "woffset"
return None
-
+
+class glXFunctionIterator(gl_XML.glFunctionIterator):
+ """Class to iterate over a list of glXFunctions"""
+
+ def __init__(self, context):
+ self.context = context
+ self.keys = context.functions.keys()
+ self.keys.sort()
+
+ for self.index in range(0, len(self.keys)):
+ if self.keys[ self.index ] >= 0: break
+
+ return
+
+
+ def next(self):
+ if self.index == len(self.keys):
+ raise StopIteration
+
+ f = self.context.functions[ self.keys[ self.index ] ]
+ self.index += 1
+
+ if f.ignore:
+ return self.next()
+ else:
+ return f
+
+
class GlxProto(gl_XML.FilterGLAPISpecBase):
name = "glX_proto_send.py (from Mesa)"
def createEnumFunction(self, n):
return glXEnumFunction(n, self)
+
+
+ def functionIterator(self):
+ return glXFunctionIterator(self)
+
+
+ def size_call(self, func):
+ """Create C code to calculate 'compsize'.
+
+ Creates code to calculate 'compsize'. If the function does
+ not need 'compsize' to be calculated, None will be
+ returned."""
+
+ if not func.image and not func.count_parameter_list:
+ return None
+
+ if not func.image:
+ parameters = string.join( func.count_parameter_list, "," )
+ compsize = "__gl%s_size(%s)" % (func.name, parameters)
+ else:
+ [dim, w, h, d, junk] = func.dimensions()
+
+ compsize = '__glImageSize(%s, %s, %s, %s, %s, %s)' % (w, h, d, func.image.img_format, func.image.img_type, func.image.img_target)
+ if not func.image.img_send_null:
+ compsize = '(%s != NULL) ? %s : 0' % (func.image.name, compsize)
+
+ return compsize
a_prod = "n"
b_prod = self.p_type.size
- if self.p_count_parameters == None and self.counter != None:
+ if not self.count_parameter_list and self.counter:
a_prod = self.counter
- elif (self.p_count_parameters != None and self.counter == None) or (self.is_output):
+ elif self.count_parameter_list and not self.counter or self.is_output:
pass
- elif self.p_count_parameters != None and self.counter != None:
+ elif self.count_parameter_list and self.counter:
b_prod = self.counter
else:
raise RuntimeError("Parameter '%s' to function '%s' has size 0." % (self.name, self.context.name))
# At some point this should be expanded to support pixel
# functions, but I'm not going to lose any sleep over it now.
- if f.fn_offset < 0 or f.client_handcode or f.server_handcode or f.ignore or f.vectorequiv or f.image:
+ if f.client_handcode or f.server_handcode or f.vectorequiv or f.image:
return
print ' %s' % (f.name)
self.set_return_type( func.fn_return_type )
self.glx_rop = ~0
self.can_be_large = func.can_be_large
- self.count_parameters = func.count_parameters
+ self.count_parameter_list = func.count_parameter_list
self.counter = func.counter
return
return
def printFunction(self, f):
- if f.fn_offset < 0 or f.client_handcode or f.ignore: return
+ if f.client_handcode: return
if f.glx_rop != 0 or f.vectorequiv != None:
if f.image:
if f.fn_return_type != 'void':
print ' %s retval = (%s) 0;' % (f.fn_return_type, f.fn_return_type)
- if f.count_parameters and not f.output_parameter():
- print ' const GLuint compsize = __gl%s_size(%s);' % (f.name, f.count_parameters)
- elif f.image:
- [dim, w, h, d, junk] = f.dimensions()
-
- compsize = '__glImageSize(%s, %s, %s, %s, %s, %s)' % (w, h, d, f.image.img_format, f.image.img_type, f.image.img_target)
- if not f.image.img_send_null:
- compsize = '(%s != NULL) ? %s : 0' % (f.image.name, compsize)
-
- print ' const GLuint compsize = %s;' % (compsize)
-
+ if not f.output_parameter():
+ compsize = self.size_call( f )
+ if compsize:
+ print ' const GLuint compsize = %s;' % (compsize)
print ' const GLuint cmdlen = %s;' % (f.command_length())
"""
def printFunction(self, f):
- if f.fn_offset < 0 or f.ignore: return
-
if f.category != self.last_category:
self.last_category = f.category
print ''
def printFunction(self, f):
- if f.fn_offset < 0 or f.ignore: return
print 'extern HIDDEN %s __indirect_gl%s(%s);' % (f.fn_return_type, f.name, f.get_parameter_string())
import sys, getopt, copy
-class SizeStubFunctionIterator:
+class SizeStubFunctionIterator(glX_XML.glXFunctionIterator):
"""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.
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():
return
- def __iter__(self):
- return self
-
-
def next(self):
if self.index == len(self.data):
raise StopIteration
self.context.common_emit_fixups(fixup)
print ''
- print ' compsize = __gl%s_size(%s);' % (self.name, f.count_parameters)
+ print ' compsize = %s;' % (context.size_call(context, f))
p = f.variable_length_parameter()
print ' return __GLX_PAD(%s);' % (p.size_string())
def printFunction(self, f):
- if f.glx_rop == 0 or f.ignore: return
+ if f.glx_rop == 0: return
has_counter = 0
for p in f.parameterIterator(1,2):
def printFunction(self, f):
- if f.glx_rop == 0 or f.server_handcode or f.ignore: return
+ if f.glx_rop == 0 or f.server_handcode: return
if self.glx_enum_functions.has_key(f.name):
ef = self.glx_enum_functions[f.name]
p_type = None
p_type_string = ""
p_count = 0
- p_count_parameters = None
counter = None
is_output = 0
is_counter = 0
def __init__(self, context, name, attrs):
p_name = attrs.get('name', None)
self.p_type_string = attrs.get('type', None)
- self.p_count_parameters = attrs.get('variable_param', None)
- if self.p_count_parameters:
- temp = self.p_count_parameters.replace( ' ', '' )
- self.count_parameter_list = temp.split( ',' )
+ temp = attrs.get('variable_param', None)
+ if temp:
+ self.count_parameter_list = temp.replace( ' ', '' ).split( ',' )
else:
self.count_parameter_list = []
- if self.p_count > 0 or self.counter or self.p_count_parameters:
+ if self.p_count > 0 or self.counter or self.count_parameter_list:
has_count = 1
else:
has_count = 0
to glCallLists, are not variable length arrays in this
sense."""
- return self.p_count_parameters or self.counter or self.width
+ return self.count_parameter_list or self.counter or self.width
def is_array(self):
glDeleteTextures), or a general variable length vector."""
if self.is_array():
- if self.p_count_parameters != None:
+ if self.count_parameter_list:
return "compsize"
elif self.counter != None:
return self.counter
def size(self):
- if self.p_count_parameters or self.counter or self.width or self.is_output:
+ if self.count_parameter_list or self.counter or self.width or self.is_output:
return 0
elif self.p_count == 0:
return self.p_type.size
if b_prod == 0: b_prod = 1
- if self.p_count_parameters == None and self.counter != None:
+ if not self.count_parameter_list and self.counter != None:
a_prod = self.counter
- elif self.p_count_parameters != None and self.counter == None:
+ elif self.count_parameter_list and self.counter == None:
pass
- elif self.p_count_parameters != None and self.counter != None:
+ elif self.count_parameter_list and self.counter != None:
b_prod = self.counter
elif self.width:
return "compsize"
class glFunction( glItem ):
- real_name = ""
- fn_alias = None
- fn_offset = -1
- fn_return_type = "void"
- fn_parameters = []
-
def __init__(self, context, name, attrs):
self.fn_alias = attrs.get('alias', None)
self.fn_parameters = []
self.image = None
self.count_parameter_list = []
+ self.fn_return_type = "void"
temp = attrs.get('offset', None)
if temp == None or temp == "?":