gl_XML.glParameter.__init__(self, context, name, attrs);
+class glXParameterIterator:
+ """Class to iterate over a list of glXParameters.
+
+ Objects of this class are returned by the parameterIterator method of
+ the glXFunction class. They are used to iterate over the list of
+ parameters to the function."""
+
+ def __init__(self, data, skip_output, max_order):
+ self.data = data
+ self.index = 0
+ self.order = 0
+ self.skip_output = skip_output
+ self.max_order = max_order
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ if len( self.data ) == 0:
+ raise StopIteration
+
+ while 1:
+ if self.index == len( self.data ):
+ if self.order == self.max_order:
+ raise StopIteration
+ else:
+ self.order += 1
+ self.index = 0
+
+ i = self.index
+ self.index += 1
+
+ if self.data[i].order == self.order and not (self.data[i].is_output and self.skip_output):
+ return self.data[i]
+
+
class glXFunction(gl_XML.glFunction):
glx_rop = 0
glx_sop = 0
gl_XML.glFunction.__init__(self, context, name, attrs)
return
+
+ def parameterIterator(self, skip_output, max_order):
+ return glXParameterIterator(self.fn_parameters, skip_output, max_order)
+
+
def startElement(self, name, attrs):
"""Process elements within a function that are specific to GLX."""
def command_payload_length(self):
size = 0
size_string = ""
- for p in self:
+ for p in gl_XML.glFunction.parameterIterator(self):
if p.is_output: continue
temp = p.size_string()
try:
def opcode_real_value(self):
+ """Get the true numeric value of the GLX opcode
+
+ Behaves similarly to opcode_value, except for
+ X_GLXVendorPrivate and X_GLXVendorPrivateWithReply commands.
+ In these cases the value for the GLX opcode field (i.e.,
+ 16 for X_GLXVendorPrivate or 17 for
+ X_GLXVendorPrivateWithReply) is returned. For other 'single'
+ commands, the opcode for the command (e.g., 101 for
+ X_GLsop_NewList) is returned."""
+
if self.glx_vendorpriv != 0:
if self.needs_reply():
return 17
return self.opcode_value()
def opcode_value(self):
+ """Get the unique protocol opcode for the glXFunction"""
+
if self.glx_rop != 0:
return self.glx_rop
elif self.glx_sop != 0:
return -1
def opcode_rop_basename(self):
+ """Return either the name to be used for GLX protocol enum.
+
+ Returns either the name of the function or the name of the
+ name of the equivalent vector (e.g., glVertex3fv for
+ glVertex3f) function."""
+
if self.vectorequiv == None:
return self.name
else:
return self.vectorequiv
def opcode_name(self):
+ """Get the unique protocol enum name for the glXFunction"""
+
if self.glx_rop != 0:
return "X_GLrop_%s" % (self.opcode_rop_basename())
elif self.glx_sop != 0:
return "ERROR"
def opcode_real_name(self):
+ """Get the true protocol enum name for the GLX opcode
+
+ Behaves similarly to opcode_name, except for
+ X_GLXVendorPrivate and X_GLXVendorPrivateWithReply commands.
+ In these cases the string 'X_GLXVendorPrivate' or
+ 'X_GLXVendorPrivateWithReply' is returned. For other
+ single or render commands 'X_GLsop' or 'X_GLrop' plus the
+ name of the function returned."""
+
if self.glx_vendorpriv != 0:
if self.needs_reply():
return "X_GLXVendorPrivateWithReply"
def common_emit_one_arg(self, p, offset, pc, indent, adjust):
- if p.is_output: return
-
t = p.p_type
if p.is_array():
src_ptr = p.name
% (indent, pc, offset + adjust, src_ptr, p.size_string() )
def common_emit_args(self, f, pc, indent, adjust, skip_vla):
- # First emit all of the fixed-length 8-byte (i.e., GLdouble)
- # parameters.
-
offset = 0
if skip_vla:
- r = [0, 1]
+ r = 1
else:
- r = [0, 1, 2]
-
- for order in r:
- for p in f:
- if p.is_output or p.order != order: continue
-
- self.common_emit_one_arg(p, offset, pc, indent, adjust)
- offset += p.size()
+ r = 2
+ for p in f.parameterIterator(1, r):
+ self.common_emit_one_arg(p, offset, pc, indent, adjust)
+ offset += p.size()
return offset
# of data, and the protocol for this functions is very
# regular. Since they are so regular and there are so many
# of them, special case them with generic functions. On
- # x86, this save about 26KB in the libGL.so binary.
+ # x86, this saves about 26KB in the libGL.so binary.
if f.variable_length_parameter() == None and len(f.fn_parameters) == 1:
p = f.fn_parameters[0]
class glParameterIterator:
"""Class to iterate over a list of glParameters.
- Objects of this class are returned by the __iter__ method of the
- glFunction class. They are used to iterate over the list of
+ Objects of this class are returned by the parameterIterator method of
+ the glFunction class. They are used to iterate over the list of
parameters to the function."""
def __init__(self, data):
self.data = data
self.index = 0
-
+
+ def __iter__(self):
+ return self
+
def next(self):
if self.index == len( self.data ):
raise StopIteration
return
- def __iter__(self):
+ def parameterIterator(self):
return glParameterIterator(self.fn_parameters)
def get_parameter_string(self):
arg_string = ""
comma = ""
- for p in self:
+ for p in glFunction.parameterIterator(self):
arg_string = arg_string + comma + p.p_type_string + " " + p.name
comma = ", "