Added some comments and fixed typeos. Slightly refactored the way
function parameters are iterated. There are no changes in the generated code.
This commit is contained in:
@@ -263,6 +263,42 @@ class glXParameter(gl_XML.glParameter):
|
|||||||
gl_XML.glParameter.__init__(self, context, name, attrs);
|
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):
|
class glXFunction(gl_XML.glFunction):
|
||||||
glx_rop = 0
|
glx_rop = 0
|
||||||
glx_sop = 0
|
glx_sop = 0
|
||||||
@@ -293,6 +329,11 @@ class glXFunction(gl_XML.glFunction):
|
|||||||
gl_XML.glFunction.__init__(self, context, name, attrs)
|
gl_XML.glFunction.__init__(self, context, name, attrs)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def parameterIterator(self, skip_output, max_order):
|
||||||
|
return glXParameterIterator(self.fn_parameters, skip_output, max_order)
|
||||||
|
|
||||||
|
|
||||||
def startElement(self, name, attrs):
|
def startElement(self, name, attrs):
|
||||||
"""Process elements within a function that are specific to GLX."""
|
"""Process elements within a function that are specific to GLX."""
|
||||||
|
|
||||||
@@ -360,7 +401,7 @@ class glXFunction(gl_XML.glFunction):
|
|||||||
def command_payload_length(self):
|
def command_payload_length(self):
|
||||||
size = 0
|
size = 0
|
||||||
size_string = ""
|
size_string = ""
|
||||||
for p in self:
|
for p in gl_XML.glFunction.parameterIterator(self):
|
||||||
if p.is_output: continue
|
if p.is_output: continue
|
||||||
temp = p.size_string()
|
temp = p.size_string()
|
||||||
try:
|
try:
|
||||||
@@ -382,6 +423,16 @@ class glXFunction(gl_XML.glFunction):
|
|||||||
|
|
||||||
|
|
||||||
def opcode_real_value(self):
|
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.glx_vendorpriv != 0:
|
||||||
if self.needs_reply():
|
if self.needs_reply():
|
||||||
return 17
|
return 17
|
||||||
@@ -391,6 +442,8 @@ class glXFunction(gl_XML.glFunction):
|
|||||||
return self.opcode_value()
|
return self.opcode_value()
|
||||||
|
|
||||||
def opcode_value(self):
|
def opcode_value(self):
|
||||||
|
"""Get the unique protocol opcode for the glXFunction"""
|
||||||
|
|
||||||
if self.glx_rop != 0:
|
if self.glx_rop != 0:
|
||||||
return self.glx_rop
|
return self.glx_rop
|
||||||
elif self.glx_sop != 0:
|
elif self.glx_sop != 0:
|
||||||
@@ -401,12 +454,20 @@ class glXFunction(gl_XML.glFunction):
|
|||||||
return -1
|
return -1
|
||||||
|
|
||||||
def opcode_rop_basename(self):
|
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:
|
if self.vectorequiv == None:
|
||||||
return self.name
|
return self.name
|
||||||
else:
|
else:
|
||||||
return self.vectorequiv
|
return self.vectorequiv
|
||||||
|
|
||||||
def opcode_name(self):
|
def opcode_name(self):
|
||||||
|
"""Get the unique protocol enum name for the glXFunction"""
|
||||||
|
|
||||||
if self.glx_rop != 0:
|
if self.glx_rop != 0:
|
||||||
return "X_GLrop_%s" % (self.opcode_rop_basename())
|
return "X_GLrop_%s" % (self.opcode_rop_basename())
|
||||||
elif self.glx_sop != 0:
|
elif self.glx_sop != 0:
|
||||||
@@ -417,6 +478,15 @@ class glXFunction(gl_XML.glFunction):
|
|||||||
return "ERROR"
|
return "ERROR"
|
||||||
|
|
||||||
def opcode_real_name(self):
|
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.glx_vendorpriv != 0:
|
||||||
if self.needs_reply():
|
if self.needs_reply():
|
||||||
return "X_GLXVendorPrivateWithReply"
|
return "X_GLXVendorPrivateWithReply"
|
||||||
|
@@ -153,8 +153,6 @@ generic_%u_byte( GLint rop, const void * ptr )
|
|||||||
|
|
||||||
|
|
||||||
def common_emit_one_arg(self, p, offset, pc, indent, adjust):
|
def common_emit_one_arg(self, p, offset, pc, indent, adjust):
|
||||||
if p.is_output: return
|
|
||||||
|
|
||||||
t = p.p_type
|
t = p.p_type
|
||||||
if p.is_array():
|
if p.is_array():
|
||||||
src_ptr = p.name
|
src_ptr = p.name
|
||||||
@@ -165,23 +163,16 @@ generic_%u_byte( GLint rop, const void * ptr )
|
|||||||
% (indent, pc, offset + adjust, src_ptr, p.size_string() )
|
% (indent, pc, offset + adjust, src_ptr, p.size_string() )
|
||||||
|
|
||||||
def common_emit_args(self, f, pc, indent, adjust, skip_vla):
|
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
|
offset = 0
|
||||||
|
|
||||||
if skip_vla:
|
if skip_vla:
|
||||||
r = [0, 1]
|
r = 1
|
||||||
else:
|
else:
|
||||||
r = [0, 1, 2]
|
r = 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()
|
|
||||||
|
|
||||||
|
for p in f.parameterIterator(1, r):
|
||||||
|
self.common_emit_one_arg(p, offset, pc, indent, adjust)
|
||||||
|
offset += p.size()
|
||||||
|
|
||||||
return offset
|
return offset
|
||||||
|
|
||||||
@@ -274,7 +265,7 @@ generic_%u_byte( GLint rop, const void * ptr )
|
|||||||
# of data, and the protocol for this functions is very
|
# of data, and the protocol for this functions is very
|
||||||
# regular. Since they are so regular and there are so many
|
# regular. Since they are so regular and there are so many
|
||||||
# of them, special case them with generic functions. On
|
# 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:
|
if f.variable_length_parameter() == None and len(f.fn_parameters) == 1:
|
||||||
p = f.fn_parameters[0]
|
p = f.fn_parameters[0]
|
||||||
|
@@ -252,14 +252,17 @@ class glParameter( glItem ):
|
|||||||
class glParameterIterator:
|
class glParameterIterator:
|
||||||
"""Class to iterate over a list of glParameters.
|
"""Class to iterate over a list of glParameters.
|
||||||
|
|
||||||
Objects of this class are returned by the __iter__ method of the
|
Objects of this class are returned by the parameterIterator method of
|
||||||
glFunction class. They are used to iterate over the list of
|
the glFunction class. They are used to iterate over the list of
|
||||||
parameters to the function."""
|
parameters to the function."""
|
||||||
|
|
||||||
def __init__(self, data):
|
def __init__(self, data):
|
||||||
self.data = data
|
self.data = data
|
||||||
self.index = 0
|
self.index = 0
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
def next(self):
|
def next(self):
|
||||||
if self.index == len( self.data ):
|
if self.index == len( self.data ):
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
@@ -295,7 +298,7 @@ class glFunction( glItem ):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def __iter__(self):
|
def parameterIterator(self):
|
||||||
return glParameterIterator(self.fn_parameters)
|
return glParameterIterator(self.fn_parameters)
|
||||||
|
|
||||||
|
|
||||||
@@ -325,7 +328,7 @@ class glFunction( glItem ):
|
|||||||
def get_parameter_string(self):
|
def get_parameter_string(self):
|
||||||
arg_string = ""
|
arg_string = ""
|
||||||
comma = ""
|
comma = ""
|
||||||
for p in self:
|
for p in glFunction.parameterIterator(self):
|
||||||
arg_string = arg_string + comma + p.p_type_string + " " + p.name
|
arg_string = arg_string + comma + p.p_type_string + " " + p.name
|
||||||
comma = ", "
|
comma = ", "
|
||||||
|
|
||||||
|
@@ -48,7 +48,7 @@ class PrintGlOffsets(gl_XML.FilterGLAPISpecBase):
|
|||||||
t_string = ""
|
t_string = ""
|
||||||
comma = ""
|
comma = ""
|
||||||
|
|
||||||
for p in f:
|
for p in f.parameterIterator():
|
||||||
cast = ""
|
cast = ""
|
||||||
|
|
||||||
if p.is_pointer:
|
if p.is_pointer:
|
||||||
|
@@ -45,7 +45,7 @@ class PrintGenericStubs(gl_XML.FilterGLAPISpecBase):
|
|||||||
|
|
||||||
def get_stack_size(self, f):
|
def get_stack_size(self, f):
|
||||||
size = 0
|
size = 0
|
||||||
for p in f:
|
for p in f.parameterIterator():
|
||||||
t = p.p_type
|
t = p.p_type
|
||||||
|
|
||||||
if p.is_array() or t.size != 8:
|
if p.is_array() or t.size != 8:
|
||||||
|
Reference in New Issue
Block a user