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/GuestHost/OpenGL/spu_loader
Files:
5 edited

Legend:

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

    r63199 r63939  
    44# See the file LICENSE.txt for information on redistributing this software.
    55
     6from __future__ import print_function
    67import sys
    78import apiutil
     
    1011apiutil.CopyrightC()
    1112
    12 print """
     13print("""
    1314
    1415/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY dispatch.py SCRIPT */
     
    4344
    4445void __buildDispatch( SPU *spu )
    45 {"""
     46{""")
    4647
    4748keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
    4849for func_name in keys:
    49         print '\tspu->dispatch_table.%s = (%sFunc_t) __findFunc( "%s", spu );' % (func_name,func_name,func_name)
    50 print '}'
     50        print('\tspu->dispatch_table.%s = (%sFunc_t) __findFunc( "%s", spu );' % (func_name,func_name,func_name))
     51print('}')
    5152
    5253
    53 print """
     54print("""
    5455
    5556/*
     
    8081 */
    8182void crSPUInitDispatch( SPUDispatchTable *dispatch, const SPUNamedFunctionTable *table )
    82 {"""
     83{""")
    8384
    8485for func_name in keys:
    85         print '\tdispatch->%s = (%sFunc_t) crSPUFindFunction(table, "%s");' % (func_name, func_name, func_name)
    86 print '}'
     86        print('\tdispatch->%s = (%sFunc_t) crSPUFindFunction(table, "%s");' % (func_name, func_name, func_name))
     87print('}')
    8788
    8889
    8990
    90 print """
     91print("""
    9192/*
    9293 * Generic no-op function
     
    123124        }
    124125}
    125 """
     126""")
  • trunk/src/VBox/GuestHost/OpenGL/spu_loader/dispatchheader.py

    r56473 r63939  
    66# This script generates the spu_dispatch_table.h file from gl_header.parsed
    77
     8from __future__ import print_function
    89import sys, string
    910
     
    1314apiutil.CopyrightC()
    1415
    15 print """
     16print("""
    1617/* DO NOT EDIT - THIS FILE GENERATED BY THE dispatchheader.py SCRIPT */
    1718
     
    2728#include "chromium.h"
    2829#include "state/cr_statetypes.h"
    29 """
     30""")
    3031
    3132keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
    3233
    3334
    34 print '/* Offsets of each function within the dispatch table */'
     35print('/* Offsets of each function within the dispatch table */')
    3536offset = 0
    3637for func_name in keys:
    37         print '#define DISPATCH_OFFSET_%s %d' % (func_name, offset)
     38        print('#define DISPATCH_OFFSET_%s %d' % (func_name, offset))
    3839        offset += 1
    39 print ''
     40print('')
    4041
    41 print '/* Function typedefs */'
     42print('/* Function typedefs */')
    4243for func_name in keys:
    4344        return_type = apiutil.ReturnType(func_name)
    4445        params = apiutil.Parameters(func_name)
    4546
    46         print 'typedef %s (SPU_APIENTRY *%sFunc_t)(%s);' % (return_type, func_name, apiutil.MakePrototypeString(params))
    47 print ''
     47        print('typedef %s (SPU_APIENTRY *%sFunc_t)(%s);' % (return_type, func_name, apiutil.MakePrototypeString(params)))
     48print('')
    4849
    49 print 'struct _copy_list_node;'
    50 print ''
    51 print '/* Prototype for SPU internal state load/unload callbacks. */'
    52 print ''
    53 print 'typedef int (*SPUStateFunc_t)(void *);'
    54 print ''
    55 print '/* The SPU dispatch table */'
    56 print 'typedef struct _spu_dispatch_table {'
     50print('struct _copy_list_node;')
     51print('')
     52print('/* Prototype for SPU internal state load/unload callbacks. */')
     53print('')
     54print('typedef int (*SPUStateFunc_t)(void *);')
     55print('')
     56print('/* The SPU dispatch table */')
     57print('typedef struct _spu_dispatch_table {')
    5758
    5859for func_name in keys:
    59         print "\t%sFunc_t %s; " % ( func_name, func_name )
     60        print("\t%sFunc_t %s; " % ( func_name, func_name ))
    6061
    61 print """
     62print("""
    6263        struct _copy_list_node *copyList;
    6364        struct _spu_dispatch_table *copy_of;
     
    7576
    7677#endif /* CR_SPU_DISPATCH_TABLE_H */
    77 """
     78""")
  • trunk/src/VBox/GuestHost/OpenGL/spu_loader/glloader.py

    r63199 r63939  
    55
    66
     7from __future__ import print_function
    78import sys
    89import apiutil
     
    1314apiutil.CopyrightC()
    1415
    15 print """
     16print("""
    1617/* DO NOT EDIT - THIS FILE GENERATED BY THE glloader.py SCRIPT */
    1718#include "cr_error.h"
     
    212213#endif
    213214}
    214 """
     215""")
    215216
    216217
     
    229230        return_type = apiutil.ReturnType(func_name);
    230231        params = apiutil.Parameters(func_name)
    231         print 'static %s GLLOADER_APIENTRY Nop%s(%s)' % (return_type, func_name, apiutil.MakeDeclarationString(params))
    232         print '{'
     232        print('static %s GLLOADER_APIENTRY Nop%s(%s)' % (return_type, func_name, apiutil.MakeDeclarationString(params)))
     233        print('{')
    233234        for (name, type, vecSize) in params:
    234235                if name != "":
    235                         print '\t(void) %s;' % name
     236                        print('\t(void) %s;' % name)
    236237        if apiutil.ReturnType(func_name) != 'void':
    237                 print '\treturn 0;'
    238         print '}'
    239         print ''
     238                print('\treturn 0;')
     239        print('}')
     240        print('')
    240241
    241242
     
    252253# Generate the crLoadOpenGL() function
    253254#
    254 print """
     255print("""
    255256void
    256257crUnloadOpenGL( void )
     
    281282{
    282283        static const char *coreFunctions[] = {
    283 """
     284""")
    284285
    285286for func_name in keys:
    286287        if not IsExtensionFunc(func_name):
    287                 print '\t\t"gl%s",' % func_name
    288 
    289 print """
     288                print('\t\t"gl%s",' % func_name)
     289
     290print("""
    290291                NULL
    291292        };
     
    338339# endif
    339340#endif
    340 """
     341""")
    341342
    342343useful_wgl_functions = [
     
    459460]
    460461
    461 print '#ifdef WINDOWS'
     462print('#ifdef WINDOWS')
    462463
    463464for fun in useful_wgl_functions:
    464         print '\tinterface->%s = (%sFunc_t) crDLLGetNoError( glDll, "%s" );' % (fun,fun,fun)
    465 
    466 print '#elif defined(DARWIN)'
    467 print '# ifndef VBOX_WITH_COCOA_QT'
     465        print('\tinterface->%s = (%sFunc_t) crDLLGetNoError( glDll, "%s" );' % (fun,fun,fun))
     466
     467print('#elif defined(DARWIN)')
     468print('# ifndef VBOX_WITH_COCOA_QT')
    468469for fun in useful_agl_functions:
    469         print '\tinterface->%s = (%sFunc_t) crDLLGetNoError( aglDll, "%s" );' % (fun,fun,fun)
    470 print '# endif'
     470        print('\tinterface->%s = (%sFunc_t) crDLLGetNoError( aglDll, "%s" );' % (fun,fun,fun))
     471print('# endif')
    471472
    472473for fun in useful_cgl_functions:
    473         print '\tinterface->%s = (%sFunc_t) crDLLGetNoError( cglDll, "%s" );' % (fun, fun,fun)
     474        print('\tinterface->%s = (%sFunc_t) crDLLGetNoError( cglDll, "%s" );' % (fun, fun,fun))
    474475
    475476for fun in in_gl_functions:
    476         print '\tinterface->%s = (%sFunc_t) crDLLGetNoError( glDll, "%s" );' % (fun, fun,fun)
    477 
    478 print '#else'
    479 print '\t/* GLX */'
     477        print('\tinterface->%s = (%sFunc_t) crDLLGetNoError( glDll, "%s" );' % (fun, fun,fun))
     478
     479print('#else')
     480print('\t/* GLX */')
    480481
    481482# XXX merge these loops?
    482483for fun in useful_glx_functions:
    483         print '\tinterface->%s = (%sFunc_t) crDLLGetNoError( glDll, "%s" );' % (fun, fun, fun)
     484        print('\tinterface->%s = (%sFunc_t) crDLLGetNoError( glDll, "%s" );' % (fun, fun, fun))
    484485for fun in possibly_useful_glx_functions:
    485         print '\tinterface->%s = (%sFunc_t) crDLLGetNoError( glDll, "%s" );' % (fun, fun, fun)
    486 print '#endif'
    487 
    488 print """
     486        print('\tinterface->%s = (%sFunc_t) crDLLGetNoError( glDll, "%s" );' % (fun, fun, fun))
     487print('#endif')
     488
     489print("""
    489490        if (!entry)
    490491                return 1; /* token value */
     
    513514{
    514515        struct extfunc {
    515                 const char *funcName;
    516                 const char *aliasName;
    517                 SPUGenericFunction nopFunction;
     516                const char *funcName;""")
     517max_aliases = apiutil.ReverseAliasesMaxCount()
     518for i in range(1, 1 + max_aliases):
     519        print("\t\tconst char *aliasName%d;" % i)
     520print("""               SPUGenericFunction nopFunction;
    518521        };
    519522        static const struct extfunc functions[] = {
    520 """
     523""")
    521524
    522525for func_name in keys:
     
    526529                else:
    527530                        prefix = "gl"
    528                 s = '\t\t{ "' + prefix + func_name + '", '
    529                 a = apiutil.ReverseAlias(func_name)
    530                 if a:
    531                         s += '"' + prefix + a + '", '
    532                 else:
    533                         s += 'NULL, '
    534                 s += '(SPUGenericFunction) Nop' + func_name + ' },'
    535                 print s
    536 
    537 print """
    538                 { NULL, NULL, NULL}
     531                s = '\t\t{ "' + prefix + func_name + '"'
     532                aliases = apiutil.ReverseAliases(func_name)
     533                s += ''.join([', "' + prefix + a + '"' for a in aliases]) + ', NULL' * (max_aliases - len(aliases))
     534                s += ', (SPUGenericFunction) Nop' + func_name + ' },'
     535                print(s)
     536
     537print('\t\t{ NULL%s, NULL}' % (', NULL' * max_aliases))
     538print("""
    539539        };
    540540        const struct extfunc *func;
     
    550550
    551551        for (func = functions; func->funcName; func++) {
    552                 SPUGenericFunction f = findExtFunction(interface, func->funcName);
    553                 if (!f && func->aliasName) {
    554                         f = findExtFunction(interface, func->aliasName);
    555                 }
    556                 if (!f) {
     552                SPUGenericFunction f = findExtFunction(interface, func->funcName);""")
     553for i in range(1, 1 + max_aliases):
     554        print("""               if (!f && func->aliasName%d) {
     555                        f = findExtFunction(interface, func->aliasName%d);
     556                }"""% (i, i))
     557print("""               if (!f) {
    557558                        f = func->nopFunction;
    558559                }
     
    566567        return entry - table;  /* number of entries filled */
    567568}
    568 """
    569 
    570 
    571 print """
     569""")
     570
     571
     572print("""
    572573
    573574#ifdef USE_OSMESA
     
    605606#endif
    606607
    607 """
    608 
     608""")
     609
  • trunk/src/VBox/GuestHost/OpenGL/spu_loader/spuchange.py

    r63199 r63939  
    44# See the file LICENSE.txt for information on redistributing this software.
    55
     6from __future__ import print_function
    67import sys
    78import apiutil
     
    1011apiutil.CopyrightC()
    1112
    12 print """
     13print("""
    1314
    1415/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY spuchange.py SCRIPT */
     
    2930        }
    3031        table->mark = 1;
    31 """
     32""")
    3233
    3334keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
    3435for func_name in keys:
    35         print '\tif ((uintptr_t)table->%s == (uintptr_t)orig_func)' % func_name
    36         print '\t{'
    37         print '\t\ttable->%s = (%sFunc_t)(uintptr_t)new_func;' % (func_name, func_name)
    38         print '\t\tfor (temp = table->copyList ; temp ; temp = temp->next)'
    39         print '\t\t{'
    40         print '\t\t\tcrSPUChangeInterface( temp->copy, orig_func, new_func );'
    41         print '\t\t}'
    42         print '\t}'
     36        print('\tif ((uintptr_t)table->%s == (uintptr_t)orig_func)' % func_name)
     37        print('\t{')
     38        print('\t\ttable->%s = (%sFunc_t)(uintptr_t)new_func;' % (func_name, func_name))
     39        print('\t\tfor (temp = table->copyList ; temp ; temp = temp->next)')
     40        print('\t\t{')
     41        print('\t\t\tcrSPUChangeInterface( temp->copy, orig_func, new_func );')
     42        print('\t\t}')
     43        print('\t}')
    4344
    44 print """
     45print("""
    4546        if (table->copy_of != NULL)
    4647        {
     
    5253        }
    5354        table->mark = 0;
    54 """
    55 print '}'
     55""")
     56print('}')
    5657
    57 print """
     58print("""
    5859void crSPUChangeDispatch(SPUDispatchTable *dispatch, const SPUNamedFunctionTable *newtable)
    5960{
    6061    SPUGenericFunction func;
    61 """
     62""")
    6263keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
    6364for func_name in keys:
    64     print '\tfunc = crSPUFindFunction(newtable, "%s");' % func_name
    65     print '\tif (func && ((SPUGenericFunction)dispatch->%s!=func))' % func_name
    66     print '\t{'
    67     print '\t\tcrDebug("%%s changed from %%p to %%p", "gl%s", (void *)(uintptr_t)dispatch->%s, (void *)(uintptr_t)func);' % (func_name, func_name)
    68     print '\t\tcrSPUChangeInterface(dispatch, (void *)(uintptr_t)dispatch->%s, (void *)(uintptr_t)func);' % func_name
    69     print '\t}\n'
    70 print """
     65    print('\tfunc = crSPUFindFunction(newtable, "%s");' % func_name)
     66    print('\tif (func && ((SPUGenericFunction)dispatch->%s!=func))' % func_name)
     67    print('\t{')
     68    print('\t\tcrDebug("%%s changed from %%p to %%p", "gl%s", (void *)(uintptr_t)dispatch->%s, (void *)(uintptr_t)func);' % (func_name, func_name))
     69    print('\t\tcrSPUChangeInterface(dispatch, (void *)(uintptr_t)dispatch->%s, (void *)(uintptr_t)func);' % func_name)
     70    print('\t}\n')
     71print("""
    7172}
    72 """
     73""")
  • trunk/src/VBox/GuestHost/OpenGL/spu_loader/spucopy.py

    r15532 r63939  
    44# See the file LICENSE.txt for information on redistributing this software.
    55
     6from __future__ import print_function
    67import sys
    78import apiutil
     
    1011apiutil.CopyrightC()
    1112
    12 print """
     13print("""
    1314
    1415/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY spucopy.py SCRIPT */
     
    1920void crSPUCopyDispatchTable( SPUDispatchTable *dst, SPUDispatchTable *src )
    2021{
    21 """
     22""")
    2223
    2324keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
    2425for func_name in keys:
    25         print '\tdst->%s = src->%s;' % (func_name, func_name)
     26        print('\tdst->%s = src->%s;' % (func_name, func_name))
    2627
    2728# if the destination is already a copy of something, we'd better make sure
    2829# that we take it off its source's copy list first.
    2930
    30 print """
     31print("""
    3132        if (dst->copy_of != NULL)
    3233        {
     
    7778        }
    7879}
    79 """
     80""")
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