VirtualBox

Ignore:
Timestamp:
Sep 22, 2016 7:58:05 AM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
110825
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/state_tracker
Files:
8 edited

Legend:

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

    r15532 r63939  
    44# See the file LICENSE.txt for information on redistributing this software.
    55
     6from __future__ import print_function
    67import sys
    78
     
    1718apiutil.CopyrightC()
    1819
    19 print '''
     20print('''
    2021#include "state/cr_statetypes.h"
    2122
     
    2829    return d;
    2930}
    30 '''
     31''')
    3132
    32 for k in gltypes.keys():
     33for k in sorted(gltypes.keys()):
    3334        for i in range(1,5):
    34                 print 'static void __convert_%s%d (GLfloat *dst, const %s *src) {' % (k,i,gltypes[k]['type'])
     35                print('static void __convert_%s%d (GLfloat *dst, const %s *src) {' % (k,i,gltypes[k]['type']))
    3536                if k == 'd':
    3637                  for j in range(i-1):
    37                     print '\t*dst++ = (GLfloat) __read_double(src++);'
    38                   print '\t*dst = (GLfloat) __read_double(src);'
     38                    print('\t*dst++ = (GLfloat) __read_double(src++);')
     39                  print('\t*dst = (GLfloat) __read_double(src);')
    3940                else:
    4041                  for j in range(i-1):
    41                     print '\t*dst++ = (GLfloat) *src++;';
    42                   print '\t*dst = (GLfloat) *src;';
    43                 print '}\n';
     42                    print('\t*dst++ = (GLfloat) *src++;')
     43                  print('\t*dst = (GLfloat) *src;')
     44                print('}\n')
    4445
    4546scale = {
     
    5455}
    5556
    56 for k in gltypes.keys():
     57for k in sorted(gltypes.keys()):
    5758        if k != 'f' and k != 'd' and k != 'l':
    5859                if k[0:1] == "N":
     
    6162                        k2 = k
    6263                for i in range(1,5):
    63                         print 'static void __convert_rescale_%s%d (GLfloat *dst, const %s *src) {' % (k,i,gltypes[k2]['type'])
     64                        print('static void __convert_rescale_%s%d (GLfloat *dst, const %s *src) {' % (k,i,gltypes[k2]['type']))
    6465                        for j in range(i-1):
    65                                 print '\t*dst++ = ((GLfloat) *src++) / %s;' % scale[k2]
    66                         print '\t*dst = ((GLfloat) *src) / %s;' % scale[k2]
    67                         print '}\n'
     66                                print('\t*dst++ = ((GLfloat) *src++) / %s;' % scale[k2])
     67                        print('\t*dst = ((GLfloat) *src) / %s;' % scale[k2])
     68                        print('}\n')
    6869
    69 print '''
     70print('''
    7071
    7172static void __convert_boolean (GLboolean *dst, const GLboolean *src) {
    7273        *dst = *src;
    7374}
    74 '''
     75''')
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/dump_gen.py

    r50041 r63939  
     1from __future__ import print_function
    12import sys
    23
     
    3435apiutil.CopyrightC()
    3536
    36 print """#include "cr_blitter.h"
     37print("""#include "cr_blitter.h"
    3738#include "cr_spu.h"
    3839#include "chromium.h"
     
    5253
    5354#ifdef VBOX_WITH_CRDUMPER
    54 """
     55""")
    5556
    5657from get_sizes import *;
     
    6970#            print "//%s" % prop
    7071#
    71 print """
     72print("""
    7273static void crRecDumpPrintVal(CR_DUMPER *pDumper, struct nv_struct *pDesc, float *pfData)
    7374{
     
    9495{
    9596    GLboolean fEnabled;
    96 """
    97 keys = params.keys()
    98 keys.sort();
    99 
    100 for pname in keys:
    101     print "\tfEnabled = pRec->pDispatch->IsEnabled(%s);" % pname
    102     print "\tcrDmpStrF(pRec->pDumper, \"%s = %%d;\", fEnabled);" % pname
    103 
    104 keys = extended_params.keys();
    105 keys.sort()
    106 
    107 for pname in keys:
     97""")
     98for pname in sorted(params.keys()):
     99    print("\tfEnabled = pRec->pDispatch->IsEnabled(%s);" % pname)
     100    print("\tcrDmpStrF(pRec->pDumper, \"%s = %%d;\", fEnabled);" % pname)
     101
     102for pname in sorted(extended_params.keys()):
    108103    (srctype,ifdef,fields) = extended_params[pname]
    109104    ext = ifdef[3:]  # the extension name with the "GL_" prefix removed
    110105    ext = ifdef
    111     print '#ifdef CR_%s' % ext
    112     print "\tfEnabled = pRec->pDispatch->IsEnabled(%s);" % pname
    113     print "\tcrDmpStrF(pRec->pDumper, \"%s = %%d;\", fEnabled);" % pname
    114     print '#endif /* CR_%s */' % ext
     106    print('#ifdef CR_%s' % ext)
     107    print("\tfEnabled = pRec->pDispatch->IsEnabled(%s);" % pname)
     108    print("\tcrDmpStrF(pRec->pDumper, \"%s = %%d;\", fEnabled);" % pname)
     109    print('#endif /* CR_%s */' % ext)
    115110
    116111#print "//missing enable props:"
     
    124119#            print "//%s" % prop
    125120#
    126 print """
     121print("""
    127122}
    128123#endif
    129 """
     124""")
    130125
    131126texenv_mappings = {
     
    184179]
    185180
    186 print """
     181print("""
    187182void crRecDumpTexParam(CR_RECORDER *pRec, CRContext *ctx, GLenum enmTarget)
    188183{
     
    191186    unsigned int cComponents;
    192187    crDmpStrF(pRec->pDumper, "==TEX_PARAM for target(0x%x)==", enmTarget);
    193 """
     188""")
    194189for pname in texparam_names:
    195     print "\tcComponents = crStateHlpComponentsCount(%s);" % pname
    196     print "\tAssert(cComponents <= RT_ELEMENTS(afBuf));"
    197     print "\tmemset(afBuf, 0, sizeof (afBuf));"
    198     print "\tpRec->pDispatch->GetTexParameterfv(enmTarget, %s, afBuf);" % pname
    199     print "\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);"
    200     print "\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname
    201 print """
     190    print("\tcComponents = crStateHlpComponentsCount(%s);" % pname)
     191    print("\tAssert(cComponents <= RT_ELEMENTS(afBuf));")
     192    print("\tmemset(afBuf, 0, sizeof (afBuf));")
     193    print("\tpRec->pDispatch->GetTexParameterfv(enmTarget, %s, afBuf);" % pname)
     194    print("\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);")
     195    print("\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname)
     196print("""
    202197    crDmpStrF(pRec->pDumper, "==Done TEX_PARAM for target(0x%x)==", enmTarget);
    203198}
    204 """
    205 
    206 print """
     199""")
     200
     201print("""
    207202void crRecDumpTexEnv(CR_RECORDER *pRec, CRContext *ctx)
    208203{
     
    211206    unsigned int cComponents;
    212207    crDmpStrF(pRec->pDumper, "==TEX_ENV==");
    213 """
    214 
    215 keys = texenv_mappings.keys()
    216 keys.sort();
    217 
    218 for target in keys:
    219     print "\tcrDmpStrF(pRec->pDumper, \"===%s===\");" % target
     208""")
     209
     210for target in sorted(texenv_mappings.keys()):
     211    print("\tcrDmpStrF(pRec->pDumper, \"===%s===\");" % target)
    220212    values = texenv_mappings[target]
    221213    for pname in values:
    222         print "\tcComponents = crStateHlpComponentsCount(%s);" % pname
    223         print "\tAssert(cComponents <= RT_ELEMENTS(afBuf));"
    224         print "\tmemset(afBuf, 0, sizeof (afBuf));"
    225         print "\tpRec->pDispatch->GetTexEnvfv(%s, %s, afBuf);" % (target, pname)
    226         print "\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);"
    227         print "\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname
    228     print "\tcrDmpStrF(pRec->pDumper, \"===Done %s===\");" % target
    229 print """
     214        print("\tcComponents = crStateHlpComponentsCount(%s);" % pname)
     215        print("\tAssert(cComponents <= RT_ELEMENTS(afBuf));")
     216        print("\tmemset(afBuf, 0, sizeof (afBuf));")
     217        print("\tpRec->pDispatch->GetTexEnvfv(%s, %s, afBuf);" % (target, pname))
     218        print("\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);")
     219        print("\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname)
     220    print("\tcrDmpStrF(pRec->pDumper, \"===Done %s===\");" % target)
     221print("""
    230222    crDmpStrF(pRec->pDumper, "==Done TEX_ENV==");
    231223}
    232 """
    233 
    234 
    235 print """
     224""")
     225
     226
     227print("""
    236228void crRecDumpTexGen(CR_RECORDER *pRec, CRContext *ctx)
    237229{
     
    240232    unsigned int cComponents;
    241233    crDmpStrF(pRec->pDumper, "==TEX_GEN==");
    242 """
     234""")
    243235
    244236for coord in texgen_coords:
    245     print "\tcrDmpStrF(pRec->pDumper, \"===%s===\");" % coord
     237    print("\tcrDmpStrF(pRec->pDumper, \"===%s===\");" % coord)
    246238    for pname in texgen_names:
    247         print "\tcComponents = crStateHlpComponentsCount(%s);" % pname
    248         print "\tAssert(cComponents <= RT_ELEMENTS(afBuf));"
    249         print "\tmemset(afBuf, 0, sizeof (afBuf));"
    250         print "\tpRec->pDispatch->GetTexGendv(%s, %s, afBuf);" % (coord, pname)
    251         print "\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);"
    252         print "\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname
    253     print "\tcrDmpStrF(pRec->pDumper, \"===Done %s===\");" % coord
    254 print """
     239        print("\tcComponents = crStateHlpComponentsCount(%s);" % pname)
     240        print("\tAssert(cComponents <= RT_ELEMENTS(afBuf));")
     241        print("\tmemset(afBuf, 0, sizeof (afBuf));")
     242        print("\tpRec->pDispatch->GetTexGendv(%s, %s, afBuf);" % (coord, pname))
     243        print("\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);")
     244        print("\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname)
     245    print("\tcrDmpStrF(pRec->pDumper, \"===Done %s===\");" % coord)
     246print("""
    255247    crDmpStrF(pRec->pDumper, "==Done TEX_GEN==");
    256248}
    257 """
     249""")
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/gendiffcode.py

    r33540 r63939  
    44# See the file LICENSE.txt for information on redistributing this software
    55
     6from __future__ import print_function
    67import sys
    78
     
    1011        Name = sys.argv[2]
    1112
    12         print """/* This code is AUTOGENERATED!!! */
     13        print("""/* This code is AUTOGENERATED!!! */
    1314
    1415#include "state.h"
    15 #include "state_internals.h\""""
    16 
    17         print """
     16#include "state_internals.h\"""")
     17
     18        print("""
    1819void crState%(Name)sDiff(CR%(Name)sBits *b, CRbitvalue *bitID,
    1920                CRContext *fromCtx, CRContext *toCtx)
    2021{
    2122        CR%(Name)sState *from = &(fromCtx->%(name)s);
    22         CR%(Name)sState *to = &(toCtx->%(name)s);"""%vars()
     23        CR%(Name)sState *to = &(toCtx->%(name)s);"""%vars())
    2324        gendiffcode("state_%s.txt"%(name.lower()), name, docopy=1, doinvalid=0)
    24         print """}
     25        print("""}
    2526
    2627void crState%(Name)sSwitch(CR%(Name)sBits *b, CRbitvalue *bitID,
     
    2829{
    2930        CR%(Name)sState *from = &(fromCtx->%(name)s);
    30         CR%(Name)sState *to = &(toCtx->%(name)s);"""%vars()
     31        CR%(Name)sState *to = &(toCtx->%(name)s);"""%vars())
    3132        gendiffcode("state_%s.txt"%(Name.lower()), Name, docopy=0, doinvalid=1)
    32         print "}\n"
     33        print("}\n")
    3334
    3435def gendiffcode(fname, state_name, docopy, doinvalid):
     
    5556        FILE = open(sys.argv[3]+"/"+fname, "r")
    5657
    57         print """       unsigned int j, i;
     58        print("""       unsigned int j, i;
    5859        CRbitvalue nbitID[CR_MAX_BITARRAY];
    5960        for (j=0;j<CR_MAX_BITARRAY;j++)
    6061                nbitID[j] = ~bitID[j];
    61         i = 0; /* silence compiler */"""
     62        i = 0; /* silence compiler */""")
    6263
    6364        import re
    64         for line in FILE.xreadlines():
     65        for line in FILE:
    6566                line = line.rstrip()
    6667
     
    8788                        if re.search("}", line):
    8889                                tab = tab[:-1]
    89                         print tab+text
     90                        print(tab+text)
    9091                        if re.search("{", line):
    9192                                tab = tab+"\t"
     
    109110                if re.search("%flush", line):
    110111                        if current_guard != "":
    111                                 print tab+"CLEARDIRTY(%(bit)s->%(current_guard)s, nbitID);"%vars()
    112                                 tab = tab[:-1]
    113                                 print tab+"}"
     112                                print(tab+"CLEARDIRTY(%(bit)s->%(current_guard)s, nbitID);"%vars())
     113                                tab = tab[:-1]
     114                                print(tab+"}")
    114115                        if docopy and current_dependency != "":
    115116                                tab = tab[:-1]
    116                                 print tab+"}"
     117                                print(tab+"}")
    117118                        current_guard = ""
    118119                        current_dependency = ""
     
    127128## Close the guardbit and dependency
    128129                if current_guard != "" and current_guard != guardbit:
    129                         print tab+"CLEARDIRTY(%(bit)s->%(current_guard)s, nbitID);"%vars()
     130                        print(tab+"CLEARDIRTY(%(bit)s->%(current_guard)s, nbitID);"%vars())
    130131                        tab = tab[:-1]
    131                         print tab+"}"
     132                        print(tab+"}")
    132133                if docopy and current_dependency != "" and current_dependency != dependency:
    133134                        tab = tab[:-1]
    134                         print tab+"}"
     135                        print(tab+"}")
    135136
    136137## Open the dependency if
    137138                if docopy and current_dependency != dependency and dependency != "":
    138                         print tab+"if (%(target)s->%(dependency)s)\n%(tab)s{"%vars()
     139                        print(tab+"if (%(target)s->%(dependency)s)\n%(tab)s{"%vars())
    139140                        tab = tab+"\t"
    140141                        current_dependency = dependency
     
    142143## Open the guard if
    143144                if docopy and current_dependency != dependency and dependency != "":
    144                         print tab+"if ($(target)s->%(dependency)s)\n%(tab)s{"%vars()
     145                        print(tab+"if ($(target)s->%(dependency)s)\n%(tab)s{"%vars())
    145146                        tab = tab+"\t"
    146147               
    147148                if current_guard != guardbit and guardbit != "":
    148                         print tab+"if (CHECKDIRTY(%(bit)s->%(guardbit)s, bitID))\n%(tab)s{"%vars()
     149                        print(tab+"if (CHECKDIRTY(%(bit)s->%(guardbit)s, bitID))\n%(tab)s{"%vars())
    149150                        tab = tab+"\t"
    150151                        if members[0] != "*" and guardbit[0:6] == "enable":
    151                                 print tab+"glAble able[2];"
    152                                 print tab+"able[0] = diff_api.Disable;"
    153                                 print tab+"able[1] = diff_api.Enable;"
     152                                print(tab+"glAble able[2];")
     153                                print(tab+"able[0] = diff_api.Disable;")
     154                                print(tab+"able[1] = diff_api.Enable;")
    154155
    155156                current_dependency = dependency
     
    158159## Handle text dump
    159160                if members[0] == "*":
    160                         print tab+members[1:]
     161                        print(tab+members[1:])
    161162                else:
    162163                        ## Parse the members variable
     
    181182                                for elem in elems:
    182183                                        if first != 1:
    183                                                 print " ||\n"+tab+"    ",
     184                                                print(" ||\n"+tab+"    ", end="")
    184185                                        first = 0
    185186                                        sys.stdout.write("%(current)s->%(elem)s != %(target)s->%(elem)s"%vars())
    186                                 print ")\n"+tab+"{"
     187                                print(")\n"+tab+"{")
    187188                                tab = tab+"\t"
    188189
     
    190191                        if func[0] == "*":
    191192                                func = func[1:]
    192                                 print tab+func
     193                                print(tab+func)
    193194                        else:
    194195                                if func != "":
    195196## Call the glhw function
    196197                                        if guardbit[0:6] == "enable":
    197                                                 print tab+"able["+target+"->"+elems[0]+"]("+func+");"
     198                                                print(tab+"able["+target+"->"+elems[0]+"]("+func+");")
    198199                                        elif guardbit == "extensions":
    199                                                 print tab+"crState$state_name",
     200                                                print(tab+"crState$state_name",end="")
    200201                                                if docopy == 1:
    201                                                         print "Diff",
     202                                                        print("Diff",end="")
    202203                                                else:
    203                                                         print "Switch",
    204                                                 print "Extensions( from, to );"
     204                                                        print("Switch",end="")
     205                                                print("Extensions( from, to );")
    205206                                        else:
    206207                                                funcargs = re.split(",", func)
     
    211212                                                        v_type = func[-2:-1]
    212213                                                        num_elems = len(elems)
    213                                                         print tab+v_types[v_type]+" varg["+str(num_elems)+"];"
     214                                                        print(tab+v_types[v_type]+" varg["+str(num_elems)+"];")
    214215                                                        i = 0
    215216                                                        for elem in elems:
    216                                                                 print tab+"varg["+str(i)+"] = "+target+"->"+elem+";"
     217                                                                print(tab+"varg["+str(i)+"] = "+target+"->"+elem+";")
    217218                                                                i += 1
    218219                                                elif func[-3:] == "vNV":
    219220                                                        v_type = func[-4:-3]
    220221                                                        num_elems = len(elems)
    221                                                         print tab+v_types[v_type]+" varg["+str(num_elems)+"];"
     222                                                        print(tab+v_types[v_type]+" varg["+str(num_elems)+"];")
    222223                                                        i = 0
    223224                                                        for elem in elems:
    224                                                                 print tab+"varg["+str(i)+"] = "+target+"->"+elem+";"
     225                                                                print(tab+"varg["+str(i)+"] = "+target+"->"+elem+";")
    225226                                                                i += 1
    226227
     
    239240                                                                first = 0
    240241                                                                sys.stdout.write(target+"->"+elem)
    241                                                 print ");"
     242                                                print(");")
    242243
    243244## Do the sync if necessary
    244245                        if docopy and guardbit != "extensions":
    245246                                for elem in  mainelem:
    246                                         print tab+current+"->"+elem+" = "+target+"->"+elem+";"
     247                                        print(tab+current+"->"+elem+" = "+target+"->"+elem+";")
    247248
    248249                        ## Do the clear if necessary
    249250                        if doinvalid:
    250251                                if guardbit != "":
    251                                         print tab+"FILLDIRTY(%(bit)s->%(guardbit)s);"%vars()
    252                                 print tab+"FILLDIRTY(%(bit)s->dirty);"%vars()
     252                                        print(tab+"FILLDIRTY(%(bit)s->%(guardbit)s);"%vars())
     253                                print(tab+"FILLDIRTY(%(bit)s->dirty);"%vars())
    253254                                if extrabit != "":
    254                                         print tab+"FILLDIRTY(%(extrabit)s->dirty);"%vars()
     255                                        print(tab+"FILLDIRTY(%(extrabit)s->dirty);"%vars())
    255256
    256257                        ## Close the compare
    257258                        if guardbit != "extensions":
    258259                                tab = tab[:-1]
    259                                 print tab+"}"
     260                                print(tab+"}")
    260261
    261262## Do final closures
    262263        if current_guard != "":
    263                 print tab+"CLEARDIRTY(%(bit)s->%(current_guard)s, nbitID);"%vars()
     264                print(tab+"CLEARDIRTY(%(bit)s->%(current_guard)s, nbitID);"%vars())
    264265                tab = tab[:-1]
    265                 print tab+"}"
     266                print(tab+"}")
    266267        if docopy and current_dependency != "":
    267268                tab = tab[:-1]
    268                 print tab+"} /*%(current_dependency)s*/"%vars()
    269 
    270         print tab+"CLEARDIRTY(%(bit)s->dirty, nbitID);"%vars()
     269                print(tab+"} /*%(current_dependency)s*/"%vars())
     270
     271        print(tab+"CLEARDIRTY(%(bit)s->dirty, nbitID);"%vars())
    271272
    272273main()
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/get_components.py

    r50041 r63939  
    33#
    44# See the file LICENSE.txt for information on redistributing this software.
     5
     6from __future__ import print_function
    57
    68num_components = {
     
    114116}
    115117
    116 print """unsigned int crStateHlpComponentsCount( GLenum pname )
     118print("""unsigned int crStateHlpComponentsCount( GLenum pname )
    117119{
    118120        switch( pname )
    119121        {
    120 """
    121 comps = num_components.keys();
    122 comps.sort();
    123 for comp in comps:
    124         print '\t\t\tcase %s: return %d;' % (comp,num_components[comp])
     122""")
     123for comp in sorted(num_components.keys()):
     124        print('\t\t\tcase %s: return %d;' % (comp,num_components[comp]))
    125125
    126 comps = num_extended_components.keys();
    127 comps.sort();
    128 for comp in comps:
     126for comp in sorted(num_extended_components.keys()):
    129127        (nc, ifdef) = num_extended_components[comp]
    130         print '#ifdef %s' % ifdef
    131         print '\t\t\tcase %s: return %d;' % (comp,nc)
    132         print '#endif /* %s */' % ifdef
     128        print('#ifdef %s' % ifdef)
     129        print('\t\t\tcase %s: return %d;' % (comp,nc))
     130        print('#endif /* %s */' % ifdef)
    133131
    134 print """
     132print("""
    135133                default:
    136134                        crError( "Unknown parameter name in crStateHlpComponentsCount: %d", (int) pname );
     
    140138        return 0;
    141139}
    142 """
     140""")
    143141
    144142
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_current.py

    r51319 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 '''
     14print('''
    1415#include "state/cr_currentpointers.h"
    1516#include "state.h"
     
    2223
    2324typedef void (*convert_func) (GLfloat *, const unsigned char *);
    24 '''
     25''')
    2526
    2627import convert
    2728
    28 for k in current_fns.keys():
     29for k in sorted(current_fns.keys()):
    2930        name = k
    3031        name = '%s%s' % (k[:1].lower(),k[1:])
     
    3233        num_members = len(current_fns[k]['default']) + 1
    3334
    34         print '#define VPINCH_CONVERT_%s(op,data,dst) \\' % ucname
    35         print '{\\'
    36         print '\tGLfloat vdata[%d] = {' % num_members,
     35        print('#define VPINCH_CONVERT_%s(op,data,dst) \\' % ucname)
     36        print('{\\')
     37        print('\tGLfloat vdata[%d] = {' % num_members, end=' ')
    3738
    3839## Copy dst data into vdata
    3940        i = 0;
    4041        for defaultvar in current_fns[k]['default']:
    41                 print '%d' % defaultvar,
     42                print('%d' % defaultvar, end=' ')
    4243                if i != num_members:
    43                         print ',',
     44                        print(',', end=' ')
    4445                i += 1
    45         print '};\\'
    46 
    47         print '\tswitch (op) { \\'
     46        print('};\\')
     47
     48        print('\tswitch (op) { \\')
    4849        for type in current_fns[k]['types']:
    4950                if type[0:1] == "N":
     
    5556                        uctype = type.upper()
    5657                        if ucname == 'EDGEFLAG':
    57                                 print '\tcase CR_%s_OPCODE: \\' % ucname
     58                                print('\tcase CR_%s_OPCODE: \\' % ucname)
    5859                        else:
    59                                 print '\tcase CR_%s%d%s_OPCODE: \\' % (ucname,size,uctype)
     60                                print('\tcase CR_%s%d%s_OPCODE: \\' % (ucname,size,uctype))
    6061                       
    6162                        if (ucname == 'COLOR' or ucname == 'NORMAL' or ucname == 'SECONDARYCOLOR' or normalize) and type != 'f' and type != 'd':
    62                                 print '\t\t__convert_rescale_%s%d (vdata, (%s *) (data)); \\' % (type,size,gltypes[type]['type'])
     63                                print('\t\t__convert_rescale_%s%d (vdata, (%s *) (data)); \\' % (type,size,gltypes[type]['type']))
    6364                        else:
    64                                 print '\t\t__convert_%s%d (vdata, (%s *) (data)); \\' % (type,size,gltypes[type]['type'])
    65                         print '\t\tbreak; \\'
    66 
    67         print '\tdefault: \\'
    68         print '\t\tcrSimpleError ( "Unknown opcode in VPINCH_CONVERT_%s" ); \\' % ucname
    69         print '\t}\\'
     65                                print('\t\t__convert_%s%d (vdata, (%s *) (data)); \\' % (type,size,gltypes[type]['type']))
     66                        print('\t\tbreak; \\')
     67
     68        print('\tdefault: \\')
     69        print('\t\tcrSimpleError ( "Unknown opcode in VPINCH_CONVERT_%s" ); \\' % ucname)
     70        print('\t}\\')
    7071
    7172        i = 0
    7273        for member in current_fns[k]['members']:
    73                 print '\t(dst).%s = vdata[%d];\\' % (member,i)
     74                print('\t(dst).%s = vdata[%d];\\' % (member,i))
    7475                i += 1
    7576
    76         print '}\n'
    77 
    78 print '''
     77        print('}\n')
     78
     79print('''
    7980
    8081void crStateCurrentRecover( void )
     
    187188        c->colorIndexPre = c->colorIndex;
    188189
    189 '''
    190 
    191 for k in current_fns.keys():
    192         print '\t/* %s */' % k
    193         print '\tv=NULL;'
     190''')
     191
     192for k in sorted(current_fns.keys()):
     193        print('\t/* %s */' % k)
     194        print('\tv=NULL;')
    194195        name = '%s%s' % (k[:1].lower(),k[1:])
    195196
    196197        indent = ""
    197         if current_fns[k].has_key( 'array' ):
    198                 print '\tfor (i = 0 ; i < %s ; i++)' % current_fns[k]['array']
    199                 print '\t{'
     198        if 'array' in current_fns[k]:
     199                print('\tfor (i = 0 ; i < %s ; i++)' % current_fns[k]['array'])
     200                print('\t{')
    200201                indent += "\t"
    201202        for type in current_fns[k]['types']:
     
    208209                for size in current_fns[k]['sizes']:
    209210                        ptr = '%s->%s%d' % (name, type, size )
    210                         if current_fns[k].has_key( 'array' ):
     211                        if 'array' in current_fns[k]:
    211212                                ptr += "[i]"
    212                         print '%s\tif (v < %s)' % (indent, ptr)
    213                         print '%s\t{' % indent
    214                         print '%s\t\tv = %s;' % (indent, ptr)
     213                        print('%s\tif (v < %s)' % (indent, ptr))
     214                        print('%s\t{' % indent)
     215                        print('%s\t\tv = %s;' % (indent, ptr))
    215216                        if (k == 'Color' or k == 'Normal' or k == 'SecondaryColor' or normalized) and type != 'f' and type != 'd' and type != 'l':
    216                                 print '%s\t\tconvert = (convert_func) __convert_rescale_%s%d;' % (indent,type,size)
     217                                print('%s\t\tconvert = (convert_func) __convert_rescale_%s%d;' % (indent,type,size))
    217218                        else:
    218                                 print '%s\t\tconvert = (convert_func) __convert_%s%d;' % (indent,type,size)
    219                         print '%s\t}' % indent
    220         print ''
    221         print '%s\tif (v != NULL) {' % indent
    222         if current_fns[k].has_key( 'array' ):
     219                                print('%s\t\tconvert = (convert_func) __convert_%s%d;' % (indent,type,size))
     220                        print('%s\t}' % indent)
     221        print('')
     222        print('%s\tif (v != NULL) {' % indent)
     223        if 'array' in current_fns[k]:
    223224                if k == 'TexCoord':
    224                         print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], %s_default);' % (indent,name)
     225                        print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], %s_default);' % (indent,name))
    225226                else:
    226                         print '%s\t\tCOPY_4V(c->%s[i], %s_default);' % (indent,name,name)
     227                        print('%s\t\tCOPY_4V(c->%s[i], %s_default);' % (indent,name,name))
    227228        else:
    228229                if k == 'Normal':
    229                         print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_NORMAL], %s_default);' % (indent,name)
     230                        print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_NORMAL], %s_default);' % (indent,name))
    230231                elif k == 'FogCoord':
    231                         print '%s\t\tc->vertexAttrib[VERT_ATTRIB_FOG][0] =  %s_default;' % (indent,name)
     232                        print('%s\t\tc->vertexAttrib[VERT_ATTRIB_FOG][0] =  %s_default;' % (indent,name))
    232233                elif k == 'Color':
    233                         print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR0], %s_default);' % (indent,name)
     234                        print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR0], %s_default);' % (indent,name))
    234235                elif k == 'SecondaryColor':
    235                         print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR1],  %s_default);' % (indent,name)
     236                        print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR1],  %s_default);' % (indent,name))
    236237                elif k == 'TexCoord':
    237                         print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0], %s_default);' % (indent,name)
     238                        print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0], %s_default);' % (indent,name))
    238239                elif k == 'Index':
    239                         print '%s\t\tc->colorIndex =  %s_default;' % (indent,name)
     240                        print('%s\t\tc->colorIndex =  %s_default;' % (indent,name))
    240241                elif k == 'EdgeFlag':
    241                         print '%s\t\tc->edgeFlag =  %s_default;' % (indent,name)
     242                        print('%s\t\tc->edgeFlag =  %s_default;' % (indent,name))
    242243                else:
    243                         print '%s\t\tc->%s = %s_default;' % (indent,name,name)
     244                        print('%s\t\tc->%s = %s_default;' % (indent,name,name))
    244245        if k == 'EdgeFlag':
    245                 print '%s\t\t__convert_boolean (&c->edgeFlag, v);' % (indent)
     246                print('%s\t\t__convert_boolean (&c->edgeFlag, v);' % (indent))
    246247                dirtyVar = 'cb->edgeFlag'
    247248        elif k == 'Normal':
    248                 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_NORMAL][0]), v);' % (indent)
     249                print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_NORMAL][0]), v);' % (indent))
    249250                dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_NORMAL]'
    250251        elif k == 'TexCoord':
    251                 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_TEX0 + i][0]), v);' % (indent)
     252                print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_TEX0 + i][0]), v);' % (indent))
    252253                dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_TEX0 + i]'
    253254        elif k == 'Color':
    254                 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR0][0]), v);' % (indent)
     255                print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR0][0]), v);' % (indent))
    255256                dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR0]'
    256257        elif k == 'Index':
    257                 print '%s\t\tconvert(&(c->colorIndex), v);' % (indent)
     258                print('%s\t\tconvert(&(c->colorIndex), v);' % (indent))
    258259                dirtyVar = 'cb->colorIndex'
    259260        elif k == 'SecondaryColor':
    260                 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR1][0]), v);' % (indent)
     261                print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR1][0]), v);' % (indent))
    261262                dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR1]'
    262263        elif k == 'FogCoord':
    263                 print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_FOG][0]), v);' % (indent)
     264                print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_FOG][0]), v);' % (indent))
    264265                dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_FOG]'
    265266        elif k == 'VertexAttrib':
    266                 print '%s\t\tconvert(&(c->vertexAttrib[i][0]), v);' % (indent)
     267                print('%s\t\tconvert(&(c->vertexAttrib[i][0]), v);' % (indent))
    267268                dirtyVar = 'cb->vertexAttrib[i]'
    268269        else:
    269270                assert 0  # should never get here
    270271
    271         print '%s\t\tDIRTY(%s, nbitID);' % (indent, dirtyVar)
     272        print('%s\t\tDIRTY(%s, nbitID);' % (indent, dirtyVar))
    272273
    273274#       if current_fns[k].has_key( 'array' ):
     
    278279
    279280
    280         print '%s\t\tDIRTY(cb->dirty, nbitID);' % indent
    281         print '%s\t}' % indent
    282         if current_fns[k].has_key( 'array' ):
    283                 print '%s\t%s->ptr[i] = v;' % (indent, name )
     281        print('%s\t\tDIRTY(cb->dirty, nbitID);' % indent)
     282        print('%s\t}' % indent)
     283        if 'array' in current_fns[k]:
     284                print('%s\t%s->ptr[i] = v;' % (indent, name ))
    284285        else:
    285                 print '%s\t%s->ptr = v;' % (indent, name )
    286         if current_fns[k].has_key( 'array' ):
    287                 print '\t}'
    288 print '}'
    289 
    290 print '''
     286                print('%s\t%s->ptr = v;' % (indent, name ))
     287        if 'array' in current_fns[k]:
     288                print('\t}')
     289print('}')
     290
     291print('''
    291292
    292293void crStateCurrentRecoverNew(CRContext *g, CRCurrentStatePointers  *current)
     
    365366
    366367
    367 '''
    368 
    369 for k in current_fns_new.keys():
    370     print '\t/* %s */' % k
    371     print '\tif (current->changed%s)' % k
    372     print '\t{'
    373     print '\t\tv=NULL;'
     368''')
     369
     370for k in sorted(current_fns_new.keys()):
     371    print('\t/* %s */' % k)
     372    print('\tif (current->changed%s)' % k)
     373    print('\t{')
     374    print('\t\tv=NULL;')
    374375    name = '%s%s' % (k[:1].lower(),k[1:])
    375376
    376377    indent = ""
    377     if current_fns_new[k].has_key( 'array' ):
    378         print '\t\tfor (i = 0 ; i < %s ; i++)' % current_fns_new[k]['array']
    379         print '\t\t{'
     378    if 'array' in current_fns_new[k]:
     379        print('\t\tfor (i = 0 ; i < %s ; i++)' % current_fns_new[k]['array'])
     380        print('\t\t{')
    380381        indent += "\t\t"
    381         print '\t\tif (!(current->changed%s & (1 << i))) continue;' % k
     382        print('\t\tif (!(current->changed%s & (1 << i))) continue;' % k)
    382383    for type in current_fns_new[k]['types']:
    383384        if type[0:1] == "N":
     
    389390        for size in current_fns_new[k]['sizes']:
    390391            ptr = '%s->%s%d' % (name, type, size )
    391             if current_fns_new[k].has_key( 'array' ):
     392            if 'array' in current_fns_new[k]:
    392393                ptr += "[i]"
    393             print '#ifdef DEBUG_misha'
    394             print '%s\tif (%s)' % (indent, ptr)
    395             print '%s\t{' % (indent)
    396             print '%s\t\tuint32_t *pTst = (uint32_t*)(%s);' % (indent, ptr)
    397             print '%s\t\t--pTst;' % (indent)
    398             print '%s\t\tAssert((*pTst) == i);' % (indent)
    399             print '%s\t}' % (indent)
    400             print '#endif'
    401             print '%s\tif (v < %s)' % (indent, ptr)
    402             print '%s\t{' % indent
    403             print '%s\t\tv = %s;' % (indent, ptr)
     394            print('#ifdef DEBUG_misha')
     395            print('%s\tif (%s)' % (indent, ptr))
     396            print('%s\t{' % (indent))
     397            print('%s\t\tuint32_t *pTst = (uint32_t*)(%s);' % (indent, ptr))
     398            print('%s\t\t--pTst;' % (indent))
     399            print('%s\t\tAssert((*pTst) == i);' % (indent))
     400            print('%s\t}' % (indent))
     401            print('#endif')
     402            print('%s\tif (v < %s)' % (indent, ptr))
     403            print('%s\t{' % indent)
     404            print('%s\t\tv = %s;' % (indent, ptr))
    404405            if (k == 'Color' or k == 'Normal' or k == 'SecondaryColor' or normalized) and type != 'f' and type != 'd' and type != 'l':
    405                 print '%s\t\tconvert = (convert_func) __convert_rescale_%s%d;' % (indent,type,size)
     406                print('%s\t\tconvert = (convert_func) __convert_rescale_%s%d;' % (indent,type,size))
    406407            else:
    407                 print '%s\t\tconvert = (convert_func) __convert_%s%d;' % (indent,type,size)
    408             print '%s\t}' % indent
    409     print ''
    410     print '%s\tif (v != NULL) {' % indent
    411     if current_fns_new[k].has_key( 'array' ):
     408                print('%s\t\tconvert = (convert_func) __convert_%s%d;' % (indent,type,size))
     409            print('%s\t}' % indent)
     410    print('')
     411    print('%s\tif (v != NULL) {' % indent)
     412    if 'array' in current_fns_new[k]:
    412413        if k == 'TexCoord':
    413             print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], %s_default);' % (indent,name)
     414            print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], %s_default);' % (indent,name))
    414415        else:
    415             print '%s\t\tCOPY_4V(c->%s[i], %s_default);' % (indent,name,name)
     416            print('%s\t\tCOPY_4V(c->%s[i], %s_default);' % (indent,name,name))
    416417    else:
    417418        if k == 'Normal':
    418             print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_NORMAL], %s_default);' % (indent,name)
     419            print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_NORMAL], %s_default);' % (indent,name))
    419420        elif k == 'FogCoord':
    420             print '%s\t\tc->vertexAttrib[VERT_ATTRIB_FOG][0] =  %s_default;' % (indent,name)
     421            print('%s\t\tc->vertexAttrib[VERT_ATTRIB_FOG][0] =  %s_default;' % (indent,name))
    421422        elif k == 'Color':
    422             print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR0], %s_default);' % (indent,name)
     423            print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR0], %s_default);' % (indent,name))
    423424        elif k == 'SecondaryColor':
    424             print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR1],  %s_default);' % (indent,name)
     425            print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR1],  %s_default);' % (indent,name))
    425426        elif k == 'TexCoord':
    426             print '%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0], %s_default);' % (indent,name)
     427            print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0], %s_default);' % (indent,name))
    427428        elif k == 'Index':
    428             print '%s\t\tc->colorIndex =  %s_default;' % (indent,name)
     429            print('%s\t\tc->colorIndex =  %s_default;' % (indent,name))
    429430        elif k == 'EdgeFlag':
    430             print '%s\t\tc->edgeFlag =  %s_default;' % (indent,name)
     431            print('%s\t\tc->edgeFlag =  %s_default;' % (indent,name))
    431432        else:
    432             print '%s\t\tc->%s = %s_default;' % (indent,name,name)
     433            print('%s\t\tc->%s = %s_default;' % (indent,name,name))
    433434    if k == 'EdgeFlag':
    434         print '%s\t\t__convert_boolean (&c->edgeFlag, v);' % (indent)
     435        print('%s\t\t__convert_boolean (&c->edgeFlag, v);' % (indent))
    435436        dirtyVar = 'cb->edgeFlag'
    436437    elif k == 'Normal':
    437         print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_NORMAL][0]), v);' % (indent)
     438        print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_NORMAL][0]), v);' % (indent))
    438439        dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_NORMAL]'
    439440    elif k == 'TexCoord':
    440         print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_TEX0 + i][0]), v);' % (indent)
     441        print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_TEX0 + i][0]), v);' % (indent))
    441442        dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_TEX0 + i]'
    442443    elif k == 'Color':
    443         print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR0][0]), v);' % (indent)
     444        print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR0][0]), v);' % (indent))
    444445        dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR0]'
    445446    elif k == 'Index':
    446         print '%s\t\tconvert(&(c->colorIndex), v);' % (indent)
     447        print('%s\t\tconvert(&(c->colorIndex), v);' % (indent))
    447448        dirtyVar = 'cb->colorIndex'
    448449    elif k == 'SecondaryColor':
    449         print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR1][0]), v);' % (indent)
     450        print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR1][0]), v);' % (indent))
    450451        dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR1]'
    451452    elif k == 'FogCoord':
    452         print '%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_FOG][0]), v);' % (indent)
     453        print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_FOG][0]), v);' % (indent))
    453454        dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_FOG]'
    454455    elif k == 'VertexAttrib':
    455         print '%s\t\tconvert(&(c->vertexAttrib[i][0]), v);' % (indent)
     456        print('%s\t\tconvert(&(c->vertexAttrib[i][0]), v);' % (indent))
    456457        dirtyVar = 'cb->vertexAttrib[i]'
    457458    else:
    458459        assert 0  # should never get here
    459460
    460     print '%s\t\tDIRTY(%s, nbitID);' % (indent, dirtyVar)
     461    print('%s\t\tDIRTY(%s, nbitID);' % (indent, dirtyVar))
    461462
    462463#   if current_fns_new[k].has_key( 'array' ):
     
    467468
    468469
    469     print '%s\t\tDIRTY(cb->dirty, nbitID);' % indent
    470     print '%s\t}' % indent
    471     if current_fns_new[k].has_key( 'array' ):
    472         print '%s\t%s->ptr[i] = v;' % (indent, name )
     470    print('%s\t\tDIRTY(cb->dirty, nbitID);' % indent)
     471    print('%s\t}' % indent)
     472    if 'array' in current_fns_new[k]:
     473        print('%s\t%s->ptr[i] = v;' % (indent, name ))
    473474    else:
    474         print '%s\t%s->ptr = v;' % (indent, name )
    475     if current_fns_new[k].has_key( 'array' ):
    476         print '\t\t}'
    477         print '\t\tcurrent->changed%s = 0;' % k
    478         print '\t}'
    479 print '\tcrStateResetCurrentPointers(current);'
    480 print '}'
     475        print('%s\t%s->ptr = v;' % (indent, name ))
     476    if 'array' in current_fns_new[k]:
     477        print('\t\t}')
     478        print('\t\tcurrent->changed%s = 0;' % k)
     479        print('\t}')
     480print('\tcrStateResetCurrentPointers(current);')
     481print('}')
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_funcs.py

    r15532 r63939  
    55
    66
     7from __future__ import print_function
    78import sys
    89
     
    1314apiutil.CopyrightC()
    1415
    15 print """
     16print("""
    1617/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY state_funcs.py SCRIPT */
    1718#ifndef CR_STATE_FUNCS_H
     
    3334#endif
    3435
    35 #define STATE_UNUSED(x) ((void)x)"""
     36#define STATE_UNUSED(x) ((void)x)""")
    3637
    3738
     
    4041        return_type = apiutil.ReturnType(func_name)
    4142        params = apiutil.Parameters(func_name)
    42         print 'DECLEXPORT(%s) STATE_APIENTRY crState%s( %s );' % (return_type, func_name, apiutil.MakeDeclarationString(params))
     43        print('DECLEXPORT(%s) STATE_APIENTRY crState%s( %s );' % (return_type, func_name, apiutil.MakeDeclarationString(params)))
    4344
    4445for func_name in apiutil.AllSpecials( "state_feedback" ):
    4546        return_type = apiutil.ReturnType(func_name)
    4647        params = apiutil.Parameters(func_name)
    47         print 'DECLEXPORT(%s) STATE_APIENTRY crStateFeedback%s( %s );' % (return_type, func_name, apiutil.MakeDeclarationString(params))
     48        print('DECLEXPORT(%s) STATE_APIENTRY crStateFeedback%s( %s );' % (return_type, func_name, apiutil.MakeDeclarationString(params)))
    4849
    4950for func_name in apiutil.AllSpecials( "state_select" ):
    5051        return_type = apiutil.ReturnType(func_name)
    5152        params = apiutil.Parameters(func_name)
    52         print 'DECLEXPORT(%s) STATE_APIENTRY crStateSelect%s( %s );' % (return_type, func_name, apiutil.MakeDeclarationString(params))
     53        print('DECLEXPORT(%s) STATE_APIENTRY crStateSelect%s( %s );' % (return_type, func_name, apiutil.MakeDeclarationString(params)))
    5354
    5455
    55 print """
     56print("""
    5657#ifdef __cplusplus
    5758}
     
    5960
    6061#endif /* CR_STATE_FUNCS_H */
    61 """
     62""")
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_get.py

    r50041 r63939  
    44# See the file LICENSE.txt for information on redistributing this software.
    55
     6from __future__ import print_function
    67import sys, re, string
    78import apiutil
     
    2122                type = match.group(1)
    2223                pname = match.group(2)
    23                 fields = string.split( match.group(3) )
     24                fields = match.group(3).split()
    2425                params[pname] = ( type, fields )
    2526
     
    3334                pname = match.group(2)
    3435                ifdef = match.group(3)
    35                 fields = string.split( match.group(4) )
     36                fields = match.group(4).split()
    3637                extended_params[pname] = ( type, ifdef, fields )
    3738
     
    104105apiutil.CopyrightC()
    105106
    106 print """
     107print("""
    107108/* DO NOT EDIT - THIS FILE GENERATED BY state_get.txt AND THE state_get.py SCRIPT */
    108109#include <stdio.h>
     
    141142    return g->framebufferobject.readFB ? g->framebufferobject.readFB->readbuffer : g->buffer.readBuffer;
    142143}
    143 """
     144""")
    144145
    145146header = """
     
    173174
    174175for rettype in types:
    175         print ''
    176         print 'void STATE_APIENTRY crStateGet%sv( GLenum pname, %s *params )' % ( rettype, ctypes[rettype] )
    177         print header
    178 
    179         keys = params.keys()
    180         keys.sort()
    181         for pname in keys:
    182                 print '\t\tcase %s:' % pname
     176        print('')
     177        print('void STATE_APIENTRY crStateGet%sv( GLenum pname, %s *params )' % ( rettype, ctypes[rettype] ))
     178        print(header)
     179
     180        for pname in sorted(params.keys()):
     181                print('\t\tcase %s:' % pname)
    183182                (srctype,fields) = params[pname]
    184183                try:
     
    187186                        for field in fields:
    188187                                expr = cvt % field
    189                                 print '\t\t\tparams[%d] = %s;' % (i,expr)
     188                                print('\t\t\tparams[%d] = %s;' % (i,expr))
    190189                                i += 1
    191190                except:
    192                         print '\t\t\tcrStateError(__LINE__,__FILE__,GL_INVALID_OPERATION, "Unimplemented glGet!");'
    193                 print "\t\t\tbreak;"
    194 
    195 
    196         keys = extended_params.keys();
    197         keys.sort()
    198         for pname in keys:
     191                        print('\t\t\tcrStateError(__LINE__,__FILE__,GL_INVALID_OPERATION, "Unimplemented glGet!");')
     192                print("\t\t\tbreak;")
     193
     194
     195        for pname in sorted(extended_params.keys()):
    199196                (srctype,ifdef,fields) = extended_params[pname]
    200197                ext = ifdef[3:]  # the extension name with the "GL_" prefix removed
    201198                #print '#ifdef %s' % ifdef
    202                 print '#ifdef CR_%s' % ext
    203                 print '\t\tcase %s:' % pname
     199                print('#ifdef CR_%s' % ext)
     200                print('\t\tcase %s:' % pname)
    204201                if ext != 'OPENGL_VERSION_1_2':
    205                         print '\t\t\tif (g->extensions.%s) {' % ext
     202                        print('\t\t\tif (g->extensions.%s) {' % ext)
    206203                try:
    207204                        cvt = convert[srctype][rettype]
     
    211208                                if field[0] == '%':
    212209                                        command = string.split(field, '%')
    213                                         print '\t\t\t\t%s;' % command[1]
     210                                        print('\t\t\t\t%s;' % command[1])
    214211                                        continue
    215212                                elif ext != 'OPENGL_VERSION_1_2':
    216                                         print '\t\t\t\tparams[%d] = %s;' % (i,expr)
     213                                        print('\t\t\t\tparams[%d] = %s;' % (i,expr))
    217214                                else:
    218                                         print '\t\t\tparams[%d] = %s;' % (i,expr)
     215                                        print('\t\t\tparams[%d] = %s;' % (i,expr))
    219216                                i += 1
    220217                except:
    221                         print '\t\t\tcrStateError(__LINE__,__FILE__,GL_INVALID_OPERATION, "Unimplemented glGet!");'
     218                        print('\t\t\tcrStateError(__LINE__,__FILE__,GL_INVALID_OPERATION, "Unimplemented glGet!");')
    222219                if ext != 'OPENGL_VERSION_1_2':
    223                         print "\t\t\t}"
    224                         print "\t\t\telse {"
    225                         print '\t\t\t\tcrStateError(__LINE__,__FILE__,GL_INVALID_ENUM, "glGet%sv");' % rettype
    226                         print "\t\t\t}"
    227                 print "\t\t\tbreak;"
     220                        print("\t\t\t}")
     221                        print("\t\t\telse {")
     222                        print('\t\t\t\tcrStateError(__LINE__,__FILE__,GL_INVALID_ENUM, "glGet%sv");' % rettype)
     223                        print("\t\t\t}")
     224                print("\t\t\tbreak;")
    228225                #print '#endif /* %s */' % ifdef
    229                 print '#endif /* CR_%s */' % ext
    230 
    231         print '\t\tdefault:'
    232         print '\t\t\tcrStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGet: Unknown enum: 0x%x", pname);'
    233         print '\t\t\treturn;'
    234         print '\t}'
    235         print '}'
     226                print('#endif /* CR_%s */' % ext)
     227
     228        print('\t\tdefault:')
     229        print('\t\t\tcrStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGet: Unknown enum: 0x%x", pname);')
     230        print('\t\t\treturn;')
     231        print('\t}')
     232        print('}')
    236233
    237234from get_components import *
  • trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.py

    r15532 r63939  
    44# See the file LICENSE.txt for information on redistributing this software.
    55
     6from __future__ import print_function
    67import sys, re, string
    78import apiutil
     
    2021                type = match.group(1)
    2122                pname = match.group(2)
    22                 fields = string.split( match.group(3) )
     23                fields = match.group(3).split()
    2324                params[pname] = ( type, fields )
    2425
     
    3031                pname = match.group(2)
    3132                ifdef = match.group(3)
    32                 fields = string.split( match.group(4) )
     33                fields = match.group(4).split()
    3334                extended_params[pname] = ( type, ifdef, fields )
    3435
    3536apiutil.CopyrightC()
    3637
    37 print """
     38print("""
    3839/* DO NOT EDIT - THIS FILE GENERATED BY THE state_isenabled.py SCRIPT */
    3940#include <stdio.h>
     
    5455
    5556    switch ( pname ) {
    56 """
     57""")
    5758
    58 keys = params.keys()
    59 keys.sort();
     59for pname in sorted(params.keys()):
     60        print("\tcase %s:" % pname)
     61        print("\t\treturn %s;" % params[pname][1][0])
    6062
    61 for pname in keys:
    62         print "\tcase %s:" % pname
    63         print "\t\treturn %s;" % params[pname][1][0]
    64 
    65 keys = extended_params.keys();
    66 keys.sort()
    67 
    68 for pname in keys:
     63for pname in sorted(extended_params.keys()):
    6964        (srctype,ifdef,fields) = extended_params[pname]
    7065        ext = ifdef[3:]  # the extension name with the "GL_" prefix removed
    7166        ext = ifdef
    72         print '#ifdef CR_%s' % ext
    73         print "\tcase %s:" % pname
    74         print "\t\treturn %s;" % extended_params[pname][2][0]
    75         print '#endif /* CR_%s */' % ext
    76 print "\tdefault:"
    77 print "\t\tcrStateError(__LINE__, __FILE__, GL_INVALID_ENUM, \"glIsEnabled: Unknown enum: %d\", pname);"
    78 print "\t\treturn 0;"
    79 print "\t}"
    80 print "}"
     67        print('#ifdef CR_%s' % ext)
     68        print("\tcase %s:" % pname)
     69        print("\t\treturn %s;" % extended_params[pname][2][0])
     70        print('#endif /* CR_%s */' % ext)
     71print("\tdefault:")
     72print("\t\tcrStateError(__LINE__, __FILE__, GL_INVALID_ENUM, \"glIsEnabled: Unknown enum: %d\", pname);")
     73print("\t\treturn 0;")
     74print("\t}")
     75print("}")
Note: See TracChangeset for help on using the changeset viewer.

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