VirtualBox

Ignore:
Timestamp:
Sep 22, 2016 7:58:05 AM (8 years ago)
Author:
vboxsync
Message:

Build/scripts (bugref:6627): Python build scripts updated to generate the same code when used with Python 2 and 3.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/OpenGL/packer/packer.py

    r52451 r63939  
    66# This script generates the packer.c file from the gl_header.parsed file.
    77
     8from __future__ import print_function
    89import sys, string, re
    910
     
    4647        name = '%s%s' % (k[:1].lower(),k[1:])
    4748        type = m.group(3) + m.group(2)
    48         print "\tpc->current.c.%s.%s = data_ptr;" % (name,type)
     49        print("\tpc->current.c.%s.%s = data_ptr;" % (name,type))
    4950        return
    5051
     
    5455        name = 'secondaryColor'
    5556        type = m.group(3) + m.group(2)
    56         print "\tpc->current.c.%s.%s = data_ptr;" % (name,type)
     57        print("\tpc->current.c.%s.%s = data_ptr;" % (name,type))
    5758        return
    5859
     
    6263        name = 'texCoord'
    6364        type = m.group(3) + m.group(2)
    64         print "\tpc->current.c.%s.%s[0] = data_ptr;" % (name,type)
     65        print("\tpc->current.c.%s.%s[0] = data_ptr;" % (name,type))
    6566        return
    6667
     
    7071        name = 'texCoord'
    7172        type = m.group(3) + m.group(2)
    72         print "\tpc->current.c.%s.%s[texture-GL_TEXTURE0_ARB] = data_ptr + 4;" % (name,type)
     73        print("\tpc->current.c.%s.%s[texture-GL_TEXTURE0_ARB] = data_ptr + 4;" % (name,type))
    7374        return
    7475
     
    7879        name = 'index'
    7980        type = m.group(2) + "1"
    80         print "\tpc->current.c.%s.%s = data_ptr;" % (name,type)
     81        print("\tpc->current.c.%s.%s = data_ptr;" % (name,type))
    8182        return
    8283
     
    8687        name = 'edgeFlag'
    8788        type = "l1"
    88         print "\tpc->current.c.%s.%s = data_ptr;" % (name,type)
     89        print("\tpc->current.c.%s.%s = data_ptr;" % (name,type))
    8990        return
    9091
     
    9495        name = 'fogCoord'
    9596        type = m.group(2) + "1"
    96         print "\tpc->current.c.%s.%s = data_ptr;" % (name,type)
     97        print("\tpc->current.c.%s.%s = data_ptr;" % (name,type))
    9798        return
    9899
     
    104105        type = m.group(3) + m.group(2)
    105106        # Add 12 to skip the packet length, opcode and index fields
    106         print "\tpc->current.c.%s.%s[index] = data_ptr + 4;" % (name,type)
     107        print("\tpc->current.c.%s.%s[index] = data_ptr + 4;" % (name,type))
    107108        if m.group(4) == "ARB" or m.group(4) == "NV":
    108             print "\tpc->current.attribsUsedMask |= (1 << index);"
    109             print "\tpc->current.changedVertexAttrib |= (1 << index);"
     109            print("\tpc->current.attribsUsedMask |= (1 << index);")
     110            print("\tpc->current.changedVertexAttrib |= (1 << index);")
    110111        return
    111112
     
    115116    """Emit a packer function."""
    116117    if is_swapped:
    117         print 'void PACK_APIENTRY crPack%sSWAP( %s )' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', params))
    118     else:
    119         print 'void PACK_APIENTRY crPack%s( %s )' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', params))
    120     print '{'
    121     print '\tCR_GET_PACKER_CONTEXT(pc);'
     118        print('void PACK_APIENTRY crPack%sSWAP( %s )' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', params)))
     119    else:
     120        print('void PACK_APIENTRY crPack%s( %s )' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', params)))
     121    print('{')
     122    print('\tCR_GET_PACKER_CONTEXT(pc);')
    122123
    123124    # Save original function name
     
    138139    if bail_out:
    139140        for (name, type, vecSize) in nonVecParams:
    140             print '\t(void)%s;' % (name)
    141         print '\tcrError ( "%s needs to be special cased %d %d!");' % (func_name, vecSize, can_have_pointers)
    142         print '\t(void) pc;'
    143         print '}'
     141            print('\t(void)%s;' % (name))
     142        print('\tcrError ( "%s needs to be special cased %d %d!");' % (func_name, vecSize, can_have_pointers))
     143        print('\t(void) pc;')
     144        print('}')
    144145        # XXX we should really abort here
    145146        return
     
    151152
    152153
    153     print "\tunsigned char *data_ptr;"
    154     print '\t(void) pc;'
     154    print("\tunsigned char *data_ptr;")
     155    print('\t(void) pc;')
    155156    #if func_name == "Enable" or func_name == "Disable":
    156157    #   print "\tCRASSERT(!pc->buffer.geometry_only); /* sanity check */"
     
    159160        (name, type, vecSize) = params[index]
    160161        if vecSize>0 and func_name!=orig_func_name:
    161             print "    if (!%s) {" % name
     162            print("    if (!%s) {" % name)
    162163            # Know the reason for this one, so avoid the spam.
    163164            if orig_func_name != "SecondaryColor3fvEXT":
    164                 print "        crDebug(\"App passed NULL as %s for %s\");" % (name, orig_func_name)
    165             print "        return;"
    166             print "    }"
     165                print("        crDebug(\"App passed NULL as %s for %s\");" % (name, orig_func_name))
     166            print("        return;")
     167            print("    }")
    167168
    168169    packet_length = apiutil.PacketLength(nonVecParams)
    169170
    170171    if packet_length == 0 and not is_extended:
    171         print "\tCR_GET_BUFFERED_POINTER_NO_ARGS( pc );"
     172        print("\tCR_GET_BUFFERED_POINTER_NO_ARGS( pc );")
    172173    elif func_name[:9] == "Translate" or func_name[:5] == "Color":
    173174        # XXX WTF is the purpose of this?
    174175        if is_extended:
    175176            packet_length += 8
    176         print "\tCR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH( pc, %d, GL_TRUE );" % packet_length
     177        print("\tCR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH( pc, %d, GL_TRUE );" % packet_length)
    177178    else:
    178179        if is_extended:
    179180            packet_length += 8
    180         print "\tCR_GET_BUFFERED_POINTER( pc, %d );" % packet_length
     181        print("\tCR_GET_BUFFERED_POINTER( pc, %d );" % packet_length)
    181182    UpdateCurrentPointer( func_name )
    182183
    183184    if is_extended:
    184185        counter = 8
    185         print WriteData( 0, 'GLint', packet_length, is_swapped )
    186         print WriteData( 4, 'GLenum', apiutil.ExtendedOpcodeName( func_name ), is_swapped )
     186        print(WriteData( 0, 'GLint', packet_length, is_swapped ))
     187        print(WriteData( 4, 'GLenum', apiutil.ExtendedOpcodeName( func_name ), is_swapped ))
    187188    else:
    188189        counter = 0
     
    195196            ptrType = apiutil.PointerType(type)
    196197            for i in range(0, vecSize):
    197                 print WriteData( counter + i * apiutil.sizeof(ptrType),
    198                                  ptrType, "%s[%d]" % (name, i), is_swapped )
     198                print(WriteData( counter + i * apiutil.sizeof(ptrType),
     199                                 ptrType, "%s[%d]" % (name, i), is_swapped ))
    199200            # XXX increment counter here?
    200201        else:
    201             print WriteData( counter, type, name, is_swapped )
     202            print(WriteData( counter, type, name, is_swapped ))
    202203            if apiutil.IsPointer(type):
    203204                counter += apiutil.PointerSize()
     
    207208    # finish up
    208209    if is_extended:
    209         print "\tWRITE_OPCODE( pc, CR_EXTEND_OPCODE );"
    210     else:
    211         print "\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name )
     210        print("\tWRITE_OPCODE( pc, CR_EXTEND_OPCODE );")
     211    else:
     212        print("\tWRITE_OPCODE( pc, %s );" % apiutil.OpcodeName( func_name ))
    212213
    213214    if "get" in apiutil.Properties(func_name):
    214         print '\tCR_CMDBLOCK_CHECK_FLUSH(pc);'
    215 
    216     print '\tCR_UNLOCK_PACKER_CONTEXT(pc);'
    217     print '}\n'
     215        print('\tCR_CMDBLOCK_CHECK_FLUSH(pc);')
     216
     217    print('\tCR_UNLOCK_PACKER_CONTEXT(pc);')
     218    print('}\n')
    218219
    219220
     
    223224apiutil.CopyrightC()
    224225
    225 print """
     226print("""
    226227/* DO NOT EDIT - THIS FILE GENERATED BY THE packer.py SCRIPT */
    227228
     
    233234#include "cr_opcodes.h"
    234235
    235 """
     236""")
    236237
    237238
     
    252253    if return_type != 'void':
    253254        # Yet another gross hack for glGetString
    254         if string.find( return_type, '*' ) == -1:
     255        if return_type.find('*') == -1:
    255256            return_type = return_type + " *"
    256257        params.append(("return_value", return_type, 0))
     
    264265
    265266    if not func_name in r0_funcs:
    266         print '#ifndef IN_RING0'
     267        print('#ifndef IN_RING0')
    267268       
    268269    PrintFunc( func_name, params, 0, pointers_ok )
     
    270271   
    271272    if not func_name in r0_funcs:
    272         print '#endif'
     273        print('#endif')
    273274   
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette