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.

Location:
trunk/src/VBox/HostServices/SharedOpenGL/unpacker
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack.py

    r52570 r63939  
    44# See the file LICENSE.txt for information on redistributing this software.
    55
     6from __future__ import print_function
    67import sys
    78
     
    1112apiutil.CopyrightC()
    1213
    13 print """/* DO NOT EDIT!  THIS CODE IS AUTOGENERATED BY unpack.py */
     14print("""/* DO NOT EDIT!  THIS CODE IS AUTOGENERATED BY unpack.py */
    1415
    1516#include "unpacker.h"
     
    4041static GLenum g_VBoxDbgCrPrevExtendOpcode = 0;
    4142#endif
    42 """
     43""")
    4344
    4445nodebug_opcodes = [
     
    8182    arg_len = apiutil.PacketLength( params )
    8283    if (return_type != 'void'):
    83         print '\tSET_RETURN_PTR( %d );' % (arg_len + 8) # extended opcode plus packet length
     84        print('\tSET_RETURN_PTR( %d );' % (arg_len + 8)) # extended opcode plus packet length
    8485    else:
    8586        paramList = [ ('foo', 'void *', 0) ]
    86         print '\tSET_RETURN_PTR( %d );' % (arg_len + 8 - apiutil.PacketLength(paramList))
     87        print('\tSET_RETURN_PTR( %d );' % (arg_len + 8 - apiutil.PacketLength(paramList)))
    8788
    8889
     
    9495        arg_len += apiutil.PacketLength( paramList )
    9596
    96     print '\tSET_WRITEBACK_PTR( %d );' % (arg_len + 8) # extended opcode plus packet length
     97    print('\tSET_WRITEBACK_PTR( %d );' % (arg_len + 8)) # extended opcode plus packet length
    9798
    9899
     
    107108            copy_of_params[i] = (copy_of_params[i][0], 'void', 0)
    108109            if not "get" in apiutil.Properties(func_name):
    109                 print '\tcrError( "%s needs to be special cased!" );' % func_name
     110                print('\tcrError( "%s needs to be special cased!" );' % func_name)
    110111        else:
    111             print "\t%s %s = %s;" % ( copy_of_params[i][1], name, ReadData( counter, copy_of_params[i][1] ) )
     112            print("\t%s %s = %s;" % ( copy_of_params[i][1], name, ReadData( counter, copy_of_params[i][1] ) ))
    112113        counter += apiutil.sizeof(copy_of_params[i][1])
    113114
     
    117118
    118119    if return_type != "void":
    119         print "\t(void)",
    120     else:
    121         print "\t",
    122     print "cr_unpackDispatch.%s( %s );" % (func_name, apiutil.MakeCallString(params))
     120        print("\t(void)", end=" ")
     121    else:
     122        print("\t", end="")
     123    print("cr_unpackDispatch.%s( %s );" % (func_name, apiutil.MakeCallString(params)))
    123124
    124125
     
    131132
    132133    if arg_type == "GLdouble" or arg_type == "GLclampd":
    133         print "#ifdef CR_UNALIGNED_ACCESS_OKAY"
    134         print "\tcr_unpackDispatch.%s((%s) cr_unpackData);" % (vec_func, vecType)
    135         print "#else"
     134        print("#ifdef CR_UNALIGNED_ACCESS_OKAY")
     135        print("\tcr_unpackDispatch.%s((%s) cr_unpackData);" % (vec_func, vecType))
     136        print("#else")
    136137        for index in range(0, vecSize):
    137             print "\tGLdouble v" + `index` + " = READ_DOUBLE(", `index * 8`, ");"
     138            print("\tGLdouble v" + repr(index) + " = READ_DOUBLE(", repr(index * 8), ");")
    138139        if return_type != "void":
    139             print "\t(void) cr_unpackDispatch.%s(" % func_name,
     140            print("\t(void) cr_unpackDispatch.%s(" % func_name, end=" ")
    140141        else:
    141             print "\tcr_unpackDispatch.%s(" % func_name,
     142            print("\tcr_unpackDispatch.%s(" % func_name, end=" ")
    142143        for index in range(0, vecSize):
    143             print "v" + `index`,
     144            print("v" + repr(index), end=" ")
    144145            if index != vecSize - 1:
    145                 print ",",
    146         print ");"
    147         print "#endif"
    148     else:
    149         print "\tcr_unpackDispatch.%s((%s) cr_unpackData);" % (vec_func, vecType)
     146                print(",", end=" ")
     147        print(");")
     148        print("#endif")
     149    else:
     150        print("\tcr_unpackDispatch.%s((%s) cr_unpackData);" % (vec_func, vecType))
    150151
    151152
     
    165166    return_type = apiutil.ReturnType(func_name)
    166167   
    167     print "static void crUnpack%s(void)" % func_name
    168     print "{"
     168    print("static void crUnpack%s(void)" % func_name)
     169    print("{")
    169170
    170171    vector_func = apiutil.VectorFunction(func_name)
     
    175176    packet_length = apiutil.PacketLength( params )
    176177    if packet_length == 0:
    177         print "\tINCR_DATA_PTR_NO_ARGS( );"
    178     else:
    179         print "\tINCR_DATA_PTR( %d );" % packet_length
    180     print "}\n"
     178        print("\tINCR_DATA_PTR_NO_ARGS( );")
     179    else:
     180        print("\tINCR_DATA_PTR( %d );" % packet_length)
     181    print("}\n")
    181182
    182183
     
    184185# Emit some code
    185186#
    186 print """
     187print("""
    187188typedef struct __dispatchNode {
    188189    const unsigned char *unpackData;
     
    268269#endif
    269270        switch( *unpack_opcodes )
    270         {"""
     271        {""")
    271272
    272273#
     
    275276for func_name in keys:
    276277    if "pack" in apiutil.ChromiumProps(func_name):
    277         print '\t\t\tcase %s:' % apiutil.OpcodeName( func_name )
     278        print('\t\t\tcase %s:' % apiutil.OpcodeName( func_name ))
    278279        if not apiutil.OpcodeName(func_name) in nodebug_opcodes:
    279             print """
     280            print("""
    280281#ifdef CR_UNPACK_DEBUG_LAST_OPCODES
    281282                if (i==(num_opcodes-1))
     
    283284#if defined(CR_UNPACK_DEBUG_OPCODES) || defined(CR_UNPACK_DEBUG_LAST_OPCODES)
    284285                crDebug("Unpack: %s");
    285 #endif """ % apiutil.OpcodeName(func_name)
    286         print '\t\t\t\tcrUnpack%s(); \n\t\t\t\tbreak;' % func_name
    287 
    288 print """       
     286#endif """ % apiutil.OpcodeName(func_name))
     287        print('\t\t\t\tcrUnpack%s(); \n\t\t\t\tbreak;' % func_name)
     288
     289print("""       
    289290            case CR_EXTEND_OPCODE:
    290291                #ifdef CR_UNPACK_DEBUG_OPCODES
     
    314315        unpack_opcodes--;
    315316    }
    316 }"""
     317}""")
    317318
    318319
     
    325326            return_type = apiutil.ReturnType(func_name)
    326327            params = apiutil.Parameters(func_name)
    327             print 'static void crUnpackExtend%s(void)' % func_name
    328             print '{'
     328            print('static void crUnpackExtend%s(void)' % func_name)
     329            print('{')
    329330            MakeNormalCall( return_type, func_name, params, 8 )
    330             print '}\n'
    331 
    332 print 'static void crUnpackExtend(void)'
    333 print '{'
    334 print '\tGLenum extend_opcode = %s;' % ReadData( 4, 'GLenum' );
    335 print ''
    336 print '#ifdef CR_UNPACK_DEBUG_PREV_OPCODES'
    337 print '\tg_VBoxDbgCrPrevExtendOpcode = extend_opcode;'
    338 print '#endif'
    339 print ''
    340 print '\t/*crDebug(\"Unpacking extended opcode \%d", extend_opcode);*/'
    341 print '\tswitch( extend_opcode )'
    342 print '\t{'
     331            print('}\n')
     332
     333print('static void crUnpackExtend(void)')
     334print('{')
     335print('\tGLenum extend_opcode = %s;' % ReadData( 4, 'GLenum' ))
     336print('')
     337print('#ifdef CR_UNPACK_DEBUG_PREV_OPCODES')
     338print('\tg_VBoxDbgCrPrevExtendOpcode = extend_opcode;')
     339print('#endif')
     340print('')
     341print('\t/*crDebug(\"Unpacking extended opcode \%d", extend_opcode);*/')
     342print('\tswitch( extend_opcode )')
     343print('\t{')
    343344
    344345
     
    348349for func_name in keys:
    349350    if "extpack" in apiutil.ChromiumProps(func_name):
    350         print '\t\tcase %s:' % apiutil.ExtendedOpcodeName( func_name )
    351 #        print '\t\t\t\tcrDebug("Unpack: %s");' % apiutil.ExtendedOpcodeName( func_name )
    352         print '\t\t\tcrUnpackExtend%s( );' % func_name
    353         print '\t\t\tbreak;'
    354 
    355 print """       default:
     351        print('\t\tcase %s:' % apiutil.ExtendedOpcodeName( func_name ))
     352#        print('\t\t\t\tcrDebug("Unpack: %s");' % apiutil.ExtendedOpcodeName( func_name )))
     353        print('\t\t\tcrUnpackExtend%s( );' % func_name)
     354        print('\t\t\tbreak;')
     355
     356print("""       default:
    356357            crError( "Unknown extended opcode: %d", (int) extend_opcode );
    357358            break;
    358359    }
    359360    INCR_VAR_PTR();
    360 }"""
    361 
    362 print 'static void crUnpackExtendDbg(void)'
    363 print '{'
    364 print '\tGLenum extend_opcode = %s;' % ReadData( 4, 'GLenum' );
    365 print ''
    366 print '#ifdef CR_UNPACK_DEBUG_PREV_OPCODES'
    367 print '\tg_VBoxDbgCrPrevExtendOpcode = extend_opcode;'
    368 print '#endif'
    369 print ''
    370 print '\t/*crDebug(\"Unpacking extended opcode \%d", extend_opcode);*/'
    371 print '\tswitch( extend_opcode )'
    372 print '\t{'
     361}""")
     362
     363print('static void crUnpackExtendDbg(void)')
     364print('{')
     365print('\tGLenum extend_opcode = %s;' % ReadData( 4, 'GLenum' ))
     366print('')
     367print('#ifdef CR_UNPACK_DEBUG_PREV_OPCODES')
     368print('\tg_VBoxDbgCrPrevExtendOpcode = extend_opcode;')
     369print('#endif')
     370print('')
     371print('\t/*crDebug(\"Unpacking extended opcode \%d", extend_opcode);*/')
     372print('\tswitch( extend_opcode )')
     373print('\t{')
    373374
    374375
     
    378379for func_name in keys:
    379380    if "extpack" in apiutil.ChromiumProps(func_name):
    380         print '\t\tcase %s:' % apiutil.ExtendedOpcodeName( func_name )
     381        print('\t\tcase %s:' % apiutil.ExtendedOpcodeName( func_name ))
    381382        if not apiutil.ExtendedOpcodeName(func_name) in nodebug_extopcodes:
    382             print '\t\t\tcrDebug("Unpack: %s");' % apiutil.ExtendedOpcodeName( func_name )
    383         print '\t\t\tcrUnpackExtend%s( );' % func_name
    384         print '\t\t\tbreak;'
    385 
    386 print """       default:
     383            print('\t\t\tcrDebug("Unpack: %s");' % apiutil.ExtendedOpcodeName( func_name ))
     384        print('\t\t\tcrUnpackExtend%s( );' % func_name)
     385        print('\t\t\tbreak;')
     386
     387print("""       default:
    387388            crError( "Unknown extended opcode: %d", (int) extend_opcode );
    388389            break;
    389390    }
    390391    INCR_VAR_PTR();
    391 }"""
     392}""")
  • trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_extend.py

    r15532 r63939  
    44# See the file LICENSE.txt for information on redistributing this software.
    55
     6from __future__ import print_function
    67import sys
    78
     
    1213apiutil.CopyrightC()
    1314
    14 print """/* DO NOT EDIT!  THIS CODE IS AUTOGENERATED BY unpack_extend.py */
     15print("""/* DO NOT EDIT!  THIS CODE IS AUTOGENERATED BY unpack_extend.py */
    1516
    1617#ifndef UNPACK_EXTEND_H
    1718#define UNPACK_EXTEND_H 1
    1819
    19 """
     20""")
    2021
    2122
     
    2526for func_name in apiutil.AllSpecials( "unpacker" ):
    2627        if "extpack" in apiutil.ChromiumProps(func_name):
    27                 print 'extern void crUnpackExtend%s(void);' % func_name
     28                print('extern void crUnpackExtend%s(void);' % func_name)
    2829        else:
    29                 print 'extern void crUnpack%s(void);' % func_name
     30                print('extern void crUnpack%s(void);' % func_name)
    3031
    31 print """
     32print("""
    3233#endif
    33 """
     34""")
    3435
    3536
  • trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_header.py

    r15532 r63939  
    44# See the file LICENSE.txt for information on redistributing this software.
    55
     6from __future__ import print_function
    67import sys;
    7 import cPickle;
     8import pickle;
    89import types;
    910import string;
     
    1516
    1617parsed_file = open( "../glapi_parser/gl_header.parsed", "rb" )
    17 gl_mapping = cPickle.load( parsed_file )
     18gl_mapping = pickle.load( parsed_file )
    1819
    1920stub_common.CopyrightC()
    2021
    21 print """#ifndef CR_UNPACKFUNCTIONS_H
     22print("""#ifndef CR_UNPACKFUNCTIONS_H
    2223#define CR_UNPACKFUNCTIONS_H
    23 """
     24""")
    2425
    25 keys = gl_mapping.keys()
    26 keys.sort()
    27 
    28 for func_name in keys:
     26for func_name in sorted(gl_mapping.keys()):
    2927        ( return_type, arg_names, arg_types ) = gl_mapping[func_name]
    30         print 'void crUnpack%s();' %( func_name )
    31 print 'void crUnpackExtend();'
    32 print '\n#endif /* CR_UNPACKFUNCTIONS_H */'
     28        print('void crUnpack%s();' %( func_name ))
     29print('void crUnpackExtend();')
     30print('\n#endif /* CR_UNPACKFUNCTIONS_H */')
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