def WriteData(offset, arg_type, arg_name, is_swapped): """Return a string to write a variable to the packing buffer.""" retval = 9 if apiutil.IsPointer(arg_type): retval = "\tWRITE_NETWORK_POINTER(%d, (void *) %s);" % (offset, arg_name) else: if is_swapped: if arg_type == "GLfloat" or arg_type == "GLclampf": retval = "\tWRITE_DATA(%d, GLuint, SWAPFLOAT(%s));" % ( offset, arg_name) elif arg_type == "GLdouble" or arg_type == "GLclampd": retval = "\tWRITE_SWAPPED_DOUBLE(%d, %s);" % (offset, arg_name) elif apiutil.sizeof(arg_type) == 1: retval = "\tWRITE_DATA(%d, %s, %s);" % (offset, arg_type, arg_name) elif apiutil.sizeof(arg_type) == 2: retval = "\tWRITE_DATA(%d, %s, SWAP16(%s));" % ( offset, arg_type, arg_name) elif apiutil.sizeof(arg_type) == 4: retval = "\tWRITE_DATA(%d, %s, SWAP32(%s));" % ( offset, arg_type, arg_name) else: if arg_type == "GLdouble" or arg_type == "GLclampd": retval = "\tWRITE_DOUBLE(%d, %s);" % (offset, arg_name) else: retval = "\tWRITE_DATA(%d, %s, %s);" % (offset, arg_type, arg_name) if retval == 9: print >> sys.stderr, "no retval for %s %s" % (arg_name, arg_type) assert 0 return retval
def WriteData( offset, arg_type, arg_name, is_swapped ): """Return a string to write a variable to the packing buffer.""" retval = 9 if apiutil.IsPointer(arg_type): retval = "\tWRITE_NETWORK_POINTER( %d, (void *) %s );" % (offset, arg_name ) else: if is_swapped: if arg_type == "GLfloat" or arg_type == "GLclampf": retval = "\tWRITE_DATA( %d, GLuint, SWAPFLOAT(%s) );" % (offset, arg_name) elif arg_type == "GLdouble" or arg_type == "GLclampd": retval = "\tWRITE_SWAPPED_DOUBLE( %d, %s );" % (offset, arg_name) elif apiutil.sizeof(arg_type) == 1: retval = "\tWRITE_DATA( %d, %s, %s );" % (offset, arg_type, arg_name) elif apiutil.sizeof(arg_type) == 2: retval = "\tWRITE_DATA( %d, %s, SWAP16(%s) );" % (offset, arg_type, arg_name) elif apiutil.sizeof(arg_type) == 4: retval = "\tWRITE_DATA( %d, %s, SWAP32(%s) );" % (offset, arg_type, arg_name) else: if arg_type == "GLdouble" or arg_type == "GLclampd": retval = "\tWRITE_DOUBLE( %d, %s );" % (offset, arg_name) else: retval = "\tWRITE_DATA( %d, %s, %s );" % (offset, arg_type, arg_name) if retval == 9: print >>sys.stderr, "no retval for %s %s" % (arg_name, arg_type) assert 0 return retval
def WriteData(offset, arg_type, arg_name, is_swapped): if string.find(arg_type, '*') != -1: retval = "\tWRITE_NETWORK_POINTER( %d, (void *) %s );" % (offset, arg_name) else: if is_swapped: if arg_type == "GLfloat" or arg_type == "GLclampf": retval = "\tWRITE_DATA( %d, GLuint, SWAPFLOAT(%s) );" % ( offset, arg_name) elif arg_type == "GLdouble" or arg_type == "GLclampd": retval = "\tWRITE_SWAPPED_DOUBLE( %d, %s );" % (offset, arg_name) elif apiutil.sizeof(arg_type) == 1: retval = "\tWRITE_DATA( %d, %s, %s );" % (offset, arg_type, arg_name) elif apiutil.sizeof(arg_type) == 2: retval = "\tWRITE_DATA( %d, %s, SWAP16(%s) );" % ( offset, arg_type, arg_name) elif apiutil.sizeof(arg_type) == 4: retval = "\tWRITE_DATA( %d, %s, SWAP32(%s) );" % ( offset, arg_type, arg_name) else: if arg_type == "GLdouble" or arg_type == "GLclampd": retval = "\tWRITE_DOUBLE( %d, %s );" % (offset, arg_name) else: retval = "\tWRITE_DATA( %d, %s, %s );" % (offset, arg_type, arg_name) return retval
def MakeNormalCall(return_type, func_name, params, counter_init=0): counter = counter_init copy_of_params = params[:] for i in range(0, len(params)): (name, type, vecSize) = params[i] if apiutil.IsPointer(copy_of_params[i][1]): params[i] = ('NULL', type, vecSize) copy_of_params[i] = (copy_of_params[i][0], 'void', 0) if not "get" in apiutil.Properties(func_name): print('\tcrError( "%s needs to be special cased!" );' % func_name) else: print("\t%s %s = %s;" % (copy_of_params[i][1], name, ReadData(counter, copy_of_params[i][1]))) counter += apiutil.sizeof(copy_of_params[i][1]) if ("get" in apiutil.Properties(func_name)): FindReturnPointer(return_type, params) FindWritebackPointer(return_type, params) if return_type != "void": print("\t(void)", end=" ") else: print("\t", end="") print("pState->pDispatchTbl->%s(%s);" % (func_name, apiutil.MakeCallStringForDispatcher(params)))
def WriteData( offset, arg_type, arg_name, is_swapped ): if string.find( arg_type, '*' ) != -1: retval = "\tWRITE_NETWORK_POINTER( %d, (void *) %s );" % (offset, arg_name ) else: if is_swapped: if arg_type == "GLfloat" or arg_type == "GLclampf": retval = "\tWRITE_DATA( %d, GLuint, SWAPFLOAT(%s) );" % (offset, arg_name) elif arg_type == "GLdouble" or arg_type == "GLclampd": retval = "\tWRITE_SWAPPED_DOUBLE( %d, %s );" % (offset, arg_name) elif apiutil.sizeof(arg_type) == 1: retval = "\tWRITE_DATA( %d, %s, %s );" % (offset, arg_type, arg_name) elif apiutil.sizeof(arg_type) == 2: retval = "\tWRITE_DATA( %d, %s, SWAP16(%s) );" % (offset, arg_type, arg_name) elif apiutil.sizeof(arg_type) == 4: retval = "\tWRITE_DATA( %d, %s, SWAP32(%s) );" % (offset, arg_type, arg_name) else: if arg_type == "GLdouble" or arg_type == "GLclampd": retval = "\tWRITE_DOUBLE( %d, %s );" % (offset, arg_name) else: retval = "\tWRITE_DATA( %d, %s, %s );" % (offset, arg_type, arg_name) return retval
def MakeNormalCall( return_type, func_name, params, counter_init = 0 ): counter = counter_init copy_of_params = params[:] for i in range( 0, len(params) ): (name, type, vecSize) = params[i] if apiutil.IsPointer(copy_of_params[i][1]): params[i] = ('NULL', type, vecSize) copy_of_params[i] = (copy_of_params[i][0], 'void', 0) if not "get" in apiutil.Properties(func_name): print '\tcrError( "%s needs to be special cased!" );' % func_name else: print "\t%s %s = %s;" % ( copy_of_params[i][1], name, ReadData( counter, copy_of_params[i][1] ) ) counter += apiutil.sizeof(copy_of_params[i][1]) if ("get" in apiutil.Properties(func_name)): FindReturnPointer( return_type, params ) FindWritebackPointer( return_type, params ) if return_type != "void": print "\t(void)", else: print "\t", print "cr_unpackDispatch.%s( %s );" % (func_name, apiutil.MakeCallString(params))
def PrintFunc( func_name, params, is_swapped, can_have_pointers ): """Emit a packer function.""" if is_swapped: print 'void PACK_APIENTRY crPack%sSWAP( %s )' % (func_name, apiutil.MakeDeclarationString(params)) else: print 'void PACK_APIENTRY crPack%s( %s )' % (func_name, apiutil.MakeDeclarationString(params)) print '{' print '\tGET_PACKER_CONTEXT(pc);' # Save original function name orig_func_name = func_name # Convert to a non-vector version of the function if possible func_name = apiutil.NonVectorFunction( func_name ) if not func_name: func_name = orig_func_name # Check if there are any pointer parameters. # That's usually a problem so we'll emit an error function. nonVecParams = apiutil.Parameters(func_name) bail_out = 0 for (name, type, vecSize) in nonVecParams: if apiutil.IsPointer(type) and vecSize == 0 and not can_have_pointers: bail_out = 1 if bail_out: for (name, type, vecSize) in nonVecParams: print '\t(void)%s;' % (name) print '\tcrError ( "%s needs to be special cased %d %d!");' % (func_name, vecSize, can_have_pointers) print '\t(void) pc;' print '}' # XXX we should really abort here return if "extpack" in apiutil.ChromiumProps(func_name): is_extended = 1 else: is_extended = 0 print "\tunsigned char *data_ptr;" print '\t(void) pc;' #if func_name == "Enable" or func_name == "Disable": # print "\tCRASSERT(!pc->buffer.geometry_only); /* sanity check */" packet_length = apiutil.PacketLength(nonVecParams) if packet_length == 0 and not is_extended: print "\tGET_BUFFERED_POINTER_NO_ARGS( pc );" elif func_name[:9] == "Translate" or func_name[:5] == "Color": # XXX WTF is the purpose of this? if is_extended: packet_length += 8 print "\tGET_BUFFERED_POINTER_NO_BEGINEND_FLUSH( pc, %d );" % packet_length else: if is_extended: packet_length += 8 print "\tGET_BUFFERED_POINTER( pc, %d );" % packet_length UpdateCurrentPointer( func_name ) if is_extended: counter = 8 print WriteData( 0, 'GLint', packet_length, is_swapped ) print WriteData( 4, 'GLenum', apiutil.ExtendedOpcodeName( func_name ), is_swapped ) else: counter = 0 # Now emit the WRITE_() macros for all parameters for index in range(0,len(params)): (name, type, vecSize) = params[index] # if we're converting a vector-valued function to a non-vector func: if vecSize > 0 and func_name != orig_func_name: ptrType = apiutil.PointerType(type) for i in range(0, vecSize): print WriteData( counter + i * apiutil.sizeof(ptrType), ptrType, "%s[%d]" % (name, i), is_swapped ) # XXX increment counter here? else: print WriteData( counter, type, name, is_swapped ) if apiutil.IsPointer(type): counter += apiutil.PointerSize() else: counter += apiutil.sizeof(type) # finish up if is_extended: print "\tWRITE_OPCODE( pc, CR_EXTEND_OPCODE );" else: print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name ) print '}\n'
def PrintFunction(func_name, extSuffix, num_coords, argtype, do_swapped, do_count, do_vector): """ Generate all the functions named crPackVertex[234][dfis][v]BBOX() and crPackVertex[234][dfis][v]BBOX_COUNT(). We also handle glVertexAttrib*ARB. Note: func_name should not have an ARB suffix. """ if do_count: countSuffix = "_COUNT" else: countSuffix = "" if do_swapped: swapSuffix = "SWAP" else: swapSuffix = "" if func_name[0:12] == "VertexAttrib": isVertexAttrib = 1 else: isVertexAttrib = 0 if argtype[0] == "N": normalized = 1 else: normalized = 0 if argtype == "b" or argtype == "Nb": vector_type = "GLbyte" elif argtype == "ub" or argtype == "Nub": vector_type = "GLubyte" elif argtype == "s" or argtype == "Ns": vector_type = "GLshort" elif argtype == "us" or argtype == "Nus": vector_type = "GLushort" elif argtype == "i" or argtype == "Ni": vector_type = "GLint" elif argtype == "ui" or argtype == "Nui": vector_type = "GLuint" elif argtype == "f": vector_type = "GLfloat" elif argtype == "d": vector_type = "GLdouble" else: print "type is %s" % argtype abort() if do_vector: if isVertexAttrib: func_name = 'VertexAttrib%d%sv' % (num_coords, argtype) else: func_name = 'Vertex%d%sv' % (num_coords, argtype) params = apiutil.Parameters(func_name + extSuffix) print 'void PACK_APIENTRY crPack%sBBOX%s%s( %s )' % ( func_name + extSuffix, countSuffix, swapSuffix, apiutil.MakeDeclarationString(params)) print '{' if do_vector: # vector version packet_length = num_coords * apiutil.sizeof(vector_type) if isVertexAttrib: packet_length += 4 # for index if packet_length % 4 != 0: packet_length += 2 else: # non-vector packet_length = apiutil.PacketLength(params) if isVertexAttrib: packet_length += 0 # for index if packet_length % 4 != 0: packet_length += 2 print "\tGET_PACKER_CONTEXT(pc);" print "\tunsigned char *data_ptr;" if normalized: if argtype == "Nb": t = "B" elif argtype == "Ni": t = "I" elif argtype == "Nui": t = "UI" elif argtype == "Nub": t = "UB" elif argtype == "Ns": t = "S" elif argtype == "Nus": t = "US" else: abort() if do_vector: print "\tCREATE_%dD_VFLOATS_%s_NORMALIZED();" % (num_coords, t) else: print "\tCREATE_%dD_FLOATS_%s_NORMALIZED();" % (num_coords, t) else: if do_vector: print "\tCREATE_%dD_VFLOATS();" % num_coords else: print "\tCREATE_%dD_FLOATS();" % num_coords print "\tGET_BUFFERED%s_POINTER( pc, %d );" % (countSuffix, packet_length) # Bounding box code if isVertexAttrib: print "\tif (pc->updateBBOX && index == 0)" else: print "\tif (pc->updateBBOX)" print "\t{" if num_coords < 4: print "\t\tUPDATE_%dD_BBOX();" % num_coords else: print "\t\tUPDATE_3D_BBOX();" print "\t}" if isVertexAttrib: print "\tif (index > 0) {" t = argtype print "\t\tpc->current.c.vertexAttrib.%s%d[index] = data_ptr + 4;" % ( t, num_coords) print "\t\tpc->current.attribsUsedMask |= (1 << index);" if do_count: print "\t\tpc->current.vtx_count--;" print "\t}" fname = func_name + extSuffix if do_vector: # use non-vector opcode opcode = apiutil.OpcodeName(func_name[:-1] + extSuffix) else: opcode = apiutil.OpcodeName(func_name + extSuffix) counter = 0 if do_vector: if isVertexAttrib: if do_swapped: print "\tWRITE_DATA( 0, GLuint, SWAP32(index) );" else: print "\tWRITE_DATA( 0, GLuint, index );" counter += 4 argname = params[1][0] # skip 'index' parameter else: argname = params[0][0] for index in range(num_coords): print WriteData(counter, vector_type, "%s[%d]" % (argname, index), do_swapped) counter += apiutil.sizeof(vector_type) if isVertexAttrib: if do_vector == 2: # this is a bit of a hack print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name + "ARB") else: print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name[:-1] + "ARB") else: print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name[:-1]) else: for index in range(0, len(params)): (name, type, vecSize) = params[index] print WriteData(counter, type, name, do_swapped) counter += apiutil.sizeof(type) if isVertexAttrib: print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName(func_name + "ARB") else: print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName(func_name) print '}\n'
# HACK HACK if space_index == -1: space_index = 1000000 # HACK HACK if quote_index == -1: quote_index = 1000000 # HACK HACK the_index = min(min(paren_index, space_index), quote_index) print("%sSWAP%s" % (line[:the_index], line[the_index:])) elif line.find("WRITE_DATA_AI") != -1: lparen_index = line.find("(") rparen_index = line.rfind(")") args = list( map(str.strip, line[lparen_index + 1:rparen_index].split(","))) indentation = line[:line.find("WRITE_DATA_AI")] if apiutil.sizeof(args[0]) == 1: print("%sWRITE_DATA_AI(%s, %s);" % (indentation, args[0], args[1])) elif apiutil.sizeof(args[0]) == 2: print("%sWRITE_DATA_AI(%s, SWAP16(%s) );" % (indentation, args[0], args[1])) elif args[0] == 'GLfloat' or args[0] == 'GLclampf': print("%sWRITE_DATA_AI(GLuint, SWAPFLOAT(%s) );" % (indentation, args[0])) elif apiutil.sizeof(args[0]) == 4: print("%sWRITE_DATA_AI(%s, SWAP32(%s));" % (indentation, args[0], args[1])) else: print >> sys.stderr, "UNKNOWN TYPE FOR WRITE_DATA: %s" % args[1] sys.exit(-1) elif line.find("WRITE_DATA") != -1: lparen_index = line.find("(")
space_index = line.find( " ", fun_index ) quote_index = line.find( '"', fun_index ) if paren_index == -1: paren_index = 1000000; # HACK HACK if space_index == -1: space_index = 1000000; # HACK HACK if quote_index == -1: quote_index = 1000000; # HACK HACK the_index = min( min( paren_index, space_index ), quote_index ) print("%sSWAP%s" % (line[:the_index], line[the_index:])) elif line.find("WRITE_DATA_AI") != -1: lparen_index = line.find( "(" ) rparen_index = line.rfind( ")" ) args = list(map( str.strip, line[lparen_index+1:rparen_index].split( "," ) )) indentation = line[:line.find( "WRITE_DATA_AI" )] if apiutil.sizeof(args[0]) == 1: print("%sWRITE_DATA_AI(%s, %s);" % (indentation, args[0], args[1])) elif apiutil.sizeof(args[0]) == 2: print("%sWRITE_DATA_AI(%s, SWAP16(%s) );" % (indentation, args[0], args[1])) elif args[0] == 'GLfloat' or args[0] == 'GLclampf': print("%sWRITE_DATA_AI(GLuint, SWAPFLOAT(%s) );" % (indentation, args[0])) elif apiutil.sizeof(args[0]) == 4: print("%sWRITE_DATA_AI(%s, SWAP32(%s));" % (indentation, args[0], args[1])) else: print >> sys.stderr, "UNKNOWN TYPE FOR WRITE_DATA: %s" % args[1] sys.exit(-1) elif line.find( "WRITE_DATA" ) != -1: lparen_index = line.find( "(" ) rparen_index = line.rfind( ")" ) args = list(map( str.strip, line[lparen_index+1:rparen_index].split( "," ) )) indentation = line[:line.find( "WRITE_DATA" )]
def PrintFunction( func_name, extSuffix, num_coords, argtype, do_swapped, do_count, do_vector ): """ Generate all the functions named crPackVertex[234][dfis][v]BBOX() and crPackVertex[234][dfis][v]BBOX_COUNT(). We also handle glVertexAttrib*ARB. Note: func_name should not have an ARB suffix. """ if do_count: countSuffix = "_COUNT" else: countSuffix = "" if do_swapped: swapSuffix = "SWAP" else: swapSuffix = "" if func_name[0:12] == "VertexAttrib": isVertexAttrib = 1 else: isVertexAttrib = 0 if argtype[0] == "N": normalized = 1 else: normalized = 0; if argtype == "b" or argtype == "Nb": vector_type = "GLbyte" elif argtype == "ub" or argtype == "Nub": vector_type = "GLubyte" elif argtype == "s" or argtype == "Ns": vector_type = "GLshort" elif argtype == "us" or argtype == "Nus": vector_type = "GLushort" elif argtype == "i" or argtype == "Ni": vector_type = "GLint" elif argtype == "ui" or argtype == "Nui": vector_type = "GLuint" elif argtype == "f": vector_type = "GLfloat" elif argtype == "d": vector_type = "GLdouble" else: print "type is %s" % argtype abort() if do_vector: if isVertexAttrib: func_name = 'VertexAttrib%d%sv' % (num_coords, argtype) else: func_name = 'Vertex%d%sv' % (num_coords,argtype) params = apiutil.Parameters(func_name + extSuffix) print 'void PACK_APIENTRY crPack%sBBOX%s%s( %s )' % (func_name + extSuffix, countSuffix, swapSuffix, apiutil.MakeDeclarationString(params)) print '{' if do_vector: # vector version packet_length = num_coords * apiutil.sizeof(vector_type) if isVertexAttrib: packet_length += 4 # for index if packet_length % 4 != 0: packet_length += 2 else: # non-vector packet_length = apiutil.PacketLength( params ) if isVertexAttrib: packet_length += 0 # for index if packet_length % 4 != 0: packet_length += 2 print "\tCR_GET_PACKER_CONTEXT(pc);" print "\tunsigned char *data_ptr;" if normalized: if argtype == "Nb": t = "B" elif argtype == "Ni": t = "I" elif argtype == "Nui": t = "UI" elif argtype == "Nub": t = "UB" elif argtype == "Ns": t = "S" elif argtype == "Nus": t = "US" else: abort() if do_vector: print "\tCREATE_%dD_VFLOATS_%s_NORMALIZED();" % (num_coords, t) else: print "\tCREATE_%dD_FLOATS_%s_NORMALIZED();" % (num_coords, t) else: if do_vector: print "\tCREATE_%dD_VFLOATS();" % num_coords else: print "\tCREATE_%dD_FLOATS();" % num_coords print "\tCR_GET_BUFFERED%s_POINTER( pc, %d );" % (countSuffix, packet_length) # Bounding box code if isVertexAttrib: print "\tif (pc->updateBBOX && index == 0)" else: print "\tif (pc->updateBBOX)" print "\t{" if num_coords < 4: print "\t\tUPDATE_%dD_BBOX();" % num_coords else: print "\t\tUPDATE_3D_BBOX();" print "\t}" if isVertexAttrib: print "\tif (index > 0) {" t = argtype print "\t\tpc->current.c.vertexAttrib.%s%d[index] = data_ptr + 4;" % (t, num_coords) print "\t\tpc->current.attribsUsedMask |= (1 << index);" if do_count: print "\t\tpc->current.vtx_count--;" print "\t}" fname = func_name + extSuffix if do_vector: # use non-vector opcode opcode = apiutil.OpcodeName( func_name[:-1] + extSuffix ) else: opcode = apiutil.OpcodeName( func_name + extSuffix ) counter = 0 if do_vector: if isVertexAttrib: if do_swapped: print "\tWRITE_DATA( 0, GLuint, SWAP32(index) );" else: print "\tWRITE_DATA( 0, GLuint, index );" counter += 4 argname = params[1][0] # skip 'index' parameter else: argname = params[0][0] for index in range(num_coords): print WriteData( counter, vector_type, "%s[%d]" % (argname, index), do_swapped ) counter += apiutil.sizeof(vector_type) if isVertexAttrib: if do_vector == 2: # this is a bit of a hack print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name + "ARB" ) else: print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name[:-1] + "ARB" ) else: print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name[:-1] ) else: for index in range(0,len(params)): (name, type, vecSize) = params[index] print WriteData( counter, type, name, do_swapped ) counter += apiutil.sizeof(type) if isVertexAttrib: print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name + "ARB" ) else: print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name ) print "\tCR_UNLOCK_PACKER_CONTEXT(pc);" print '}\n'
def PrintFunc(func_name, params, is_swapped, can_have_pointers): """Emit a packer function.""" if is_swapped: print('void PACK_APIENTRY crPack%sSWAP(%s)' % (func_name, apiutil.MakeDeclarationStringWithContext( 'CR_PACKER_CONTEXT', params))) else: print('void PACK_APIENTRY crPack%s(%s)' % (func_name, apiutil.MakeDeclarationStringWithContext( 'CR_PACKER_CONTEXT', params))) print('{') print('\tCR_GET_PACKER_CONTEXT(pc);') # Save original function name orig_func_name = func_name # Convert to a non-vector version of the function if possible func_name = apiutil.NonVectorFunction(func_name) if not func_name: func_name = orig_func_name # Check if there are any pointer parameters. # That's usually a problem so we'll emit an error function. nonVecParams = apiutil.Parameters(func_name) bail_out = 0 for (name, type, vecSize) in nonVecParams: if apiutil.IsPointer(type) and vecSize == 0 and not can_have_pointers: bail_out = 1 if bail_out: for (name, type, vecSize) in nonVecParams: print('\t(void)%s;' % (name)) print('\tcrError ( "%s needs to be special cased %d %d!");' % (func_name, vecSize, can_have_pointers)) print('\t(void) pc;') print('}') # XXX we should really abort here return if "extpack" in apiutil.ChromiumProps(func_name): is_extended = 1 else: is_extended = 0 print("\tunsigned char *data_ptr;") print('\t(void) pc;') #if func_name == "Enable" or func_name == "Disable": # print "\tCRASSERT(!pc->buffer.geometry_only); /* sanity check */" for index in range(0, len(params)): (name, type, vecSize) = params[index] if vecSize > 0 and func_name != orig_func_name: print(" if (!%s) {" % name) # Know the reason for this one, so avoid the spam. if orig_func_name != "SecondaryColor3fvEXT": print(" crDebug(\"App passed NULL as %s for %s\");" % (name, orig_func_name)) print(" return;") print(" }") packet_length = apiutil.PacketLength(nonVecParams) if packet_length == 0 and not is_extended: print("\tCR_GET_BUFFERED_POINTER_NO_ARGS(pc);") elif func_name[:9] == "Translate" or func_name[:5] == "Color": # XXX WTF is the purpose of this? if is_extended: packet_length += 8 print("\tCR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH(pc, %d, GL_TRUE);" % packet_length) else: if is_extended: packet_length += 8 print("\tCR_GET_BUFFERED_POINTER(pc, %d);" % packet_length) UpdateCurrentPointer(func_name) if is_extended: counter = 8 print(WriteData(0, 'GLint', packet_length, is_swapped)) print( WriteData(4, 'GLenum', apiutil.ExtendedOpcodeName(func_name), is_swapped)) else: counter = 0 # Now emit the WRITE_() macros for all parameters for index in range(0, len(params)): (name, type, vecSize) = params[index] # if we're converting a vector-valued function to a non-vector func: if vecSize > 0 and func_name != orig_func_name: ptrType = apiutil.PointerType(type) for i in range(0, vecSize): print( WriteData(counter + i * apiutil.sizeof(ptrType), ptrType, "%s[%d]" % (name, i), is_swapped)) # XXX increment counter here? else: print(WriteData(counter, type, name, is_swapped)) if apiutil.IsPointer(type): counter += apiutil.PointerSize() else: counter += apiutil.sizeof(type) # finish up if is_extended: print("\tWRITE_OPCODE(pc, CR_EXTEND_OPCODE);") else: print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName(func_name)) if "get" in apiutil.Properties(func_name): print('\tCR_CMDBLOCK_CHECK_FLUSH(pc);') print('\tCR_UNLOCK_PACKER_CONTEXT(pc);') print('}\n')