Ticket #26379: mesa-python3.diff

File mesa-python3.diff, 232.6 KB (added by jmroot (Joshua Root), 13 years ago)
  • Mesa-7.8.2/src/gallium/auxiliary/indices/u_indices_gen.py

    old new  
    6060
    6161
    6262def prolog():
    63     print '''/* File automatically generated by indices.py */'''
    64     print copyright
    65     print r'''
     63    print ('''/* File automatically generated by indices.py */''')
     64    print (copyright)
     65    print (r'''
    6666
    6767/**
    6868 * @file
     
    101101static u_generate_func  generate[OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT];
    102102
    103103
    104 '''
     104''')
    105105
    106106def vert( intype, outtype, v0 ):
    107107    if intype == GENERATE:
     
    110110        return '(' + outtype + ')in[' + v0 + ']'
    111111
    112112def point( intype, outtype, ptr, v0 ):
    113     print '      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
     113    print ('      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
    114114
    115115def line( intype, outtype, ptr, v0, v1 ):
    116     print '      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
    117     print '      (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
     116    print ('      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
     117    print ('      (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';')
    118118
    119119def tri( intype, outtype, ptr, v0, v1, v2 ):
    120     print '      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
    121     print '      (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
    122     print '      (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';'
     120    print ('      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
     121    print ('      (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';')
     122    print ('      (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';')
    123123
    124124def do_point( intype, outtype, ptr, v0 ):
    125125    point( intype, outtype, ptr, v0 )
     
    150150        return 'translate_' + prim + '_' + intype + '2' + outtype + '_' + inpv + '2' + outpv
    151151
    152152def preamble(intype, outtype, inpv, outpv, prim):
    153     print 'static void ' + name( intype, outtype, inpv, outpv, prim ) + '('
     153    print ('static void ' + name( intype, outtype, inpv, outpv, prim ) + '(')
    154154    if intype != GENERATE:
    155         print '    const void * _in,'
    156     print '    unsigned nr,'
    157     print '    void *_out )'
    158     print '{'
     155        print ('    const void * _in,')
     156    print ('    unsigned nr,')
     157    print ('    void *_out )')
     158    print ('{')
    159159    if intype != GENERATE:
    160         print '  const ' + intype + '*in = (const ' + intype + '*)_in;'
    161     print '  ' + outtype + ' *out = (' + outtype + '*)_out;'
    162     print '  unsigned i, j;'
    163     print '  (void)j;'
     160        print ('  const ' + intype + '*in = (const ' + intype + '*)_in;')
     161    print ('  ' + outtype + ' *out = (' + outtype + '*)_out;')
     162    print ('  unsigned i, j;')
     163    print ('  (void)j;')
    164164
    165165def postamble():
    166     print '}'
     166    print ('}')
    167167
    168168
    169169def points(intype, outtype, inpv, outpv):
    170170    preamble(intype, outtype, inpv, outpv, prim='points')
    171     print '  for (i = 0; i < nr; i++) { '
     171    print ('  for (i = 0; i < nr; i++) { ')
    172172    do_point( intype, outtype, 'out+i',  'i' );
    173     print '   }'
     173    print ('   }')
    174174    postamble()
    175175
    176176def lines(intype, outtype, inpv, outpv):
    177177    preamble(intype, outtype, inpv, outpv, prim='lines')
    178     print '  for (i = 0; i < nr; i+=2) { '
     178    print ('  for (i = 0; i < nr; i+=2) { ')
    179179    do_line( intype, outtype, 'out+i',  'i', 'i+1', inpv, outpv );
    180     print '   }'
     180    print ('   }')
    181181    postamble()
    182182
    183183def linestrip(intype, outtype, inpv, outpv):
    184184    preamble(intype, outtype, inpv, outpv, prim='linestrip')
    185     print '  for (j = i = 0; j < nr; j+=2, i++) { '
     185    print ('  for (j = i = 0; j < nr; j+=2, i++) { ')
    186186    do_line( intype, outtype, 'out+j',  'i', 'i+1', inpv, outpv );
    187     print '   }'
     187    print ('   }')
    188188    postamble()
    189189
    190190def lineloop(intype, outtype, inpv, outpv):
    191191    preamble(intype, outtype, inpv, outpv, prim='lineloop')
    192     print '  for (j = i = 0; j < nr - 2; j+=2, i++) { '
     192    print ('  for (j = i = 0; j < nr - 2; j+=2, i++) { ')
    193193    do_line( intype, outtype, 'out+j',  'i', 'i+1', inpv, outpv );
    194     print '   }'
     194    print ('   }')
    195195    do_line( intype, outtype, 'out+j',  'i', '0', inpv, outpv );
    196196    postamble()
    197197
    198198def tris(intype, outtype, inpv, outpv):
    199199    preamble(intype, outtype, inpv, outpv, prim='tris')
    200     print '  for (i = 0; i < nr; i+=3) { '
     200    print ('  for (i = 0; i < nr; i+=3) { ')
    201201    do_tri( intype, outtype, 'out+i',  'i', 'i+1', 'i+2', inpv, outpv );
    202     print '   }'
     202    print ('   }')
    203203    postamble()
    204204
    205205
    206206def tristrip(intype, outtype, inpv, outpv):
    207207    preamble(intype, outtype, inpv, outpv, prim='tristrip')
    208     print '  for (j = i = 0; j < nr; j+=3, i++) { '
     208    print ('  for (j = i = 0; j < nr; j+=3, i++) { ')
    209209    if inpv == FIRST:
    210210        do_tri( intype, outtype, 'out+j',  'i', 'i+1+(i&1)', 'i+2-(i&1)', inpv, outpv );
    211211    else:
    212212        do_tri( intype, outtype, 'out+j',  'i+(i&1)', 'i+1-(i&1)', 'i+2', inpv, outpv );
    213     print '   }'
     213    print ('   }')
    214214    postamble()
    215215
    216216
    217217def trifan(intype, outtype, inpv, outpv):
    218218    preamble(intype, outtype, inpv, outpv, prim='trifan')
    219     print '  for (j = i = 0; j < nr; j+=3, i++) { '
     219    print ('  for (j = i = 0; j < nr; j+=3, i++) { ')
    220220    do_tri( intype, outtype, 'out+j',  '0', 'i+1', 'i+2', inpv, outpv );
    221     print '   }'
     221    print ('   }')
    222222    postamble()
    223223
    224224
    225225
    226226def polygon(intype, outtype, inpv, outpv):
    227227    preamble(intype, outtype, inpv, outpv, prim='polygon')
    228     print '  for (j = i = 0; j < nr; j+=3, i++) { '
     228    print ('  for (j = i = 0; j < nr; j+=3, i++) { ')
    229229    if inpv == FIRST:
    230230        do_tri( intype, outtype, 'out+j',  '0', 'i+1', 'i+2', inpv, outpv );
    231231    else:
    232232        do_tri( intype, outtype, 'out+j',  'i+1', 'i+2', '0', inpv, outpv );
    233     print '   }'
     233    print ('   }')
    234234    postamble()
    235235
    236236
    237237def quads(intype, outtype, inpv, outpv):
    238238    preamble(intype, outtype, inpv, outpv, prim='quads')
    239     print '  for (j = i = 0; j < nr; j+=6, i+=4) { '
     239    print ('  for (j = i = 0; j < nr; j+=6, i+=4) { ')
    240240    do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv );
    241     print '   }'
     241    print ('   }')
    242242    postamble()
    243243
    244244
    245245def quadstrip(intype, outtype, inpv, outpv):
    246246    preamble(intype, outtype, inpv, outpv, prim='quadstrip')
    247     print '  for (j = i = 0; j < nr; j+=6, i+=2) { '
     247    print ('  for (j = i = 0; j < nr; j+=6, i+=2) { ')
    248248    do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3', inpv, outpv );
    249     print '   }'
     249    print ('   }')
    250250    postamble()
    251251
    252252
     
    293293                        init(intype, outtype, inpv, outpv, prim)
    294294
    295295def emit_init():
    296     print 'void u_index_init( void )'
    297     print '{'
    298     print '  static int firsttime = 1;'
    299     print '  if (!firsttime) return;'
    300     print '  firsttime = 0;'
     296    print ('void u_index_init( void )')
     297    print ('{')
     298    print ('  static int firsttime = 1;')
     299    print ('  if (!firsttime) return;')
     300    print ('  firsttime = 0;')
    301301    emit_all_inits()
    302     print '}'
     302    print ('}')
    303303
    304304
    305305   
    306306
    307307def epilog():
    308     print '#include "indices/u_indices.c"'
     308    print ('#include "indices/u_indices.c"')
    309309
    310310
    311311def main():
  • Mesa-7.8.2/src/gallium/auxiliary/indices/u_unfilled_gen.py

    old new  
    5050
    5151
    5252def prolog():
    53     print '''/* File automatically generated by u_unfilled_gen.py */'''
    54     print copyright
    55     print r'''
     53    print ('''/* File automatically generated by u_unfilled_gen.py */''')
     54    print (copyright)
     55    print (r'''
    5656
    5757/**
    5858 * @file
     
    9090static u_generate_func generate_line[OUT_COUNT][PRIM_COUNT];
    9191static u_translate_func translate_line[IN_COUNT][OUT_COUNT][PRIM_COUNT];
    9292
    93 '''
     93''')
    9494
    9595def vert( intype, outtype, v0 ):
    9696    if intype == GENERATE:
     
    9999        return '(' + outtype + ')in[' + v0 + ']'
    100100
    101101def line( intype, outtype, ptr, v0, v1 ):
    102     print '      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
    103     print '      (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
     102    print ('      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
     103    print ('      (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';')
    104104
    105105# XXX: have the opportunity here to avoid over-drawing shared lines in
    106106# tristrips, fans, etc, by integrating this into the calling functions
     
    124124        return 'translate_' + prim + '_' + intype + '2' + outtype
    125125
    126126def preamble(intype, outtype, prim):
    127     print 'static void ' + name( intype, outtype, prim ) + '('
     127    print ('static void ' + name( intype, outtype, prim ) + '(')
    128128    if intype != GENERATE:
    129         print '    const void * _in,'
    130     print '    unsigned nr,'
    131     print '    void *_out )'
    132     print '{'
     129        print ('    const void * _in,')
     130    print ('    unsigned nr,')
     131    print ('    void *_out )')
     132    print ('{')
    133133    if intype != GENERATE:
    134         print '  const ' + intype + '*in = (const ' + intype + '*)_in;'
    135     print '  ' + outtype + ' *out = (' + outtype + '*)_out;'
    136     print '  unsigned i, j;'
    137     print '  (void)j;'
     134        print ('  const ' + intype + '*in = (const ' + intype + '*)_in;')
     135    print ('  ' + outtype + ' *out = (' + outtype + '*)_out;')
     136    print ('  unsigned i, j;')
     137    print ('  (void)j;')
    138138
    139139def postamble():
    140     print '}'
     140    print ('}')
    141141
    142142
    143143def tris(intype, outtype):
    144144    preamble(intype, outtype, prim='tris')
    145     print '  for (j = i = 0; j < nr; j+=6, i+=3) { '
     145    print ('  for (j = i = 0; j < nr; j+=6, i+=3) { ')
    146146    do_tri( intype, outtype, 'out+j',  'i', 'i+1', 'i+2' );
    147     print '   }'
     147    print ('   }')
    148148    postamble()
    149149
    150150
    151151def tristrip(intype, outtype):
    152152    preamble(intype, outtype, prim='tristrip')
    153     print '  for (j = i = 0; j < nr; j+=6, i++) { '
     153    print ('  for (j = i = 0; j < nr; j+=6, i++) { ')
    154154    do_tri( intype, outtype, 'out+j',  'i', 'i+1/*+(i&1)*/', 'i+2/*-(i&1)*/' );
    155     print '   }'
     155    print ('   }')
    156156    postamble()
    157157
    158158
    159159def trifan(intype, outtype):
    160160    preamble(intype, outtype, prim='trifan')
    161     print '  for (j = i = 0; j < nr; j+=6, i++) { '
     161    print ('  for (j = i = 0; j < nr; j+=6, i++) { ')
    162162    do_tri( intype, outtype, 'out+j',  '0', 'i+1', 'i+2' );
    163     print '   }'
     163    print ('   }')
    164164    postamble()
    165165
    166166
    167167
    168168def polygon(intype, outtype):
    169169    preamble(intype, outtype, prim='polygon')
    170     print '  for (j = i = 0; j < nr; j+=6, i++) { '
     170    print ('  for (j = i = 0; j < nr; j+=6, i++) { ')
    171171    do_tri( intype, outtype, 'out+j',  '0', 'i+1', 'i+2' );
    172     print '   }'
     172    print ('   }')
    173173    postamble()
    174174
    175175
    176176def quads(intype, outtype):
    177177    preamble(intype, outtype, prim='quads')
    178     print '  for (j = i = 0; j < nr; j+=8, i+=4) { '
     178    print ('  for (j = i = 0; j < nr; j+=8, i+=4) { ')
    179179    do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3' );
    180     print '   }'
     180    print ('   }')
    181181    postamble()
    182182
    183183
    184184def quadstrip(intype, outtype):
    185185    preamble(intype, outtype, prim='quadstrip')
    186     print '  for (j = i = 0; j < nr; j+=8, i+=2) { '
     186    print ('  for (j = i = 0; j < nr; j+=8, i+=2) { ')
    187187    do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3' );
    188     print '   }'
     188    print ('   }')
    189189    postamble()
    190190
    191191
     
    220220                init(intype, outtype, prim)
    221221
    222222def emit_init():
    223     print 'void u_unfilled_init( void )'
    224     print '{'
    225     print '  static int firsttime = 1;'
    226     print '  if (!firsttime) return;'
    227     print '  firsttime = 0;'
     223    print ('void u_unfilled_init( void )')
     224    print ('{')
     225    print ('  static int firsttime = 1;')
     226    print ('  if (!firsttime) return;')
     227    print ('  firsttime = 0;')
    228228    emit_all_inits()
    229     print '}'
     229    print ('}')
    230230
    231231
    232232   
    233233
    234234def epilog():
    235     print '#include "indices/u_unfilled_indices.c"'
     235    print ('#include "indices/u_unfilled_indices.c"')
    236236
    237237
    238238def main():
  • Mesa-7.8.2/src/gallium/auxiliary/util/u_format_access.py

    old new  
    9696
    9797
    9898def generate_srgb_tables():
    99     print 'static ubyte srgb_to_linear[256] = {'
     99    print ('static ubyte srgb_to_linear[256] = {')
    100100    for i in range(256):
    101         print '   %s,' % (int(math.pow((i / 255.0 + 0.055) / 1.055, 2.4) * 255))
    102     print '};'
    103     print
    104     print 'static ubyte linear_to_srgb[256] = {'
    105     print '   0,'
     101        print ('   %s,' % (int(math.pow((i / 255.0 + 0.055) / 1.055, 2.4) * 255)))
     102    print ('};')
     103    print ('')
     104    print ('static ubyte linear_to_srgb[256] = {')
     105    print ('   0,')
    106106    for i in range(1, 256):
    107         print '   %s,' % (int((1.055 * math.pow(i / 255.0, 0.41666) - 0.055) * 255))
    108     print '};'
    109     print
     107        print ('   %s,' % (int((1.055 * math.pow(i / 255.0, 0.41666) - 0.055) * 255)))
     108    print ('};')
     109    print ('')
    110110
    111111
    112112def generate_format_read(format, dst_channel, dst_native_type, dst_suffix):
     
    116116
    117117    src_native_type = native_type(format)
    118118
    119     print 'static void'
    120     print 'util_format_%s_read_%s(%s *dst, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, dst_suffix, dst_native_type)
    121     print '{'
    122     print '   unsigned x, y;'
    123     print '   const uint8_t *src_row = src + y0*src_stride;'
    124     print '   %s *dst_row = dst;' % dst_native_type
    125     print '   for (y = 0; y < h; ++y) {'
    126     print '      const %s *src_pixel = (const %s *)(src_row + x0*%u);' % (src_native_type, src_native_type, format.stride())
    127     print '      %s *dst_pixel = dst_row;' %dst_native_type
    128     print '      for (x = 0; x < w; ++x) {'
     119    print ('static void')
     120    print ('util_format_%s_read_%s(%s *dst, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, dst_suffix, dst_native_type))
     121    print ('{')
     122    print ('   unsigned x, y;')
     123    print ('   const uint8_t *src_row = src + y0*src_stride;')
     124    print ('   %s *dst_row = dst;' % dst_native_type)
     125    print ('   for (y = 0; y < h; ++y) {')
     126    print ('      const %s *src_pixel = (const %s *)(src_row + x0*%u);' % (src_native_type, src_native_type, format.stride()))
     127    print ('      %s *dst_pixel = dst_row;' %dst_native_type)
     128    print ('      for (x = 0; x < w; ++x) {')
    129129
    130130    names = ['']*4
    131131    if format.colorspace == 'rgb':
     
    144144
    145145    if format.layout == PLAIN:
    146146        if not format.is_array():
    147             print '         %s pixel = *src_pixel++;' % src_native_type
     147            print ('         %s pixel = *src_pixel++;' % src_native_type)
    148148            shift = 0;
    149149            for i in range(4):
    150150                src_channel = format.channels[i]
     
    157157                    if shift + width < format.block_size():
    158158                        value = '(%s & 0x%x)' % (value, mask)
    159159                    value = conversion_expr(src_channel, dst_channel, dst_native_type, value)
    160                     print '         %s %s = %s;' % (dst_native_type, names[i], value)
     160                    print ('         %s %s = %s;' % (dst_native_type, names[i], value))
    161161                shift += width
    162162        else:
    163163            for i in range(4):
     
    165165                if names[i]:
    166166                    value = 'src_pixel[%u]' % i
    167167                    value = conversion_expr(src_channel, dst_channel, dst_native_type, value)
    168                     print '         %s %s = %s;' % (dst_native_type, names[i], value)
    169             print '         src_pixel += %u;' % (format.nr_channels())
     168                    print ('         %s %s = %s;' % (dst_native_type, names[i], value))
     169            print ('         src_pixel += %u;' % (format.nr_channels()))
    170170    else:
    171171        assert False
    172172
     
    188188                value = get_one(dst_channel)
    189189        else:
    190190            assert False
    191         print '         *dst_pixel++ = %s; /* %s */' % (value, 'rgba'[i])
     191        print ('         *dst_pixel++ = %s; /* %s */' % (value, 'rgba'[i]))
    192192
    193     print '      }'
    194     print '      src_row += src_stride;'
    195     print '      dst_row += dst_stride/sizeof(*dst_row);'
    196     print '   }'
    197     print '}'
    198     print
     193    print ('      }')
     194    print ('      src_row += src_stride;')
     195    print ('      dst_row += dst_stride/sizeof(*dst_row);')
     196    print ('   }')
     197    print ('}')
     198    print ('')
    199199   
    200200
    201201def generate_format_write(format, src_channel, src_native_type, src_suffix):
     
    205205
    206206    dst_native_type = native_type(format)
    207207
    208     print 'static void'
    209     print 'util_format_%s_write_%s(const %s *src, unsigned src_stride, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, src_suffix, src_native_type)
    210     print '{'
    211     print '   unsigned x, y;'
    212     print '   uint8_t *dst_row = dst + y0*dst_stride;'
    213     print '   const %s *src_row = src;' % src_native_type
    214     print '   for (y = 0; y < h; ++y) {'
    215     print '      %s *dst_pixel = (%s *)(dst_row + x0*%u);' % (dst_native_type, dst_native_type, format.stride())
    216     print '      const %s *src_pixel = src_row;' %src_native_type
    217     print '      for (x = 0; x < w; ++x) {'
     208    print ('static void')
     209    print ('util_format_%s_write_%s(const %s *src, unsigned src_stride, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, src_suffix, src_native_type))
     210    print ('{')
     211    print ('   unsigned x, y;')
     212    print ('   uint8_t *dst_row = dst + y0*dst_stride;')
     213    print ('   const %s *src_row = src;' % src_native_type)
     214    print ('   for (y = 0; y < h; ++y) {')
     215    print ('      %s *dst_pixel = (%s *)(dst_row + x0*%u);' % (dst_native_type, dst_native_type, format.stride()))
     216    print ('      const %s *src_pixel = src_row;' %src_native_type)
     217    print ('      for (x = 0; x < w; ++x) {')
    218218
    219219    inv_swizzle = format.inv_swizzles()
    220220
    221221    if format.layout == PLAIN:
    222222        if not format.is_array():
    223             print '         %s pixel = 0;' % dst_native_type
     223            print ('         %s pixel = 0;' % dst_native_type)
    224224            shift = 0;
    225225            for i in range(4):
    226226                dst_channel = format.channels[i]
     
    230230                    value = conversion_expr(src_channel, dst_channel, dst_native_type, value)
    231231                    if shift:
    232232                        value = '(%s << %u)' % (value, shift)
    233                     print '         pixel |= %s;' % value
     233                    print ('         pixel |= %s;' % value)
    234234                shift += width
    235             print '         *dst_pixel++ = pixel;'
     235            print ('         *dst_pixel++ = pixel;')
    236236        else:
    237237            for i in range(4):
    238238                dst_channel = format.channels[i]
    239239                if inv_swizzle[i] is not None:
    240240                    value = 'src_pixel[%u]' % inv_swizzle[i]
    241241                    value = conversion_expr(src_channel, dst_channel, dst_native_type, value)
    242                     print '         *dst_pixel++ = %s;' % value
     242                    print ('         *dst_pixel++ = %s;' % value)
    243243    else:
    244244        assert False
    245     print '         src_pixel += 4;'
     245    print ('         src_pixel += 4;')
    246246
    247     print '      }'
    248     print '      dst_row += dst_stride;'
    249     print '      src_row += src_stride/sizeof(*src_row);'
    250     print '   }'
    251     print '}'
    252     print
     247    print ('      }')
     248    print ('      dst_row += dst_stride;')
     249    print ('      src_row += src_stride/sizeof(*src_row);')
     250    print ('   }')
     251    print ('}')
     252    print ('')
    253253   
    254254
    255255def generate_read(formats, dst_channel, dst_native_type, dst_suffix):
     
    259259        if is_format_supported(format):
    260260            generate_format_read(format, dst_channel, dst_native_type, dst_suffix)
    261261
    262     print 'void'
    263     print 'util_format_read_%s(enum pipe_format format, %s *dst, unsigned dst_stride, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type)
    264     print '{'
    265     print '   void (*func)(%s *dst, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % dst_native_type
    266     print '   switch(format) {'
     262    print ('void')
     263    print ('util_format_read_%s(enum pipe_format format, %s *dst, unsigned dst_stride, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type))
     264    print ('{')
     265    print ('   void (*func)(%s *dst, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % dst_native_type)
     266    print ('   switch(format) {')
    267267    for format in formats:
    268268        if is_format_supported(format):
    269             print '   case %s:' % format.name
    270             print '      func = &util_format_%s_read_%s;' % (format.short_name(), dst_suffix)
    271             print '      break;'
    272     print '   default:'
    273     print '      debug_printf("unsupported format\\n");'
    274     print '      return;'
    275     print '   }'
    276     print '   func(dst, dst_stride, (const uint8_t *)src, src_stride, x, y, w, h);'
    277     print '}'
    278     print
     269            print ('   case %s:' % format.name)
     270            print ('      func = &util_format_%s_read_%s;' % (format.short_name(), dst_suffix))
     271            print ('      break;')
     272    print ('   default:')
     273    print ('      debug_printf("unsupported format\\n");')
     274    print ('      return;')
     275    print ('   }')
     276    print ('   func(dst, dst_stride, (const uint8_t *)src, src_stride, x, y, w, h);')
     277    print ('}')
     278    print ('')
    279279
    280280
    281281def generate_write(formats, src_channel, src_native_type, src_suffix):
     
    285285        if is_format_supported(format):
    286286            generate_format_write(format, src_channel, src_native_type, src_suffix)
    287287
    288     print 'void'
    289     print 'util_format_write_%s(enum pipe_format format, const %s *src, unsigned src_stride, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type)
     288    print ('void')
     289    print ('util_format_write_%s(enum pipe_format format, const %s *src, unsigned src_stride, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type))
    290290   
    291     print '{'
    292     print '   void (*func)(const %s *src, unsigned src_stride, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % src_native_type
    293     print '   switch(format) {'
     291    print ('{')
     292    print ('   void (*func)(const %s *src, unsigned src_stride, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % src_native_type)
     293    print ('   switch(format) {')
    294294    for format in formats:
    295295        if is_format_supported(format):
    296             print '   case %s:' % format.name
    297             print '      func = &util_format_%s_write_%s;' % (format.short_name(), src_suffix)
    298             print '      break;'
    299     print '   default:'
    300     print '      debug_printf("unsupported format\\n");'
    301     print '      return;'
    302     print '   }'
    303     print '   func(src, src_stride, (uint8_t *)dst, dst_stride, x, y, w, h);'
    304     print '}'
    305     print
     296            print ('   case %s:' % format.name)
     297            print ('      func = &util_format_%s_write_%s;' % (format.short_name(), src_suffix))
     298            print ('      break;')
     299    print ('   default:')
     300    print ('      debug_printf("unsupported format\\n");')
     301    print ('      return;')
     302    print ('   }')
     303    print ('   func(src, src_stride, (uint8_t *)dst, dst_stride, x, y, w, h);')
     304    print ('}')
     305    print ('')
    306306
    307307
    308308def main():
     
    310310    for arg in sys.argv[1:]:
    311311        formats.extend(parse(arg))
    312312
    313     print '/* This file is autogenerated by u_format_access.py from u_format.csv. Do not edit directly. */'
    314     print
     313    print ('/* This file is autogenerated by u_format_access.py from u_format.csv. Do not edit directly. */')
     314    print ('')
    315315    # This will print the copyright message on the top of this file
    316     print __doc__.strip()
    317     print
    318     print '#include "pipe/p_compiler.h"'
    319     print '#include "u_math.h"'
    320     print '#include "u_format_pack.h"'
    321     print
     316    print (__doc__.strip())
     317    print ('')
     318    print ('#include "pipe/p_compiler.h"')
     319    print ('#include "u_math.h"')
     320    print ('#include "u_format_pack.h"')
     321    print ('')
    322322
    323323    generate_srgb_tables()
    324324
  • Mesa-7.8.2/src/gallium/auxiliary/util/u_format_pack.py

    old new  
    4545def generate_format_type(format):
    4646    '''Generate a structure that describes the format.'''
    4747
    48     print 'union util_format_%s {' % format.short_name()
     48    print ('union util_format_%s {' % format.short_name())
    4949    if format.is_bitmask():
    50         print '   uint%u_t value;' % (format.block_size(),)
    51     print '   struct {'
     50        print ('   uint%u_t value;' % (format.block_size(),))
     51    print ('   struct {')
    5252    for channel in format.channels:
    5353        if format.is_bitmask() and not format.is_array():
    5454            if channel.type == VOID:
    5555                if channel.size:
    56                     print '      unsigned %s:%u;' % (channel.name, channel.size)
     56                    print ('      unsigned %s:%u;' % (channel.name, channel.size))
    5757            elif channel.type == UNSIGNED:
    58                 print '      unsigned %s:%u;' % (channel.name, channel.size)
     58                print ('      unsigned %s:%u;' % (channel.name, channel.size))
    5959            elif channel.type == SIGNED:
    60                 print '      int %s:%u;' % (channel.name, channel.size)
     60                print ('      int %s:%u;' % (channel.name, channel.size))
    6161            else:
    6262                assert 0
    6363        else:
    6464            assert channel.size % 8 == 0 and is_pot(channel.size)
    6565            if channel.type == VOID:
    6666                if channel.size:
    67                     print '      uint%u_t %s;' % (channel.size, channel.name)
     67                    print ('      uint%u_t %s;' % (channel.size, channel.name))
    6868            elif channel.type == UNSIGNED:
    69                 print '      uint%u_t %s;' % (channel.size, channel.name)
     69                print ('      uint%u_t %s;' % (channel.size, channel.name))
    7070            elif channel.type in (SIGNED, FIXED):
    71                 print '      int%u_t %s;' % (channel.size, channel.name)
     71                print ('      int%u_t %s;' % (channel.size, channel.name))
    7272            elif channel.type == FLOAT:
    7373                if channel.size == 64:
    74                     print '      double %s;' % (channel.name)
     74                    print ('      double %s;' % (channel.name))
    7575                elif channel.size == 32:
    76                     print '      float %s;' % (channel.name)
     76                    print ('      float %s;' % (channel.name))
    7777                elif channel.size == 16:
    78                     print '      uint16_t %s;' % (channel.name)
     78                    print ('      uint16_t %s;' % (channel.name))
    7979                else:
    8080                    assert 0
    8181            else:
    8282                assert 0
    83     print '   } chan;'
    84     print '};'
    85     print
     83    print ('   } chan;')
     84    print ('};')
     85    print ('')
    8686
    8787
    8888def bswap_format(format):
    8989    '''Generate a structure that describes the format.'''
    9090
    9191    if format.is_bitmask() and not format.is_array():
    92         print '#ifdef PIPE_ARCH_BIG_ENDIAN'
    93         print '   pixel.value = util_bswap%u(pixel.value);' % format.block_size()
    94         print '#endif'
     92        print ('#ifdef PIPE_ARCH_BIG_ENDIAN')
     93        print ('   pixel.value = util_bswap%u(pixel.value);' % format.block_size())
     94        print ('#endif')
    9595
    9696
    9797def is_format_supported(format):
     
    192192        ('ui', 'unsigned int'),
    193193        ('si', 'int'),
    194194    ]:
    195         print 'static INLINE %s' % native_type
    196         print 'clamp%s(%s value, %s lbound, %s ubound)' % (suffix, native_type, native_type, native_type)
    197         print '{'
    198         print '   if(value < lbound)'
    199         print '      return lbound;'
    200         print '   if(value > ubound)'
    201         print '      return ubound;'
    202         print '   return value;'
    203         print '}'
    204         print
     195        print ('static INLINE %s' % native_type)
     196        print ('clamp%s(%s value, %s lbound, %s ubound)' % (suffix, native_type, native_type, native_type))
     197        print ('{')
     198        print ('   if(value < lbound)')
     199        print ('      return lbound;')
     200        print ('   if(value > ubound)')
     201        print ('      return ubound;')
     202        print ('   return value;')
     203        print ('}')
     204        print ('')
    205205
    206206
    207207def clamp_expr(src_channel, dst_channel, dst_native_type, value):
     
    311311
    312312    src_native_type = native_type(format)
    313313
    314     print 'static INLINE void'
    315     print 'util_format_%s_unpack_%s(%s *dst, const void *src)' % (name, dst_suffix, dst_native_type)
    316     print '{'
    317     print '   union util_format_%s pixel;' % format.short_name()
    318     print '   memcpy(&pixel, src, sizeof pixel);'
     314    print ('static INLINE void')
     315    print ('util_format_%s_unpack_%s(%s *dst, const void *src)' % (name, dst_suffix, dst_native_type))
     316    print ('{')
     317    print ('   union util_format_%s pixel;' % format.short_name())
     318    print ('   memcpy(&pixel, src, sizeof pixel);')
    319319    bswap_format(format)
    320320
    321321    assert format.layout == PLAIN
     
    339339                value = get_one(dst_channel)
    340340            elif i >= 1:
    341341                value = 'dst[0]'
    342         print '   dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
     342        print ('   dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]))
    343343
    344     print '}'
    345     print
     344    print ('}')
     345    print ('')
    346346   
    347347
    348348def generate_format_pack(format, src_channel, src_native_type, src_suffix):
     
    352352
    353353    dst_native_type = native_type(format)
    354354
    355     print 'static INLINE void'
    356     print 'util_format_%s_pack_%s(void *dst, %s r, %s g, %s b, %s a)' % (name, src_suffix, src_native_type, src_native_type, src_native_type, src_native_type)
    357     print '{'
    358     print '   union util_format_%s pixel;' % format.short_name()
     355    print ('static INLINE void')
     356    print ('util_format_%s_pack_%s(void *dst, %s r, %s g, %s b, %s a)' % (name, src_suffix, src_native_type, src_native_type, src_native_type, src_native_type))
     357    print ('{')
     358    print ('   union util_format_%s pixel;' % format.short_name())
    359359
    360360    assert format.layout == PLAIN
    361361
     
    373373                value = get_one(dst_channel)
    374374            elif i >= 1:
    375375                value = '0'
    376         print '   pixel.chan.%s = %s;' % (dst_channel.name, value)
     376        print ('   pixel.chan.%s = %s;' % (dst_channel.name, value))
    377377
    378378    bswap_format(format)
    379     print '   memcpy(dst, &pixel, sizeof pixel);'
    380     print '}'
    381     print
     379    print ('   memcpy(dst, &pixel, sizeof pixel);')
     380    print ('}')
     381    print ('')
    382382   
    383383
    384384def generate_unpack(formats, dst_channel, dst_native_type, dst_suffix):
     
    388388        if is_format_supported(format):
    389389            generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix)
    390390
    391     print 'static INLINE void'
    392     print 'util_format_unpack_%s(enum pipe_format format, %s *dst, const void *src)' % (dst_suffix, dst_native_type)
    393     print '{'
    394     print '   void (*func)(%s *dst, const void *src);' % dst_native_type
    395     print '   switch(format) {'
     391    print ('static INLINE void')
     392    print ('util_format_unpack_%s(enum pipe_format format, %s *dst, const void *src)' % (dst_suffix, dst_native_type))
     393    print ('{')
     394    print ('   void (*func)(%s *dst, const void *src);' % dst_native_type)
     395    print ('   switch(format) {')
    396396    for format in formats:
    397397        if is_format_supported(format):
    398             print '   case %s:' % format.name
    399             print '      func = &util_format_%s_unpack_%s;' % (format.short_name(), dst_suffix)
    400             print '      break;'
    401     print '   default:'
    402     print '      debug_printf("unsupported format\\n");'
    403     print '      return;'
    404     print '   }'
    405     print '   func(dst, src);'
    406     print '}'
    407     print
     398            print ('   case %s:' % format.name)
     399            print ('      func = &util_format_%s_unpack_%s;' % (format.short_name(), dst_suffix))
     400            print ('      break;')
     401    print ('   default:')
     402    print ('      debug_printf("unsupported format\\n");')
     403    print ('      return;')
     404    print ('   }')
     405    print ('   func(dst, src);')
     406    print ('}')
     407    print ('')
    408408
    409409
    410410def generate_pack(formats, src_channel, src_native_type, src_suffix):
     
    414414        if is_format_supported(format):
    415415            generate_format_pack(format, src_channel, src_native_type, src_suffix)
    416416
    417     print 'static INLINE void'
    418     print 'util_format_pack_%s(enum pipe_format format, void *dst, %s r, %s g, %s b, %s a)' % (src_suffix, src_native_type, src_native_type, src_native_type, src_native_type)
    419     print '{'
    420     print '   void (*func)(void *dst, %s r, %s g, %s b, %s a);' % (src_native_type, src_native_type, src_native_type, src_native_type)
    421     print '   switch(format) {'
     417    print ('static INLINE void')
     418    print ('util_format_pack_%s(enum pipe_format format, void *dst, %s r, %s g, %s b, %s a)' % (src_suffix, src_native_type, src_native_type, src_native_type, src_native_type))
     419    print ('{')
     420    print ('   void (*func)(void *dst, %s r, %s g, %s b, %s a);' % (src_native_type, src_native_type, src_native_type, src_native_type))
     421    print ('   switch(format) {')
    422422    for format in formats:
    423423        if is_format_supported(format):
    424             print '   case %s:' % format.name
    425             print '      func = &util_format_%s_pack_%s;' % (format.short_name(), src_suffix)
    426             print '      break;'
    427     print '   default:'
    428     print '      debug_printf("%s: unsupported format\\n", __FUNCTION__);'
    429     print '      return;'
    430     print '   }'
    431     print '   func(dst, r, g, b, a);'
    432     print '}'
    433     print
     424            print ('   case %s:' % format.name)
     425            print ('      func = &util_format_%s_pack_%s;' % (format.short_name(), src_suffix))
     426            print ('      break;')
     427    print ('   default:')
     428    print ('      debug_printf("%s: unsupported format\\n", __FUNCTION__);')
     429    print ('      return;')
     430    print ('   }')
     431    print ('   func(dst, r, g, b, a);')
     432    print ('}')
     433    print ('')
    434434
    435435
    436436def main():
     
    438438    for arg in sys.argv[1:]:
    439439        formats.extend(parse(arg))
    440440
    441     print '/* This file is autogenerated by u_format_pack.py from u_format.csv. Do not edit directly. */'
    442     print
     441    print ('/* This file is autogenerated by u_format_pack.py from u_format.csv. Do not edit directly. */')
     442    print ('')
    443443    # This will print the copyright message on the top of this file
    444     print __doc__.strip()
     444    print (__doc__.strip())
    445445
    446     print
    447     print '#ifndef U_FORMAT_PACK_H'
    448     print '#define U_FORMAT_PACK_H'
    449     print
    450     print '#include "pipe/p_compiler.h"'
    451     print '#include "u_math.h"'
    452     print '#include "u_format.h"'
    453     print
     446    print ('')
     447    print ('#ifndef U_FORMAT_PACK_H')
     448    print ('#define U_FORMAT_PACK_H')
     449    print ('')
     450    print ('#include "pipe/p_compiler.h"')
     451    print ('#include "u_math.h"')
     452    print ('#include "u_format.h"')
     453    print ('')
    454454
    455455    generate_clamp()
    456456
     
    472472    generate_unpack(formats, channel, native_type, suffix)
    473473    generate_pack(formats, channel, native_type, suffix)
    474474
    475     print
    476     print '#ifdef __cplusplus'
    477     print '}'
    478     print '#endif'
    479     print
    480     print '#endif /* ! U_FORMAT_PACK_H */'
     475    print ('')
     476    print ('#ifdef __cplusplus')
     477    print ('}')
     478    print ('#endif')
     479    print ('')
     480    print ('#endif /* ! U_FORMAT_PACK_H */')
    481481
    482482
    483483if __name__ == '__main__':
  • Mesa-7.8.2/src/gallium/auxiliary/util/u_format_table.py

    old new  
    7979
    8080
    8181def write_format_table(formats):
    82     print '/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */'
    83     print
     82    print ('/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */')
     83    print ('')
    8484    # This will print the copyright message on the top of this file
    85     print __doc__.strip()
    86     print
    87     print '#include "u_format.h"'
    88     print
    89     print 'const struct util_format_description'
    90     print 'util_format_none_description = {'
    91     print "   PIPE_FORMAT_NONE,"
    92     print "   \"PIPE_FORMAT_NONE\","
    93     print "   {0, 0, 0},"
    94     print "   0,"
    95     print "   0,"
    96     print "   0,"
    97     print "   0,"
    98     print "   {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},"
    99     print "   {0, 0, 0, 0},"
    100     print "   0"
    101     print "};"
    102     print
     85    print (__doc__.strip())
     86    print ('')
     87    print ('#include "u_format.h"')
     88    print ('')
     89    print ('const struct util_format_description')
     90    print ('util_format_none_description = {')
     91    print ("   PIPE_FORMAT_NONE,")
     92    print ("   \"PIPE_FORMAT_NONE\",")
     93    print ("   {0, 0, 0},")
     94    print ("   0,")
     95    print ("   0,")
     96    print ("   0,")
     97    print ("   0,")
     98    print ("   {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},")
     99    print ("   {0, 0, 0, 0},")
     100    print ("   0")
     101    print ("};")
     102    print ('')
    103103    for format in formats:
    104         print 'const struct util_format_description'
    105         print 'util_format_%s_description = {' % (format.short_name(),)
    106         print "   %s," % (format.name,)
    107         print "   \"%s\"," % (format.name,)
    108         print "   {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size())
    109         print "   %s," % (layout_map(format.layout),)
    110         print "   %u,\t/* nr_channels */" % (format.nr_channels(),)
    111         print "   %s,\t/* is_array */" % (bool_map(format.is_array()),)
    112         print "   %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),)
    113         print "   {"
     104        print ('const struct util_format_description')
     105        print ('util_format_%s_description = {' % (format.short_name(),))
     106        print ("   %s," % (format.name,))
     107        print ("   \"%s\"," % (format.name,))
     108        print ("   {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()))
     109        print ("   %s," % (layout_map(format.layout),))
     110        print ("   %u,\t/* nr_channels */" % (format.nr_channels(),))
     111        print ("   %s,\t/* is_array */" % (bool_map(format.is_array()),))
     112        print ("   %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),))
     113        print ("   {")
    114114        for i in range(4):
    115115            channel = format.channels[i]
    116116            if i < 3:
     
    118118            else:
    119119                sep = ""
    120120            if channel.size:
    121                 print "      {%s, %s, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), channel.size, sep, "xyzw"[i], channel.name)
     121                print ("      {%s, %s, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), channel.size, sep, "xyzw"[i], channel.name))
    122122            else:
    123                 print "      {0, 0, 0}%s" % (sep,)
    124         print "   },"
    125         print "   {"
     123                print ("      {0, 0, 0}%s" % (sep,))
     124        print ("   },")
     125        print ("   {")
    126126        for i in range(4):
    127127            swizzle = format.swizzles[i]
    128128            if i < 3:
     
    133133                comment = colorspace_channels_map[format.colorspace][i]
    134134            except (KeyError, IndexError):
    135135                comment = 'ignored'
    136             print "      %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment)
    137         print "   },"
    138         print "   %s," % (colorspace_map(format.colorspace),)
    139         print "};"
    140         print
    141     print "const struct util_format_description *"
    142     print "util_format_description(enum pipe_format format)"
    143     print "{"
    144     print "   if (format >= PIPE_FORMAT_COUNT) {"
    145     print "      return NULL;"
    146     print "   }"
    147     print
    148     print "   switch (format) {"
    149     print "   case PIPE_FORMAT_NONE:"
    150     print "      return &util_format_none_description;"
     136            print ("      %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment))
     137        print ("   },")
     138        print ("   %s," % (colorspace_map(format.colorspace),))
     139        print ("};")
     140        print ('')
     141    print ("const struct util_format_description *")
     142    print ("util_format_description(enum pipe_format format)")
     143    print ("{")
     144    print ("   if (format >= PIPE_FORMAT_COUNT) {")
     145    print ("      return NULL;")
     146    print ("   }")
     147    print ('')
     148    print ("   switch (format) {")
     149    print ("   case PIPE_FORMAT_NONE:")
     150    print ("      return &util_format_none_description;")
    151151    for format in formats:
    152         print "   case %s:" % format.name
    153         print "      return &util_format_%s_description;" % (format.short_name(),)
    154     print "   default:"
    155     print "      assert(0);"
    156     print "      return NULL;"
    157     print "   }"
    158     print "}"
    159     print
     152        print ("   case %s:" % format.name)
     153        print ("      return &util_format_%s_description;" % (format.short_name(),))
     154    print ("   default:")
     155    print ("      assert(0);")
     156    print ("      return NULL;")
     157    print ("   }")
     158    print ("}")
     159    print ('')
    160160
    161161
    162162def main():
  • Mesa-7.8.2/src/gallium/drivers/llvmpipe/lp_tile_soa.py

    old new  
    5252
    5353    src_native_type = native_type(format)
    5454
    55     print 'static void'
    56     print 'lp_tile_%s_read_%s(%s *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, dst_suffix, dst_native_type)
    57     print '{'
    58     print '   unsigned x, y;'
    59     print '   const uint8_t *src_row = src + y0*src_stride;'
    60     print '   for (y = 0; y < h; ++y) {'
    61     print '      const %s *src_pixel = (const %s *)(src_row + x0*%u);' % (src_native_type, src_native_type, format.stride())
    62     print '      for (x = 0; x < w; ++x) {'
     55    print ('static void')
     56    print ('lp_tile_%s_read_%s(%s *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, dst_suffix, dst_native_type))
     57    print ('{')
     58    print ('   unsigned x, y;')
     59    print ('   const uint8_t *src_row = src + y0*src_stride;')
     60    print ('   for (y = 0; y < h; ++y) {')
     61    print ('      const %s *src_pixel = (const %s *)(src_row + x0*%u);' % (src_native_type, src_native_type, format.stride()))
     62    print ('      for (x = 0; x < w; ++x) {')
    6363
    6464    names = ['']*4
    6565    if format.colorspace == 'rgb':
     
    7878
    7979    if format.layout == PLAIN:
    8080        if not format.is_array():
    81             print '         %s pixel = *src_pixel++;' % src_native_type
     81            print ('         %s pixel = *src_pixel++;' % src_native_type)
    8282            shift = 0;
    8383            for i in range(4):
    8484                src_channel = format.channels[i]
     
    9191                    if shift + width < format.block_size():
    9292                        value = '(%s & 0x%x)' % (value, mask)
    9393                    value = conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=False)
    94                     print '         %s %s = %s;' % (dst_native_type, names[i], value)
     94                    print ('         %s %s = %s;' % (dst_native_type, names[i], value))
    9595                shift += width
    9696        else:
    9797            for i in range(4):
     
    9999                if names[i]:
    100100                    value = '(*src_pixel++)'
    101101                    value = conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=False)
    102                     print '         %s %s = %s;' % (dst_native_type, names[i], value)
     102                    print ('         %s %s = %s;' % (dst_native_type, names[i], value))
    103103    else:
    104104        assert False
    105105
     
    121121                value = get_one(dst_channel)
    122122        else:
    123123            assert False
    124         print '         TILE_PIXEL(dst, x, y, %u) = %s; /* %s */' % (i, value, 'rgba'[i])
     124        print ('         TILE_PIXEL(dst, x, y, %u) = %s; /* %s */' % (i, value, 'rgba'[i]))
    125125
    126     print '      }'
    127     print '      src_row += src_stride;'
    128     print '   }'
    129     print '}'
    130     print
     126    print ('      }')
     127    print ('      src_row += src_stride;')
     128    print ('   }')
     129    print ('}')
     130    print ('')
    131131   
    132132
    133133def pack_rgba(format, src_channel, r, g, b, a):
     
    171171    This is considerably faster than the TILE_PIXEL-based code below.
    172172    '''
    173173    dst_native_type = 'uint%u_t' % format.block_size()
    174     print '   const unsigned dstpix_stride = dst_stride / %d;' % format.stride()
    175     print '   %s *dstpix = (%s *) dst;' % (dst_native_type, dst_native_type)
    176     print '   unsigned int qx, qy, i;'
    177     print
    178     print '   for (qy = 0; qy < h; qy += TILE_VECTOR_HEIGHT) {'
    179     print '      const unsigned py = y0 + qy;'
    180     print '      for (qx = 0; qx < w; qx += TILE_VECTOR_WIDTH) {'
    181     print '         const unsigned px = x0 + qx;'
    182     print '         const uint8_t *r = src + 0 * TILE_C_STRIDE;'
    183     print '         const uint8_t *g = src + 1 * TILE_C_STRIDE;'
    184     print '         const uint8_t *b = src + 2 * TILE_C_STRIDE;'
    185     print '         const uint8_t *a = src + 3 * TILE_C_STRIDE;'
    186     print '         (void) r; (void) g; (void) b; (void) a; /* silence warnings */'
    187     print '         for (i = 0; i < TILE_C_STRIDE; i += 2) {'
    188     print '            const uint32_t pixel0 = %s;' % pack_rgba(format, src_channel, "r[i+0]", "g[i+0]", "b[i+0]", "a[i+0]")
    189     print '            const uint32_t pixel1 = %s;' % pack_rgba(format, src_channel, "r[i+1]", "g[i+1]", "b[i+1]", "a[i+1]")
    190     print '            const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]);'
    191     print '            dstpix[offset + 0] = pixel0;'
    192     print '            dstpix[offset + 1] = pixel1;'
    193     print '         }'
    194     print '         src += TILE_X_STRIDE;'
    195     print '      }'
    196     print '   }'
     174    print ('   const unsigned dstpix_stride = dst_stride / %d;' % format.stride())
     175    print ('   %s *dstpix = (%s *) dst;' % (dst_native_type, dst_native_type))
     176    print ('   unsigned int qx, qy, i;')
     177    print ('')
     178    print ('   for (qy = 0; qy < h; qy += TILE_VECTOR_HEIGHT) {')
     179    print ('      const unsigned py = y0 + qy;')
     180    print ('      for (qx = 0; qx < w; qx += TILE_VECTOR_WIDTH) {')
     181    print ('         const unsigned px = x0 + qx;')
     182    print ('         const uint8_t *r = src + 0 * TILE_C_STRIDE;')
     183    print ('         const uint8_t *g = src + 1 * TILE_C_STRIDE;')
     184    print ('         const uint8_t *b = src + 2 * TILE_C_STRIDE;')
     185    print ('         const uint8_t *a = src + 3 * TILE_C_STRIDE;')
     186    print ('         (void) r; (void) g; (void) b; (void) a; /* silence warnings */')
     187    print ('         for (i = 0; i < TILE_C_STRIDE; i += 2) {')
     188    print ('            const uint32_t pixel0 = %s;' % pack_rgba(format, src_channel, "r[i+0]", "g[i+0]", "b[i+0]", "a[i+0]"))
     189    print ('            const uint32_t pixel1 = %s;' % pack_rgba(format, src_channel, "r[i+1]", "g[i+1]", "b[i+1]", "a[i+1]"))
     190    print ('            const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]);')
     191    print ('            dstpix[offset + 0] = pixel0;')
     192    print ('            dstpix[offset + 1] = pixel1;')
     193    print ('         }')
     194    print ('         src += TILE_X_STRIDE;')
     195    print ('      }')
     196    print ('   }')
    197197
    198198
    199199def emit_tile_pixel_write_code(format, src_channel):
     
    202202
    203203    inv_swizzle = format.inv_swizzles()
    204204
    205     print '   unsigned x, y;'
    206     print '   uint8_t *dst_row = dst + y0*dst_stride;'
    207     print '   for (y = 0; y < h; ++y) {'
    208     print '      %s *dst_pixel = (%s *)(dst_row + x0*%u);' % (dst_native_type, dst_native_type, format.stride())
    209     print '      for (x = 0; x < w; ++x) {'
     205    print ('   unsigned x, y;')
     206    print ('   uint8_t *dst_row = dst + y0*dst_stride;')
     207    print ('   for (y = 0; y < h; ++y) {')
     208    print ('      %s *dst_pixel = (%s *)(dst_row + x0*%u);' % (dst_native_type, dst_native_type, format.stride()))
     209    print ('      for (x = 0; x < w; ++x) {')
    210210
    211211    if format.layout == PLAIN:
    212212        if not format.is_array():
    213             print '         %s pixel = 0;' % dst_native_type
     213            print ('         %s pixel = 0;' % dst_native_type)
    214214            shift = 0;
    215215            for i in range(4):
    216216                dst_channel = format.channels[i]
     
    220220                    value = conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=False)
    221221                    if shift:
    222222                        value = '(%s << %u)' % (value, shift)
    223                     print '         pixel |= %s;' % value
     223                    print ('         pixel |= %s;' % value)
    224224                shift += width
    225             print '         *dst_pixel++ = pixel;'
     225            print ('         *dst_pixel++ = pixel;')
    226226        else:
    227227            for i in range(4):
    228228                dst_channel = format.channels[i]
    229229                if inv_swizzle[i] is not None:
    230230                    value = 'TILE_PIXEL(src, x, y, %u)' % inv_swizzle[i]
    231231                    value = conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=False)
    232                     print '         *dst_pixel++ = %s;' % value
     232                    print ('         *dst_pixel++ = %s;' % value)
    233233    else:
    234234        assert False
    235235
    236     print '      }'
    237     print '      dst_row += dst_stride;'
    238     print '   }'
     236    print ('      }')
     237    print ('      dst_row += dst_stride;')
     238    print ('   }')
    239239
    240240
    241241def generate_format_write(format, src_channel, src_native_type, src_suffix):
     
    243243
    244244    name = format.short_name()
    245245
    246     print 'static void'
    247     print 'lp_tile_%s_write_%s(const %s *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, src_suffix, src_native_type)
    248     print '{'
     246    print ('static void')
     247    print ('lp_tile_%s_write_%s(const %s *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, src_suffix, src_native_type))
     248    print ('{')
    249249    if format.layout == PLAIN \
    250250        and format.colorspace == 'rgb' \
    251251        and format.block_size() <= 32 \
     
    255255        emit_unrolled_write_code(format, src_channel)
    256256    else:
    257257        emit_tile_pixel_write_code(format, src_channel)
    258     print '}'
    259     print
     258    print ('}')
     259    print ('')
    260260   
    261261
    262262def generate_read(formats, dst_channel, dst_native_type, dst_suffix):
     
    266266        if is_format_supported(format):
    267267            generate_format_read(format, dst_channel, dst_native_type, dst_suffix)
    268268
    269     print 'void'
    270     print 'lp_tile_read_%s(enum pipe_format format, %s *dst, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type)
    271     print '{'
    272     print '   void (*func)(%s *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % dst_native_type
    273     print '   switch(format) {'
     269    print ('void')
     270    print ('lp_tile_read_%s(enum pipe_format format, %s *dst, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type))
     271    print ('{')
     272    print ('   void (*func)(%s *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % dst_native_type)
     273    print ('   switch(format) {')
    274274    for format in formats:
    275275        if is_format_supported(format):
    276             print '   case %s:' % format.name
    277             print '      func = &lp_tile_%s_read_%s;' % (format.short_name(), dst_suffix)
    278             print '      break;'
    279     print '   default:'
    280     print '      debug_printf("unsupported format\\n");'
    281     print '      return;'
    282     print '   }'
    283     print '   func(dst, (const uint8_t *)src, src_stride, x, y, w, h);'
    284     print '}'
    285     print
     276            print ('   case %s:' % format.name)
     277            print ('      func = &lp_tile_%s_read_%s;' % (format.short_name(), dst_suffix))
     278            print ('      break;')
     279    print ('   default:')
     280    print ('      debug_printf("unsupported format\\n");')
     281    print ('      return;')
     282    print ('   }')
     283    print ('   func(dst, (const uint8_t *)src, src_stride, x, y, w, h);')
     284    print ('}')
     285    print ('')
    286286
    287287
    288288def generate_write(formats, src_channel, src_native_type, src_suffix):
     
    292292        if is_format_supported(format):
    293293            generate_format_write(format, src_channel, src_native_type, src_suffix)
    294294
    295     print 'void'
    296     print 'lp_tile_write_%s(enum pipe_format format, const %s *src, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type)
     295    print ('void')
     296    print ('lp_tile_write_%s(enum pipe_format format, const %s *src, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type))
    297297   
    298     print '{'
    299     print '   void (*func)(const %s *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % src_native_type
    300     print '   switch(format) {'
     298    print ('{')
     299    print ('   void (*func)(const %s *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % src_native_type)
     300    print ('   switch(format) {')
    301301    for format in formats:
    302302        if is_format_supported(format):
    303             print '   case %s:' % format.name
    304             print '      func = &lp_tile_%s_write_%s;' % (format.short_name(), src_suffix)
    305             print '      break;'
    306     print '   default:'
    307     print '      debug_printf("unsupported format\\n");'
    308     print '      return;'
    309     print '   }'
    310     print '   func(src, (uint8_t *)dst, dst_stride, x, y, w, h);'
    311     print '}'
    312     print
     303            print ('   case %s:' % format.name)
     304            print ('      func = &lp_tile_%s_write_%s;' % (format.short_name(), src_suffix))
     305            print ('      break;')
     306    print ('   default:')
     307    print ('      debug_printf("unsupported format\\n");')
     308    print ('      return;')
     309    print ('   }')
     310    print ('   func(src, (uint8_t *)dst, dst_stride, x, y, w, h);')
     311    print ('}')
     312    print ('')
    313313
    314314
    315315def main():
     
    317317    for arg in sys.argv[1:]:
    318318        formats.extend(parse(arg))
    319319
    320     print '/* This file is autogenerated by lp_tile_soa.py from u_format.csv. Do not edit directly. */'
    321     print
     320    print ('/* This file is autogenerated by lp_tile_soa.py from u_format.csv. Do not edit directly. */')
     321    print ('')
    322322    # This will print the copyright message on the top of this file
    323     print __doc__.strip()
    324     print
    325     print '#include "pipe/p_compiler.h"'
    326     print '#include "util/u_format.h"'
    327     print '#include "util/u_math.h"'
    328     print '#include "lp_tile_soa.h"'
    329     print
    330     print 'const unsigned char'
    331     print 'tile_offset[TILE_VECTOR_HEIGHT][TILE_VECTOR_WIDTH] = {'
    332     print '   {  0,  1,  4,  5},'
    333     print '   {  2,  3,  6,  7},'
    334     print '   {  8,  9, 12, 13},'
    335     print '   { 10, 11, 14, 15}'
    336     print '};'
    337     print
    338     print '/* Note: these lookup tables could be replaced with some'
    339     print ' * bit-twiddling code, but this is a little faster.'
    340     print ' */'
    341     print 'static unsigned tile_x_offset[TILE_VECTOR_WIDTH * TILE_VECTOR_HEIGHT] = {'
    342     print '   0, 1, 0, 1, 2, 3, 2, 3,'
    343     print '   0, 1, 0, 1, 2, 3, 2, 3'
    344     print '};'
    345     print
    346     print 'static unsigned tile_y_offset[TILE_VECTOR_WIDTH * TILE_VECTOR_HEIGHT] = {'
    347     print '   0, 0, 1, 1, 0, 0, 1, 1,'
    348     print '   2, 2, 3, 3, 2, 2, 3, 3'
    349     print '};'
    350     print
     323    print (__doc__.strip())
     324    print ('')
     325    print ('#include "pipe/p_compiler.h"')
     326    print ('#include "util/u_format.h"')
     327    print ('#include "util/u_math.h"')
     328    print ('#include "lp_tile_soa.h"')
     329    print ('')
     330    print ('const unsigned char')
     331    print ('tile_offset[TILE_VECTOR_HEIGHT][TILE_VECTOR_WIDTH] = {')
     332    print ('   {  0,  1,  4,  5},')
     333    print ('   {  2,  3,  6,  7},')
     334    print ('   {  8,  9, 12, 13},')
     335    print ('   { 10, 11, 14, 15}')
     336    print ('};')
     337    print ('')
     338    print ('/* Note: these lookup tables could be replaced with some')
     339    print (' * bit-twiddling code, but this is a little faster.')
     340    print (' */')
     341    print ('static unsigned tile_x_offset[TILE_VECTOR_WIDTH * TILE_VECTOR_HEIGHT] = {')
     342    print ('   0, 1, 0, 1, 2, 3, 2, 3,')
     343    print ('   0, 1, 0, 1, 2, 3, 2, 3')
     344    print ('};')
     345    print ('')
     346    print ('static unsigned tile_y_offset[TILE_VECTOR_WIDTH * TILE_VECTOR_HEIGHT] = {')
     347    print ('   0, 0, 1, 1, 0, 0, 1, 1,')
     348    print ('   2, 2, 3, 3, 2, 2, 3, 3')
     349    print ('};')
     350    print ('')
    351351
    352352    generate_clamp()
    353353
  • Mesa-7.8.2/src/gallium/drivers/svga/svgadump/svga_dump.py

    old new  
    6363
    6464        for variable in class_.variables():
    6565            if variable.name != '':
    66                 #print 'variable = %r' % variable.name
     66                #print ('variable = %r' % variable.name)
    6767                dump_type(self._instance + '.' + variable.name, variable.type)
    6868
    6969    def visit_enumeration(self):
    7070        if enums:
    71             print '   switch(%s) {' % ("(*cmd)" + self._instance,)
     71            print ('   switch(%s) {' % ("(*cmd)" + self._instance,))
    7272            for name, value in self.decl.values:
    73                 print '   case %s:' % (name,)
    74                 print '      _debug_printf("\\t\\t%s = %s\\n");' % (self._instance, name)
    75                 print '      break;'
    76             print '   default:'
    77             print '      _debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance)
    78             print '      break;'
    79             print '   }'
     73                print ('   case %s:' % (name,))
     74                print ('      _debug_printf("\\t\\t%s = %s\\n");' % (self._instance, name))
     75                print ('      break;')
     76            print ('   default:')
     77            print ('      _debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance))
     78            print ('      break;')
     79            print ('   }')
    8080        else:
    81             print '   _debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance)
     81            print ('   _debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance))
    8282
    8383
    8484def dump_decl(instance, decl):
     
    149149        self.print_instance('%p')
    150150
    151151    def visit_declarated(self):
    152         #print 'decl = %r' % self.type.decl_string
     152        #print ('decl = %r' % self.type.decl_string)
    153153        decl = type_traits.remove_declarated(self.type)
    154154        dump_decl(self.instance, decl)
    155155
    156156    def print_instance(self, format):
    157         print '   _debug_printf("\\t\\t%s = %s\\n", %s);' % (self.instance, format, "(*cmd)" + self.instance)
     157        print ('   _debug_printf("\\t\\t%s = %s\\n", %s);' % (self.instance, format, "(*cmd)" + self.instance))
    158158
    159159
    160160def dump_type(instance, type_):
     
    164164
    165165
    166166def dump_struct(decls, class_):
    167     print 'static void'
    168     print 'dump_%s(const %s *cmd)' % (class_.name, class_.name)
    169     print '{'
     167    print ('static void')
     168    print ('dump_%s(const %s *cmd)' % (class_.name, class_.name))
     169    print ('{')
    170170    dump_decl('', class_)
    171     print '}'
    172     print ''
     171    print ('}')
     172    print ('')
    173173
    174174
    175175cmds = [
     
    206206]
    207207
    208208def dump_cmds():
    209     print r'''
     209    print (r'''
    210210void           
    211211svga_dump_command(uint32_t cmd_id, const void *data, uint32_t size)
    212212{
    213213   const uint8_t *body = (const uint8_t *)data;
    214214   const uint8_t *next = body + size;
    215 '''
    216     print '   switch(cmd_id) {'
     215''')
     216    print ('   switch(cmd_id) {')
    217217    indexes = 'ijklmn'
    218218    for id, header, body, footer in cmds:
    219         print '   case %s:' % id
    220         print '      _debug_printf("\\t%s\\n");' % id
    221         print '      {'
    222         print '         const %s *cmd = (const %s *)body;' % (header, header)
     219        print ('   case %s:' % id)
     220        print ('      _debug_printf("\\t%s\\n");' % id)
     221        print ('      {')
     222        print ('         const %s *cmd = (const %s *)body;' % (header, header))
    223223        if len(body):
    224             print '         unsigned ' + ', '.join(indexes[:len(body)]) + ';'
    225         print '         dump_%s(cmd);' % header
    226         print '         body = (const uint8_t *)&cmd[1];'
     224            print ('         unsigned ' + ', '.join(indexes[:len(body)]) + ';')
     225        print ('         dump_%s(cmd);' % header)
     226        print ('         body = (const uint8_t *)&cmd[1];')
    227227        for i in range(len(body)):
    228228            struct, count = body[i]
    229229            idx = indexes[i]
    230             print '         for(%s = 0; %s < cmd->%s; ++%s) {' % (idx, idx, count, idx)
    231             print '            dump_%s((const %s *)body);' % (struct, struct)
    232             print '            body += sizeof(%s);' % struct
    233             print '         }'
     230            print ('         for(%s = 0; %s < cmd->%s; ++%s) {' % (idx, idx, count, idx))
     231            print ('            dump_%s((const %s *)body);' % (struct, struct))
     232            print ('            body += sizeof(%s);' % struct)
     233            print ('         }')
    234234        if footer is not None:
    235             print '         while(body + sizeof(%s) <= next) {' % footer
    236             print '            dump_%s((const %s *)body);' % (footer, footer)
    237             print '            body += sizeof(%s);' % footer
    238             print '         }'
     235            print ('         while(body + sizeof(%s) <= next) {' % footer)
     236            print ('            dump_%s((const %s *)body);' % (footer, footer))
     237            print ('            body += sizeof(%s);' % footer)
     238            print ('         }')
    239239        if id == 'SVGA_3D_CMD_SHADER_DEFINE':
    240             print '         svga_shader_dump((const uint32_t *)body,'
    241             print '                          (unsigned)(next - body)/sizeof(uint32_t),'
    242             print '                          FALSE);'
    243             print '         body = next;'
    244         print '      }'
    245         print '      break;'
    246     print '   default:'
    247     print '      _debug_printf("\\t0x%08x\\n", cmd_id);'
    248     print '      break;'
    249     print '   }'
    250     print r'''
     240            print ('         svga_shader_dump((const uint32_t *)body,')
     241            print ('                          (unsigned)(next - body)/sizeof(uint32_t),')
     242            print ('                          FALSE);')
     243            print ('         body = next;')
     244        print ('      }')
     245        print ('      break;')
     246    print ('   default:')
     247    print ('      _debug_printf("\\t0x%08x\\n", cmd_id);')
     248    print ('      break;')
     249    print ('   }')
     250    print (r'''
    251251   while(body + sizeof(uint32_t) <= next) {
    252252      _debug_printf("\t\t0x%08x\n", *(const uint32_t *)body);
    253253      body += sizeof(uint32_t);
     
    255255   while(body + sizeof(uint32_t) <= next)
    256256      _debug_printf("\t\t0x%02x\n", *body++);
    257257}
    258 '''
    259     print r'''
     258''')
     259    print (r'''
    260260void           
    261261svga_dump_commands(const void *commands, uint32_t size)
    262262{
     
    289289      }
    290290   }
    291291}
    292 '''
     292''')
    293293
    294294def main():
    295     print copyright.strip()
    296     print
    297     print '/**'
    298     print ' * @file'
    299     print ' * Dump SVGA commands.'
    300     print ' *'
    301     print ' * Generated automatically from svga3d_reg.h by svga_dump.py.'
    302     print ' */'
    303     print
    304     print '#include "svga_types.h"'
    305     print '#include "svga_shader_dump.h"'
    306     print '#include "svga3d_reg.h"'
    307     print
    308     print '#include "util/u_debug.h"'
    309     print '#include "svga_dump.h"'
    310     print
     295    print (copyright.strip())
     296    print ('')
     297    print ('/**')
     298    print (' * @file')
     299    print (' * Dump SVGA commands.')
     300    print (' *')
     301    print (' * Generated automatically from svga3d_reg.h by svga_dump.py.')
     302    print (' */')
     303    print ('')
     304    print ('#include "svga_types.h"')
     305    print ('#include "svga_shader_dump.h"')
     306    print ('#include "svga3d_reg.h"')
     307    print ('')
     308    print ('#include "util/u_debug.h"')
     309    print ('#include "svga_dump.h"')
     310    print ('')
    311311
    312312    config = parser.config_t(
    313313        include_paths = ['../../../include', '../include'],
  • Mesa-7.8.2/src/mesa/es/glapi/gl_compare.py

    old new  
    226226
    227227    # no child
    228228    if not e.functions:
    229         print '%s<enum %s/>' % (spaces(indent), attrs)
     229        print ('%s<enum %s/>' % (spaces(indent), attrs))
    230230        return
    231231
    232     print '%s<enum %s>' % (spaces(indent), attrs)
     232    print ('%s<enum %s>' % (spaces(indent), attrs))
    233233    for key, val in e.functions.iteritems():
    234234        attrs = 'name="%s"' % key
    235235        if val[0] != e.default_count:
     
    237237        if not val[1]:
    238238            attrs += ' mode="get"'
    239239
    240         print '%s<size %s/>' % (spaces(indent * 2), attrs)
     240        print ('%s<size %s/>' % (spaces(indent * 2), attrs))
    241241
    242     print '%s</enum>' % spaces(indent)
     242    print ('%s</enum>' % spaces(indent))
    243243
    244244def output_type(t, indent=0):
    245245    tab = spaces(16, t.name)
     
    249249        attrs += ' unsigned="true"'
    250250    elif ctype.find("signed") == -1:
    251251        attrs += ' float="true"'
    252     print '%s<type %s/>' % (spaces(indent), attrs)
     252    print ('%s<type %s/>' % (spaces(indent), attrs))
    253253
    254254def output_function(f, indent=0):
    255255    attrs = 'name="%s"' % f.name
     
    258258            attrs += ' offset="assign"'
    259259        else:
    260260            attrs += ' offset="%d"' % f.offset
    261     print '%s<function %s>' % (spaces(indent), attrs)
     261    print ('%s<function %s>' % (spaces(indent), attrs))
    262262
    263263    for p in f.parameters:
    264264        attrs = 'name="%s" type="%s"' \
    265265                % (p.name, p.type_expr.original_string)
    266         print '%s<param %s/>' % (spaces(indent * 2), attrs)
     266        print ('%s<param %s/>' % (spaces(indent * 2), attrs))
    267267    if f.return_type != "void":
    268268        attrs = 'type="%s"' % f.return_type
    269         print '%s<return %s/>' % (spaces(indent * 2), attrs)
     269        print ('%s<return %s/>' % (spaces(indent * 2), attrs))
    270270
    271     print '%s</function>' % spaces(indent)
     271    print ('%s</function>' % spaces(indent))
    272272
    273273def output_category(api, indent=0):
    274274    enums = api.enums_by_name.values()
     
    281281    for e in enums:
    282282        output_enum(e, indent)
    283283    if enums and types:
    284         print
     284        print ('')
    285285    for t in types:
    286286        output_type(t, indent)
    287287    if enums or types:
    288         print
     288        print ('')
    289289    for f in functions:
    290290        output_function(f, indent)
    291291        if f != functions[-1]:
    292             print
     292            print ('')
    293293
    294294def is_api_empty(api):
    295295    return bool(not api.enums_by_name and
     
    297297                not api.functions_by_name)
    298298
    299299def show_usage(ops):
    300     print "Usage: %s [-k elts] <%s> <file1> <file2>" % (sys.argv[0], "|".join(ops))
    301     print "    -k elts   A comma separated string of types of elements to"
    302     print "              skip.  Possible types are enum, type, and function."
     300    print ("Usage: %s [-k elts] <%s> <file1> <file2>" % (sys.argv[0], "|".join(ops)))
     301    print ("    -k elts   A comma separated string of types of elements to")
     302    print ("              skip.  Possible types are enum, type, and function.")
    303303    sys.exit(1)
    304304
    305305def main():
     
    339339        cat_name = "%s_of_%s_and_%s" \
    340340                % (op, os.path.basename(file1), os.path.basename(file2))
    341341
    342         print '<?xml version="1.0"?>'
    343         print '<!DOCTYPE OpenGLAPI SYSTEM "%s/gl_API.dtd">' % GLAPI
    344         print
    345         print '<OpenGLAPI>'
    346         print
    347         print '<category name="%s">' % (cat_name)
     342        print ('<?xml version="1.0"?>')
     343        print ('<!DOCTYPE OpenGLAPI SYSTEM "%s/gl_API.dtd">' % GLAPI)
     344        print ('')
     345        print ('<OpenGLAPI>')
     346        print ('')
     347        print ('<category name="%s">' % (cat_name))
    348348        output_category(result, 4)
    349         print '</category>'
    350         print
    351         print '</OpenGLAPI>'
     349        print ('</category>')
     350        print ('')
     351        print ('</OpenGLAPI>')
    352352
    353353if __name__ == "__main__":
    354354    main()
  • Mesa-7.8.2/src/mesa/es/glapi/gl_parse_header.py

    old new  
    106106        m = self.DEFINE.search(line)
    107107        if not m:
    108108            if self.verbose and line.find("#define") >= 0:
    109                 print "ignore %s" % (line)
     109                print ("ignore %s" % (line))
    110110            return None
    111111
    112112        key = m.group("key").strip()
     
    116116        if ((not (key.startswith("GL_") and key.isupper())) or
    117117            (self.ignore_enum.match(key) and val == "1")):
    118118            if self.verbose:
    119                 print "ignore enum %s" % (key)
     119                print ("ignore enum %s" % (key))
    120120            return None
    121121
    122122        return (key, val)
     
    126126        m = self.TYPEDEF.search(line)
    127127        if not m:
    128128            if self.verbose and line.find("typedef") >= 0:
    129                 print "ignore %s" % (line)
     129                print ("ignore %s" % (line))
    130130            return None
    131131
    132132        f = m.group("from").strip()
    133133        t = m.group("to").strip()
    134134        if not t.startswith("GL"):
    135135            if self.verbose:
    136                 print "ignore type %s" % (t)
     136                print ("ignore type %s" % (t))
    137137            return None
    138138        attrs = self._get_ctype_attrs(f)
    139139
     
    144144        m = self.GLAPI.search(line)
    145145        if not m:
    146146            if self.verbose and line.find("APIENTRY") >= 0:
    147                 print "ignore %s" % (line)
     147                print ("ignore %s" % (line))
    148148            return None
    149149
    150150        rettype = m.group("return")
     
    213213            lines = fp.readlines()
    214214            fp.close()
    215215        except IOError, e:
    216             print "failed to read %s: %s" % (header, e)
     216            print ("failed to read %s: %s" % (header, e))
    217217        return lines
    218218
    219219    def _cmp_enum(self, enum1, enum2):
     
    287287            for i in dup:
    288288                e = cat["enums"].pop(i)
    289289                if self.verbose:
    290                     print "remove duplicate enum %s" % e[0]
     290                    print ("remove duplicate enum %s" % e[0])
    291291
    292292            cat["types"].sort(self._cmp_type)
    293293            cat["functions"].sort(self._cmp_function)
     
    305305        self._reset()
    306306
    307307        if self.verbose:
    308             print "Parsing %s" % (header)
     308            print ("Parsing %s" % (header))
    309309
    310310        hdict = {}
    311311        lines = self._read_header(header)
     
    347347
    348348        if self.need_char:
    349349            if self.verbose:
    350                 print "define GLchar"
     350                print ("define GLchar")
    351351            elem = self._parse_typedef("typedef char GLchar;")
    352352            cat["types"].append(elem)
    353353        return self._postprocess_dict(hdict)
     
    364364    for i in xrange(len(hlist)):
    365365        cat_name, cat = hlist[i]
    366366
    367         print '<category name="%s">' % (cat_name)
     367        print ('<category name="%s">' % (cat_name))
    368368        indent = 4
    369369
    370370        for enum in cat["enums"]:
     
    372372            value = enum[1]
    373373            tab = spaces(41, name)
    374374            attrs = 'name="%s"%svalue="%s"' % (name, tab, value)
    375             print '%s<enum %s/>' % (spaces(indent), attrs)
     375            print ('%s<enum %s/>' % (spaces(indent), attrs))
    376376
    377377        if cat["enums"] and cat["types"]:
    378             print
     378            print ('')
    379379
    380380        for type in cat["types"]:
    381381            ctype = type[0]
     
    388388            elif not is_signed:
    389389                attrs += ' unsigned="true"'
    390390
    391             print '%s<type %s/>' % (spaces(indent), attrs)
     391            print ('%s<type %s/>' % (spaces(indent), attrs))
    392392
    393393        for func in cat["functions"]:
    394             print
     394            print ('')
    395395            ret = func[0]
    396396            name = func[1][2:]
    397397            params = func[2]
    398398
    399399            attrs = 'name="%s" offset="assign"' % name
    400             print '%s<function %s>' % (spaces(indent), attrs)
     400            print ('%s<function %s>' % (spaces(indent), attrs))
    401401
    402402            for param in params:
    403403                attrs = 'name="%s" type="%s"' % (param[1], param[0])
    404                 print '%s<param %s/>' % (spaces(indent * 2), attrs)
     404                print ('%s<param %s/>' % (spaces(indent * 2), attrs))
    405405            if ret:
    406406                attrs = 'type="%s"' % ret
    407                 print '%s<return %s/>' % (spaces(indent * 2), attrs)
     407                print ('%s<return %s/>' % (spaces(indent * 2), attrs))
    408408
    409             print '%s</function>' % spaces(indent)
     409            print ('%s</function>' % spaces(indent))
    410410
    411         print '</category>'
    412         print
     411        print ('</category>')
     412        print ('')
    413413
    414414def show_usage():
    415     print "Usage: %s [-v] <header> ..." % sys.argv[0]
     415    print ("Usage: %s [-v] <header> ..." % sys.argv[0])
    416416    sys.exit(1)
    417417
    418418def main():
     
    435435        hlist = parser.parse(h)
    436436
    437437        if need_xml_header:
    438             print '<?xml version="1.0"?>'
    439             print '<!DOCTYPE OpenGLAPI SYSTEM "%s/gl_API.dtd">' % GLAPI
     438            print ('<?xml version="1.0"?>')
     439            print ('<!DOCTYPE OpenGLAPI SYSTEM "%s/gl_API.dtd">' % GLAPI)
    440440            need_xml_header = False
    441441
    442         print
    443         print '<!-- %s -->' % (h)
    444         print '<OpenGLAPI>'
    445         print
     442        print ('')
     443        print ('<!-- %s -->' % (h))
     444        print ('<OpenGLAPI>')
     445        print ('')
    446446        output_xml(h, hlist)
    447         print '</OpenGLAPI>'
     447        print ('</OpenGLAPI>')
    448448
    449449if __name__ == '__main__':
    450450    main()
  • Mesa-7.8.2/src/mesa/es/main/APIspec.py

    old new  
    431431        stmts = []
    432432        for name in self.switches.iterkeys():
    433433            c_switch = self._c_switch(name)
    434             print "\n".join(c_switch)
     434            print ("\n".join(c_switch))
    435435
    436436
    437437class Description(object):
     
    610610
    611611    doc.freeDoc()
    612612
    613     print "%s is successfully parsed" % filename
     613    print ("%s is successfully parsed" % filename)
    614614
    615615
    616616if __name__ == "__main__":
  • Mesa-7.8.2/src/mesa/es/main/APIspecutil.py

    old new  
    6161        if not alias:
    6262            # external functions are manually dispatched
    6363            if not func.is_external:
    64                 print >>sys.stderr, "Error: unable to dispatch %s" % func.name
     64                sys.stderr.write("Error: unable to dispatch %s\n" % func.name)
    6565            alias = func
    6666            need_conv = False
    6767
     
    119119
    120120        items = desc.checker.switches.items()
    121121        if len(items) > 1:
    122             print >>sys.stderr, "%s: more than one parameter depend on %s" % \
    123                     (func.name, desc.name)
     122            sys.stderr.write("%s: more than one parameter depend on %s\n" % \
     123                    (func.name, desc.name))
    124124        dep_name, dep_switch = items[0]
    125125
    126126        for dep_desc in dep_switch:
    127127            if dep_desc.index >= 0 and dep_desc.index != 0:
    128                 print >>sys.stderr, "%s: not first element of a vector" % func.name
     128                sys.stderr.write("%s: not first element of a vector\n" % func.name)
    129129            if dep_desc.checker.switches:
    130                 print >>sys.stderr, "%s: deep nested dependence" % func.name
     130                sys.stderr.write("%s: deep nested dependence\n" % func.name)
    131131
    132132            convert = None if dep_desc.convert else "noconvert"
    133133            for val in desc.values:
     
    188188    if not size:
    189189        need_conv = __aliases[func.name][1]
    190190        if need_conv:
    191             print >>sys.stderr, \
    192                     "Error: unable to dicide the max size of %s in %s" % \
    193                     (param.name, func.name)
     191            sys.stderr.write( \
     192                    "Error: unable to dicide the max size of %s in %s\n" % \
     193                    (param.name, func.name))
    194194    return size
    195195
    196196
  • Mesa-7.8.2/src/mesa/es/main/es_generator.py

    old new  
    7070    type-converted if necessary."""
    7171
    7272    if not Converters.has_key(fromType):
    73         print >> sys.stderr, "No base converter for type '%s' found.  Ignoring." % fromType
     73        sys.stderr.write("No base converter for type '%s' found.  Ignoring.\n" % fromType)
    7474        return value
    7575
    7676    if not Converters[fromType].has_key(toType):
    77         print >> sys.stderr, "No converter found for type '%s' to type '%s'.  Ignoring." % (fromType, toType)
     77        sys.stderr.write("No converter found for type '%s' to type '%s'.  Ignoring.\n" % (fromType, toType))
    7878        return value
    7979
    8080    # This part is simple.  Return the proper conversion.
     
    175175
    176176allSpecials = apiutil.AllSpecials()
    177177
    178 print """/* DO NOT EDIT *************************************************
     178print ("""/* DO NOT EDIT *************************************************
    179179 * THIS FILE AUTOMATICALLY GENERATED BY THE %s SCRIPT
    180180 * API specification file:   %s
    181181 * GLES version:             %s
    182182 * date:                     %s
    183183 */
    184 """ % (program, functionList, version, time.strftime("%Y-%m-%d %H:%M:%S"))
     184""" % (program, functionList, version, time.strftime("%Y-%m-%d %H:%M:%S")))
    185185
    186186# The headers we choose are version-specific.
    187 print """
     187print ("""
    188188#include "%s"
    189189#include "%s"
    190 """ % (versionHeader, versionExtHeader)
     190""" % (versionHeader, versionExtHeader))
    191191
    192192# Everyone needs these types.
    193 print """
     193print ("""
    194194/* These types are needed for the Mesa veneer, but are not defined in
    195195 * the standard GLES headers.
    196196 */
     
    210210#include "main/dispatch.h"
    211211
    212212typedef void (*_glapi_proc)(void); /* generic function pointer */
    213 """
     213""")
    214214
    215215# Finally we get to the all-important functions
    216 print """/*************************************************************
     216print ("""/*************************************************************
    217217 * Generated functions begin here
    218218 */
    219 """
     219""")
    220220for funcName in keys:
    221221    if verbose > 0: sys.stderr.write("%s: processing function %s\n" % (program, funcName))
    222222
     
    569569    # header files.  The easiest way to manage declarations
    570570    # is to create them ourselves.
    571571    if funcName in allSpecials:
    572         print "/* this function is special and is defined elsewhere */"
    573     print "extern %s GLAPIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString)
     572        print ("/* this function is special and is defined elsewhere */")
     573    print ("extern %s GLAPIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString))
    574574
    575575    # A function may be a core function (i.e. it exists in
    576576    # the core specification), a core addition (extension
     
    612612        # Now the generated function.  The text used to mark an API-level
    613613        # function, oddly, is version-specific.
    614614        if extensionName:
    615             print "/* Extension %s */" % extensionName
     615            print ("/* Extension %s */" % extensionName)
    616616
    617617        if (not variables and
    618618            not switchCode and
    619619            not conversionCodeOutgoing and
    620620            not conversionCodeIncoming):
    621621            # pass through directly
    622             print "#define %s %s" % (fullFuncName, passthroughFuncName)
    623             print
     622            print ("#define %s %s" % (fullFuncName, passthroughFuncName))
     623            print ('')
    624624            continue
    625625
    626         print "static %s %s(%s)" % (returnType, fullFuncName, declarationString)
    627         print "{"
     626        print ("static %s %s(%s)" % (returnType, fullFuncName, declarationString))
     627        print ("{")
    628628
    629629        # Start printing our code pieces.  Start with any local
    630630        # variables we need.  This unusual syntax joins the
    631631        # lines in the variables[] array with the "\n" separator.
    632632        if len(variables) > 0:
    633             print "\n".join(variables) + "\n"
     633            print ("\n".join(variables) + "\n")
    634634
    635635        # If there's any sort of parameter checking or variable
    636636        # array sizing, the switch code will contain it.
    637637        if len(switchCode) > 0:
    638             print "\n".join(switchCode) + "\n"
     638            print ("\n".join(switchCode) + "\n")
    639639
    640640        # In the case of an outgoing conversion (i.e. parameters must
    641641        # be converted before calling the underlying Mesa function),
    642642        # use the appropriate code.
    643643        if "get" not in props and len(conversionCodeOutgoing) > 0:
    644             print "\n".join(conversionCodeOutgoing) + "\n"
     644            print ("\n".join(conversionCodeOutgoing) + "\n")
    645645
    646646        # Call the Mesa function.  Note that there are very few functions
    647647        # that return a value (i.e. returnType is not "void"), and that
     
    650650        # even though it's not completely independent.
    651651
    652652        if returnType == "void":
    653             print "    %s(%s);" % (passthroughFuncName, passthroughCallString)
     653            print ("    %s(%s);" % (passthroughFuncName, passthroughCallString))
    654654        else:
    655             print "    return %s(%s);" % (passthroughFuncName, passthroughCallString)
     655            print ("    return %s(%s);" % (passthroughFuncName, passthroughCallString))
    656656
    657657        # If the function is one that returns values (i.e. "get" in props),
    658658        # it might return values of a different type than we need, that
    659659        # require conversion before passing back to the application.
    660660        if "get" in props and len(conversionCodeIncoming) > 0:
    661             print "\n".join(conversionCodeIncoming)
     661            print ("\n".join(conversionCodeIncoming))
    662662
    663663        # All done.
    664         print "}"
    665         print
     664        print ("}")
     665        print ('')
    666666    # end for each category provided for a function
    667667
    668668# end for each function
    669669
    670 print "void"
    671 print "_mesa_init_exec_table(struct _glapi_table *exec)"
    672 print "{"
     670print ("void")
     671print ("_mesa_init_exec_table(struct _glapi_table *exec)")
     672print ("{")
    673673for func in keys:
    674674    prefix = "_es_" if func not in allSpecials else "_check_"
    675675    for spec in apiutil.Categories(func):
     
    681681        if ext:
    682682            suffix = ext[0].split("_")[0]
    683683            entry += suffix
    684         print "    SET_%s(exec, %s%s);" % (entry, prefix, entry)
    685 print "}"
     684        print ("    SET_%s(exec, %s%s);" % (entry, prefix, entry))
     685print ("}")
  • Mesa-7.8.2/src/mesa/es/main/get_gen.py

    old new  
    585585        else:
    586586                abort()
    587587
    588         print "void GLAPIENTRY"
    589         print "%s( GLenum pname, %s *params )" % (function, strType)
    590         print "{"
    591         print "   GET_CURRENT_CONTEXT(ctx);"
    592         print "   ASSERT_OUTSIDE_BEGIN_END(ctx);"
    593         print ""
    594         print "   if (!params)"
    595         print "      return;"
    596         print ""
    597         print "   if (ctx->NewState)"
    598         print "      _mesa_update_state(ctx);"
    599         print ""
    600         print "   switch (pname) {"
     588        print ("void GLAPIENTRY")
     589        print ("%s( GLenum pname, %s *params )" % (function, strType))
     590        print ("{")
     591        print ("   GET_CURRENT_CONTEXT(ctx);")
     592        print ("   ASSERT_OUTSIDE_BEGIN_END(ctx);")
     593        print ("")
     594        print ("   if (!params)")
     595        print ("      return;")
     596        print ("")
     597        print ("   if (ctx->NewState)")
     598        print ("      _mesa_update_state(ctx);")
     599        print ("")
     600        print ("   switch (pname) {")
    601601
    602602        for (name, varType, state, optionalCode, extensions) in stateVars:
    603                 print "      case " + name + ":"
     603                print ("      case " + name + ":")
    604604                if extensions:
    605605                        if len(extensions) == 1:
    606606                                print ('         CHECK_EXT1(%s, "%s");' %
     
    616616                                print ('         CHECK_EXT4(%s, %s, %s, %s, "%s");' %
    617617                                           (extensions[0], extensions[1], extensions[2], extensions[3], function))
    618618                if optionalCode:
    619                         print "         {"
    620                         print "         " + optionalCode
     619                        print ("         {")
     620                        print ("         " + optionalCode)
    621621                conversion = ConversionFunc(varType, returnType)
    622622                n = len(state)
    623623                for i in range(n):
    624624                        if conversion:
    625                                 print "         params[%d] = %s(%s);" % (i, conversion, state[i])
     625                                print ("         params[%d] = %s(%s);" % (i, conversion, state[i]))
    626626                        else:
    627                                 print "         params[%d] = %s;" % (i, state[i])
     627                                print ("         params[%d] = %s;" % (i, state[i]))
    628628                if optionalCode:
    629                         print "         }"
    630                 print "         break;"
     629                        print ("         }")
     630                print ("         break;")
    631631
    632         print "      default:"
    633         print '         _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(pname=0x%%x)", pname);' % function
    634         print "   }"
    635         print "}"
    636         print ""
     632        print ("      default:")
     633        print ('         _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(pname=0x%%x)", pname);' % function)
     634        print ("   }")
     635        print ("}")
     636        print ("")
    637637        return
    638638
    639639
    640640
    641641def EmitHeader():
    642642        """Print the get.c file header."""
    643         print """
     643        print ("""
    644644/***
    645645 ***  NOTE!!!  DO NOT EDIT THIS FILE!!!  IT IS GENERATED BY get_gen.py
    646646 ***/
     
    776776void GLAPIENTRY
    777777_mesa_GetFixedv( GLenum pname, GLfixed *params );
    778778
    779 """
     779""")
    780780        return
    781781
    782782
     
    797797                API = 2
    798798        else:
    799799                API = 1
    800         #print "len args = %d  API = %d" % (len(args), API)
     800        #print ("len args = %d  API = %d" % (len(args), API))
    801801
    802802        if API == 1:
    803803                vars = StateVars_common + StateVars_es1
  • Mesa-7.8.2/src/mesa/glapi/gen/extension_helper.py

    old new  
    150150
    151151
    152152        def printRealHeader(self):
    153                 print '#include "utils.h"'
    154                 print '#include "main/dispatch.h"'
    155                 print ''
     153                print ('#include "utils.h"')
     154                print ('#include "main/dispatch.h"')
     155                print ('')
    156156                return
    157157
    158158
     
    161161
    162162                category_list = {}
    163163
    164                 print '#ifndef NULL'
    165                 print '# define NULL 0'
    166                 print '#endif'
    167                 print ''
     164                print ('#ifndef NULL')
     165                print ('# define NULL 0')
     166                print ('#endif')
     167                print ('')
    168168
    169169                for f in api.functionIterateAll():
    170170                        condition = condition_for_function(f, abi, 0)
    171171                        if len(condition):
    172                                 print '#if %s' % (string.join(condition, " || "))
    173                                 print 'static const char %s_names[] =' % (f.name)
     172                                print ('#if %s' % (string.join(condition, " || ")))
     173                                print ('static const char %s_names[] =' % (f.name))
    174174
    175175                                parameter_signature = ''
    176176                                for p in f.parameterIterator():
     
    189189                                        else:
    190190                                                parameter_signature += 'd'
    191191
    192                                 print '    "%s\\0" /* Parameter signature */' % (parameter_signature)
     192                                print ('    "%s\\0" /* Parameter signature */' % (parameter_signature))
    193193
    194194                                for n in f.entry_points:
    195                                         print '    "gl%s\\0"' % (n)
     195                                        print ('    "gl%s\\0"' % (n))
    196196
    197197                                        [category, num] = api.get_category_for_name( n )
    198198                                        if category not in abi:
     
    202202
    203203                                                category_list[ c ].append( f )
    204204
    205                                 print '    "";'
    206                                 print '#endif'
    207                                 print ''
     205                                print ('    "";')
     206                                print ('#endif')
     207                                print ('')
    208208
    209209                keys = category_list.keys()
    210210                keys.sort()
    211211
    212212                for category in keys:
    213                         print '#if defined(need_%s)' % (category)
    214                         print 'static const struct dri_extension_function %s_functions[] = {' % (category)
     213                        print ('#if defined(need_%s)' % (category))
     214                        print ('static const struct dri_extension_function %s_functions[] = {' % (category))
    215215                       
    216216                        for f in category_list[ category ]:
    217217                                # A function either has an offset that is
     
    224224                                        index_name = "%s_remap_index" % (f.name)
    225225                                        offset = -1
    226226
    227                                 print '    { %s_names, %s, %d },' % (f.name, index_name, offset)
     227                                print ('    { %s_names, %s, %d },' % (f.name, index_name, offset))
    228228
    229229
    230                         print '    { NULL, 0, 0 }'
    231                         print '};'
    232                         print '#endif'
    233                         print ''
     230                        print ('    { NULL, 0, 0 }')
     231                        print ('};')
     232                        print ('#endif')
     233                        print ('')
    234234               
    235235                return
    236236
     
    258258
    259259                        if condition_string != last_condition_string:
    260260                                if last_condition_string:
    261                                         print '#endif /* %s */' % (last_condition_string)
     261                                        print ('#endif /* %s */' % (last_condition_string))
    262262
    263263                                if condition_string:
    264                                         print '#if %s' % (condition_string)
     264                                        print ('#if %s' % (condition_string))
    265265                               
    266266                        if vtxfmt_only:
    267                                 print '   disp->%s = vfmt->%s;' % (f.name, f.name)
     267                                print ('   disp->%s = vfmt->%s;' % (f.name, f.name))
    268268                        else:
    269                                 print '   disp->%s = _mesa_%s;' % (f.name, f.name)
     269                                print ('   disp->%s = _mesa_%s;' % (f.name, f.name))
    270270
    271271                        last_condition_string = condition_string
    272272
    273273                if last_condition_string:
    274                         print '#endif /* %s */' % (last_condition_string)
     274                        print ('#endif /* %s */' % (last_condition_string))
    275275               
    276276
    277277
    278278        def printBody(self, api):
    279279                abi = [ "1.0", "1.1", "1.2", "GL_ARB_multitexture" ]
    280280               
    281                 print 'void driver_init_exec_table(struct _glapi_table *disp)'
    282                 print '{'
     281                print ('void driver_init_exec_table(struct _glapi_table *disp)')
     282                print ('{')
    283283                self.do_function_body(api, abi, 0)
    284                 print '}'
    285                 print ''
    286                 print 'void driver_install_vtxfmt(struct _glapi_table *disp, const GLvertexformat *vfmt)'
    287                 print '{'
     284                print ('}')
     285                print ('')
     286                print ('void driver_install_vtxfmt(struct _glapi_table *disp, const GLvertexformat *vfmt)')
     287                print ('{')
    288288                self.do_function_body(api, abi, 1)
    289                 print '}'
     289                print ('}')
    290290
    291291                return
    292292
    293293
    294294def show_usage():
    295         print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]
    296         print "    -m output_mode   Output mode can be one of 'extensions' or 'exec_init'."
     295        print ("Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0])
     296        print ("    -m output_mode   Output mode can be one of 'extensions' or 'exec_init'.")
    297297        sys.exit(1)
    298298
    299299if __name__ == '__main__':
  • Mesa-7.8.2/src/mesa/glapi/gen/gl_apitemp.py

    old new  
    9292                        if (cat.startswith("es") or cat.startswith("GL_OES")):
    9393                                need_proto = True
    9494                if need_proto:
    95                         print '%s %s KEYWORD2 NAME(%s)(%s);' % (keyword, f.return_type, n, f.get_parameter_string(name))
    96                         print ''
     95                        print ('%s %s KEYWORD2 NAME(%s)(%s);' % (keyword, f.return_type, n, f.get_parameter_string(name)))
     96                        print ('')
    9797
    98                 print '%s %s KEYWORD2 NAME(%s)(%s)' % (keyword, f.return_type, n, f.get_parameter_string(name))
    99                 print '{'
     98                print ('%s %s KEYWORD2 NAME(%s)(%s)' % (keyword, f.return_type, n, f.get_parameter_string(name)))
     99                print ('{')
    100100                if p_string == "":
    101                         print '   %s(%s, (), (F, "gl%s();\\n"));' \
    102                                 % (dispatch, f.name, name)
     101                        print ('   %s(%s, (), (F, "gl%s();\\n"));' \
     102                                % (dispatch, f.name, name))
    103103                else:
    104                         print '   %s(%s, (%s), (F, "gl%s(%s);\\n", %s));' \
    105                                 % (dispatch, f.name, p_string, name, t_string, o_string)
    106                 print '}'
    107                 print ''
     104                        print ('   %s(%s, (%s), (F, "gl%s(%s);\\n", %s));' \
     105                                % (dispatch, f.name, p_string, name, t_string, o_string))
     106                print ('}')
     107                print ('')
    108108                return
    109109
    110110        def printRealHeader(self):
    111                 print ''
     111                print ('')
    112112                self.printVisibility( "HIDDEN", "hidden" )
    113                 print """
     113                print ("""
    114114/*
    115115 * This file is a template which generates the OpenGL API entry point
    116116 * functions.  It should be included by a .c file which first defines
     
    157157#error RETURN_DISPATCH must be defined
    158158#endif
    159159
    160 """
     160""")
    161161                return
    162162
    163163   
    164164
    165165        def printInitDispatch(self, api):
    166                 print """
     166                print ("""
    167167#endif /* defined( NAME ) */
    168168
    169169/*
     
    180180#error _GLAPI_SKIP_NORMAL_ENTRY_POINTS must not be defined
    181181#endif
    182182
    183 _glapi_proc DISPATCH_TABLE_NAME[] = {"""
     183_glapi_proc DISPATCH_TABLE_NAME[] = {""")
    184184                for f in api.functionIterateByOffset():
    185                         print '   TABLE_ENTRY(%s),' % (f.dispatch_name())
     185                        print ('   TABLE_ENTRY(%s),' % (f.dispatch_name()))
    186186
    187                 print '   /* A whole bunch of no-op functions.  These might be called'
    188                 print '    * when someone tries to call a dynamically-registered'
    189                 print '    * extension function without a current rendering context.'
    190                 print '    */'
     187                print ('   /* A whole bunch of no-op functions.  These might be called')
     188                print ('    * when someone tries to call a dynamically-registered')
     189                print ('    * extension function without a current rendering context.')
     190                print ('    */')
    191191                for i in range(1, 100):
    192                         print '   TABLE_ENTRY(Unused),'
     192                        print ('   TABLE_ENTRY(Unused),')
    193193
    194                 print '};'
    195                 print '#endif /* DISPATCH_TABLE_NAME */'
    196                 print ''
     194                print ('};')
     195                print ('#endif /* DISPATCH_TABLE_NAME */')
     196                print ('')
    197197                return
    198198
    199199
    200200        def printAliasedTable(self, api):
    201                 print """
     201                print ("""
    202202/*
    203203 * This is just used to silence compiler warnings.
    204204 * We list the functions which are not otherwise used.
    205205 */
    206206#ifdef UNUSED_TABLE_NAME
    207 _glapi_proc UNUSED_TABLE_NAME[] = {"""
     207_glapi_proc UNUSED_TABLE_NAME[] = {""")
    208208
    209209                normal_entries = []
    210210                proto_entries = []
     
    223223                        normal_entries.extend(normal_ents)
    224224                        proto_entries.extend(proto_ents)
    225225
    226                 print '#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS'
     226                print ('#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS')
    227227                for ent in normal_entries:
    228                         print '   TABLE_ENTRY(%s),' % (ent)
    229                 print '#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */'
    230                 print '#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS'
     228                        print ('   TABLE_ENTRY(%s),' % (ent))
     229                print ('#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */')
     230                print ('#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS')
    231231                for ent in proto_entries:
    232                         print '   TABLE_ENTRY(%s),' % (ent)
    233                 print '#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */'
     232                        print ('   TABLE_ENTRY(%s),' % (ent))
     233                print ('#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */')
    234234
    235                 print '};'
    236                 print '#endif /*UNUSED_TABLE_NAME*/'
    237                 print ''
     235                print ('};')
     236                print ('#endif /*UNUSED_TABLE_NAME*/')
     237                print ('')
    238238                return
    239239
    240240
     
    271271                        normal_entry_points.append((func, normal_ents))
    272272                        proto_entry_points.append((func, proto_ents))
    273273
    274                 print '#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS'
    275                 print ''
     274                print ('#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS')
     275                print ('')
    276276                for func, ents in normal_entry_points:
    277277                        for ent in ents:
    278278                                self.printFunction(func, ent)
    279                 print ''
    280                 print '#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */'
    281                 print ''
    282                 print '/* these entry points might require different protocols */'
    283                 print '#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS'
    284                 print ''
     279                print ('')
     280                print ('#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */')
     281                print ('')
     282                print ('/* these entry points might require different protocols */')
     283                print ('#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS')
     284                print ('')
    285285                for func, ents in proto_entry_points:
    286286                        for ent in ents:
    287287                                self.printFunction(func, ent)
    288                 print ''
    289                 print '#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */'
    290                 print ''
     288                print ('')
     289                print ('#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */')
     290                print ('')
    291291
    292292                self.printInitDispatch(api)
    293293                self.printAliasedTable(api)
     
    295295
    296296
    297297def show_usage():
    298         print "Usage: %s [-f input_file_name] [-c]" % sys.argv[0]
    299         print "-c          Enable compatibility with OpenGL ES."
     298        print ("Usage: %s [-f input_file_name] [-c]" % sys.argv[0])
     299        print ("-c          Enable compatibility with OpenGL ES.")
    300300        sys.exit(1)
    301301
    302302if __name__ == '__main__':
  • Mesa-7.8.2/src/mesa/glapi/gen/gl_enums.py

    old new  
    4242
    4343
    4444        def printRealHeader(self):
    45                 print '#include "main/glheader.h"'
    46                 print '#include "main/mfeatures.h"'
    47                 print '#include "main/enums.h"'
    48                 print '#include "main/imports.h"'
    49                 print ''
    50                 print 'typedef struct {'
    51                 print '   size_t offset;'
    52                 print '   int n;'
    53                 print '} enum_elt;'
    54                 print ''
     45                print ('#include "main/glheader.h"')
     46                print ('#include "main/mfeatures.h"')
     47                print ('#include "main/enums.h"')
     48                print ('#include "main/imports.h"')
     49                print ('')
     50                print ('typedef struct {')
     51                print ('   size_t offset;')
     52                print ('   int n;')
     53                print ('} enum_elt;')
     54                print ('')
    5555                return
    5656
    5757        def print_code(self):
    58                 print """
     58                print ("""
    5959typedef int (*cfunc)(const void *, const void *);
    6060
    6161/**
     
    147147   return (f != NULL) ? f->n : -1;
    148148}
    149149
    150 """
     150""")
    151151                return
    152152
    153153
     
    174174
    175175                string_offsets = {}
    176176                i = 0;
    177                 print 'LONGSTRING static const char enum_string_table[] = '
     177                print ('LONGSTRING static const char enum_string_table[] = ')
    178178                for [name, enum] in name_table:
    179                         print '   "%s\\0"' % (name)
     179                        print ('   "%s\\0"' % (name))
    180180                        string_offsets[ name ] = i
    181181                        i += len(name) + 1
    182182
    183                 print '   ;'
    184                 print ''
     183                print ('   ;')
     184                print ('')
    185185
    186186
    187                 print 'static const enum_elt all_enums[%u] =' % (len(name_table))
    188                 print '{'
     187                print ('static const enum_elt all_enums[%u] =' % (len(name_table)))
     188                print ('{')
    189189                for [name, enum] in name_table:
    190                         print '   { %5u, 0x%08X }, /* %s */' % (string_offsets[name], enum, name)
    191                 print '};'
    192                 print ''
     190                        print ('   { %5u, 0x%08X }, /* %s */' % (string_offsets[name], enum, name))
     191                print ('};')
     192                print ('')
    193193
    194                 print 'static const unsigned reduced_enums[%u] =' % (len(keys))
    195                 print '{'
     194                print ('static const unsigned reduced_enums[%u] =' % (len(keys)))
     195                print ('{')
    196196                for enum in keys:
    197197                        name = enum_table[ enum ]
    198198                        if [name, enum] not in name_table:
    199                                 print '      /* Error! %s, 0x%04x */ 0,' % (name, enum)
     199                                print ('      /* Error! %s, 0x%04x */ 0,' % (name, enum))
    200200                        else:
    201201                                i = name_table.index( [name, enum] )
    202202
    203                                 print '      %4u, /* %s */' % (i, name)
    204                 print '};'
     203                                print ('      %4u, /* %s */' % (i, name))
     204                print ('};')
    205205
    206206
    207207                self.print_code()
     
    222222
    223223
    224224def show_usage():
    225         print "Usage: %s [-f input_file_name]" % sys.argv[0]
     225        print ("Usage: %s [-f input_file_name]" % sys.argv[0])
    226226        sys.exit(1)
    227227
    228228if __name__ == '__main__':
  • Mesa-7.8.2/src/mesa/glapi/gen/gl_offsets.py

    old new  
    4242                return
    4343
    4444        def printBody(self, api):
    45                 print '/* this file should not be included directly in mesa */'
    46                 print ''
     45                print ('/* this file should not be included directly in mesa */')
     46                print ('')
    4747
    4848                functions = []
    4949                abi_functions = []
     
    6262                                        alias_functions.append(f)
    6363
    6464                for f in abi_functions:
    65                         print '#define _gloffset_%s %d' % (f.name, f.offset)
     65                        print ('#define _gloffset_%s %d' % (f.name, f.offset))
    6666                        last_static = f.offset
    6767
    68                 print ''
    69                 print '#if !defined(_GLAPI_USE_REMAP_TABLE)'
    70                 print ''
     68                print ('')
     69                print ('#if !defined(_GLAPI_USE_REMAP_TABLE)')
     70                print ('')
    7171
    7272                for [f, index] in functions:
    73                         print '#define _gloffset_%s %d' % (f.name, f.offset)
     73                        print ('#define _gloffset_%s %d' % (f.name, f.offset))
    7474
    75                 print '#define _gloffset_FIRST_DYNAMIC %d' % (api.next_offset)
     75                print ('#define _gloffset_FIRST_DYNAMIC %d' % (api.next_offset))
    7676
    77                 print ''
    78                 print '#else'
    79                 print ''
     77                print ('')
     78                print ('#else')
     79                print ('')
    8080
    8181                for [f, index] in functions:
    82                         print '#define _gloffset_%s driDispatchRemapTable[%s_remap_index]' % (f.name, f.name)
     82                        print ('#define _gloffset_%s driDispatchRemapTable[%s_remap_index]' % (f.name, f.name))
    8383
    84                 print ''
    85                 print '#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */'
     84                print ('')
     85                print ('#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */')
    8686
    8787                if alias_functions:
    88                         print ''
    89                         print '/* define aliases for compatibility */'
     88                        print ('')
     89                        print ('/* define aliases for compatibility */')
    9090                        for f in alias_functions:
    9191                                for name in f.entry_points:
    9292                                        if name != f.name:
    93                                                 print '#define _gloffset_%s _gloffset_%s' % (name, f.name)
     93                                                print ('#define _gloffset_%s _gloffset_%s' % (name, f.name))
    9494                return
    9595
    9696
    9797def show_usage():
    98         print "Usage: %s [-f input_file_name] [-c]" % sys.argv[0]
    99         print "    -c        Enable compatibility with OpenGL ES."
     98        print ("Usage: %s [-f input_file_name] [-c]" % sys.argv[0])
     99        print ("    -c        Enable compatibility with OpenGL ES.")
    100100        sys.exit(1)
    101101
    102102if __name__ == '__main__':
  • Mesa-7.8.2/src/mesa/glapi/gen/gl_procs.py

    old new  
    4242
    4343
    4444        def printRealHeader(self):
    45                 print """
     45                print ("""
    4646/* This file is only included by glapi.c and is used for
    4747 * the GetProcAddress() function
    4848 */
     
    6565#  define NAME_FUNC_OFFSET(n,f1,f2,f3,o) { n , (_glapi_proc) f3 , o }
    6666#endif
    6767
    68 """
     68""")
    6969                return
    7070
    7171        def printRealFooter(self):
    72                 print ''
    73                 print '#undef NAME_FUNC_OFFSET'
     72                print ('')
     73                print ('#undef NAME_FUNC_OFFSET')
    7474                return
    7575
    7676        def printFunctionString(self, name):
    7777                if self.long_strings:
    78                         print '    "gl%s\\0"' % (name)
     78                        print ('    "gl%s\\0"' % (name))
    7979                else:
    80                         print "    'g','l',",
     80                        print ("    'g','l',",)
    8181                        for c in name:
    82                                 print "'%s'," % (c),
     82                                print ("'%s'," % (c),)
    8383                       
    84                         print "'\\0',"
     84                        print ("'\\0',")
    8585
    8686
    8787        def printBody(self, api):
    88                 print ''
     88                print ('')
    8989                if self.long_strings:
    90                         print 'static const char gl_string_table[] ='
     90                        print ('static const char gl_string_table[] =')
    9191                else:
    92                         print 'static const char gl_string_table[] = {'
     92                        print ('static const char gl_string_table[] = {')
    9393
    9494                base_offset = 0
    9595                table = []
     
    120120
    121121
    122122                if self.long_strings:
    123                         print '    ;'
     123                        print ('    ;')
    124124                else:
    125                         print '};'
     125                        print ('};')
    126126
    127                 print ''
    128                 print ''
    129                 print "#ifdef USE_MGL_NAMESPACE"
     127                print ('')
     128                print ('')
     129                print ("#ifdef USE_MGL_NAMESPACE")
    130130                for func in api.functionIterateByOffset():
    131131                        for n in func.entry_points:
    132132                                if (not func.is_static_entry_point(func.name)) or (func.has_different_protocol(n) and not func.is_static_entry_point(n)):
    133                                         print '#define gl_dispatch_stub_%u mgl_dispatch_stub_%u' % (func.offset, func.offset)
     133                                        print ('#define gl_dispatch_stub_%u mgl_dispatch_stub_%u' % (func.offset, func.offset))
    134134                                        break
    135                 print "#endif /* USE_MGL_NAMESPACE */"
    136                 print ''
    137                 print ''
    138                 print '#if defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING)'
     135                print ("#endif /* USE_MGL_NAMESPACE */")
     136                print ('')
     137                print ('')
     138                print ('#if defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING)')
    139139                for func in api.functionIterateByOffset():
    140140                        for n in func.entry_points:
    141141                                if (not func.is_static_entry_point(func.name)) or (func.has_different_protocol(n) and not func.is_static_entry_point(n)):
    142                                         print '%s GLAPIENTRY gl_dispatch_stub_%u(%s);' % (func.return_type, func.offset, func.get_parameter_string())
     142                                        print ('%s GLAPIENTRY gl_dispatch_stub_%u(%s);' % (func.return_type, func.offset, func.get_parameter_string()))
    143143                                        break
    144144
    145145                if self.es:
     
    154154                                                                % (func.return_type, "gl" + n, func.get_parameter_string(n))
    155155                                                categories[cat].append(proto)
    156156                        if categories:
    157                                 print ''
    158                                 print '/* OpenGL ES specific prototypes */'
    159                                 print ''
     157                                print ('')
     158                                print ('/* OpenGL ES specific prototypes */')
     159                                print ('')
    160160                                keys = categories.keys()
    161161                                keys.sort()
    162162                                for key in keys:
    163                                         print '/* category %s */' % key
    164                                         print "\n".join(categories[key])
    165                                 print ''
     163                                        print ('/* category %s */' % key)
     164                                        print ("\n".join(categories[key]))
     165                                print ('')
    166166
    167                 print '#endif /* defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING) */'
     167                print ('#endif /* defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING) */')
    168168
    169                 print ''
    170                 print 'static const glprocs_table_t static_functions[] = {'
     169                print ('')
     170                print ('static const glprocs_table_t static_functions[] = {')
    171171
    172172                for info in table:
    173                         print '    NAME_FUNC_OFFSET(%5u, %s, %s, %s, _gloffset_%s),' % info
     173                        print ('    NAME_FUNC_OFFSET(%5u, %s, %s, %s, _gloffset_%s),' % info)
    174174
    175                 print '    NAME_FUNC_OFFSET(-1, NULL, NULL, NULL, 0)'
    176                 print '};'
     175                print ('    NAME_FUNC_OFFSET(-1, NULL, NULL, NULL, 0)')
     176                print ('};')
    177177                return
    178178
    179179
    180180def show_usage():
    181         print "Usage: %s [-f input_file_name] [-m mode] [-c]" % sys.argv[0]
    182         print "-c          Enable compatibility with OpenGL ES."
    183         print "-m mode     mode can be one of:"
    184         print "    long  - Create code for compilers that can handle very"
    185         print "            long string constants. (default)"
    186         print "    short - Create code for compilers that can only handle"
    187         print "            ANSI C89 string constants."
     181        print ("Usage: %s [-f input_file_name] [-m mode] [-c]" % sys.argv[0])
     182        print ("-c          Enable compatibility with OpenGL ES.")
     183        print ("-m mode     mode can be one of:")
     184        print ("    long  - Create code for compilers that can handle very")
     185        print ("            long string constants. (default)")
     186        print ("    short - Create code for compilers that can only handle")
     187        print ("            ANSI C89 string constants.")
    188188        sys.exit(1)
    189189
    190190if __name__ == '__main__':
  • Mesa-7.8.2/src/mesa/glapi/gen/gl_SPARC_asm.py

    old new  
    3939
    4040
    4141        def printRealHeader(self):
    42                 print '#include "glapi/glapioffsets.h"'
    43                 print ''
    44                 print '#ifdef __arch64__'
    45                 print '#define GL_OFF(N)\t((N) * 8)'
    46                 print '#define GL_LL\t\tldx'
    47                 print '#define GL_TIE_LD(SYM)\t%tie_ldx(SYM)'
    48                 print '#define GL_STACK_SIZE\t128'
    49                 print '#else'
    50                 print '#define GL_OFF(N)\t((N) * 4)'
    51                 print '#define GL_LL\t\tld'
    52                 print '#define GL_TIE_LD(SYM)\t%tie_ld(SYM)'
    53                 print '#define GL_STACK_SIZE\t64'
    54                 print '#endif'
    55                 print ''
    56                 print '#define GLOBL_FN(x) .globl x ; .type x, @function'
    57                 print '#define HIDDEN(x) .hidden x'
    58                 print ''
    59                 print '\t.register %g2, #scratch'
    60                 print '\t.register %g3, #scratch'
    61                 print ''
    62                 print '\t.text'
    63                 print ''
    64                 print '\tGLOBL_FN(__glapi_sparc_icache_flush)'
    65                 print '\tHIDDEN(__glapi_sparc_icache_flush)'
    66                 print '\t.type\t__glapi_sparc_icache_flush, @function'
    67                 print '__glapi_sparc_icache_flush: /* %o0 = insn_addr */'
    68                 print '\tflush\t%o0'
    69                 print '\tretl'
    70                 print '\t nop'
    71                 print ''
    72                 print '\t.align\t32'
    73                 print ''
    74                 print '\t.type\t__glapi_sparc_get_pc, @function'
    75                 print '__glapi_sparc_get_pc:'
    76                 print '\tretl'
    77                 print '\t add\t%o7, %g2, %g2'
    78                 print '\t.size\t__glapi_sparc_get_pc, .-__glapi_sparc_get_pc'
    79                 print ''
    80                 print '#ifdef GLX_USE_TLS'
    81                 print ''
    82                 print '\tGLOBL_FN(__glapi_sparc_get_dispatch)'
    83                 print '\tHIDDEN(__glapi_sparc_get_dispatch)'
    84                 print '__glapi_sparc_get_dispatch:'
    85                 print '\tmov\t%o7, %g1'
    86                 print '\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2'
    87                 print '\tcall\t__glapi_sparc_get_pc'
    88                 print '\tadd\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2'
    89                 print '\tmov\t%g1, %o7'
    90                 print '\tsethi\t%tie_hi22(_glapi_tls_Dispatch), %g1'
    91                 print '\tadd\t%g1, %tie_lo10(_glapi_tls_Dispatch), %g1'
    92                 print '\tGL_LL\t[%g2 + %g1], %g2, GL_TIE_LD(_glapi_tls_Dispatch)'
    93                 print '\tretl'
    94                 print '\t mov\t%g2, %o0'
    95                 print ''
    96                 print '\t.data'
    97                 print '\t.align\t32'
    98                 print ''
    99                 print '\t/* --> sethi %hi(_glapi_tls_Dispatch), %g1 */'
    100                 print '\t/* --> or %g1, %lo(_glapi_tls_Dispatch), %g1 */'
    101                 print '\tGLOBL_FN(__glapi_sparc_tls_stub)'
    102                 print '\tHIDDEN(__glapi_sparc_tls_stub)'
    103                 print '__glapi_sparc_tls_stub: /* Call offset in %g3 */'
    104                 print '\tmov\t%o7, %g1'
    105                 print '\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2'
    106                 print '\tcall\t__glapi_sparc_get_pc'
    107                 print '\tadd\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2'
    108                 print '\tmov\t%g1, %o7'
    109                 print '\tsrl\t%g3, 10, %g3'
    110                 print '\tsethi\t%tie_hi22(_glapi_tls_Dispatch), %g1'
    111                 print '\tadd\t%g1, %tie_lo10(_glapi_tls_Dispatch), %g1'
    112                 print '\tGL_LL\t[%g2 + %g1], %g2, GL_TIE_LD(_glapi_tls_Dispatch)'
    113                 print '\tGL_LL\t[%g7+%g2], %g1'
    114                 print '\tGL_LL\t[%g1 + %g3], %g1'
    115                 print '\tjmp\t%g1'
    116                 print '\t nop'
    117                 print '\t.size\t__glapi_sparc_tls_stub, .-__glapi_sparc_tls_stub'
    118                 print ''
    119                 print '#define GL_STUB(fn, off)\t\t\t\t\\'
    120                 print '\tGLOBL_FN(fn);\t\t\t\t\t\\'
    121                 print 'fn:\tba\t__glapi_sparc_tls_stub;\t\t\t\\'
    122                 print '\t sethi\tGL_OFF(off), %g3;\t\t\t\\'
    123                 print '\t.size\tfn,.-fn;'
    124                 print ''
    125                 print '#elif defined(PTHREADS)'
    126                 print ''
    127                 print '\t/* 64-bit 0x00 --> sethi %hh(_glapi_Dispatch), %g1 */'
    128                 print '\t/* 64-bit 0x04 --> sethi %lm(_glapi_Dispatch), %g2 */'
    129                 print '\t/* 64-bit 0x08 --> or %g1, %hm(_glapi_Dispatch), %g1 */'
    130                 print '\t/* 64-bit 0x0c --> sllx %g1, 32, %g1 */'
    131                 print '\t/* 64-bit 0x10 --> add %g1, %g2, %g1 */'
    132                 print '\t/* 64-bit 0x14 --> ldx [%g1 + %lo(_glapi_Dispatch)], %g1 */'
    133                 print ''
    134                 print '\t/* 32-bit 0x00 --> sethi %hi(_glapi_Dispatch), %g1 */'
    135                 print '\t/* 32-bit 0x04 --> ld [%g1 + %lo(_glapi_Dispatch)], %g1 */'
    136                 print ''
    137                 print '\t.data'
    138                 print '\t.align\t32'
    139                 print ''
    140                 print '\tGLOBL_FN(__glapi_sparc_pthread_stub)'
    141                 print '\tHIDDEN(__glapi_sparc_pthread_stub)'
    142                 print '__glapi_sparc_pthread_stub: /* Call offset in %g3 */'
    143                 print '\tmov\t%o7, %g1'
    144                 print '\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2'
    145                 print '\tcall\t__glapi_sparc_get_pc'
    146                 print '\t add\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2'
    147                 print '\tmov\t%g1, %o7'
    148                 print '\tsethi\t%hi(_glapi_Dispatch), %g1'
    149                 print '\tor\t%g1, %lo(_glapi_Dispatch), %g1'
    150                 print '\tsrl\t%g3, 10, %g3'
    151                 print '\tGL_LL\t[%g2+%g1], %g2'
    152                 print '\tGL_LL\t[%g2], %g1'
    153                 print '\tcmp\t%g1, 0'
    154                 print '\tbe\t2f'
    155                 print '\t nop'
    156                 print '1:\tGL_LL\t[%g1 + %g3], %g1'
    157                 print '\tjmp\t%g1'
    158                 print '\t nop'
    159                 print '2:\tsave\t%sp, GL_STACK_SIZE, %sp'
    160                 print '\tmov\t%g3, %l0'
    161                 print '\tcall\t_glapi_get_dispatch'
    162                 print '\t nop'
    163                 print '\tmov\t%o0, %g1'
    164                 print '\tmov\t%l0, %g3'
    165                 print '\tba\t1b'
    166                 print '\t restore %g0, %g0, %g0'
    167                 print '\t.size\t__glapi_sparc_pthread_stub, .-__glapi_sparc_pthread_stub'
    168                 print ''
    169                 print '#define GL_STUB(fn, off)\t\t\t\\'
    170                 print '\tGLOBL_FN(fn);\t\t\t\t\\'
    171                 print 'fn:\tba\t__glapi_sparc_pthread_stub;\t\\'
    172                 print '\t sethi\tGL_OFF(off), %g3;\t\t\\'
    173                 print '\t.size\tfn,.-fn;'
    174                 print ''
    175                 print '#else /* Non-threaded version. */'
    176                 print ''
    177                 print '\t.type  __glapi_sparc_nothread_stub, @function'
    178                 print '__glapi_sparc_nothread_stub: /* Call offset in %g3 */'
    179                 print '\tmov\t%o7, %g1'
    180                 print '\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2'
    181                 print '\tcall\t__glapi_sparc_get_pc'
    182                 print '\t add\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2'
    183                 print '\tmov\t%g1, %o7'
    184                 print '\tsrl\t%g3, 10, %g3'
    185                 print '\tsethi\t%hi(_glapi_Dispatch), %g1'
    186                 print '\tor\t%g1, %lo(_glapi_Dispatch), %g1'
    187                 print '\tGL_LL\t[%g2+%g1], %g2'
    188                 print '\tGL_LL\t[%g2], %g1'
    189                 print '\tGL_LL\t[%g1 + %g3], %g1'
    190                 print '\tjmp\t%g1'
    191                 print '\t nop'
    192                 print '\t.size\t__glapi_sparc_nothread_stub, .-__glapi_sparc_nothread_stub'
    193                 print ''
    194                 print '#define GL_STUB(fn, off)\t\t\t\\'
    195                 print '\tGLOBL_FN(fn);\t\t\t\t\\'
    196                 print 'fn:\tba\t__glapi_sparc_nothread_stub;\t\\'
    197                 print '\t sethi\tGL_OFF(off), %g3;\t\t\\'
    198                 print '\t.size\tfn,.-fn;'
    199                 print ''
    200                 print '#endif'
    201                 print ''
    202                 print '#define GL_STUB_ALIAS(fn, alias)         \\'
    203                 print ' .globl  fn;                             \\'
    204                 print ' .set    fn, alias'
    205                 print ''
    206                 print '\t.text'
    207                 print '\t.align\t32'
    208                 print ''
    209                 print '\t.globl\tgl_dispatch_functions_start'
    210                 print '\tHIDDEN(gl_dispatch_functions_start)'
    211                 print 'gl_dispatch_functions_start:'
    212                 print ''
     42                print ('#include "glapi/glapioffsets.h"')
     43                print ('')
     44                print ('#ifdef __arch64__')
     45                print ('#define GL_OFF(N)\t((N) * 8)')
     46                print ('#define GL_LL\t\tldx')
     47                print ('#define GL_TIE_LD(SYM)\t%tie_ldx(SYM)')
     48                print ('#define GL_STACK_SIZE\t128')
     49                print ('#else')
     50                print ('#define GL_OFF(N)\t((N) * 4)')
     51                print ('#define GL_LL\t\tld')
     52                print ('#define GL_TIE_LD(SYM)\t%tie_ld(SYM)')
     53                print ('#define GL_STACK_SIZE\t64')
     54                print ('#endif')
     55                print ('')
     56                print ('#define GLOBL_FN(x) .globl x ; .type x, @function')
     57                print ('#define HIDDEN(x) .hidden x')
     58                print ('')
     59                print ('\t.register %g2, #scratch')
     60                print ('\t.register %g3, #scratch')
     61                print ('')
     62                print ('\t.text')
     63                print ('')
     64                print ('\tGLOBL_FN(__glapi_sparc_icache_flush)')
     65                print ('\tHIDDEN(__glapi_sparc_icache_flush)')
     66                print ('\t.type\t__glapi_sparc_icache_flush, @function')
     67                print ('__glapi_sparc_icache_flush: /* %o0 = insn_addr */')
     68                print ('\tflush\t%o0')
     69                print ('\tretl')
     70                print ('\t nop')
     71                print ('')
     72                print ('\t.align\t32')
     73                print ('')
     74                print ('\t.type\t__glapi_sparc_get_pc, @function')
     75                print ('__glapi_sparc_get_pc:')
     76                print ('\tretl')
     77                print ('\t add\t%o7, %g2, %g2')
     78                print ('\t.size\t__glapi_sparc_get_pc, .-__glapi_sparc_get_pc')
     79                print ('')
     80                print ('#ifdef GLX_USE_TLS')
     81                print ('')
     82                print ('\tGLOBL_FN(__glapi_sparc_get_dispatch)')
     83                print ('\tHIDDEN(__glapi_sparc_get_dispatch)')
     84                print ('__glapi_sparc_get_dispatch:')
     85                print ('\tmov\t%o7, %g1')
     86                print ('\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2')
     87                print ('\tcall\t__glapi_sparc_get_pc')
     88                print ('\tadd\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2')
     89                print ('\tmov\t%g1, %o7')
     90                print ('\tsethi\t%tie_hi22(_glapi_tls_Dispatch), %g1')
     91                print ('\tadd\t%g1, %tie_lo10(_glapi_tls_Dispatch), %g1')
     92                print ('\tGL_LL\t[%g2 + %g1], %g2, GL_TIE_LD(_glapi_tls_Dispatch)')
     93                print ('\tretl')
     94                print ('\t mov\t%g2, %o0')
     95                print ('')
     96                print ('\t.data')
     97                print ('\t.align\t32')
     98                print ('')
     99                print ('\t/* --> sethi %hi(_glapi_tls_Dispatch), %g1 */')
     100                print ('\t/* --> or %g1, %lo(_glapi_tls_Dispatch), %g1 */')
     101                print ('\tGLOBL_FN(__glapi_sparc_tls_stub)')
     102                print ('\tHIDDEN(__glapi_sparc_tls_stub)')
     103                print ('__glapi_sparc_tls_stub: /* Call offset in %g3 */')
     104                print ('\tmov\t%o7, %g1')
     105                print ('\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2')
     106                print ('\tcall\t__glapi_sparc_get_pc')
     107                print ('\tadd\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2')
     108                print ('\tmov\t%g1, %o7')
     109                print ('\tsrl\t%g3, 10, %g3')
     110                print ('\tsethi\t%tie_hi22(_glapi_tls_Dispatch), %g1')
     111                print ('\tadd\t%g1, %tie_lo10(_glapi_tls_Dispatch), %g1')
     112                print ('\tGL_LL\t[%g2 + %g1], %g2, GL_TIE_LD(_glapi_tls_Dispatch)')
     113                print ('\tGL_LL\t[%g7+%g2], %g1')
     114                print ('\tGL_LL\t[%g1 + %g3], %g1')
     115                print ('\tjmp\t%g1')
     116                print ('\t nop')
     117                print ('\t.size\t__glapi_sparc_tls_stub, .-__glapi_sparc_tls_stub')
     118                print ('')
     119                print ('#define GL_STUB(fn, off)\t\t\t\t\\')
     120                print ('\tGLOBL_FN(fn);\t\t\t\t\t\\')
     121                print ('fn:\tba\t__glapi_sparc_tls_stub;\t\t\t\\')
     122                print ('\t sethi\tGL_OFF(off), %g3;\t\t\t\\')
     123                print ('\t.size\tfn,.-fn;')
     124                print ('')
     125                print ('#elif defined(PTHREADS)')
     126                print ('')
     127                print ('\t/* 64-bit 0x00 --> sethi %hh(_glapi_Dispatch), %g1 */')
     128                print ('\t/* 64-bit 0x04 --> sethi %lm(_glapi_Dispatch), %g2 */')
     129                print ('\t/* 64-bit 0x08 --> or %g1, %hm(_glapi_Dispatch), %g1 */')
     130                print ('\t/* 64-bit 0x0c --> sllx %g1, 32, %g1 */')
     131                print ('\t/* 64-bit 0x10 --> add %g1, %g2, %g1 */')
     132                print ('\t/* 64-bit 0x14 --> ldx [%g1 + %lo(_glapi_Dispatch)], %g1 */')
     133                print ('')
     134                print ('\t/* 32-bit 0x00 --> sethi %hi(_glapi_Dispatch), %g1 */')
     135                print ('\t/* 32-bit 0x04 --> ld [%g1 + %lo(_glapi_Dispatch)], %g1 */')
     136                print ('')
     137                print ('\t.data')
     138                print ('\t.align\t32')
     139                print ('')
     140                print ('\tGLOBL_FN(__glapi_sparc_pthread_stub)')
     141                print ('\tHIDDEN(__glapi_sparc_pthread_stub)')
     142                print ('__glapi_sparc_pthread_stub: /* Call offset in %g3 */')
     143                print ('\tmov\t%o7, %g1')
     144                print ('\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2')
     145                print ('\tcall\t__glapi_sparc_get_pc')
     146                print ('\t add\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2')
     147                print ('\tmov\t%g1, %o7')
     148                print ('\tsethi\t%hi(_glapi_Dispatch), %g1')
     149                print ('\tor\t%g1, %lo(_glapi_Dispatch), %g1')
     150                print ('\tsrl\t%g3, 10, %g3')
     151                print ('\tGL_LL\t[%g2+%g1], %g2')
     152                print ('\tGL_LL\t[%g2], %g1')
     153                print ('\tcmp\t%g1, 0')
     154                print ('\tbe\t2f')
     155                print ('\t nop')
     156                print ('1:\tGL_LL\t[%g1 + %g3], %g1')
     157                print ('\tjmp\t%g1')
     158                print ('\t nop')
     159                print ('2:\tsave\t%sp, GL_STACK_SIZE, %sp')
     160                print ('\tmov\t%g3, %l0')
     161                print ('\tcall\t_glapi_get_dispatch')
     162                print ('\t nop')
     163                print ('\tmov\t%o0, %g1')
     164                print ('\tmov\t%l0, %g3')
     165                print ('\tba\t1b')
     166                print ('\t restore %g0, %g0, %g0')
     167                print ('\t.size\t__glapi_sparc_pthread_stub, .-__glapi_sparc_pthread_stub')
     168                print ('')
     169                print ('#define GL_STUB(fn, off)\t\t\t\\')
     170                print ('\tGLOBL_FN(fn);\t\t\t\t\\')
     171                print ('fn:\tba\t__glapi_sparc_pthread_stub;\t\\')
     172                print ('\t sethi\tGL_OFF(off), %g3;\t\t\\')
     173                print ('\t.size\tfn,.-fn;')
     174                print ('')
     175                print ('#else /* Non-threaded version. */')
     176                print ('')
     177                print ('\t.type __glapi_sparc_nothread_stub, @function')
     178                print ('__glapi_sparc_nothread_stub: /* Call offset in %g3 */')
     179                print ('\tmov\t%o7, %g1')
     180                print ('\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2')
     181                print ('\tcall\t__glapi_sparc_get_pc')
     182                print ('\t add\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2')
     183                print ('\tmov\t%g1, %o7')
     184                print ('\tsrl\t%g3, 10, %g3')
     185                print ('\tsethi\t%hi(_glapi_Dispatch), %g1')
     186                print ('\tor\t%g1, %lo(_glapi_Dispatch), %g1')
     187                print ('\tGL_LL\t[%g2+%g1], %g2')
     188                print ('\tGL_LL\t[%g2], %g1')
     189                print ('\tGL_LL\t[%g1 + %g3], %g1')
     190                print ('\tjmp\t%g1')
     191                print ('\t nop')
     192                print ('\t.size\t__glapi_sparc_nothread_stub, .-__glapi_sparc_nothread_stub')
     193                print ('')
     194                print ('#define GL_STUB(fn, off)\t\t\t\\')
     195                print ('\tGLOBL_FN(fn);\t\t\t\t\\')
     196                print ('fn:\tba\t__glapi_sparc_nothread_stub;\t\\')
     197                print ('\t sethi\tGL_OFF(off), %g3;\t\t\\')
     198                print ('\t.size\tfn,.-fn;')
     199                print ('')
     200                print ('#endif')
     201                print ('')
     202                print ('#define GL_STUB_ALIAS(fn, alias)                \\')
     203                print ('        .globl  fn;                             \\')
     204                print ('        .set    fn, alias')
     205                print ('')
     206                print ('\t.text')
     207                print ('\t.align\t32')
     208                print ('')
     209                print ('\t.globl\tgl_dispatch_functions_start')
     210                print ('\tHIDDEN(gl_dispatch_functions_start)')
     211                print ('gl_dispatch_functions_start:')
     212                print ('')
    213213                return
    214214
    215215        def printRealFooter(self):
    216                 print ''
    217                 print '\t.globl\tgl_dispatch_functions_end'
    218                 print '\tHIDDEN(gl_dispatch_functions_end)'
    219                 print 'gl_dispatch_functions_end:'
     216                print ('')
     217                print ('\t.globl\tgl_dispatch_functions_end')
     218                print ('\tHIDDEN(gl_dispatch_functions_end)')
     219                print ('gl_dispatch_functions_end:')
    220220                return
    221221
    222222        def printBody(self, api):
    223223                for f in api.functionIterateByOffset():
    224224                        name = f.dispatch_name()
    225225
    226                         print '\tGL_STUB(gl%s, _gloffset_%s)' % (name, f.name)
     226                        print ('\tGL_STUB(gl%s, _gloffset_%s)' % (name, f.name))
    227227
    228228                        if not f.is_static_entry_point(f.name):
    229                                 print '\tHIDDEN(gl%s)' % (name)
     229                                print ('\tHIDDEN(gl%s)' % (name))
    230230
    231231                for f in api.functionIterateByOffset():
    232232                        name = f.dispatch_name()
     
    237237                                                text = '\tGL_STUB_ALIAS(gl%s, gl%s)' % (n, f.name)
    238238
    239239                                                if f.has_different_protocol(n):
    240                                                         print '#ifndef GLX_INDIRECT_RENDERING'
    241                                                         print text
    242                                                         print '#endif'
     240                                                        print ('#ifndef GLX_INDIRECT_RENDERING')
     241                                                        print (text)
     242                                                        print ('#endif')
    243243                                                else:
    244                                                         print text
     244                                                        print (text)
    245245
    246246                return
    247247
    248248
    249249def show_usage():
    250         print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]
     250        print ("Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0])
    251251        sys.exit(1)
    252252
    253253if __name__ == '__main__':
     
    268268        if mode == "generic":
    269269                printer = PrintGenericStubs()
    270270        else:
    271                 print "ERROR: Invalid mode \"%s\" specified." % mode
     271                print ("ERROR: Invalid mode \"%s\" specified." % mode)
    272272                show_usage()
    273273
    274274        api = gl_XML.parse_GL_API(file_name, glX_XML.glx_item_factory())
  • Mesa-7.8.2/src/mesa/glapi/gen/gl_table.py

    old new  
    4545        def printBody(self, api):
    4646                for f in api.functionIterateByOffset():
    4747                        arg_string = f.get_parameter_string()
    48                         print '   %s (GLAPIENTRYP %s)(%s); /* %d */' % (f.return_type, f.name, arg_string, f.offset)
     48                        print ('   %s (GLAPIENTRYP %s)(%s); /* %d */' % (f.return_type, f.name, arg_string, f.offset))
    4949
    5050
    5151        def printRealHeader(self):
    52                 print '#ifndef GLAPIENTRYP'
    53                 print '# ifndef GLAPIENTRY'
    54                 print '#  define GLAPIENTRY'
    55                 print '# endif'
    56                 print ''
    57                 print '# define GLAPIENTRYP GLAPIENTRY *'
    58                 print '#endif'
    59                 print ''
    60                 print ''
    61                 print 'struct _glapi_table'
    62                 print '{'
     52                print ('#ifndef GLAPIENTRYP')
     53                print ('# ifndef GLAPIENTRY')
     54                print ('#  define GLAPIENTRY')
     55                print ('# endif')
     56                print ('')
     57                print ('# define GLAPIENTRYP GLAPIENTRY *')
     58                print ('#endif')
     59                print ('')
     60                print ('')
     61                print ('struct _glapi_table')
     62                print ('{')
    6363                return
    6464
    6565
    6666        def printRealFooter(self):
    67                 print '};'
     67                print ('};')
    6868                return
    6969
    7070
     
    8080
    8181
    8282        def printRealHeader(self):
    83                 print """
     83                print ("""
    8484/* this file should not be included directly in mesa */
    8585
    8686/**
     
    9393 * can SET_FuncName, are used to get and set the dispatch pointer for the
    9494 * named function in the specified dispatch table.
    9595 */
    96 """
     96""")
    9797               
    9898                return
    9999
    100100        def printBody(self, api):
    101                 print '#define CALL_by_offset(disp, cast, offset, parameters) \\'
    102                 print '    (*(cast (GET_by_offset(disp, offset)))) parameters'
    103                 print '#define GET_by_offset(disp, offset) \\'
    104                 print '    (offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : NULL'
    105                 print '#define SET_by_offset(disp, offset, fn) \\'
    106                 print '    do { \\'
    107                 print '        if ( (offset) < 0 ) { \\'
    108                 print '            /* fprintf( stderr, "[%s:%u] SET_by_offset(%p, %d, %s)!\\n", */ \\'
    109                 print '            /*         __func__, __LINE__, disp, offset, # fn); */ \\'
    110                 print '            /* abort(); */ \\'
    111                 print '        } \\'
    112                 print '        else { \\'
    113                 print '            ( (_glapi_proc *) (disp) )[offset] = (_glapi_proc) fn; \\'
    114                 print '        } \\'
    115                 print '    } while(0)'
    116                 print ''
     101                print ('#define CALL_by_offset(disp, cast, offset, parameters) \\')
     102                print ('    (*(cast (GET_by_offset(disp, offset)))) parameters')
     103                print ('#define GET_by_offset(disp, offset) \\')
     104                print ('    (offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : NULL')
     105                print ('#define SET_by_offset(disp, offset, fn) \\')
     106                print ('    do { \\')
     107                print ('        if ( (offset) < 0 ) { \\')
     108                print ('            /* fprintf( stderr, "[%s:%u] SET_by_offset(%p, %d, %s)!\\n", */ \\')
     109                print ('            /*         __func__, __LINE__, disp, offset, # fn); */ \\')
     110                print ('            /* abort(); */ \\')
     111                print ('        } \\')
     112                print ('        else { \\')
     113                print ('            ( (_glapi_proc *) (disp) )[offset] = (_glapi_proc) fn; \\')
     114                print ('        } \\')
     115                print ('    } while(0)')
     116                print ('')
    117117
    118118                functions = []
    119119                abi_functions = []
     
    133133
    134134
    135135                for f in abi_functions:
    136                         print '#define CALL_%s(disp, parameters) (*((disp)->%s)) parameters' % (f.name, f.name)
    137                         print '#define GET_%s(disp) ((disp)->%s)' % (f.name, f.name)
    138                         print '#define SET_%s(disp, fn) ((disp)->%s = fn)' % (f.name, f.name)
     136                        print ('#define CALL_%s(disp, parameters) (*((disp)->%s)) parameters' % (f.name, f.name))
     137                        print ('#define GET_%s(disp) ((disp)->%s)' % (f.name, f.name))
     138                        print ('#define SET_%s(disp, fn) ((disp)->%s = fn)' % (f.name, f.name))
    139139
    140140
    141                 print ''
    142                 print '#if !defined(_GLAPI_USE_REMAP_TABLE)'
    143                 print ''
     141                print ('')
     142                print ('#if !defined(_GLAPI_USE_REMAP_TABLE)')
     143                print ('')
    144144
    145145                for [f, index] in functions:
    146                         print '#define CALL_%s(disp, parameters) (*((disp)->%s)) parameters' % (f.name, f.name)
    147                         print '#define GET_%s(disp) ((disp)->%s)' % (f.name, f.name)
    148                         print '#define SET_%s(disp, fn) ((disp)->%s = fn)' % (f.name, f.name)
    149 
    150                 print ''
    151                 print '#else'
    152                 print ''
    153                 print '#define driDispatchRemapTable_size %u' % (count)
    154                 print 'extern int driDispatchRemapTable[ driDispatchRemapTable_size ];'
    155                 print ''
     146                        print ('#define CALL_%s(disp, parameters) (*((disp)->%s)) parameters' % (f.name, f.name))
     147                        print ('#define GET_%s(disp) ((disp)->%s)' % (f.name, f.name))
     148                        print ('#define SET_%s(disp, fn) ((disp)->%s = fn)' % (f.name, f.name))
     149
     150                print ('')
     151                print ('#else')
     152                print ('')
     153                print ('#define driDispatchRemapTable_size %u' % (count))
     154                print ('extern int driDispatchRemapTable[ driDispatchRemapTable_size ];')
     155                print ('')
    156156
    157157                for [f, index] in functions:
    158                         print '#define %s_remap_index %u' % (f.name, index)
     158                        print ('#define %s_remap_index %u' % (f.name, index))
    159159
    160                 print ''
     160                print ('')
    161161
    162162                for [f, index] in functions:
    163163                        arg_string = gl_XML.create_parameter_string( f.parameters, 0 )
    164164                        cast = '%s (GLAPIENTRYP)(%s)' % (f.return_type, arg_string)
    165165
    166                         print '#define CALL_%s(disp, parameters) CALL_by_offset(disp, (%s), driDispatchRemapTable[%s_remap_index], parameters)' % (f.name, cast, f.name)
    167                         print '#define GET_%s(disp) GET_by_offset(disp, driDispatchRemapTable[%s_remap_index])' % (f.name, f.name)
    168                         print '#define SET_%s(disp, fn) SET_by_offset(disp, driDispatchRemapTable[%s_remap_index], fn)' % (f.name, f.name)
     166                        print ('#define CALL_%s(disp, parameters) CALL_by_offset(disp, (%s), driDispatchRemapTable[%s_remap_index], parameters)' % (f.name, cast, f.name))
     167                        print ('#define GET_%s(disp) GET_by_offset(disp, driDispatchRemapTable[%s_remap_index])' % (f.name, f.name))
     168                        print ('#define SET_%s(disp, fn) SET_by_offset(disp, driDispatchRemapTable[%s_remap_index], fn)' % (f.name, f.name))
    169169
    170170
    171                 print ''
    172                 print '#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */'
     171                print ('')
     172                print ('#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */')
    173173
    174174                if alias_functions:
    175                         print ''
    176                         print '/* define aliases for compatibility */'
     175                        print ('')
     176                        print ('/* define aliases for compatibility */')
    177177                        for f in alias_functions:
    178178                                for name in f.entry_points:
    179179                                        if name != f.name:
    180                                                 print '#define CALL_%s(disp, parameters) CALL_%s(disp, parameters)' % (name, f.name)
    181                                                 print '#define GET_%s(disp) GET_%s(disp)' % (name, f.name)
    182                                                 print '#define SET_%s(disp, fn) SET_%s(disp, fn)' % (name, f.name)
    183                         print ''
     180                                                print ('#define CALL_%s(disp, parameters) CALL_%s(disp, parameters)' % (name, f.name))
     181                                                print ('#define GET_%s(disp) GET_%s(disp)' % (name, f.name))
     182                                                print ('#define SET_%s(disp, fn) SET_%s(disp, fn)' % (name, f.name))
     183                        print ('')
    184184
    185                         print '#if defined(_GLAPI_USE_REMAP_TABLE)'
     185                        print ('#if defined(_GLAPI_USE_REMAP_TABLE)')
    186186                        for f in alias_functions:
    187187                                for name in f.entry_points:
    188188                                        if name != f.name:
    189                                                 print '#define %s_remap_index %s_remap_index' % (name, f.name)
    190                         print '#endif /* defined(_GLAPI_USE_REMAP_TABLE) */'
    191                         print ''
     189                                                print ('#define %s_remap_index %s_remap_index' % (name, f.name))
     190                        print ('#endif /* defined(_GLAPI_USE_REMAP_TABLE) */')
     191                        print ('')
    192192
    193193                return
    194194
    195195
    196196def show_usage():
    197         print "Usage: %s [-f input_file_name] [-m mode] [-c]" % sys.argv[0]
    198         print "    -m mode   Mode can be 'table' or 'remap_table'."
    199         print "    -c        Enable compatibility with OpenGL ES."
     197        print ("Usage: %s [-f input_file_name] [-m mode] [-c]" % sys.argv[0])
     198        print ("    -m mode   Mode can be 'table' or 'remap_table'.")
     199        print ("    -c        Enable compatibility with OpenGL ES.")
    200200        sys.exit(1)
    201201
    202202if __name__ == '__main__':
  • Mesa-7.8.2/src/mesa/glapi/gen/gl_x86-64_asm.py

    old new  
    5353        adjust_stack = 0
    5454        if not should_use_push(registers):
    5555                adjust_stack = local_size(registers)
    56                 print '\tsubq\t$%u, %%rsp' % (adjust_stack)
     56                print ('\tsubq\t$%u, %%rsp' % (adjust_stack))
    5757
    5858        for [reg, stack_offset] in registers:
    5959                save_reg( reg, stack_offset, adjust_stack )
     
    7171                restore_reg(reg, stack_offset, adjust_stack)
    7272
    7373        if adjust_stack:
    74                 print '\taddq\t$%u, %%rsp' % (adjust_stack)
     74                print ('\taddq\t$%u, %%rsp' % (adjust_stack))
    7575        return
    7676
    7777
    7878def save_reg(reg, offset, use_move):
    7979        if use_move:
    8080                if offset == 0:
    81                         print '\tmovq\t%s, (%%rsp)' % (reg)
     81                        print ('\tmovq\t%s, (%%rsp)' % (reg))
    8282                else:
    83                         print '\tmovq\t%s, %u(%%rsp)' % (reg, offset)
     83                        print ('\tmovq\t%s, %u(%%rsp)' % (reg, offset))
    8484        else:
    85                 print '\tpushq\t%s' % (reg)
     85                print ('\tpushq\t%s' % (reg))
    8686
    8787        return
    8888
     
    9090def restore_reg(reg, offset, use_move):
    9191        if use_move:
    9292                if offset == 0:
    93                         print '\tmovq\t(%%rsp), %s' % (reg)
     93                        print ('\tmovq\t(%%rsp), %s' % (reg))
    9494                else:
    95                         print '\tmovq\t%u(%%rsp), %s' % (offset, reg)
     95                        print ('\tmovq\t%u(%%rsp), %s' % (offset, reg))
    9696        else:
    97                 print '\tpopq\t%s' % (reg)
     97                print ('\tpopq\t%s' % (reg))
    9898
    9999        return
    100100
     
    118118
    119119
    120120        def printRealHeader(self):
    121                 print "/* If we build with gcc's -fvisibility=hidden flag, we'll need to change"
    122                 print " * the symbol visibility mode to 'default'."
    123                 print ' */'
    124                 print ''
    125                 print '#include "x86/assyntax.h"'
    126                 print ''
    127                 print '#ifdef __GNUC__'
    128                 print '#  pragma GCC visibility push(default)'
    129                 print '#  define HIDDEN(x) .hidden x'
    130                 print '#else'
    131                 print '#  define HIDDEN(x)'
    132                 print '#endif'
    133                 print ''
    134                 print '# if defined(USE_MGL_NAMESPACE)'
    135                 print '#  define GL_PREFIX(n) GLNAME(CONCAT(mgl,n))'
    136                 print '#  define _glapi_Dispatch _mglapi_Dispatch'
    137                 print '# else'
    138                 print '#  define GL_PREFIX(n) GLNAME(CONCAT(gl,n))'
    139                 print '# endif'
    140                 print ''
    141                 print '#if defined(PTHREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)'
    142                 print '#  define THREADS'
    143                 print '#endif'
    144                 print ''
    145                 print '\t.text'
    146                 print ''
    147                 print '#ifdef GLX_USE_TLS'
    148                 print ''
    149                 print '\t.globl _x86_64_get_get_dispatch; HIDDEN(_x86_64_get_get_dispatch)'
    150                 print '_x86_64_get_get_dispatch:'
    151                 print '\tlea\t_x86_64_get_dispatch(%rip), %rax'
    152                 print '\tret'
    153                 print ''
    154                 print '\t.p2align\t4,,15'
    155                 print '_x86_64_get_dispatch:'
    156                 print '\tmovq\t_glapi_tls_Dispatch@GOTTPOFF(%rip), %rax'
    157                 print '\tmovq\t%fs:(%rax), %rax'
    158                 print '\tret'
    159                 print '\t.size\t_x86_64_get_dispatch, .-_x86_64_get_dispatch'
    160                 print ''
    161                 print '#elif defined(PTHREADS)'
    162                 print ''
    163                 print '\t.extern\t_glapi_Dispatch'
    164                 print '\t.extern\t_gl_DispatchTSD'
    165                 print '\t.extern\tpthread_getspecific'
    166                 print ''
    167                 print '\t.p2align\t4,,15'
    168                 print '_x86_64_get_dispatch:'
    169                 print '\tmovq\t_gl_DispatchTSD(%rip), %rdi'
    170                 print '\tjmp\tpthread_getspecific@PLT'
    171                 print ''
    172                 print '#elif defined(THREADS)'
    173                 print ''
    174                 print '\t.extern\t_glapi_get_dispatch'
    175                 print ''
    176                 print '#endif'
    177                 print ''
     121                print ("/* If we build with gcc's -fvisibility=hidden flag, we'll need to change")
     122                print (" * the symbol visibility mode to 'default'.")
     123                print (' */')
     124                print ('')
     125                print ('#include "x86/assyntax.h"')
     126                print ('')
     127                print ('#ifdef __GNUC__')
     128                print ('#  pragma GCC visibility push(default)')
     129                print ('#  define HIDDEN(x) .hidden x')
     130                print ('#else')
     131                print ('#  define HIDDEN(x)')
     132                print ('#endif')
     133                print ('')
     134                print ('# if defined(USE_MGL_NAMESPACE)')
     135                print ('#  define GL_PREFIX(n) GLNAME(CONCAT(mgl,n))')
     136                print ('#  define _glapi_Dispatch _mglapi_Dispatch')
     137                print ('# else')
     138                print ('#  define GL_PREFIX(n) GLNAME(CONCAT(gl,n))')
     139                print ('# endif')
     140                print ('')
     141                print ('#if defined(PTHREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)')
     142                print ('#  define THREADS')
     143                print ('#endif')
     144                print ('')
     145                print ('\t.text')
     146                print ('')
     147                print ('#ifdef GLX_USE_TLS')
     148                print ('')
     149                print ('\t.globl _x86_64_get_get_dispatch; HIDDEN(_x86_64_get_get_dispatch)')
     150                print ('_x86_64_get_get_dispatch:')
     151                print ('\tlea\t_x86_64_get_dispatch(%rip), %rax')
     152                print ('\tret')
     153                print ('')
     154                print ('\t.p2align\t4,,15')
     155                print ('_x86_64_get_dispatch:')
     156                print ('\tmovq\t_glapi_tls_Dispatch@GOTTPOFF(%rip), %rax')
     157                print ('\tmovq\t%fs:(%rax), %rax')
     158                print ('\tret')
     159                print ('\t.size\t_x86_64_get_dispatch, .-_x86_64_get_dispatch')
     160                print ('')
     161                print ('#elif defined(PTHREADS)')
     162                print ('')
     163                print ('\t.extern\t_glapi_Dispatch')
     164                print ('\t.extern\t_gl_DispatchTSD')
     165                print ('\t.extern\tpthread_getspecific')
     166                print ('')
     167                print ('\t.p2align\t4,,15')
     168                print ('_x86_64_get_dispatch:')
     169                print ('\tmovq\t_gl_DispatchTSD(%rip), %rdi')
     170                print ('\tjmp\tpthread_getspecific@PLT')
     171                print ('')
     172                print ('#elif defined(THREADS)')
     173                print ('')
     174                print ('\t.extern\t_glapi_get_dispatch')
     175                print ('')
     176                print ('#endif')
     177                print ('')
    178178                return
    179179
    180180
    181181        def printRealFooter(self):
    182                 print ''
    183                 print '#if defined(GLX_USE_TLS) && defined(__linux__)'
    184                 print ' .section ".note.ABI-tag", "a"'
    185                 print ' .p2align 2'
    186                 print ' .long   1f - 0f   /* name length */'
    187                 print ' .long   3f - 2f   /* data length */'
    188                 print ' .long   1         /* note length */'
    189                 print '0:       .asciz "GNU"      /* vendor name */'
    190                 print '1:       .p2align 2'
    191                 print '2:       .long   0         /* note data: the ABI tag */'
    192                 print ' .long   2,4,20    /* Minimum kernel version w/TLS */'
    193                 print '3:       .p2align 2        /* pad out section */'
    194                 print '#endif /* GLX_USE_TLS */'
    195                 print ''
    196                 print '#if defined (__ELF__) && defined (__linux__)'
    197                 print ' .section .note.GNU-stack,"",%progbits'
    198                 print '#endif'
     182                print ('')
     183                print ('#if defined(GLX_USE_TLS) && defined(__linux__)')
     184                print ('        .section ".note.ABI-tag", "a"')
     185                print ('        .p2align 2')
     186                print ('        .long   1f - 0f   /* name length */')
     187                print ('        .long   3f - 2f   /* data length */')
     188                print ('        .long   1         /* note length */')
     189                print ('0:      .asciz "GNU"      /* vendor name */')
     190                print ('1:      .p2align 2')
     191                print ('2:      .long   0         /* note data: the ABI tag */')
     192                print ('        .long   2,4,20    /* Minimum kernel version w/TLS */')
     193                print ('3:      .p2align 2        /* pad out section */')
     194                print ('#endif /* GLX_USE_TLS */')
     195                print ('')
     196                print ('#if defined (__ELF__) && defined (__linux__)')
     197                print ('        .section .note.GNU-stack,"",%progbits')
     198                print ('#endif')
    199199                return
    200200
    201201
     
    240240
    241241                name = f.dispatch_name()
    242242
    243                 print '\t.p2align\t4,,15'
    244                 print '\t.globl\tGL_PREFIX(%s)' % (name)
    245                 print '\t.type\tGL_PREFIX(%s), @function' % (name)
     243                print ('\t.p2align\t4,,15')
     244                print ('\t.globl\tGL_PREFIX(%s)' % (name))
     245                print ('\t.type\tGL_PREFIX(%s), @function' % (name))
    246246                if not f.is_static_entry_point(f.name):
    247                         print '\tHIDDEN(GL_PREFIX(%s))' % (name)
    248                 print 'GL_PREFIX(%s):' % (name)
    249                 print '#if defined(GLX_USE_TLS)'
    250                 print '\tcall\t_x86_64_get_dispatch@PLT'
    251                 print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)
    252                 print '\tjmp\t*%r11'
    253                 print '#elif defined(PTHREADS)'
     247                        print ('\tHIDDEN(GL_PREFIX(%s))' % (name))
     248                print ('GL_PREFIX(%s):' % (name))
     249                print ('#if defined(GLX_USE_TLS)')
     250                print ('\tcall\t_x86_64_get_dispatch@PLT')
     251                print ('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8))
     252                print ('\tjmp\t*%r11')
     253                print ('#elif defined(PTHREADS)')
    254254               
    255255                save_all_regs(registers)
    256                 print '\tcall\t_x86_64_get_dispatch@PLT'
     256                print ('\tcall\t_x86_64_get_dispatch@PLT')
    257257                restore_all_regs(registers)
    258258
    259259                if f.offset == 0:
    260                         print '\tmovq\t(%rax), %r11'
     260                        print ('\tmovq\t(%rax), %r11')
    261261                else:
    262                         print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)
     262                        print ('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8))
    263263
    264                 print '\tjmp\t*%r11'
     264                print ('\tjmp\t*%r11')
    265265
    266                 print '#else'
    267                 print '\tmovq\t_glapi_Dispatch(%rip), %rax'
    268                 print '\ttestq\t%rax, %rax'
    269                 print '\tje\t1f'
    270                 print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)
    271                 print '\tjmp\t*%r11'
    272                 print '1:'
     266                print ('#else')
     267                print ('\tmovq\t_glapi_Dispatch(%rip), %rax')
     268                print ('\ttestq\t%rax, %rax')
     269                print ('\tje\t1f')
     270                print ('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8))
     271                print ('\tjmp\t*%r11')
     272                print ('1:')
    273273
    274274                save_all_regs(registers)
    275                 print '\tcall\t_glapi_get_dispatch'
     275                print ('\tcall\t_glapi_get_dispatch')
    276276                restore_all_regs(registers)
    277277
    278                 print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)
    279                 print '\tjmp\t*%r11'
    280                 print '#endif /* defined(GLX_USE_TLS) */'
     278                print ('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8))
     279                print ('\tjmp\t*%r11')
     280                print ('#endif /* defined(GLX_USE_TLS) */')
    281281
    282                 print '\t.size\tGL_PREFIX(%s), .-GL_PREFIX(%s)' % (name, name)
    283                 print ''
     282                print ('\t.size\tGL_PREFIX(%s), .-GL_PREFIX(%s)' % (name, name))
     283                print ('')
    284284                return
    285285
    286286
     
    297297                                                text = '\t.globl GL_PREFIX(%s) ; .set GL_PREFIX(%s), GL_PREFIX(%s)' % (n, n, dispatch)
    298298
    299299                                                if f.has_different_protocol(n):
    300                                                         print '#ifndef GLX_INDIRECT_RENDERING'
    301                                                         print text
    302                                                         print '#endif'
     300                                                        print ('#ifndef GLX_INDIRECT_RENDERING')
     301                                                        print (text)
     302                                                        print ('#endif')
    303303                                                else:
    304                                                         print text
     304                                                        print (text)
    305305
    306306                return
    307307
    308308def show_usage():
    309         print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]
     309        print ("Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0])
    310310        sys.exit(1)
    311311
    312312if __name__ == '__main__':
     
    327327        if mode == "generic":
    328328                printer = PrintGenericStubs()
    329329        else:
    330                 print "ERROR: Invalid mode \"%s\" specified." % mode
     330                print ("ERROR: Invalid mode \"%s\" specified." % mode)
    331331                show_usage()
    332332
    333333        api = gl_XML.parse_GL_API(file_name, glX_XML.glx_item_factory())
  • Mesa-7.8.2/src/mesa/glapi/gen/gl_x86_asm.py

    old new  
    5353
    5454
    5555        def printRealHeader(self):
    56                 print '#include "x86/assyntax.h"'
    57                 print '#include "glapi/glapioffsets.h"'
    58                 print ''
    59                 print '#if defined(STDCALL_API)'
    60                 print '# if defined(USE_MGL_NAMESPACE)'
    61                 print '#  define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n2))'
    62                 print '# else'
    63                 print '#  define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n2))'
    64                 print '# endif'
    65                 print '#else'
    66                 print '# if defined(USE_MGL_NAMESPACE)'
    67                 print '#  define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n))'
    68                 print '#  define _glapi_Dispatch _mglapi_Dispatch'
    69                 print '# else'
    70                 print '#  define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n))'
    71                 print '# endif'
    72                 print '#endif'
    73                 print ''
    74                 print '#define GL_OFFSET(x) CODEPTR(REGOFF(4 * x, EAX))'
    75                 print ''
    76                 print '#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__)'
    77                 print '#define GLOBL_FN(x) GLOBL x ; .type x, function'
    78                 print '#else'
    79                 print '#define GLOBL_FN(x) GLOBL x'
    80                 print '#endif'
    81                 print ''
    82                 print '#if defined(PTHREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)'
    83                 print '#  define THREADS'
    84                 print '#endif'
    85                 print ''
    86                 print '#ifdef GLX_USE_TLS'
    87                 print ''
    88                 print '#ifdef GLX_X86_READONLY_TEXT'
    89                 print '# define CTX_INSNS MOV_L(GS:(EAX), EAX)'
    90                 print '#else'
    91                 print '# define CTX_INSNS NOP /* Pad for init_glapi_relocs() */'
    92                 print '#endif'
    93                 print ''
    94                 print '#  define GL_STUB(fn,off,fn_alt)\t\t\t\\'
    95                 print 'ALIGNTEXT16;\t\t\t\t\t\t\\'
    96                 print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'
    97                 print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'
    98                 print '\tCALL(_x86_get_dispatch) ;\t\t\t\\'
    99                 print '\tCTX_INSNS ;                                    \\'
    100                 print '\tJMP(GL_OFFSET(off))'
    101                 print ''
    102                 print '#elif defined(PTHREADS)'
    103                 print '#  define GL_STUB(fn,off,fn_alt)\t\t\t\\'
    104                 print 'ALIGNTEXT16;\t\t\t\t\t\t\\'
    105                 print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'
    106                 print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'
    107                 print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\'
    108                 print '\tTEST_L(EAX, EAX) ;\t\t\t\t\\'
    109                 print '\tJE(1f) ;\t\t\t\t\t\\'
    110                 print '\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\'
    111                 print '1:\tCALL(_x86_get_dispatch) ;\t\t\t\\'
    112                 print '\tJMP(GL_OFFSET(off))'
    113                 print '#elif defined(THREADS)'
    114                 print '#  define GL_STUB(fn,off,fn_alt)\t\t\t\\'
    115                 print 'ALIGNTEXT16;\t\t\t\t\t\t\\'
    116                 print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'
    117                 print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'
    118                 print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\'
    119                 print '\tTEST_L(EAX, EAX) ;\t\t\t\t\\'
    120                 print '\tJE(1f) ;\t\t\t\t\t\\'
    121                 print '\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\'
    122                 print '1:\tCALL(_glapi_get_dispatch) ;\t\t\t\\'
    123                 print '\tJMP(GL_OFFSET(off))'
    124                 print '#else /* Non-threaded version. */'
    125                 print '#  define GL_STUB(fn,off,fn_alt)\t\t\t\\'
    126                 print 'ALIGNTEXT16;\t\t\t\t\t\t\\'
    127                 print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'
    128                 print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'
    129                 print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\'
    130                 print '\tJMP(GL_OFFSET(off))'
    131                 print '#endif'
    132                 print ''
    133                 print '#ifdef HAVE_ALIAS'
    134                 print '#  define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\'
    135                 print '\t.globl\tGL_PREFIX(fn, fn_alt) ;\t\t\t\\'
    136                 print '\t.set\tGL_PREFIX(fn, fn_alt), GL_PREFIX(alias, alias_alt)'
    137                 print '#else'
    138                 print '#  define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\'
    139                 print '    GL_STUB(fn, off, fn_alt)'
    140                 print '#endif'
    141                 print ''
    142                 print 'SEG_TEXT'
    143                 print ''
    144                 print '#ifdef GLX_USE_TLS'
    145                 print ''
    146                 print '\tGLOBL\tGLNAME(_x86_get_dispatch)'
    147                 print '\tHIDDEN(GLNAME(_x86_get_dispatch))'
    148                 print 'ALIGNTEXT16'
    149                 print 'GLNAME(_x86_get_dispatch):'
    150                 print '\tcall   1f'
    151                 print '1:\tpopl %eax'
    152                 print '\taddl   $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax'
    153                 print '\tmovl   _glapi_tls_Dispatch@GOTNTPOFF(%eax), %eax'
    154                 print '\tret'
    155                 print ''
    156                 print '#elif defined(PTHREADS)'
    157                 print 'EXTERN GLNAME(_glapi_Dispatch)'
    158                 print 'EXTERN GLNAME(_gl_DispatchTSD)'
    159                 print 'EXTERN GLNAME(pthread_getspecific)'
    160                 print ''
    161                 print 'ALIGNTEXT16'
    162                 print 'GLNAME(_x86_get_dispatch):'
    163                 print '\tSUB_L(CONST(24), ESP)'
    164                 print '\tPUSH_L(GLNAME(_gl_DispatchTSD))'
    165                 print '\tCALL(GLNAME(pthread_getspecific))'
    166                 print '\tADD_L(CONST(28), ESP)'
    167                 print '\tRET'
    168                 print '#elif defined(THREADS)'
    169                 print 'EXTERN GLNAME(_glapi_get_dispatch)'
    170                 print '#endif'
    171                 print ''
    172 
    173                 print '#if defined( GLX_USE_TLS ) && !defined( GLX_X86_READONLY_TEXT )'
    174                 print '\t\t.section\twtext, "awx", @progbits'
    175                 print '#endif /* defined( GLX_USE_TLS ) */'
    176 
    177                 print ''
    178                 print '\t\tALIGNTEXT16'
    179                 print '\t\tGLOBL GLNAME(gl_dispatch_functions_start)'
    180                 print '\t\tHIDDEN(GLNAME(gl_dispatch_functions_start))'
    181                 print 'GLNAME(gl_dispatch_functions_start):'
    182                 print ''
     56                print ('#include "x86/assyntax.h"')
     57                print ('#include "glapi/glapioffsets.h"')
     58                print ('')
     59                print ('#if defined(STDCALL_API)')
     60                print ('# if defined(USE_MGL_NAMESPACE)')
     61                print ('#  define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n2))')
     62                print ('# else')
     63                print ('#  define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n2))')
     64                print ('# endif')
     65                print ('#else')
     66                print ('# if defined(USE_MGL_NAMESPACE)')
     67                print ('#  define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n))')
     68                print ('#  define _glapi_Dispatch _mglapi_Dispatch')
     69                print ('# else')
     70                print ('#  define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n))')
     71                print ('# endif')
     72                print ('#endif')
     73                print ('')
     74                print ('#define GL_OFFSET(x) CODEPTR(REGOFF(4 * x, EAX))')
     75                print ('')
     76                print ('#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__)')
     77                print ('#define GLOBL_FN(x) GLOBL x ; .type x, function')
     78                print ('#else')
     79                print ('#define GLOBL_FN(x) GLOBL x')
     80                print ('#endif')
     81                print ('')
     82                print ('#if defined(PTHREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)')
     83                print ('#  define THREADS')
     84                print ('#endif')
     85                print ('')
     86                print ('#ifdef GLX_USE_TLS')
     87                print ('')
     88                print ('#ifdef GLX_X86_READONLY_TEXT')
     89                print ('# define CTX_INSNS MOV_L(GS:(EAX), EAX)')
     90                print ('#else')
     91                print ('# define CTX_INSNS NOP /* Pad for init_glapi_relocs() */')
     92                print ('#endif')
     93                print ('')
     94                print ('#  define GL_STUB(fn,off,fn_alt)\t\t\t\\')
     95                print ('ALIGNTEXT16;\t\t\t\t\t\t\\')
     96                print ('GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\')
     97                print ('GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\')
     98                print ('\tCALL(_x86_get_dispatch) ;\t\t\t\\')
     99                print ('\tCTX_INSNS ;                                   \\')
     100                print ('\tJMP(GL_OFFSET(off))')
     101                print ('')
     102                print ('#elif defined(PTHREADS)')
     103                print ('#  define GL_STUB(fn,off,fn_alt)\t\t\t\\')
     104                print ('ALIGNTEXT16;\t\t\t\t\t\t\\')
     105                print ('GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\')
     106                print ('GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\')
     107                print ('\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\')
     108                print ('\tTEST_L(EAX, EAX) ;\t\t\t\t\\')
     109                print ('\tJE(1f) ;\t\t\t\t\t\\')
     110                print ('\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\')
     111                print ('1:\tCALL(_x86_get_dispatch) ;\t\t\t\\')
     112                print ('\tJMP(GL_OFFSET(off))')
     113                print ('#elif defined(THREADS)')
     114                print ('#  define GL_STUB(fn,off,fn_alt)\t\t\t\\')
     115                print ('ALIGNTEXT16;\t\t\t\t\t\t\\')
     116                print ('GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\')
     117                print ('GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\')
     118                print ('\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\')
     119                print ('\tTEST_L(EAX, EAX) ;\t\t\t\t\\')
     120                print ('\tJE(1f) ;\t\t\t\t\t\\')
     121                print ('\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\')
     122                print ('1:\tCALL(_glapi_get_dispatch) ;\t\t\t\\')
     123                print ('\tJMP(GL_OFFSET(off))')
     124                print ('#else /* Non-threaded version. */')
     125                print ('#  define GL_STUB(fn,off,fn_alt)\t\t\t\\')
     126                print ('ALIGNTEXT16;\t\t\t\t\t\t\\')
     127                print ('GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\')
     128                print ('GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\')
     129                print ('\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\')
     130                print ('\tJMP(GL_OFFSET(off))')
     131                print ('#endif')
     132                print ('')
     133                print ('#ifdef HAVE_ALIAS')
     134                print ('#  define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\')
     135                print ('\t.globl\tGL_PREFIX(fn, fn_alt) ;\t\t\t\\')
     136                print ('\t.set\tGL_PREFIX(fn, fn_alt), GL_PREFIX(alias, alias_alt)')
     137                print ('#else')
     138                print ('#  define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\')
     139                print ('    GL_STUB(fn, off, fn_alt)')
     140                print ('#endif')
     141                print ('')
     142                print ('SEG_TEXT')
     143                print ('')
     144                print ('#ifdef GLX_USE_TLS')
     145                print ('')
     146                print ('\tGLOBL\tGLNAME(_x86_get_dispatch)')
     147                print ('\tHIDDEN(GLNAME(_x86_get_dispatch))')
     148                print ('ALIGNTEXT16')
     149                print ('GLNAME(_x86_get_dispatch):')
     150                print ('\tcall  1f')
     151                print ('1:\tpopl        %eax')
     152                print ('\taddl  $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax')
     153                print ('\tmovl  _glapi_tls_Dispatch@GOTNTPOFF(%eax), %eax')
     154                print ('\tret')
     155                print ('')
     156                print ('#elif defined(PTHREADS)')
     157                print ('EXTERN GLNAME(_glapi_Dispatch)')
     158                print ('EXTERN GLNAME(_gl_DispatchTSD)')
     159                print ('EXTERN GLNAME(pthread_getspecific)')
     160                print ('')
     161                print ('ALIGNTEXT16')
     162                print ('GLNAME(_x86_get_dispatch):')
     163                print ('\tSUB_L(CONST(24), ESP)')
     164                print ('\tPUSH_L(GLNAME(_gl_DispatchTSD))')
     165                print ('\tCALL(GLNAME(pthread_getspecific))')
     166                print ('\tADD_L(CONST(28), ESP)')
     167                print ('\tRET')
     168                print ('#elif defined(THREADS)')
     169                print ('EXTERN GLNAME(_glapi_get_dispatch)')
     170                print ('#endif')
     171                print ('')
     172
     173                print ('#if defined( GLX_USE_TLS ) && !defined( GLX_X86_READONLY_TEXT )')
     174                print ('\t\t.section\twtext, "awx", @progbits')
     175                print ('#endif /* defined( GLX_USE_TLS ) */')
     176
     177                print ('')
     178                print ('\t\tALIGNTEXT16')
     179                print ('\t\tGLOBL GLNAME(gl_dispatch_functions_start)')
     180                print ('\t\tHIDDEN(GLNAME(gl_dispatch_functions_start))')
     181                print ('GLNAME(gl_dispatch_functions_start):')
     182                print ('')
    183183                return
    184184
    185185
    186186        def printRealFooter(self):
    187                 print ''
    188                 print '\t\tGLOBL\tGLNAME(gl_dispatch_functions_end)'
    189                 print '\t\tHIDDEN(GLNAME(gl_dispatch_functions_end))'
    190                 print '\t\tALIGNTEXT16'
    191                 print 'GLNAME(gl_dispatch_functions_end):'
    192                 print ''
    193                 print '#if defined(GLX_USE_TLS) && defined(__linux__)'
    194                 print ' .section ".note.ABI-tag", "a"'
    195                 print ' .p2align 2'
    196                 print ' .long   1f - 0f   /* name length */'
    197                 print ' .long   3f - 2f   /* data length */'
    198                 print ' .long   1         /* note length */'
    199                 print '0:       .asciz "GNU"      /* vendor name */'
    200                 print '1:       .p2align 2'
    201                 print '2:       .long   0         /* note data: the ABI tag */'
    202                 print ' .long   2,4,20    /* Minimum kernel version w/TLS */'
    203                 print '3:       .p2align 2        /* pad out section */'
    204                 print '#endif /* GLX_USE_TLS */'
    205                 print ''
    206                 print '#if defined (__ELF__) && defined (__linux__)'
    207                 print ' .section .note.GNU-stack,"",%progbits'
    208                 print '#endif'
     187                print ('')
     188                print ('\t\tGLOBL\tGLNAME(gl_dispatch_functions_end)')
     189                print ('\t\tHIDDEN(GLNAME(gl_dispatch_functions_end))')
     190                print ('\t\tALIGNTEXT16')
     191                print ('GLNAME(gl_dispatch_functions_end):')
     192                print ('')
     193                print ('#if defined(GLX_USE_TLS) && defined(__linux__)')
     194                print ('        .section ".note.ABI-tag", "a"')
     195                print ('        .p2align 2')
     196                print ('        .long   1f - 0f   /* name length */')
     197                print ('        .long   3f - 2f   /* data length */')
     198                print ('        .long   1         /* note length */')
     199                print ('0:      .asciz "GNU"      /* vendor name */')
     200                print ('1:      .p2align 2')
     201                print ('2:      .long   0         /* note data: the ABI tag */')
     202                print ('        .long   2,4,20    /* Minimum kernel version w/TLS */')
     203                print ('3:      .p2align 2        /* pad out section */')
     204                print ('#endif /* GLX_USE_TLS */')
     205                print ('')
     206                print ('#if defined (__ELF__) && defined (__linux__)')
     207                print ('        .section .note.GNU-stack,"",%progbits')
     208                print ('#endif')
    209209                return
    210210
    211211
     
    215215                        stack = self.get_stack_size(f)
    216216                        alt = "%s@%u" % (name, stack)
    217217
    218                         print '\tGL_STUB(%s, _gloffset_%s, %s)' % (name, f.name, alt)
     218                        print ('\tGL_STUB(%s, _gloffset_%s, %s)' % (name, f.name, alt))
    219219
    220220                        if not f.is_static_entry_point(f.name):
    221                                 print '\tHIDDEN(GL_PREFIX(%s, %s))' % (name, alt)
     221                                print ('\tHIDDEN(GL_PREFIX(%s, %s))' % (name, alt))
    222222
    223223
    224224                for f in api.functionIterateByOffset():
     
    233233                                                text = '\tGL_STUB_ALIAS(%s, _gloffset_%s, %s, %s, %s)' % (n, f.name, alt2, name, alt)
    234234
    235235                                                if f.has_different_protocol(n):
    236                                                         print '#ifndef GLX_INDIRECT_RENDERING'
    237                                                         print text
    238                                                         print '#endif'
     236                                                        print ('#ifndef GLX_INDIRECT_RENDERING')
     237                                                        print (text)
     238                                                        print ('#endif')
    239239                                                else:
    240                                                         print text
     240                                                        print (text)
    241241
    242242                return
    243243
    244244def show_usage():
    245         print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]
     245        print ("Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0])
    246246        sys.exit(1)
    247247
    248248if __name__ == '__main__':
     
    263263        if mode == "generic":
    264264                printer = PrintGenericStubs()
    265265        else:
    266                 print "ERROR: Invalid mode \"%s\" specified." % mode
     266                print ("ERROR: Invalid mode \"%s\" specified." % mode)
    267267                show_usage()
    268268
    269269        api = gl_XML.parse_GL_API(file_name, glX_XML.glx_item_factory())
  • Mesa-7.8.2/src/mesa/glapi/gen/gl_XML.py

    old new  
    127127        def printHeader(self):
    128128                """Print the header associated with all files and call the printRealHeader method."""
    129129
    130                 print '/* DO NOT EDIT - This file generated automatically by %s script */' \
     130                print ('/* DO NOT EDIT - This file generated automatically by %s script */' \)
    131131                        % (self.name)
    132                 print ''
    133                 print '/*'
    134                 print ' * ' + self.license.replace('\n', '\n * ')
    135                 print ' */'
    136                 print ''
     132                print ('')
     133                print ('/*')
     134                print (' * ' + self.license.replace('\n', '\n * '))
     135                print (' */')
     136                print ('')
    137137                if self.header_tag:
    138                     print '#if !defined( %s )' % (self.header_tag)
    139                     print '#  define %s' % (self.header_tag)
    140                     print ''
     138                    print ('#if !defined( %s )' % (self.header_tag))
     139                    print ('#  define %s' % (self.header_tag))
     140                    print ('')
    141141                self.printRealHeader();
    142142                return
    143143
     
    148148                self.printRealFooter()
    149149
    150150                if self.undef_list:
    151                         print ''
     151                        print ('')
    152152                        for u in self.undef_list:
    153                                 print "#  undef %s" % (u)
     153                                print ("#  undef %s" % (u))
    154154
    155155                if self.header_tag:
    156                         print ''
    157                         print '#endif /* !defined( %s ) */' % (self.header_tag)
     156                        print ('')
     157                        print ('#endif /* !defined( %s ) */' % (self.header_tag))
    158158
    159159
    160160        def printRealHeader(self):
     
    184184                The name is also added to the file's undef_list.
    185185                """
    186186                self.undef_list.append("PURE")
    187                 print """#  if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
     187                print ("""#  if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)))
    188188#    define PURE __attribute__((pure))
    189189#  else
    190190#    define PURE
     
    204204                """
    205205
    206206                self.undef_list.append("FASTCALL")
    207                 print """#  if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__)
     207                print ("""#  if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__))
    208208#    define FASTCALL __attribute__((fastcall))
    209209#  else
    210210#    define FASTCALL
     
    224224                """
    225225
    226226                self.undef_list.append(S)
    227                 print """#  if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) && defined(__ELF__)
     227                print ("""#  if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) && defined(__ELF__))
    228228#    define %s  __attribute__((visibility("%s")))
    229229#  else
    230230#    define %s
     
    244244                """
    245245
    246246                self.undef_list.append("NOINLINE")
    247                 print """#  if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
     247                print ("""#  if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)))
    248248#    define NOINLINE __attribute__((noinline))
    249249#  else
    250250#    define NOINLINE
     
    435435                        elements = 0
    436436
    437437                #if ts == "GLdouble":
    438                 #       print '/* stack size -> %s = %u (before)*/' % (self.name, self.type_expr.get_stack_size())
    439                 #       print '/* # elements = %u */' % (elements)
     438                #       print ('/* stack size -> %s = %u (before)*/' % (self.name, self.type_expr.get_stack_size()))
     439                #       print ('/* # elements = %u */' % (elements))
    440440                self.type_expr.set_elements( elements )
    441441                #if ts == "GLdouble":
    442                 #       print '/* stack size -> %s = %u (after) */' % (self.name, self.type_expr.get_stack_size())
     442                #       print ('/* stack size -> %s = %u (after) */' % (self.name, self.type_expr.get_stack_size()))
    443443
    444444                self.is_client_only = is_attr_true( element, 'client_only' )
    445445                self.is_counter     = is_attr_true( element, 'counter' )
     
    963963                if type_name in self.types_by_name:
    964964                        return self.types_by_name[ type_name ].type_expr
    965965                else:
    966                         print "Unable to find base type matching \"%s\"." % (type_name)
     966                        print ("Unable to find base type matching \"%s\"." % (type_name))
    967967                        return None
  • Mesa-7.8.2/src/mesa/glapi/gen/glX_doc.py

    old new  
    128128                else:
    129129                        s = "%u+%s" % (size, size_str)
    130130
    131                 print '            2        %-15s rendering command length' % (s)
    132                 print '            2        %-4u            rendering command opcode' % (f.glx_rop)
     131                print ('            2        %-15s rendering command length' % (s))
     132                print ('            2        %-4u            rendering command opcode' % (f.glx_rop))
    133133                return
    134134
    135135
     
    140140                if f.glx_vendorpriv != 0:
    141141                        size += 1
    142142
    143                 print '            1        CARD8           opcode (X assigned)'
    144                 print '            1        %-4u            GLX opcode (%s)' % (f.opcode_real_value(), f.opcode_real_name())
     143                print ('            1        CARD8           opcode (X assigned)')
     144                print ('            1        %-4u            GLX opcode (%s)' % (f.opcode_real_value(), f.opcode_real_name()))
    145145
    146146                if size_str == "":
    147147                        s = "%u" % (size)
     
    150150                else:
    151151                        s = "%u+((%s)/4)" % (size, size_str)
    152152
    153                 print '            2        %-15s request length' % (s)
     153                print ('            2        %-15s request length' % (s))
    154154
    155155                if f.glx_vendorpriv != 0:
    156                         print '            4        %-4u            vendor specific opcode' % (f.opcode_value())
     156                        print ('            4        %-4u            vendor specific opcode' % (f.opcode_value()))
    157157                       
    158                 print '            4        GLX_CONTEXT_TAG context tag'
     158                print ('            4        GLX_CONTEXT_TAG context tag')
    159159
    160160                return
    161161               
    162162
    163163        def print_reply(self, f):
    164                 print '          =>'
    165                 print '            1        1               reply'
    166                 print '            1                        unused'
    167                 print '            2        CARD16          sequence number'
     164                print ('          =>')
     165                print ('            1        1               reply')
     166                print ('            1                        unused')
     167                print ('            2        CARD16          sequence number')
    168168
    169169                if f.output == None:
    170                         print '            4        0               reply length'
     170                        print ('            4        0               reply length')
    171171                elif f.reply_always_array:
    172                         print '            4        m               reply length'
     172                        print ('            4        m               reply length')
    173173                else:
    174                         print '            4        m               reply length, m = (n == 1 ? 0 : n)'
     174                        print ('            4        m               reply length, m = (n == 1 ? 0 : n)')
    175175
    176176
    177177                output = None
     
    182182
    183183                unused = 24
    184184                if f.return_type != 'void':
    185                         print '            4        %-15s return value' % (f.return_type)
     185                        print ('            4        %-15s return value' % (f.return_type))
    186186                        unused -= 4
    187187                elif output != None:
    188                         print '            4                        unused'
     188                        print ('            4                        unused')
    189189                        unused -= 4
    190190
    191191                if output != None:
    192                         print '            4        CARD32          n'
     192                        print ('            4        CARD32          n')
    193193                        unused -= 4
    194194
    195195                if output != None:
    196196                        if not f.reply_always_array:
    197                                 print ''
    198                                 print '            if (n = 1) this follows:'
    199                                 print ''
    200                                 print '            4        CARD32          %s' % (output.name)
    201                                 print '            %-2u                       unused' % (unused - 4)
    202                                 print ''
    203                                 print '            otherwise this follows:'
    204                                 print ''
     197                                print ('')
     198                                print ('            if (n = 1) this follows:')
     199                                print ('')
     200                                print ('            4        CARD32          %s' % (output.name))
     201                                print ('            %-2u                       unused' % (unused - 4))
     202                                print ('')
     203                                print ('            otherwise this follows:')
     204                                print ('')
    205205
    206                         print '            %-2u                       unused' % (unused)
     206                        print ('            %-2u                       unused' % (unused))
    207207
    208208                        [s, pad] = output.packet_size()
    209                         print '            %-8s %-15s %s' % (s, output.packet_type( self.type_map ), output.name)
     209                        print ('            %-8s %-15s %s' % (s, output.packet_type( self.type_map ), output.name))
    210210                        if pad != None:
    211211                                try:
    212212                                        bytes = int(s)
    213213                                        bytes = 4 - (bytes & 3)
    214                                         print '            %-8u %-15s unused' % (bytes, "")
     214                                        print ('            %-8u %-15s unused' % (bytes, ""))
    215215                                except Exception,e:
    216                                         print '            %-8s %-15s unused, %s=pad(%s)' % (pad, "", pad, s)
     216                                        print ('            %-8s %-15s unused, %s=pad(%s)' % (pad, "", pad, s))
    217217                else:
    218                         print '            %-2u                       unused' % (unused)
     218                        print ('            %-2u                       unused' % (unused))
    219219
    220220
    221221        def print_body(self, f):
    222222                for p in f.parameterIterateGlxSend():
    223223                        [s, pad] = p.packet_size()
    224                         print '            %-8s %-15s %s' % (s, p.packet_type( self.type_map ), p.name)
     224                        print ('            %-8s %-15s %s' % (s, p.packet_type( self.type_map ), p.name))
    225225                        if pad != None:
    226226                                try:
    227227                                        bytes = int(s)
    228228                                        bytes = 4 - (bytes & 3)
    229                                         print '            %-8u %-15s unused' % (bytes, "")
     229                                        print ('            %-8u %-15s unused' % (bytes, ""))
    230230                                except Exception,e:
    231                                         print '            %-8s %-15s unused, %s=pad(%s)' % (pad, "", pad, s)
     231                                        print ('            %-8s %-15s unused, %s=pad(%s)' % (pad, "", pad, s))
    232232
    233233        def printBody(self, api):
    234234                self.type_map = {}
     
    245245
    246246
    247247                        if f.glx_rop:
    248                                 print '        %s' % (f.name)
     248                                print ('        %s' % (f.name))
    249249                                self.print_render_header(f)
    250250                        elif f.glx_sop or f.glx_vendorpriv:
    251                                 print '        %s' % (f.name)
     251                                print ('        %s' % (f.name))
    252252                                self.print_single_header(f)
    253253                        else:
    254254                                continue
     
    258258                        if f.needs_reply():
    259259                                self.print_reply(f)
    260260
    261                         print ''
     261                        print ('')
    262262                return
    263263
    264264
  • Mesa-7.8.2/src/mesa/glapi/gen/glX_proto_common.py

    old new  
    8484
    8585                compsize = self.size_call(f)
    8686                if compsize:
    87                         print '    const GLuint compsize = %s;' % (compsize)
     87                        print ('    const GLuint compsize = %s;' % (compsize))
    8888
    8989                if bias:
    90                         print '    const GLuint cmdlen = %s - %u;' % (f.command_length(), bias)
     90                        print ('    const GLuint cmdlen = %s - %u;' % (f.command_length(), bias))
    9191                else:
    92                         print '    const GLuint cmdlen = %s;' % (f.command_length())
     92                        print ('    const GLuint cmdlen = %s;' % (f.command_length()))
    9393
    94                 #print ''
     94                #print ('')
    9595                return compsize
  • Mesa-7.8.2/src/mesa/glapi/gen/glX_proto_recv.py

    old new  
    4242
    4343        def printRealHeader(self):
    4444                self.printVisibility( "HIDDEN", "hidden" )
    45                 print 'struct __GLXclientStateRec;'
    46                 print ''
     45                print ('struct __GLXclientStateRec;')
     46                print ('')
    4747                return
    4848
    4949
     
    5151                for func in api.functionIterateAll():
    5252                        if not func.ignore and not func.vectorequiv:
    5353                                if func.glx_rop:
    54                                         print 'extern HIDDEN void __glXDisp_%s(GLbyte * pc);' % (func.name)
    55                                         print 'extern HIDDEN void __glXDispSwap_%s(GLbyte * pc);' % (func.name)
     54                                        print ('extern HIDDEN void __glXDisp_%s(GLbyte * pc);' % (func.name))
     55                                        print ('extern HIDDEN void __glXDispSwap_%s(GLbyte * pc);' % (func.name))
    5656                                elif func.glx_sop or func.glx_vendorpriv:
    57                                         print 'extern HIDDEN int __glXDisp_%s(struct __GLXclientStateRec *, GLbyte *);' % (func.name)
    58                                         print 'extern HIDDEN int __glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (func.name)
     57                                        print ('extern HIDDEN int __glXDisp_%s(struct __GLXclientStateRec *, GLbyte *);' % (func.name))
     58                                        print ('extern HIDDEN int __glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (func.name))
    5959
    6060                                        if func.glx_sop and func.glx_vendorpriv:
    6161                                                n = func.glx_vendorpriv_names[0]
    62                                                 print 'extern HIDDEN int __glXDisp_%s(struct __GLXclientStateRec *, GLbyte *);' % (n)
    63                                                 print 'extern HIDDEN int __glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (n)
     62                                                print ('extern HIDDEN int __glXDisp_%s(struct __GLXclientStateRec *, GLbyte *);' % (n))
     63                                                print ('extern HIDDEN int __glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (n))
    6464
    6565                return
    6666
     
    7777
    7878
    7979        def printRealHeader(self):
    80                 print '#include <X11/Xmd.h>'
    81                 print '#include <GL/gl.h>'
    82                 print '#include <GL/glxproto.h>'
    83 
    84                 print '#include <inttypes.h>'
    85                 print '#include "indirect_size.h"'
    86                 print '#include "indirect_size_get.h"'
    87                 print '#include "indirect_dispatch.h"'
    88                 print '#include "glxserver.h"'
    89                 print '#include "glxbyteorder.h"'
    90                 print '#include "indirect_util.h"'
    91                 print '#include "singlesize.h"'
    92                 print '#include "glapi.h"'
    93                 print '#include "glapitable.h"'
    94                 print '#include "glthread.h"'
    95                 print '#include "glapidispatch.h"'
    96                 print ''
    97                 print '#define __GLX_PAD(x)  (((x) + 3) & ~3)'
    98                 print ''
    99                 print 'typedef struct {'
    100                 print '    __GLX_PIXEL_3D_HDR;'
    101                 print '} __GLXpixel3DHeader;'
    102                 print ''
    103                 print 'extern GLboolean __glXErrorOccured( void );'
    104                 print 'extern void __glXClearErrorOccured( void );'
    105                 print ''
    106                 print 'static const unsigned dummy_answer[2] = {0, 0};'
    107                 print ''
     80                print ('#include <X11/Xmd.h>')
     81                print ('#include <GL/gl.h>')
     82                print ('#include <GL/glxproto.h>')
     83
     84                print ('#include <inttypes.h>')
     85                print ('#include "indirect_size.h"')
     86                print ('#include "indirect_size_get.h"')
     87                print ('#include "indirect_dispatch.h"')
     88                print ('#include "glxserver.h"')
     89                print ('#include "glxbyteorder.h"')
     90                print ('#include "indirect_util.h"')
     91                print ('#include "singlesize.h"')
     92                print ('#include "glapi.h"')
     93                print ('#include "glapitable.h"')
     94                print ('#include "glthread.h"')
     95                print ('#include "glapidispatch.h"')
     96                print ('')
     97                print ('#define __GLX_PAD(x)  (((x) + 3) & ~3)')
     98                print ('')
     99                print ('typedef struct {')
     100                print ('    __GLX_PIXEL_3D_HDR;')
     101                print ('} __GLXpixel3DHeader;')
     102                print ('')
     103                print ('extern GLboolean __glXErrorOccured( void );')
     104                print ('extern void __glXClearErrorOccured( void );')
     105                print ('')
     106                print ('static const unsigned dummy_answer[2] = {0, 0};')
     107                print ('')
    108108                return
    109109
    110110
     
    133133                        base = '__glXDispSwap'
    134134
    135135                if f.glx_rop:
    136                         print 'void %s_%s(GLbyte * pc)' % (base, name)
     136                        print ('void %s_%s(GLbyte * pc)' % (base, name))
    137137                else:
    138                         print 'int %s_%s(__GLXclientState *cl, GLbyte *pc)' % (base, name)
     138                        print ('int %s_%s(__GLXclientState *cl, GLbyte *pc)' % (base, name))
    139139
    140                 print '{'
     140                print ('{')
    141141
    142142                if f.glx_rop or f.vectorequiv:
    143143                        self.printRenderFunction(f)
     
    145145                        if len(f.get_images()) == 0:
    146146                                self.printSingleFunction(f, name)
    147147                else:
    148                         print "/* Missing GLX protocol for %s. */" % (name)
     148                        print ("/* Missing GLX protocol for %s. */" % (name))
    149149
    150                 print '}'
    151                 print ''
     150                print ('}')
     151                print ('')
    152152                return
    153153
    154154
     
    172172                                if t.glx_name not in already_done:
    173173                                        real_name = self.real_types[t_size]
    174174
    175                                         print 'static %s' % (t_name)
    176                                         print 'bswap_%s( const void * src )' % (t.glx_name)
    177                                         print '{'
    178                                         print '    union { %s dst; %s ret; } x;' % (real_name, t_name)
    179                                         print '    x.dst = bswap_%u( *(%s *) src );' % (t_size * 8, real_name)
    180                                         print '    return x.ret;'
    181                                         print '}'
    182                                         print ''
     175                                        print ('static %s' % (t_name))
     176                                        print ('bswap_%s( const void * src )' % (t.glx_name))
     177                                        print ('{')
     178                                        print ('    union { %s dst; %s ret; } x;' % (real_name, t_name))
     179                                        print ('    x.dst = bswap_%u( *(%s *) src );' % (t_size * 8, real_name))
     180                                        print ('    return x.ret;')
     181                                        print ('}')
     182                                        print ('')
    183183                                        already_done.append( t.glx_name )
    184184
    185185                for bits in [16, 32, 64]:
    186                         print 'static void *'
    187                         print 'bswap_%u_array( uint%u_t * src, unsigned count )' % (bits, bits)
    188                         print '{'
    189                         print '    unsigned  i;'
    190                         print ''
    191                         print '    for ( i = 0 ; i < count ; i++ ) {'
    192                         print '        uint%u_t temp = bswap_%u( src[i] );' % (bits, bits)
    193                         print '        src[i] = temp;'
    194                         print '    }'
    195                         print ''
    196                         print '    return src;'
    197                         print '}'
    198                         print ''
     186                        print ('static void *')
     187                        print ('bswap_%u_array( uint%u_t * src, unsigned count )' % (bits, bits))
     188                        print ('{')
     189                        print ('    unsigned  i;')
     190                        print ('')
     191                        print ('    for ( i = 0 ; i < count ; i++ ) {')
     192                        print ('        uint%u_t temp = bswap_%u( src[i] );' % (bits, bits))
     193                        print ('        src[i] = temp;')
     194                        print ('    }')
     195                        print ('')
     196                        print ('    return src;')
     197                        print ('}')
     198                        print ('')
    199199                       
    200200
    201201        def fetch_param(self, param):
     
    237237                       
    238238
    239239                if len( list ):
    240                         print '%s    %sCALL_%s( GET_DISPATCH(), (' % (indent, retval_assign, f.name)
    241                         print string.join( list, ",\n" )
    242                         print '%s    ) );' % (indent)
     240                        print ('%s    %sCALL_%s( GET_DISPATCH(), (' % (indent, retval_assign, f.name))
     241                        print (string.join( list, ",\n" ))
     242                        print ('%s    ) );' % (indent))
    243243                else:
    244                         print '%s    %sCALL_%s( GET_DISPATCH(), () );' % (indent, retval_assign, f.name)
     244                        print ('%s    %sCALL_%s( GET_DISPATCH(), () );' % (indent, retval_assign, f.name))
    245245                return
    246246
    247247
     
    266266                        # FIXME or something similar.
    267267
    268268                        if param.img_null_flag:
    269                                 print '%s    const CARD32 ptr_is_null = *(CARD32 *)(pc + %s);' % (indent, param.offset - 4)
     269                                print ('%s    const CARD32 ptr_is_null = *(CARD32 *)(pc + %s);' % (indent, param.offset - 4))
    270270                                cond = '(ptr_is_null != 0) ? NULL : '
    271271                        else:
    272272                                cond = ""
     
    277277                        if param.is_image():
    278278                                offset = f.offset_of( param.name )
    279279
    280                                 print '%s    %s const %s = (%s) (%s(pc + %s));' % (indent, type_string, param.name, type_string, cond, offset)
     280                                print ('%s    %s const %s = (%s) (%s(pc + %s));' % (indent, type_string, param.name, type_string, cond, offset))
    281281                               
    282282                                if param.depth:
    283                                         print '%s    __GLXpixel3DHeader * const hdr = (__GLXpixel3DHeader *)(pc);' % (indent)
     283                                        print ('%s    __GLXpixel3DHeader * const hdr = (__GLXpixel3DHeader *)(pc);' % (indent))
    284284                                else:
    285                                         print '%s    __GLXpixelHeader * const hdr = (__GLXpixelHeader *)(pc);' % (indent)
     285                                        print ('%s    __GLXpixelHeader * const hdr = (__GLXpixelHeader *)(pc);' % (indent))
    286286
    287287                                need_blank = 1
    288288                        elif param.is_counter or param.name in f.count_parameter_list:
    289289                                location = self.fetch_param(param)
    290                                 print '%s    const %s %s = %s;' % (indent, type_string, param.name, location)
     290                                print ('%s    const %s %s = %s;' % (indent, type_string, param.name, location))
    291291                                need_blank = 1
    292292                        elif len(param.count_parameter_list):
    293293                                if param.size() == 1 and not self.do_swap:
    294294                                        location = self.fetch_param(param)
    295                                         print '%s    %s %s = %s%s;' % (indent, type_string, param.name, cond, location)
     295                                        print ('%s    %s %s = %s%s;' % (indent, type_string, param.name, cond, location))
    296296                                else:
    297                                         print '%s    %s %s;' % (indent, type_string, param.name)
     297                                        print ('%s    %s %s;' % (indent, type_string, param.name))
    298298                                need_blank = 1
    299299
    300300
    301301
    302302                if need_blank:
    303                         print ''
     303                        print ('')
    304304
    305305                if align64:
    306                         print '#ifdef __GLX_ALIGN64'
     306                        print ('#ifdef __GLX_ALIGN64')
    307307
    308308                        if f.has_variable_size_request():
    309309                                self.emit_packet_size_calculation(f, 4)
     
    311311                        else:
    312312                                s = str((f.command_fixed_length() + 3) & ~3)
    313313
    314                         print '    if ((unsigned long)(pc) & 7) {'
    315                         print '        (void) memmove(pc-4, pc, %s);' % (s)
    316                         print '        pc -= 4;'
    317                         print '    }'
    318                         print '#endif'
    319                         print ''
     314                        print ('    if ((unsigned long)(pc) & 7) {')
     315                        print ('        (void) memmove(pc-4, pc, %s);' % (s))
     316                        print ('        pc -= 4;')
     317                        print ('    }')
     318                        print ('#endif')
     319                        print ('')
    320320
    321321
    322322                need_blank = 0
     
    341341                                                x.append( [2, ['SHORT', 'UNSIGNED_SHORT']] )
    342342                                                x.append( [4, ['INT', 'UNSIGNED_INT', 'FLOAT']] )
    343343
    344                                                 print '    switch(%s) {' % (param.count_parameter_list[0])
     344                                                print ('    switch(%s) {' % (param.count_parameter_list[0]))
    345345                                                for sub in x:
    346346                                                        for t_name in sub[1]:
    347                                                                 print '    case GL_%s:' % (t_name)
     347                                                                print ('    case GL_%s:' % (t_name))
    348348
    349349                                                        if sub[0] == 1:
    350                                                                 print '        %s = (%s) (pc + %s); break;' % (param.name, param.type_string(), o)
     350                                                                print ('        %s = (%s) (pc + %s); break;' % (param.name, param.type_string(), o))
    351351                                                        else:
    352352                                                                swap_func = self.swap_name(sub[0])
    353                                                                 print '        %s = (%s) %s( (%s *) (pc + %s), %s ); break;' % (param.name, param.type_string(), swap_func, self.real_types[sub[0]], o, count_name)
    354                                                 print '    default:'
    355                                                 print '        return;'
    356                                                 print '    }'
     353                                                                print ('        %s = (%s) %s( (%s *) (pc + %s), %s ); break;' % (param.name, param.type_string(), swap_func, self.real_types[sub[0]], o, count_name))
     354                                                print ('    default:')
     355                                                print ('        return;')
     356                                                print ('    }')
    357357                                        else:
    358358                                                swap_func = self.swap_name(type_size)
    359359                                                compsize = self.size_call(f, 1)
    360                                                 print '    %s = (%s) %s( (%s *) (pc + %s), %s );' % (param.name, param.type_string(), swap_func, self.real_types[type_size], o, compsize)
     360                                                print ('    %s = (%s) %s( (%s *) (pc + %s), %s );' % (param.name, param.type_string(), swap_func, self.real_types[type_size], o, compsize))
    361361
    362362                                        need_blank = 1
    363363
    364364                else:
    365365                        for param in f.parameterIterateGlxSend():
    366366                                if param.count_parameter_list:
    367                                         print '%s    %s = (%s) (pc + %s);' % (indent, param.name, param.type_string(), param.offset)
     367                                        print ('%s    %s = (%s) (pc + %s);' % (indent, param.name, param.type_string(), param.offset))
    368368                                        need_blank = 1
    369369
    370370
    371371                if need_blank:
    372                         print ''
     372                        print ('')
    373373
    374374
    375375                return
     
    377377
    378378        def printSingleFunction(self, f, name):
    379379                if name not in f.glx_vendorpriv_names:
    380                         print '    xGLXSingleReq * const req = (xGLXSingleReq *) pc;'
     380                        print ('    xGLXSingleReq * const req = (xGLXSingleReq *) pc;')
    381381                else:
    382                         print '    xGLXVendorPrivateReq * const req = (xGLXVendorPrivateReq *) pc;'
     382                        print ('    xGLXVendorPrivateReq * const req = (xGLXVendorPrivateReq *) pc;')
    383383
    384                 print '    int error;'
     384                print ('    int error;')
    385385
    386386                if self.do_swap:
    387                     print '    __GLXcontext * const cx = __glXForceCurrent(cl, bswap_CARD32( &req->contextTag ), &error);'
     387                    print ('    __GLXcontext * const cx = __glXForceCurrent(cl, bswap_CARD32( &req->contextTag ), &error);')
    388388                else:
    389                     print '    __GLXcontext * const cx = __glXForceCurrent(cl, req->contextTag, &error);'
     389                    print ('    __GLXcontext * const cx = __glXForceCurrent(cl, req->contextTag, &error);')
    390390
    391                 print ''
     391                print ('')
    392392                if name not in f.glx_vendorpriv_names:
    393                         print '    pc += __GLX_SINGLE_HDR_SIZE;'
     393                        print ('    pc += __GLX_SINGLE_HDR_SIZE;')
    394394                else:
    395                         print '    pc += __GLX_VENDPRIV_HDR_SIZE;'
     395                        print ('    pc += __GLX_VENDPRIV_HDR_SIZE;')
    396396
    397                 print '    if ( cx != NULL ) {'
     397                print ('    if ( cx != NULL ) {')
    398398                self.common_func_print_just_start(f, "    ")
    399399               
    400400
    401401                if f.return_type != 'void':
    402                         print '        %s retval;' % (f.return_type)
     402                        print ('        %s retval;' % (f.return_type))
    403403                        retval_string = "retval"
    404404                        retval_assign = "retval = "
    405405                else:
     
    427427
    428428
    429429                        if param.count_parameter_list:
    430                                 print '        const GLuint compsize = %s;' % (self.size_call(f, 1))
    431                                 print '        %s answerBuffer[200];' %  (answer_type)
    432                                 print '        %s %s = __glXGetAnswerBuffer(cl, compsize%s, answerBuffer, sizeof(answerBuffer), %u);' % (param.type_string(), param.name, size_scale, type_size )
     430                                print ('        const GLuint compsize = %s;' % (self.size_call(f, 1)))
     431                                print ('        %s answerBuffer[200];' %  (answer_type))
     432                                print ('        %s %s = __glXGetAnswerBuffer(cl, compsize%s, answerBuffer, sizeof(answerBuffer), %u);' % (param.type_string(), param.name, size_scale, type_size ))
    433433                                answer_string = param.name
    434434                                answer_count = "compsize"
    435435
    436                                 print ''
    437                                 print '        if (%s == NULL) return BadAlloc;' % (param.name)
    438                                 print '        __glXClearErrorOccured();'
    439                                 print ''
     436                                print ('')
     437                                print ('        if (%s == NULL) return BadAlloc;' % (param.name))
     438                                print ('        __glXClearErrorOccured();')
     439                                print ('')
    440440                        elif param.counter:
    441                                 print '        %s answerBuffer[200];' %  (answer_type)
    442                                 print '        %s %s = __glXGetAnswerBuffer(cl, %s%s, answerBuffer, sizeof(answerBuffer), %u);' % (param.type_string(), param.name, param.counter, size_scale, type_size)
     441                                print ('        %s answerBuffer[200];' %  (answer_type))
     442                                print ('        %s %s = __glXGetAnswerBuffer(cl, %s%s, answerBuffer, sizeof(answerBuffer), %u);' % (param.type_string(), param.name, param.counter, size_scale, type_size))
    443443                                answer_string = param.name
    444444                                answer_count = param.counter
    445445                        elif c >= 1:
    446                                 print '        %s %s[%u];' % (answer_type, param.name, c)
     446                                print ('        %s %s[%u];' % (answer_type, param.name, c))
    447447                                answer_string = param.name
    448448                                answer_count = "%u" % (c)
    449449
     
    462462
    463463                                        if type_size > 1:
    464464                                                swap_name = self.swap_name( type_size )
    465                                                 print '        (void) %s( (uint%u_t *) %s, %s );' % (swap_name, 8 * type_size, param.name, answer_count)
     465                                                print ('        (void) %s( (uint%u_t *) %s, %s );' % (swap_name, 8 * type_size, param.name, answer_count))
    466466
    467467
    468468                                reply_func = '__glXSendReplySwap'
    469469                        else:
    470470                                reply_func = '__glXSendReply'
    471471
    472                         print '        %s(cl->client, %s, %s, %u, %s, %s);' % (reply_func, answer_string, answer_count, type_size, is_array_string, retval_string)
     472                        print ('        %s(cl->client, %s, %s, %u, %s, %s);' % (reply_func, answer_string, answer_count, type_size, is_array_string, retval_string))
    473473                #elif f.note_unflushed:
    474                 #       print '        cx->hasUnflushedCommands = GL_TRUE;'
     474                #       print ('        cx->hasUnflushedCommands = GL_TRUE;')
    475475
    476                 print '        error = Success;'
    477                 print '    }'
    478                 print ''
    479                 print '    return error;'
     476                print ('        error = Success;')
     477                print ('    }')
     478                print ('')
     479                print ('    return error;')
    480480                return
    481481
    482482
     
    505505                        # the must NEVER be byte-swapped.
    506506
    507507                        if not (img.img_type == "GL_BITMAP" and img.img_format == "GL_COLOR_INDEX"):
    508                                 print '    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES,   hdr->swapBytes) );'
     508                                print ('    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES,   hdr->swapBytes) );')
    509509
    510                         print '    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_LSB_FIRST,    hdr->lsbFirst) );'
     510                        print ('    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_LSB_FIRST,    hdr->lsbFirst) );')
    511511
    512                         print '    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_ROW_LENGTH,   (GLint) %shdr->rowLength%s) );' % (pre, post)
     512                        print ('    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_ROW_LENGTH,   (GLint) %shdr->rowLength%s) );' % (pre, post))
    513513                        if img.depth:
    514                                 print '    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_IMAGE_HEIGHT, (GLint) %shdr->imageHeight%s) );' % (pre, post)
    515                         print '    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_ROWS,    (GLint) %shdr->skipRows%s) );' % (pre, post)
     514                                print ('    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_IMAGE_HEIGHT, (GLint) %shdr->imageHeight%s) );' % (pre, post))
     515                        print ('    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_ROWS,    (GLint) %shdr->skipRows%s) );' % (pre, post))
    516516                        if img.depth:
    517                                 print '    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_IMAGES,  (GLint) %shdr->skipImages%s) );' % (pre, post)
    518                         print '    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_PIXELS,  (GLint) %shdr->skipPixels%s) );' % (pre, post)
    519                         print '    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_ALIGNMENT,    (GLint) %shdr->alignment%s) );' % (pre, post)
    520                         print ''
     517                                print ('    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_IMAGES,  (GLint) %shdr->skipImages%s) );' % (pre, post))
     518                        print ('    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_PIXELS,  (GLint) %shdr->skipPixels%s) );' % (pre, post))
     519                        print ('    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_ALIGNMENT,    (GLint) %shdr->alignment%s) );' % (pre, post))
     520                        print ('')
    521521
    522522
    523523                self.emit_function_call(f, "", "")
  • Mesa-7.8.2/src/mesa/glapi/gen/glX_proto_send.py

    old new  
    161161                return
    162162
    163163        def printRealHeader(self):
    164                 print ''
    165                 print '#include <GL/gl.h>'
    166                 print '#include "indirect.h"'
    167                 print '#include "glxclient.h"'
    168                 print '#include "indirect_size.h"'
    169                 print '#include "glapidispatch.h"'
    170                 print '#include "glapi.h"'
    171                 print '#include "glthread.h"'
    172                 print '#include <GL/glxproto.h>'
    173                 print '#ifdef USE_XCB'
    174                 print '#include <X11/Xlib-xcb.h>'
    175                 print '#include <xcb/xcb.h>'
    176                 print '#include <xcb/glx.h>'
    177                 print '#endif /* USE_XCB */'
    178 
    179                 print ''
    180                 print '#define __GLX_PAD(n) (((n) + 3) & ~3)'
    181                 print ''
     164                print ('')
     165                print ('#include <GL/gl.h>')
     166                print ('#include "indirect.h"')
     167                print ('#include "glxclient.h"')
     168                print ('#include "indirect_size.h"')
     169                print ('#include "glapidispatch.h"')
     170                print ('#include "glapi.h"')
     171                print ('#include "glthread.h"')
     172                print ('#include <GL/glxproto.h>')
     173                print ('#ifdef USE_XCB')
     174                print ('#include <X11/Xlib-xcb.h>')
     175                print ('#include <xcb/xcb.h>')
     176                print ('#include <xcb/glx.h>')
     177                print ('#endif /* USE_XCB */')
     178
     179                print ('')
     180                print ('#define __GLX_PAD(n) (((n) + 3) & ~3)')
     181                print ('')
    182182                self.printFastcall()
    183183                self.printNoinline()
    184                 print ''
    185                 print '#ifndef __GNUC__'
    186                 print '#  define __builtin_expect(x, y) x'
    187                 print '#endif'
    188                 print ''
    189                 print '/* If the size and opcode values are known at compile-time, this will, on'
    190                 print ' * x86 at least, emit them with a single instruction.'
    191                 print ' */'
    192                 print '#define emit_header(dest, op, size)            \\'
    193                 print '    do { union { short s[2]; int i; } temp;    \\'
    194                 print '         temp.s[0] = (size); temp.s[1] = (op); \\'
    195                 print '         *((int *)(dest)) = temp.i; } while(0)'
    196                 print ''
    197                 print """NOINLINE CARD32
     184                print ('')
     185                print ('#ifndef __GNUC__')
     186                print ('#  define __builtin_expect(x, y) x')
     187                print ('#endif')
     188                print ('')
     189                print ('/* If the size and opcode values are known at compile-time, this will, on')
     190                print (' * x86 at least, emit them with a single instruction.')
     191                print (' */')
     192                print ('#define emit_header(dest, op, size)            \\')
     193                print ('    do { union { short s[2]; int i; } temp;    \\')
     194                print ('         temp.s[0] = (size); temp.s[1] = (op); \\')
     195                print ('         *((int *)(dest)) = temp.i; } while(0)')
     196                print ('')
     197                print ("""NOINLINE CARD32
    198198__glXReadReply( Display *dpy, size_t size, void * dest, GLboolean reply_is_always_array )
    199199{
    200200    xGLXSingleReply reply;
     
    306306#define default_pixel_store_3D_size 36
    307307#define default_pixel_store_4D      (__glXDefaultPixelStore+0)
    308308#define default_pixel_store_4D_size 36
    309 """
     309""")
    310310
    311311                for size in self.generic_sizes:
    312312                        self.print_generic_function(size)
     
    357357        def printFunction(self, func, name):
    358358                footer = '}\n'
    359359                if func.glx_rop == ~0:
    360                         print 'static %s' % (func.return_type)
    361                         print '%s( unsigned opcode, unsigned dim, %s )' % (func.name, func.get_parameter_string())
    362                         print '{'
     360                        print ('static %s' % (func.return_type))
     361                        print ('%s( unsigned opcode, unsigned dim, %s )' % (func.name, func.get_parameter_string()))
     362                        print ('{')
    363363                else:
    364364                        if func.has_different_protocol(name):
    365365                                if func.return_type == "void":
     
    368368                                        ret_string = "return "
    369369
    370370                                func_name = func.static_glx_name(name)
    371                                 print '#define %s %d' % (func.opcode_vendor_name(name), func.glx_vendorpriv)
    372                                 print '%s gl%s(%s)' % (func.return_type, func_name, func.get_parameter_string())
    373                                 print '{'
    374                                 print '    __GLXcontext * const gc = __glXGetCurrentContext();'
    375                                 print ''
    376                                 print '#ifdef GLX_DIRECT_RENDERING'
    377                                 print '    if (gc->driContext) {'
    378                                 print '    %sCALL_%s(GET_DISPATCH(), (%s));' % (ret_string, func.name, func.get_called_parameter_string())
    379                                 print '    } else'
    380                                 print '#endif'
    381                                 print '    {'
     371                                print ('#define %s %d' % (func.opcode_vendor_name(name), func.glx_vendorpriv))
     372                                print ('%s gl%s(%s)' % (func.return_type, func_name, func.get_parameter_string()))
     373                                print ('{')
     374                                print ('    __GLXcontext * const gc = __glXGetCurrentContext();')
     375                                print ('')
     376                                print ('#ifdef GLX_DIRECT_RENDERING')
     377                                print ('    if (gc->driContext) {')
     378                                print ('    %sCALL_%s(GET_DISPATCH(), (%s));' % (ret_string, func.name, func.get_called_parameter_string()))
     379                                print ('    } else')
     380                                print ('#endif')
     381                                print ('    {')
    382382
    383383                                footer = '}\n}\n'
    384384                        else:
    385                                 print '#define %s %d' % (func.opcode_name(), func.opcode_value())
     385                                print ('#define %s %d' % (func.opcode_name(), func.opcode_value()))
    386386
    387                                 print '%s __indirect_gl%s(%s)' % (func.return_type, name, func.get_parameter_string())
    388                                 print '{'
     387                                print ('%s __indirect_gl%s(%s)' % (func.return_type, name, func.get_parameter_string()))
     388                                print ('{')
    389389
    390390
    391391                if func.glx_rop != 0 or func.vectorequiv != None:
     
    397397                        self.printSingleFunction(func, name)
    398398                        pass
    399399                else:
    400                         print "/* Missing GLX protocol for %s. */" % (name)
     400                        print ("/* Missing GLX protocol for %s. */" % (name))
    401401
    402                 print footer
     402                print (footer)
    403403                return
    404404
    405405
    406406        def print_generic_function(self, n):
    407407                size = (n + 3) & ~3
    408                 print """static FASTCALL NOINLINE void
     408                print ("""static FASTCALL NOINLINE void
    409409generic_%u_byte( GLint rop, const void * ptr )
    410410{
    411411    __GLXcontext * const gc = __glXGetCurrentContext();
     
    416416    gc->pc += cmdlen;
    417417    if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
    418418}
    419 """ % (n, size + 4, size)
     419""" % (n, size + 4, size))
    420420                return
    421421
    422422
     
    427427                        src_ptr = "&" + p.name
    428428
    429429                if p.is_padding:
    430                         print '(void) memset((void *)(%s + %u), 0, %s);' \
    431                             % (pc, p.offset + adjust, p.size_string() )
     430                        print ('(void) memset((void *)(%s + %u), 0, %s);' \
     431                            % (pc, p.offset + adjust, p.size_string() ))
    432432                elif not extra_offset:
    433                         print '(void) memcpy((void *)(%s + %u), (void *)(%s), %s);' \
    434                             % (pc, p.offset + adjust, src_ptr, p.size_string() )
     433                        print ('(void) memcpy((void *)(%s + %u), (void *)(%s), %s);' \
     434                            % (pc, p.offset + adjust, src_ptr, p.size_string() ))
    435435                else:
    436                         print '(void) memcpy((void *)(%s + %u + %s), (void *)(%s), %s);' \
    437                             % (pc, p.offset + adjust, extra_offset, src_ptr, p.size_string() )
     436                        print ('(void) memcpy((void *)(%s + %u + %s), (void *)(%s), %s);' \
     437                            % (pc, p.offset + adjust, extra_offset, src_ptr, p.size_string() ))
    438438
    439439        def common_emit_args(self, f, pc, adjust, skip_vla):
    440440                extra_offset = None
     
    470470                                self.common_emit_one_arg(param, pc, adjust, None)
    471471
    472472                                if f.pad_after(param):
    473                                         print '(void) memcpy((void *)(%s + %u), zero, 4);' % (pc, (param.offset + param.size()) + adjust)
     473                                        print ('(void) memcpy((void *)(%s + %u), zero, 4);' % (pc, (param.offset + param.size()) + adjust))
    474474
    475475                        else:
    476476                                [dim, width, height, depth, extent] = param.get_dimensions()
     
    480480                                        dim_str = str(dim)
    481481
    482482                                if param.is_padding:
    483                                         print '(void) memset((void *)(%s + %u), 0, %s);' \
    484                                         % (pc, (param.offset - 4) + adjust, param.size_string() )
     483                                        print ('(void) memset((void *)(%s + %u), 0, %s);' \
     484                                        % (pc, (param.offset - 4) + adjust, param.size_string() ))
    485485
    486486                                if param.img_null_flag:
    487487                                        if large:
    488                                                 print '(void) memcpy((void *)(%s + %u), zero, 4);' % (pc, (param.offset - 4) + adjust)
     488                                                print ('(void) memcpy((void *)(%s + %u), zero, 4);' % (pc, (param.offset - 4) + adjust))
    489489                                        else:
    490                                                 print '(void) memcpy((void *)(%s + %u), (void *)((%s == NULL) ? one : zero), 4);' % (pc, (param.offset - 4) + adjust, param.name)
     490                                                print ('(void) memcpy((void *)(%s + %u), (void *)((%s == NULL) ? one : zero), 4);' % (pc, (param.offset - 4) + adjust, param.name))
    491491
    492492
    493493                                pixHeaderPtr = "%s + %u" % (pc, adjust)
     
    499499                                        else:
    500500                                                condition = 'compsize > 0'
    501501
    502                                         print 'if (%s) {' % (condition)
    503                                         print '    (*gc->fillImage)(gc, %s, %s, %s, %s, %s, %s, %s, %s, %s);' % (dim_str, width, height, depth, param.img_format, param.img_type, param.name, pcPtr, pixHeaderPtr)
    504                                         print '} else {'
    505                                         print '    (void) memcpy( %s, default_pixel_store_%uD, default_pixel_store_%uD_size );' % (pixHeaderPtr, dim, dim)
    506                                         print '}'
     502                                        print ('if (%s) {' % (condition))
     503                                        print ('    (*gc->fillImage)(gc, %s, %s, %s, %s, %s, %s, %s, %s, %s);' % (dim_str, width, height, depth, param.img_format, param.img_type, param.name, pcPtr, pixHeaderPtr))
     504                                        print ('} else {')
     505                                        print ('    (void) memcpy( %s, default_pixel_store_%uD, default_pixel_store_%uD_size );' % (pixHeaderPtr, dim, dim))
     506                                        print ('}')
    507507                                else:
    508                                         print '__glXSendLargeImage(gc, compsize, %s, %s, %s, %s, %s, %s, %s, %s, %s);' % (dim_str, width, height, depth, param.img_format, param.img_type, param.name, pcPtr, pixHeaderPtr)
     508                                        print ('__glXSendLargeImage(gc, compsize, %s, %s, %s, %s, %s, %s, %s, %s, %s);' % (dim_str, width, height, depth, param.img_format, param.img_type, param.name, pcPtr, pixHeaderPtr))
    509509
    510510                return
    511511
     
    514514                if not op_name:
    515515                        op_name = f.opcode_real_name()
    516516
    517                 print 'const GLint op = %s;' % (op_name)
    518                 print 'const GLuint cmdlenLarge = cmdlen + 4;'
    519                 print 'GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);'
    520                 print '(void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);'
    521                 print '(void) memcpy((void *)(pc + 4), (void *)(&op), 4);'
     517                print ('const GLint op = %s;' % (op_name))
     518                print ('const GLuint cmdlenLarge = cmdlen + 4;')
     519                print ('GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);')
     520                print ('(void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);')
     521                print ('(void) memcpy((void *)(pc + 4), (void *)(&op), 4);')
    522522                return
    523523
    524524
    525525        def common_func_print_just_start(self, f, name):
    526                 print '    __GLXcontext * const gc = __glXGetCurrentContext();'
     526                print ('    __GLXcontext * const gc = __glXGetCurrentContext();')
    527527
    528528                # The only reason that single and vendor private commands need
    529529                # a variable called 'dpy' is becuase they use the SyncHandle
     
    541541                if not f.glx_rop:
    542542                        for p in f.parameterIterateOutputs():
    543543                                if p.is_image() and (p.img_format != "GL_COLOR_INDEX" or p.img_type != "GL_BITMAP"):
    544                                         print '    const __GLXattribute * const state = gc->client_state_private;'
     544                                        print ('    const __GLXattribute * const state = gc->client_state_private;')
    545545                                        break
    546546
    547                         print '    Display * const dpy = gc->currentDpy;'
     547                        print ('    Display * const dpy = gc->currentDpy;')
    548548                        skip_condition = "dpy != NULL"
    549549                elif f.can_be_large:
    550550                        skip_condition = "gc->currentDpy != NULL"
     
    553553
    554554
    555555                if f.return_type != 'void':
    556                         print '    %s retval = (%s) 0;' % (f.return_type, f.return_type)
     556                        print ('    %s retval = (%s) 0;' % (f.return_type, f.return_type))
    557557
    558558
    559559                if name != None and name not in f.glx_vendorpriv_names:
    560                         print '#ifndef USE_XCB'
     560                        print ('#ifndef USE_XCB')
    561561                self.emit_packet_size_calculation(f, 0)
    562562                if name != None and name not in f.glx_vendorpriv_names:
    563                         print '#endif'
     563                        print ('#endif')
    564564
    565565                condition_list = []
    566566                for p in f.parameterIterateCounters():
    567567                        condition_list.append( "%s >= 0" % (p.name) )
    568568                        # 'counter' parameters cannot be negative
    569                         print "    if (%s < 0) {" % p.name
    570                         print "        __glXSetError(gc, GL_INVALID_VALUE);"
     569                        print ("    if (%s < 0) {" % p.name)
     570                        print ("        __glXSetError(gc, GL_INVALID_VALUE);")
    571571                        if f.return_type != 'void':
    572                                 print "        return 0;"
     572                                print ("        return 0;")
    573573                        else:
    574                                 print "        return;"
    575                         print "    }"
     574                                print ("        return;")
     575                        print ("    }")
    576576
    577577                if skip_condition:
    578578                        condition_list.append( skip_condition )
     
    583583                        else:
    584584                                skip_condition = "%s" % (condition_list.pop(0))
    585585
    586                         print '    if (__builtin_expect(%s, 1)) {' % (skip_condition)
     586                        print ('    if (__builtin_expect(%s, 1)) {' % (skip_condition))
    587587                        return 1
    588588                else:
    589589                        return 0
     
    593593                self.common_func_print_just_start(f, name)
    594594
    595595                if self.debug:
    596                         print '        printf( "Enter %%s...\\n", "gl%s" );' % (f.name)
     596                        print ('        printf( "Enter %%s...\\n", "gl%s" );' % (f.name))
    597597
    598598                if name not in f.glx_vendorpriv_names:
    599599
    600600                        # XCB specific:
    601                         print '#ifdef USE_XCB'
     601                        print ('#ifdef USE_XCB')
    602602                        if self.debug:
    603                                 print '        printf("\\tUsing XCB.\\n");'
    604                         print '        xcb_connection_t *c = XGetXCBConnection(dpy);'
    605                         print '        (void) __glXFlushRenderBuffer(gc, gc->pc);'
     603                                print ('        printf("\\tUsing XCB.\\n");')
     604                        print ('        xcb_connection_t *c = XGetXCBConnection(dpy);')
     605                        print ('        (void) __glXFlushRenderBuffer(gc, gc->pc);')
    606606                        xcb_name = 'xcb_glx%s' % convertStringForXCB(name)
    607607
    608608                        iparams=[]
     
    629629                        xcb_request = '%s(%s)' % (xcb_name, ", ".join(["c", "gc->currentContextTag"] + iparams + extra_iparams))
    630630
    631631                        if f.needs_reply():
    632                                 print '        %s_reply_t *reply = %s_reply(c, %s, NULL);' % (xcb_name, xcb_name, xcb_request)
     632                                print ('        %s_reply_t *reply = %s_reply(c, %s, NULL);' % (xcb_name, xcb_name, xcb_request))
    633633                                if output and f.reply_always_array:
    634                                         print '        (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string())
     634                                        print ('        (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string()))
    635635
    636636                                elif output and not f.reply_always_array:
    637637                                        if not output.is_image():
    638                                                 print '        if (%s_data_length(reply) == 0)' % (xcb_name)
    639                                                 print '            (void)memcpy(%s, &reply->datum, sizeof(reply->datum));' % (output.name)
    640                                                 print '        else'
    641                                         print '        (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string())
     638                                                print ('        if (%s_data_length(reply) == 0)' % (xcb_name))
     639                                                print ('            (void)memcpy(%s, &reply->datum, sizeof(reply->datum));' % (output.name))
     640                                                print ('        else')
     641                                        print ('        (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string()))
    642642
    643643
    644644                                if f.return_type != 'void':
    645                                         print '        retval = reply->ret_val;'
    646                                 print '        free(reply);'
     645                                        print ('        retval = reply->ret_val;')
     646                                print ('        free(reply);')
    647647                        else:
    648                                 print '        ' + xcb_request + ';'
    649                         print '#else'
     648                                print ('        ' + xcb_request + ';')
     649                        print ('#else')
    650650                        # End of XCB specific.
    651651
    652652
     
    656656                        pc_decl = "(void)"
    657657
    658658                if name in f.glx_vendorpriv_names:
    659                         print '        %s __glXSetupVendorRequest(gc, %s, %s, cmdlen);' % (pc_decl, f.opcode_real_name(), f.opcode_vendor_name(name))
     659                        print ('        %s __glXSetupVendorRequest(gc, %s, %s, cmdlen);' % (pc_decl, f.opcode_real_name(), f.opcode_vendor_name(name)))
    660660                else:
    661                         print '        %s __glXSetupSingleRequest(gc, %s, cmdlen);' % (pc_decl, f.opcode_name())
     661                        print ('        %s __glXSetupSingleRequest(gc, %s, cmdlen);' % (pc_decl, f.opcode_name()))
    662662
    663663                self.common_emit_args(f, "pc", 0, 0)
    664664
     
    667667                for img in images:
    668668                        if img.is_output:
    669669                                o = f.command_fixed_length() - 4
    670                                 print '        *(int32_t *)(pc + %u) = 0;' % (o)
     670                                print ('        *(int32_t *)(pc + %u) = 0;' % (o))
    671671                                if img.img_format != "GL_COLOR_INDEX" or img.img_type != "GL_BITMAP":
    672                                         print '        * (int8_t *)(pc + %u) = state->storePack.swapEndian;' % (o)
     672                                        print ('        * (int8_t *)(pc + %u) = state->storePack.swapEndian;' % (o))
    673673               
    674674                                if f.img_reset:
    675                                         print '        * (int8_t *)(pc + %u) = %s;' % (o + 1, f.img_reset)
     675                                        print ('        * (int8_t *)(pc + %u) = %s;' % (o + 1, f.img_reset))
    676676
    677677
    678678                return_name = ''
     
    689689                                if p.is_image():
    690690                                        [dim, w, h, d, junk] = p.get_dimensions()
    691691                                        if f.dimensions_in_reply:
    692                                                 print "        __glXReadPixelReply(dpy, gc, %u, 0, 0, 0, %s, %s, %s, GL_TRUE);" % (dim, p.img_format, p.img_type, p.name)
     692                                                print ("        __glXReadPixelReply(dpy, gc, %u, 0, 0, 0, %s, %s, %s, GL_TRUE);" % (dim, p.img_format, p.img_type, p.name))
    693693                                        else:
    694                                                 print "        __glXReadPixelReply(dpy, gc, %u, %s, %s, %s, %s, %s, %s, GL_FALSE);" % (dim, w, h, d, p.img_format, p.img_type, p.name)
     694                                                print ("        __glXReadPixelReply(dpy, gc, %u, %s, %s, %s, %s, %s, %s, GL_FALSE);" % (dim, w, h, d, p.img_format, p.img_type, p.name))
    695695
    696696                                        got_reply = 1
    697697                                else:
     
    711711                                        # non-arrays) gives us this.
    712712
    713713                                        s = p.size() / p.get_element_count()
    714                                         print "       %s __glXReadReply(dpy, %s, %s, %s);" % (return_str, s, p.name, aa)
     714                                        print ("       %s __glXReadReply(dpy, %s, %s, %s);" % (return_str, s, p.name, aa))
    715715                                        got_reply = 1
    716716
    717717
     
    719719                        # read a NULL reply to get the return value.
    720720
    721721                        if not got_reply:
    722                                 print "       %s __glXReadReply(dpy, 0, NULL, GL_FALSE);" % (return_str)
     722                                print ("       %s __glXReadReply(dpy, 0, NULL, GL_FALSE);" % (return_str))
    723723
    724724
    725725                elif self.debug:
    726726                        # Only emit the extra glFinish call for functions
    727727                        # that don't already require a reply from the server.
    728                         print '        __indirect_glFinish();'
     728                        print ('        __indirect_glFinish();')
    729729
    730730                if self.debug:
    731                         print '        printf( "Exit %%s.\\n", "gl%s" );' % (name)
     731                        print ('        printf( "Exit %%s.\\n", "gl%s" );' % (name))
    732732
    733733
    734                 print '        UnlockDisplay(dpy); SyncHandle();'
     734                print ('        UnlockDisplay(dpy); SyncHandle();')
    735735
    736736                if name not in f.glx_vendorpriv_names:
    737                         print '#endif /* USE_XCB */'
     737                        print ('#endif /* USE_XCB */')
    738738
    739                 print '    }'
    740                 print '    return%s;' % (return_name)
     739                print ('    }')
     740                print ('    return%s;' % (return_name))
    741741                return
    742742
    743743
     
    761761                                if f.pad_after(param):
    762762                                        p_string += ", 1"
    763763
    764                         print '    %s(%s, %u%s );' % (self.pixel_stubs[f.name] , f.opcode_name(), dim, p_string)
     764                        print ('    %s(%s, %u%s );' % (self.pixel_stubs[f.name] , f.opcode_name(), dim, p_string))
    765765                        return
    766766
    767767
     
    772772
    773773
    774774                if f.can_be_large:
    775                         print 'if (cmdlen <= gc->maxSmallRenderCommandSize) {'
    776                         print '    if ( (gc->pc + cmdlen) > gc->bufEnd ) {'
    777                         print '        (void) __glXFlushRenderBuffer(gc, gc->pc);'
    778                         print '    }'
     775                        print ('if (cmdlen <= gc->maxSmallRenderCommandSize) {')
     776                        print ('    if ( (gc->pc + cmdlen) > gc->bufEnd ) {')
     777                        print ('        (void) __glXFlushRenderBuffer(gc, gc->pc);')
     778                        print ('    }')
    779779
    780780                if f.glx_rop == ~0:
    781781                        opcode = "opcode"
    782782                else:
    783783                        opcode = f.opcode_real_name()
    784784
    785                 print 'emit_header(gc->pc, %s, cmdlen);' % (opcode)
     785                print ('emit_header(gc->pc, %s, cmdlen);' % (opcode))
    786786
    787787                self.pixel_emit_args( f, "gc->pc", 0 )
    788                 print 'gc->pc += cmdlen;'
    789                 print 'if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }'
     788                print ('gc->pc += cmdlen;')
     789                print ('if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }')
    790790
    791791                if f.can_be_large:
    792                         print '}'
    793                         print 'else {'
     792                        print ('}')
     793                        print ('else {')
    794794
    795795                        self.large_emit_begin(f, opcode)
    796796                        self.pixel_emit_args(f, "pc", 1)
    797797
    798                         print '}'
     798                        print ('}')
    799799
    800                 if trailer: print trailer
     800                if trailer: print (trailer)
    801801                return
    802802
    803803
     
    814814                        if p.is_pointer():
    815815                                cmdlen = f.command_fixed_length()
    816816                                if cmdlen in self.generic_sizes:
    817                                         print '    generic_%u_byte( %s, %s );' % (cmdlen, f.opcode_real_name(), p.name)
     817                                        print ('    generic_%u_byte( %s, %s );' % (cmdlen, f.opcode_real_name(), p.name))
    818818                                        return
    819819
    820820                if self.common_func_print_just_start(f, None):
     
    823823                        trailer = None
    824824
    825825                if self.debug:
    826                         print 'printf( "Enter %%s...\\n", "gl%s" );' % (f.name)
     826                        print ('printf( "Enter %%s...\\n", "gl%s" );' % (f.name))
    827827
    828828                if f.can_be_large:
    829                         print 'if (cmdlen <= gc->maxSmallRenderCommandSize) {'
    830                         print '    if ( (gc->pc + cmdlen) > gc->bufEnd ) {'
    831                         print '        (void) __glXFlushRenderBuffer(gc, gc->pc);'
    832                         print '    }'
     829                        print ('if (cmdlen <= gc->maxSmallRenderCommandSize) {')
     830                        print ('    if ( (gc->pc + cmdlen) > gc->bufEnd ) {')
     831                        print ('        (void) __glXFlushRenderBuffer(gc, gc->pc);')
     832                        print ('    }')
    833833
    834                 print 'emit_header(gc->pc, %s, cmdlen);' % (f.opcode_real_name())
     834                print ('emit_header(gc->pc, %s, cmdlen);' % (f.opcode_real_name()))
    835835
    836836                self.common_emit_args(f, "gc->pc", 4, 0)
    837                 print 'gc->pc += cmdlen;'
    838                 print 'if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }'
     837                print ('gc->pc += cmdlen;')
     838                print ('if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }')
    839839
    840840                if f.can_be_large:
    841                         print '}'
    842                         print 'else {'
     841                        print ('}')
     842                        print ('else {')
    843843
    844844                        self.large_emit_begin(f)
    845845                        self.common_emit_args(f, "pc", 8, 1)
    846846
    847847                        p = f.variable_length_parameter()
    848                         print '    __glXSendLargeCommand(gc, pc, %u, %s, %s);' % (p.offset + 8, p.name, p.size_string())
    849                         print '}'
     848                        print ('    __glXSendLargeCommand(gc, pc, %u, %s, %s);' % (p.offset + 8, p.name, p.size_string()))
     849                        print ('}')
    850850
    851851                if self.debug:
    852                         print '__indirect_glFinish();'
    853                         print 'printf( "Exit %%s.\\n", "gl%s" );' % (f.name)
     852                        print ('__indirect_glFinish();')
     853                        print ('printf( "Exit %%s.\\n", "gl%s" );' % (f.name))
    854854
    855                 if trailer: print trailer
     855                if trailer: print (trailer)
    856856                return
    857857
    858858
     
    868868
    869869
    870870        def printRealHeader(self):
    871                 print """/**
     871                print ("""/**
    872872 * \\file indirect_init.c
    873873 * Initialize indirect rendering dispatch table.
    874874 *
     
    918918                print """
    919919    return glAPI;
    920920}
    921 """
     921""")
    922922                return
    923923
    924924
     
    931931
    932932                        for func in api.functionIterateByCategory(name):
    933933                                if func.client_supported_for_indirect():
    934                                         print '%s    glAPI->%s = __indirect_gl%s;' % (preamble, func.name, func.name)
     934                                        print ('%s    glAPI->%s = __indirect_gl%s;' % (preamble, func.name, func.name))
    935935                                        preamble = ''
    936936
    937937                return
     
    952952
    953953
    954954        def printRealHeader(self):
    955                 print """/**
     955                print ("""/**
    956956 * \\file
    957957 * Prototypes for indirect rendering functions.
    958958 *
    959959 * \\author Kevin E. Martin <kevin@precisioninsight.com>
    960960 * \\author Ian Romanick <idr@us.ibm.com>
    961961 */
    962 """
     962""")
    963963                self.printVisibility( "HIDDEN", "hidden" )
    964964                self.printFastcall()
    965965                self.printNoinline()
    966966
    967                 print """
     967                print ("""
    968968#include "glxclient.h"
    969969
    970970extern HIDDEN NOINLINE CARD32 __glXReadReply( Display *dpy, size_t size,
     
    980980
    981981extern HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupVendorRequest(
    982982    __GLXcontext * gc, GLint code, GLint vop, GLint cmdlen );
    983 """
     983""")
    984984
    985985
    986986        def printBody(self, api):
    987987                for func in api.functionIterateGlx():
    988988                        params = func.get_parameter_string()
    989989
    990                         print 'extern HIDDEN %s __indirect_gl%s(%s);' % (func.return_type, func.name, params)
     990                        print ('extern HIDDEN %s __indirect_gl%s(%s);' % (func.return_type, func.name, params))
    991991
    992992                        for n in func.entry_points:
    993993                                if func.has_different_protocol(n):
    994994                                        asdf = func.static_glx_name(n)
    995995                                        if asdf not in func.static_entry_points:
    996                                                 print 'extern HIDDEN %s gl%s(%s);' % (func.return_type, asdf, params)
     996                                                print ('extern HIDDEN %s gl%s(%s);' % (func.return_type, asdf, params))
    997997                                        else:
    998                                                 print 'GLAPI %s GLAPIENTRY gl%s(%s);' % (func.return_type, asdf, params)
     998                                                print ('GLAPI %s GLAPIENTRY gl%s(%s);' % (func.return_type, asdf, params))
    999999                                               
    10001000                                        break
    10011001
    10021002
    10031003
    10041004def show_usage():
    1005         print "Usage: %s [-f input_file_name] [-m output_mode] [-d]" % sys.argv[0]
    1006         print "    -m output_mode   Output mode can be one of 'proto', 'init_c' or 'init_h'."
    1007         print "    -d               Enable extra debug information in the generated code."
     1005        print ("Usage: %s [-f input_file_name] [-m output_mode] [-d]" % sys.argv[0])
     1006        print ("    -m output_mode   Output mode can be one of 'proto', 'init_c' or 'init_h'.")
     1007        print ("    -d               Enable extra debug information in the generated code.")
    10081008        sys.exit(1)
    10091009
    10101010
  • Mesa-7.8.2/src/mesa/glapi/gen/glX_proto_size.py

    old new  
    166166                                        masked_count[i] = c
    167167
    168168
    169                         print '    static const GLushort a[%u] = {' % (mask + 1)
     169                        print ('    static const GLushort a[%u] = {' % (mask + 1))
    170170                        for e in masked_enums:
    171                                 print '        %s, ' % (masked_enums[e])
    172                         print '    };'
     171                                print ('        %s, ' % (masked_enums[e]))
     172                        print ('    };')
    173173
    174                         print '    static const GLubyte b[%u] = {' % (mask + 1)
     174                        print ('    static const GLubyte b[%u] = {' % (mask + 1))
    175175                        for c in masked_count:
    176                                 print '        %u, ' % (masked_count[c])
    177                         print '    };'
     176                                print ('        %u, ' % (masked_count[c]))
     177                        print ('    };')
    178178
    179                         print '    const unsigned idx = (e & 0x%02xU);' % (mask)
    180                         print ''
    181                         print '    return (e == a[idx]) ? (GLint) b[idx] : 0;'
     179                        print ('    const unsigned idx = (e & 0x%02xU);' % (mask))
     180                        print ('')
     181                        print ('    return (e == a[idx]) ? (GLint) b[idx] : 0;')
    182182                        return 1;
    183183                else:
    184184                        return 0;
     
    188188                """Emit the body of the __gl*_size function using a
    189189                switch-statement."""
    190190
    191                 print '    switch( e ) {'
     191                print ('    switch( e ) {')
    192192
    193193                for c in self.count:
    194194                        for e in self.count[c]:
     
    210210                                for k in keys:
    211211                                        j = list[k]
    212212                                        if first:
    213                                                 print '        case GL_%s:' % (j)
     213                                                print ('        case GL_%s:' % (j))
    214214                                                first = 0
    215215                                        else:
    216                                                 print '/*      case GL_%s:*/' % (j)
     216                                                print ('/*      case GL_%s:*/' % (j))
    217217                                       
    218218                        if c == -1:
    219                                 print '            return __gl%s_variable_size( e );' % (name)
     219                                print ('            return __gl%s_variable_size( e );' % (name))
    220220                        else:
    221                                 print '            return %u;' % (c)
     221                                print ('            return %u;' % (c))
    222222                                       
    223                 print '        default: return 0;'
    224                 print '    }'
     223                print ('        default: return 0;')
     224                print ('    }')
    225225
    226226
    227227        def Print(self, name):
    228                 print 'INTERNAL PURE FASTCALL GLint'
    229                 print '__gl%s_size( GLenum e )' % (name)
    230                 print '{'
     228                print ('INTERNAL PURE FASTCALL GLint')
     229                print ('__gl%s_size( GLenum e )' % (name))
     230                print ('{')
    231231
    232232                if not self.PrintUsingTable():
    233233                        self.PrintUsingSwitch(name)
    234234
    235                 print '}'
    236                 print ''
     235                print ('}')
     236                print ('')
    237237
    238238
    239239class glx_server_enum_function(glx_enum_function):
     
    281281                        fixup.append( p.name )
    282282
    283283
    284                 print '    GLsizei compsize;'
    285                 print ''
     284                print ('    GLsizei compsize;')
     285                print ('')
    286286
    287287                printer.common_emit_fixups(fixup)
    288288
    289                 print ''
    290                 print '    compsize = __gl%s_size(%s);' % (f.name, string.join(f.count_parameter_list, ","))
     289                print ('')
     290                print ('    compsize = __gl%s_size(%s);' % (f.name, string.join(f.count_parameter_list, ",")))
    291291                p = f.variable_length_parameter()
    292                 print '    return __GLX_PAD(%s);' % (p.size_string())
     292                print ('    return __GLX_PAD(%s);' % (p.size_string()))
    293293
    294                 print '}'
    295                 print ''
     294                print ('}')
     295                print ('')
    296296
    297297
    298298class PrintGlxSizeStubs_common(gl_XML.gl_print_base):
     
    312312
    313313class PrintGlxSizeStubs_c(PrintGlxSizeStubs_common):
    314314        def printRealHeader(self):
    315                 print ''
    316                 print '#include <GL/gl.h>'
     315                print ('')
     316                print ('#include <GL/gl.h>')
    317317                if self.emit_get:
    318                         print '#include "indirect_size_get.h"'
    319                         print '#include "glxserver.h"'
    320                         print '#include "indirect_util.h"'
     318                        print ('#include "indirect_size_get.h"')
     319                        print ('#include "glxserver.h"')
     320                        print ('#include "indirect_util.h"')
    321321               
    322                 print '#include "indirect_size.h"'
     322                print ('#include "indirect_size.h"')
    323323
    324                 print ''
     324                print ('')
    325325                self.printPure()
    326                 print ''
     326                print ('')
    327327                self.printFastcall()
    328                 print ''
     328                print ('')
    329329                self.printVisibility( "INTERNAL", "internal" )
    330                 print ''
    331                 print ''
    332                 print '#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__APPLE__)'
    333                 print '#  undef HAVE_ALIAS'
    334                 print '#endif'
    335                 print '#ifdef HAVE_ALIAS'
    336                 print '#  define ALIAS2(from,to) \\'
    337                 print '    INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\'
    338                 print '        __attribute__ ((alias( # to )));'
    339                 print '#  define ALIAS(from,to) ALIAS2( from, __gl ## to ## _size )'
    340                 print '#else'
    341                 print '#  define ALIAS(from,to) \\'
    342                 print '    INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\'
    343                 print '    { return __gl ## to ## _size( e ); }'
    344                 print '#endif'
    345                 print ''
    346                 print ''
     330                print ('')
     331                print ('')
     332                print ('#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__APPLE__)')
     333                print ('#  undef HAVE_ALIAS')
     334                print ('#endif')
     335                print ('#ifdef HAVE_ALIAS')
     336                print ('#  define ALIAS2(from,to) \\')
     337                print ('    INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\')
     338                print ('        __attribute__ ((alias( # to )));')
     339                print ('#  define ALIAS(from,to) ALIAS2( from, __gl ## to ## _size )')
     340                print ('#else')
     341                print ('#  define ALIAS(from,to) \\')
     342                print ('    INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\')
     343                print ('    { return __gl ## to ## _size( e ); }')
     344                print ('#endif')
     345                print ('')
     346                print ('')
    347347
    348348
    349349        def printBody(self, api):
     
    365365
    366366
    367367                for [alias_name, real_name] in aliases:
    368                         print 'ALIAS( %s, %s )' % (alias_name, real_name)
     368                        print ('ALIAS( %s, %s )' % (alias_name, real_name))
    369369
    370370
    371371                               
    372372class PrintGlxSizeStubs_h(PrintGlxSizeStubs_common):
    373373        def printRealHeader(self):
    374                 print """/**
     374                print ("""/**
    375375 * \\file
    376376 * Prototypes for functions used to determine the number of data elements in
    377377 * various GLX protocol messages.
    378378 *
    379379 * \\author Ian Romanick <idr@us.ibm.com>
    380380 */
    381 """
     381""")
    382382                self.printPure();
    383                 print ''
     383                print ('')
    384384                self.printFastcall();
    385                 print ''
     385                print ('')
    386386                self.printVisibility( "INTERNAL", "internal" );
    387                 print ''
     387                print ('')
    388388
    389389
    390390        def printBody(self, api):
     
    394394                                continue
    395395
    396396                        if (ef.is_set() and self.emit_set) or (not ef.is_set() and self.emit_get):
    397                                 print 'extern INTERNAL PURE FASTCALL GLint __gl%s_size(GLenum);' % (func.name)
     397                                print ('extern INTERNAL PURE FASTCALL GLint __gl%s_size(GLenum);' % (func.name))
    398398
    399399
    400400class PrintGlxReqSize_common(gl_XML.gl_print_base):
     
    419419
    420420        def printRealHeader(self):
    421421                self.printVisibility("HIDDEN", "hidden")
    422                 print ''
     422                print ('')
    423423                self.printPure()
    424                 print ''
     424                print ('')
    425425
    426426
    427427        def printBody(self, api):
    428428                for func in api.functionIterateGlx():
    429429                        if not func.ignore and func.has_variable_size_request():
    430                                 print 'extern PURE HIDDEN int __glX%sReqSize(const GLbyte *pc, Bool swap);' % (func.name)
     430                                print ('extern PURE HIDDEN int __glX%sReqSize(const GLbyte *pc, Bool swap);' % (func.name))
    431431
    432432
    433433class PrintGlxReqSize_c(PrintGlxReqSize_common):
     
    444444
    445445
    446446        def printRealHeader(self):
    447                 print ''
    448                 print '#include <GL/gl.h>'
    449                 print '#include "glxserver.h"'
    450                 print '#include "glxbyteorder.h"'
    451                 print '#include "indirect_size.h"'
    452                 print '#include "indirect_reqsize.h"'
    453                 print ''
    454                 print '#define __GLX_PAD(x)  (((x) + 3) & ~3)'
    455                 print ''
    456                 print '#if defined(__CYGWIN__) || defined(__MINGW32__)'
    457                 print '#  undef HAVE_ALIAS'
    458                 print '#endif'
    459                 print '#ifdef HAVE_ALIAS'
    460                 print '#  define ALIAS2(from,to) \\'
    461                 print '    GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap ) \\'
    462                 print '        __attribute__ ((alias( # to )));'
    463                 print '#  define ALIAS(from,to) ALIAS2( from, __glX ## to ## ReqSize )'
    464                 print '#else'
    465                 print '#  define ALIAS(from,to) \\'
    466                 print '    GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap ) \\'
    467                 print '    { return __glX ## to ## ReqSize( pc, swap ); }'
    468                 print '#endif'
    469                 print ''
    470                 print ''
     447                print ('')
     448                print ('#include <GL/gl.h>')
     449                print ('#include "glxserver.h"')
     450                print ('#include "glxbyteorder.h"')
     451                print ('#include "indirect_size.h"')
     452                print ('#include "indirect_reqsize.h"')
     453                print ('')
     454                print ('#define __GLX_PAD(x)  (((x) + 3) & ~3)')
     455                print ('')
     456                print ('#if defined(__CYGWIN__) || defined(__MINGW32__)')
     457                print ('#  undef HAVE_ALIAS')
     458                print ('#endif')
     459                print ('#ifdef HAVE_ALIAS')
     460                print ('#  define ALIAS2(from,to) \\')
     461                print ('    GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap ) \\')
     462                print ('        __attribute__ ((alias( # to )));')
     463                print ('#  define ALIAS(from,to) ALIAS2( from, __glX ## to ## ReqSize )')
     464                print ('#else')
     465                print ('#  define ALIAS(from,to) \\')
     466                print ('    GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap ) \\')
     467                print ('    { return __glX ## to ## ReqSize( pc, swap ); }')
     468                print ('#endif')
     469                print ('')
     470                print ('')
    471471
    472472
    473473        def printBody(self, api):
     
    519519
    520520
    521521                for [alias_name, real_name] in aliases:
    522                         print 'ALIAS( %s, %s )' % (alias_name, real_name)
     522                        print ('ALIAS( %s, %s )' % (alias_name, real_name))
    523523
    524524                return
    525525
     
    528528                """Utility function to emit conditional byte-swaps."""
    529529
    530530                if fixup:
    531                         print '    if (swap) {'
     531                        print ('    if (swap) {')
    532532                        for name in fixup:
    533                                 print '        %s = bswap_32(%s);' % (name, name)
    534                         print '    }'
     533                                print ('        %s = bswap_32(%s);' % (name, name))
     534                        print ('    }')
    535535
    536536                return
    537537
     
    540540                offset = p.offset
    541541                dst = p.string()
    542542                src = '(%s *)' % (p.type_string())
    543                 print '%-18s = *%11s(%s + %u);' % (dst, src, pc, offset + adjust);
     543                print ('%-18s = *%11s(%s + %u);' % (dst, src, pc, offset + adjust))
    544544                return
    545545
    546546
    547547        def common_func_print_just_header(self, f):
    548                 print 'int'
    549                 print '__glX%sReqSize( const GLbyte * pc, Bool swap )' % (f.name)
    550                 print '{'
     548                print ('int')
     549                print ('__glX%sReqSize( const GLbyte * pc, Bool swap )' % (f.name))
     550                print ('{')
    551551
    552552
    553553        def printPixelFunction(self, f):
     
    556556                f.offset_of( f.parameters[0].name )
    557557                [dim, w, h, d, junk] = f.get_images()[0].get_dimensions()
    558558
    559                 print '    GLint row_length   = *  (GLint *)(pc +  4);'
     559                print ('    GLint row_length   = *  (GLint *)(pc +  4);')
    560560
    561561                if dim < 3:
    562562                        fixup = ['row_length', 'skip_rows', 'alignment']
    563                         print '    GLint image_height = 0;'
    564                         print '    GLint skip_images  = 0;'
    565                         print '    GLint skip_rows    = *  (GLint *)(pc +  8);'
    566                         print '    GLint alignment    = *  (GLint *)(pc + 16);'
     563                        print ('    GLint image_height = 0;')
     564                        print ('    GLint skip_images  = 0;')
     565                        print ('    GLint skip_rows    = *  (GLint *)(pc +  8);')
     566                        print ('    GLint alignment    = *  (GLint *)(pc + 16);')
    567567                else:
    568568                        fixup = ['row_length', 'image_height', 'skip_rows', 'skip_images', 'alignment']
    569                         print '    GLint image_height = *  (GLint *)(pc +  8);'
    570                         print '    GLint skip_rows    = *  (GLint *)(pc + 16);'
    571                         print '    GLint skip_images  = *  (GLint *)(pc + 20);'
    572                         print '    GLint alignment    = *  (GLint *)(pc + 32);'
     569                        print ('    GLint image_height = *  (GLint *)(pc +  8);')
     570                        print ('    GLint skip_rows    = *  (GLint *)(pc + 16);')
     571                        print ('    GLint skip_images  = *  (GLint *)(pc + 20);')
     572                        print ('    GLint alignment    = *  (GLint *)(pc + 32);')
    573573
    574574                img = f.images[0]
    575575                for p in f.parameterIterateGlxSend():
     
    577577                                self.common_emit_one_arg(p, "pc", 0)
    578578                                fixup.append( p.name )
    579579
    580                 print ''
     580                print ('')
    581581
    582582                self.common_emit_fixups(fixup)
    583583
    584584                if img.img_null_flag:
    585                         print ''
    586                         print '    if (*(CARD32 *) (pc + %s))' % (img.offset - 4)
    587                         print '        return 0;'
    588 
    589                 print ''
    590                 print '    return __glXImageSize(%s, %s, %s, %s, %s, %s,' % (img.img_format, img.img_type, img.img_target, w, h, d )
    591                 print '                          image_height, row_length, skip_images,'
    592                 print '                          skip_rows, alignment);'
    593                 print '}'
    594                 print ''
     585                        print ('')
     586                        print ('           if (*(CARD32 *) (pc + %s))' % (img.offset - 4))
     587                        print ('               return 0;')
     588
     589                print ('')
     590                print ('    return __glXImageSize(%s, %s, %s, %s, %s, %s,' % (img.img_format, img.img_type, img.img_target, w, h, d ))
     591                print ('                          image_height, row_length, skip_images,')
     592                print ('                          skip_rows, alignment);')
     593                print ('}')
     594                print ('')
    595595                return
    596596
    597597
     
    640640                                self.common_emit_one_arg(p, "pc", 0)
    641641
    642642
    643                         print ''
     643                        print ('')
    644644                        self.common_emit_fixups(fixup)
    645                         print ''
     645                        print ('')
    646646
    647                         print '    return __GLX_PAD(%s);' % (size)
    648                         print '}'
    649                         print ''
     647                        print ('    return __GLX_PAD(%s);' % (size))
     648                        print ('}')
     649                        print ('')
    650650
    651651                return alias
    652652
    653653
    654654def show_usage():
    655         print "Usage: %s [-f input_file_name] -m output_mode [--only-get | --only-set] [--get-alias-set]" % sys.argv[0]
    656         print "    -m output_mode   Output mode can be one of 'size_c' or 'size_h'."
    657         print "    --only-get       Only emit 'get'-type functions."
    658         print "    --only-set       Only emit 'set'-type functions."
    659         print ""
    660         print "By default, both 'get' and 'set'-type functions are emitted."
     655        print ("Usage: %s [-f input_file_name] -m output_mode [--only-get | --only-set] [--get-alias-set]" % sys.argv[0])
     656        print ("    -m output_mode   Output mode can be one of 'size_c' or 'size_h'.")
     657        print ("    --only-get       Only emit 'get'-type functions.")
     658        print ("    --only-set       Only emit 'set'-type functions.")
     659        print ("")
     660        print ("By default, both 'get' and 'set'-type functions are emitted.")
    661661        sys.exit(1)
    662662
    663663
  • Mesa-7.8.2/src/mesa/glapi/gen/glX_server_table.py

    old new  
    172172                if children == []:
    173173                        return
    174174
    175                 print '    /* [%u] -> opcode range [%u, %u], node depth %u */' % (base_entry, base_opcode, base_opcode + (1 << remaining_bits), depth)
    176                 print '    %u,' % (M)
     175                print ('    /* [%u] -> opcode range [%u, %u], node depth %u */' % (base_entry, base_opcode, base_opcode + (1 << remaining_bits), depth))
     176                print ('    %u,' % (M))
    177177
    178178                base_entry += (1 << M) + 1
    179179
     
    182182                for child in children:
    183183                        if child[1] == []:
    184184                                if self.is_empty_leaf(child_base_opcode, child_M):
    185                                         print '    EMPTY_LEAF,'
     185                                        print ('    EMPTY_LEAF,')
    186186                                else:
    187187                                        # Emit the index of the next dispatch
    188188                                        # function.  Then add all the
     
    190190                                        # node to the dispatch function
    191191                                        # lookup table.
    192192
    193                                         print '    LEAF(%u),' % (len(self.lookup_table))
     193                                        print ('    LEAF(%u),' % (len(self.lookup_table)))
    194194
    195195                                        for op in range(child_base_opcode, child_base_opcode + (1 << child_M)):
    196196                                                if self.functions.has_key(op):
     
    218218
    219219                                                self.lookup_table.append(temp)
    220220                        else:
    221                                 print '    %u,' % (child_index)
     221                                print ('    %u,' % (child_index))
    222222                                child_index += child[2]
    223223
    224224                        child_base_opcode += 1 << child_M
    225225
    226                 print ''
     226                print ('')
    227227
    228228                child_index = base_entry
    229229                for child in children:
     
    278278
    279279                tree = self.divide_group(0, 0)
    280280
    281                 print '/*****************************************************************/'
    282                 print '/* tree depth = %u */' % (tree[3])
    283                 print 'static const int_fast16_t %s_dispatch_tree[%u] = {' % (self.name_base, tree[2])
     281                print ('/*****************************************************************/')
     282                print ('/* tree depth = %u */' % (tree[3]))
     283                print ('static const int_fast16_t %s_dispatch_tree[%u] = {' % (self.name_base, tree[2]))
    284284                self.dump_tree(tree, 0, self.max_bits, 0, 1)
    285                 print '};\n'
     285                print ('};\n')
    286286               
    287287                # After dumping the tree, dump the function lookup table.
    288288               
    289                 print 'static const void *%s_function_table[%u][2] = {' % (self.name_base, len(self.lookup_table))
     289                print ('static const void *%s_function_table[%u][2] = {' % (self.name_base, len(self.lookup_table)))
    290290                index = 0
    291291                for func in self.lookup_table:
    292292                        opcode = func[0]
    293293                        name = func[1]
    294294                        name_swap = func[2]
    295295                       
    296                         print '    /* [% 3u] = %5u */ {%s, %s},' % (index, opcode, name, name_swap)
     296                        print ('    /* [% 3u] = %5u */ {%s, %s},' % (index, opcode, name, name_swap))
    297297                       
    298298                        index += 1
    299299
    300                 print '};\n'
     300                print ('};\n')
    301301               
    302302                if self.do_size_check:
    303303                        var_table = []
    304304
    305                         print 'static const int_fast16_t %s_size_table[%u][2] = {' % (self.name_base, len(self.lookup_table))
     305                        print ('static const int_fast16_t %s_size_table[%u][2] = {' % (self.name_base, len(self.lookup_table)))
    306306                        index = 0
    307307                        var_table = []
    308308                        for func in self.lookup_table:
     
    316316                                else:
    317317                                        var_offset = "~0"
    318318
    319                                 print '    /* [%3u] = %5u */ {%3u, %s},' % (index, opcode, fixed, var_offset)
     319                                print ('    /* [%3u] = %5u */ {%3u, %s},' % (index, opcode, fixed, var_offset))
    320320                                index += 1
    321321
    322322                               
    323                         print '};\n'
     323                        print ('};\n')
    324324
    325325
    326                         print 'static const gl_proto_size_func %s_size_func_table[%u] = {' % (self.name_base, len(var_table))
     326                        print ('static const gl_proto_size_func %s_size_func_table[%u] = {' % (self.name_base, len(var_table)))
    327327                        for func in var_table:
    328                                 print '   %s,' % (func)
     328                                print ('   %s,' % (func))
    329329 
    330                         print '};\n'
     330                        print ('};\n')
    331331
    332332
    333                 print 'const struct __glXDispatchInfo %s_dispatch_info = {' % (self.name_base)
    334                 print '    %u,' % (self.max_bits)
    335                 print '    %s_dispatch_tree,' % (self.name_base)
    336                 print '    %s_function_table,' % (self.name_base)
     333                print ('const struct __glXDispatchInfo %s_dispatch_info = {' % (self.name_base))
     334                print ('    %u,' % (self.max_bits))
     335                print ('    %s_dispatch_tree,' % (self.name_base))
     336                print ('    %s_function_table,' % (self.name_base))
    337337                if self.do_size_check:
    338                         print '    %s_size_table,' % (self.name_base)
    339                         print '    %s_size_func_table' % (self.name_base)
     338                        print ('    %s_size_table,' % (self.name_base))
     339                        print ('    %s_size_func_table' % (self.name_base))
    340340                else:
    341                         print '    NULL,'
    342                         print '    NULL'
    343                 print '};\n'
     341                        print ('    NULL,')
     342                        print ('    NULL')
     343                print ('};\n')
    344344                return
    345345
    346346
     
    357357
    358358
    359359        def printRealHeader(self):
    360                 print '#include <inttypes.h>'
    361                 print '#include "glxserver.h"'
    362                 print '#include "glxext.h"'
    363                 print '#include "indirect_dispatch.h"'
    364                 print '#include "indirect_reqsize.h"'
    365                 print '#include "g_disptab.h"'
    366                 print '#include "indirect_table.h"'
    367                 print ''
     360                print ('#include <inttypes.h>')
     361                print ('#include "glxserver.h"')
     362                print ('#include "glxext.h"')
     363                print ('#include "indirect_dispatch.h"')
     364                print ('#include "indirect_reqsize.h"')
     365                print ('#include "g_disptab.h"')
     366                print ('#include "indirect_table.h"')
     367                print ('')
    368368                return
    369369
    370370
  • Mesa-7.8.2/src/mesa/glapi/gen/mesadef.py

    old new  
    4040
    4141
    4242def PrintHead():
    43         print '; DO NOT EDIT - This file generated automatically by mesadef.py script'
    44         print 'DESCRIPTION \'Mesa (OpenGL work-alike) for Win32\''
    45         print 'VERSION 6.0'
    46         print ';'
    47         print '; Module definition file for Mesa (OPENGL32.DLL)'
    48         print ';'
    49         print '; Note: The OpenGL functions use the STDCALL'
    50         print '; function calling convention.  Microsoft\'s'
    51         print '; OPENGL32 uses this convention and so must the'
    52         print '; Mesa OPENGL32 so that the Mesa DLL can be used'
    53         print '; as a drop-in replacement.'
    54         print ';'
    55         print '; The linker exports STDCALL entry points with'
    56         print '; \'decorated\' names; e.g., _glBegin@0, where the'
    57         print '; trailing number is the number of bytes of '
    58         print '; parameter data pushed onto the stack.  The'
    59         print '; callee is responsible for popping this data'
    60         print '; off the stack, usually via a RETF n instruction.'
    61         print ';'
    62         print '; However, the Microsoft OPENGL32.DLL does not export'
    63         print '; the decorated names, even though the calling convention'
    64         print '; is STDCALL.  So, this module definition file is'
    65         print '; needed to force the Mesa OPENGL32.DLL to export the'
    66         print '; symbols in the same manner as the Microsoft DLL.'
    67         print '; Were it not for this problem, this file would not'
    68         print '; be needed (for the gl* functions) since the entry'
    69         print '; points are compiled with dllexport declspec.'
    70         print ';'
    71         print '; However, this file is still needed to export "internal"'
    72         print '; Mesa symbols for the benefit of the OSMESA32.DLL.'
    73         print ';'
    74         print 'EXPORTS'
     43        print ('; DO NOT EDIT - This file generated automatically by mesadef.py script')
     44        print ('DESCRIPTION \'Mesa (OpenGL work-alike) for Win32\'')
     45        print ('VERSION 6.0')
     46        print (';')
     47        print ('; Module definition file for Mesa (OPENGL32.DLL)')
     48        print (';')
     49        print ('; Note: The OpenGL functions use the STDCALL')
     50        print ('; function calling convention.  Microsoft\'s')
     51        print ('; OPENGL32 uses this convention and so must the')
     52        print ('; Mesa OPENGL32 so that the Mesa DLL can be used')
     53        print ('; as a drop-in replacement.')
     54        print (';')
     55        print ('; The linker exports STDCALL entry points with')
     56        print ('; \'decorated\' names; e.g., _glBegin@0, where the')
     57        print ('; trailing number is the number of bytes of ')
     58        print ('; parameter data pushed onto the stack.  The')
     59        print ('; callee is responsible for popping this data')
     60        print ('; off the stack, usually via a RETF n instruction.')
     61        print (';')
     62        print ('; However, the Microsoft OPENGL32.DLL does not export')
     63        print ('; the decorated names, even though the calling convention')
     64        print ('; is STDCALL.  So, this module definition file is')
     65        print ('; needed to force the Mesa OPENGL32.DLL to export the')
     66        print ('; symbols in the same manner as the Microsoft DLL.')
     67        print ('; Were it not for this problem, this file would not')
     68        print ('; be needed (for the gl* functions) since the entry')
     69        print ('; points are compiled with dllexport declspec.')
     70        print (';')
     71        print ('; However, this file is still needed to export "internal"')
     72        print ('; Mesa symbols for the benefit of the OSMESA32.DLL.')
     73        print (';')
     74        print ('EXPORTS')
    7575        return
    7676#enddef
    7777
    7878
    7979def PrintTail():
    80         print ';'
    81         print '; WGL API'
    82         print '\twglChoosePixelFormat'
    83         print '\twglCopyContext'
    84         print '\twglCreateContext'
    85         print '\twglCreateLayerContext'
    86         print '\twglDeleteContext'
    87         print '\twglDescribeLayerPlane'
    88         print '\twglDescribePixelFormat'
    89         print '\twglGetCurrentContext'
    90         print '\twglGetCurrentDC'
    91         print '\twglGetExtensionsStringARB'
    92         print '\twglGetLayerPaletteEntries'
    93         print '\twglGetPixelFormat'
    94         print '\twglGetProcAddress'
    95         print '\twglMakeCurrent'
    96         print '\twglRealizeLayerPalette'
    97         print '\twglSetLayerPaletteEntries'
    98         print '\twglSetPixelFormat'
    99         print '\twglShareLists'
    100         print '\twglSwapBuffers'
    101         print '\twglSwapLayerBuffers'
    102         print '\twglUseFontBitmapsA'
    103         print '\twglUseFontBitmapsW'
    104         print '\twglUseFontOutlinesA'
    105         print '\twglUseFontOutlinesW'
    106         print ';'
    107         print '; Mesa internals - mostly for OSMESA'
    108         print '\t_ac_CreateContext'
    109         print '\t_ac_DestroyContext'
    110         print '\t_ac_InvalidateState'
    111         print '\t_glapi_get_context'
    112         print '\t_glapi_get_proc_address'
    113         print '\t_mesa_buffer_data'
    114         print '\t_mesa_buffer_map'
    115         print '\t_mesa_buffer_subdata'
    116         print '\t_mesa_choose_tex_format'
    117         print '\t_mesa_compressed_texture_size'
    118         print '\t_mesa_create_framebuffer'
    119         print '\t_mesa_create_visual'
    120         print '\t_mesa_delete_buffer_object'
    121         print '\t_mesa_delete_texture_object'
    122         print '\t_mesa_destroy_framebuffer'
    123         print '\t_mesa_destroy_visual'
    124         print '\t_mesa_enable_1_3_extensions'
    125         print '\t_mesa_enable_1_4_extensions'
    126         print '\t_mesa_enable_1_5_extensions'
    127         print '\t_mesa_enable_sw_extensions'
    128         print '\t_mesa_error'
    129         print '\t_mesa_free_context_data'
    130         print '\t_mesa_get_current_context'
    131         print '\t_mesa_init_default_imports'
    132         print '\t_mesa_initialize_context'
    133         print '\t_mesa_make_current'
    134         print '\t_mesa_new_buffer_object'
    135         print '\t_mesa_new_texture_object'
    136         print '\t_mesa_problem'
    137         print '\t_mesa_ResizeBuffersMESA'
    138         print '\t_mesa_store_compressed_teximage1d'
    139         print '\t_mesa_store_compressed_teximage2d'
    140         print '\t_mesa_store_compressed_teximage3d'
    141         print '\t_mesa_store_compressed_texsubimage1d'
    142         print '\t_mesa_store_compressed_texsubimage2d'
    143         print '\t_mesa_store_compressed_texsubimage3d'
    144         print '\t_mesa_store_teximage1d'
    145         print '\t_mesa_store_teximage2d'
    146         print '\t_mesa_store_teximage3d'
    147         print '\t_mesa_store_texsubimage1d'
    148         print '\t_mesa_store_texsubimage2d'
    149         print '\t_mesa_store_texsubimage3d'
    150         print '\t_mesa_test_proxy_teximage'
    151         print '\t_mesa_Viewport'
    152         print '\t_mesa_meta_CopyColorSubTable'
    153         print '\t_mesa_meta_CopyColorTable'
    154         print '\t_mesa_meta_CopyConvolutionFilter1D'
    155         print '\t_mesa_meta_CopyConvolutionFilter2D'
    156         print '\t_mesa_meta_CopyTexImage1D'
    157         print '\t_mesa_meta_CopyTexImage2D'
    158         print '\t_mesa_meta_CopyTexSubImage1D'
    159         print '\t_mesa_meta_CopyTexSubImage2D'
    160         print '\t_mesa_meta_CopyTexSubImage3D'
    161         print '\t_swrast_Accum'
    162         print '\t_swrast_alloc_buffers'
    163         print '\t_swrast_Bitmap'
    164         print '\t_swrast_CopyPixels'
    165         print '\t_swrast_DrawPixels'
    166         print '\t_swrast_GetDeviceDriverReference'
    167         print '\t_swrast_Clear'
    168         print '\t_swrast_choose_line'
    169         print '\t_swrast_choose_triangle'
    170         print '\t_swrast_CreateContext'
    171         print '\t_swrast_DestroyContext'
    172         print '\t_swrast_InvalidateState'
    173         print '\t_swrast_ReadPixels'
    174         print '\t_swrast_zbuffer_address'
    175         print '\t_swsetup_Wakeup'
    176         print '\t_swsetup_CreateContext'
    177         print '\t_swsetup_DestroyContext'
    178         print '\t_swsetup_InvalidateState'
    179         print '\t_tnl_CreateContext'
    180         print '\t_tnl_DestroyContext'
    181         print '\t_tnl_InvalidateState'
    182         print '\t_tnl_MakeCurrent'
    183         print '\t_tnl_run_pipeline'
     80        print (';')
     81        print ('; WGL API')
     82        print ('\twglChoosePixelFormat')
     83        print ('\twglCopyContext')
     84        print ('\twglCreateContext')
     85        print ('\twglCreateLayerContext')
     86        print ('\twglDeleteContext')
     87        print ('\twglDescribeLayerPlane')
     88        print ('\twglDescribePixelFormat')
     89        print ('\twglGetCurrentContext')
     90        print ('\twglGetCurrentDC')
     91        print ('\twglGetExtensionsStringARB')
     92        print ('\twglGetLayerPaletteEntries')
     93        print ('\twglGetPixelFormat')
     94        print ('\twglGetProcAddress')
     95        print ('\twglMakeCurrent')
     96        print ('\twglRealizeLayerPalette')
     97        print ('\twglSetLayerPaletteEntries')
     98        print ('\twglSetPixelFormat')
     99        print ('\twglShareLists')
     100        print ('\twglSwapBuffers')
     101        print ('\twglSwapLayerBuffers')
     102        print ('\twglUseFontBitmapsA')
     103        print ('\twglUseFontBitmapsW')
     104        print ('\twglUseFontOutlinesA')
     105        print ('\twglUseFontOutlinesW')
     106        print (';')
     107        print ('; Mesa internals - mostly for OSMESA')
     108        print ('\t_ac_CreateContext')
     109        print ('\t_ac_DestroyContext')
     110        print ('\t_ac_InvalidateState')
     111        print ('\t_glapi_get_context')
     112        print ('\t_glapi_get_proc_address')
     113        print ('\t_mesa_buffer_data')
     114        print ('\t_mesa_buffer_map')
     115        print ('\t_mesa_buffer_subdata')
     116        print ('\t_mesa_choose_tex_format')
     117        print ('\t_mesa_compressed_texture_size')
     118        print ('\t_mesa_create_framebuffer')
     119        print ('\t_mesa_create_visual')
     120        print ('\t_mesa_delete_buffer_object')
     121        print ('\t_mesa_delete_texture_object')
     122        print ('\t_mesa_destroy_framebuffer')
     123        print ('\t_mesa_destroy_visual')
     124        print ('\t_mesa_enable_1_3_extensions')
     125        print ('\t_mesa_enable_1_4_extensions')
     126        print ('\t_mesa_enable_1_5_extensions')
     127        print ('\t_mesa_enable_sw_extensions')
     128        print ('\t_mesa_error')
     129        print ('\t_mesa_free_context_data')
     130        print ('\t_mesa_get_current_context')
     131        print ('\t_mesa_init_default_imports')
     132        print ('\t_mesa_initialize_context')
     133        print ('\t_mesa_make_current')
     134        print ('\t_mesa_new_buffer_object')
     135        print ('\t_mesa_new_texture_object')
     136        print ('\t_mesa_problem')
     137        print ('\t_mesa_ResizeBuffersMESA')
     138        print ('\t_mesa_store_compressed_teximage1d')
     139        print ('\t_mesa_store_compressed_teximage2d')
     140        print ('\t_mesa_store_compressed_teximage3d')
     141        print ('\t_mesa_store_compressed_texsubimage1d')
     142        print ('\t_mesa_store_compressed_texsubimage2d')
     143        print ('\t_mesa_store_compressed_texsubimage3d')
     144        print ('\t_mesa_store_teximage1d')
     145        print ('\t_mesa_store_teximage2d')
     146        print ('\t_mesa_store_teximage3d')
     147        print ('\t_mesa_store_texsubimage1d')
     148        print ('\t_mesa_store_texsubimage2d')
     149        print ('\t_mesa_store_texsubimage3d')
     150        print ('\t_mesa_test_proxy_teximage')
     151        print ('\t_mesa_Viewport')
     152        print ('\t_mesa_meta_CopyColorSubTable')
     153        print ('\t_mesa_meta_CopyColorTable')
     154        print ('\t_mesa_meta_CopyConvolutionFilter1D')
     155        print ('\t_mesa_meta_CopyConvolutionFilter2D')
     156        print ('\t_mesa_meta_CopyTexImage1D')
     157        print ('\t_mesa_meta_CopyTexImage2D')
     158        print ('\t_mesa_meta_CopyTexSubImage1D')
     159        print ('\t_mesa_meta_CopyTexSubImage2D')
     160        print ('\t_mesa_meta_CopyTexSubImage3D')
     161        print ('\t_swrast_Accum')
     162        print ('\t_swrast_alloc_buffers')
     163        print ('\t_swrast_Bitmap')
     164        print ('\t_swrast_CopyPixels')
     165        print ('\t_swrast_DrawPixels')
     166        print ('\t_swrast_GetDeviceDriverReference')
     167        print ('\t_swrast_Clear')
     168        print ('\t_swrast_choose_line')
     169        print ('\t_swrast_choose_triangle')
     170        print ('\t_swrast_CreateContext')
     171        print ('\t_swrast_DestroyContext')
     172        print ('\t_swrast_InvalidateState')
     173        print ('\t_swrast_ReadPixels')
     174        print ('\t_swrast_zbuffer_address')
     175        print ('\t_swsetup_Wakeup')
     176        print ('\t_swsetup_CreateContext')
     177        print ('\t_swsetup_DestroyContext')
     178        print ('\t_swsetup_InvalidateState')
     179        print ('\t_tnl_CreateContext')
     180        print ('\t_tnl_DestroyContext')
     181        print ('\t_tnl_InvalidateState')
     182        print ('\t_tnl_MakeCurrent')
     183        print ('\t_tnl_run_pipeline')
    184184#enddef
    185185
    186186
     
    204204        if offset < 0:
    205205                offset = FindOffset(dispatchName)
    206206        if offset >= 0 and string.find(name, "unused") == -1:
    207                 print '\tgl%s' % (name)
     207                print ('\tgl%s' % (name))
    208208                # save this info in case we need to look up an alias later
    209209                records.append((name, dispatchName, offset))
    210210
  • Mesa-7.8.2/src/mesa/glapi/gen/remap_helper.py

    old new  
    6464
    6565
    6666        def printRealHeader(self):
    67                 print '#include "main/dispatch.h"'
    68                 print ''
     67                print ('#include "main/dispatch.h"')
     68                print ('')
    6969                return
    7070
    7171
    7272        def printBody(self, api):
    73                 print 'struct gl_function_remap {'
    74                 print '   GLint func_index;'
    75                 print '   GLint dispatch_offset; /* for sanity check */'
    76                 print '};'
    77                 print ''
     73                print ('struct gl_function_remap {')
     74                print ('   GLint func_index;')
     75                print ('   GLint dispatch_offset; /* for sanity check */')
     76                print ('};')
     77                print ('')
    7878
    7979                pool_indices = {}
    8080
    81                 print '/* this is internal to remap.c */'
    82                 print '#ifdef need_MESA_remap_table'
    83                 print ''
    84                 print 'static const char _mesa_function_pool[] ='
     81                print ('/* this is internal to remap.c */')
     82                print ('#ifdef need_MESA_remap_table')
     83                print ('')
     84                print ('static const char _mesa_function_pool[] =')
    8585
    8686                # output string pool
    8787                index = 0;
     
    9999                        else:
    100100                                comments = "dynamic"
    101101
    102                         print '   /* _mesa_function_pool[%d]: %s (%s) */' \
    103                                         % (index, f.name, comments)
     102                        print ('   /* _mesa_function_pool[%d]: %s (%s) */' \
     103                                        % (index, f.name, comments))
    104104                        for line in spec:
    105                                 print '   "%s\\0"' % line
     105                                print ('   "%s\\0"' % line)
    106106                                index += len(line) + 1
    107                 print '   ;'
    108                 print ''
     107                print ('   ;')
     108                print ('')
    109109
    110                 print '/* these functions need to be remapped */'
    111                 print 'static const struct {'
    112                 print '   GLint pool_index;'
    113                 print '   GLint remap_index;'
    114                 print '} MESA_remap_table_functions[] = {'
     110                print ('/* these functions need to be remapped */')
     111                print ('static const struct {')
     112                print ('   GLint pool_index;')
     113                print ('   GLint remap_index;')
     114                print ('} MESA_remap_table_functions[] = {')
    115115                # output all functions that need to be remapped
    116116                # iterate by offsets so that they are sorted by remap indices
    117117                for f in api.functionIterateByOffset():
    118118                        if not f.assign_offset:
    119119                                continue
    120                         print '   { %5d, %s_remap_index },' \
    121                                         % (pool_indices[f], f.name)
    122                 print '   {    -1, -1 }'
    123                 print '};'
    124                 print ''
     120                        print ('   { %5d, %s_remap_index },' \
     121                                        % (pool_indices[f], f.name))
     122                print ('   {    -1, -1 }')
     123                print ('};')
     124                print ('')
    125125
    126126                # collect functions by versions/extensions
    127127                extension_functions = {}
     
    147147                extensions.sort()
    148148
    149149                # output ABI functions that have alternative names (with ext suffix)
    150                 print '/* these functions are in the ABI, but have alternative names */'
    151                 print 'static const struct gl_function_remap MESA_alt_functions[] = {'
     150                print ('/* these functions are in the ABI, but have alternative names */')
     151                print ('static const struct gl_function_remap MESA_alt_functions[] = {')
    152152                for ext in extensions:
    153153                        funcs = []
    154154                        for f in extension_functions[ext]:
     
    157157                                        funcs.append(f)
    158158                        if not funcs:
    159159                                continue
    160                         print '   /* from %s */' % ext
     160                        print ('   /* from %s */' % ext)
    161161                        for f in funcs:
    162                                 print '   { %5d, _gloffset_%s },' \
    163                                                 % (pool_indices[f], f.name)
    164                 print '   {    -1, -1 }'
    165                 print '};'
    166                 print ''
     162                                print ('   { %5d, _gloffset_%s },' \
     163                                                % (pool_indices[f], f.name))
     164                print ('   {    -1, -1 }')
     165                print ('};')
     166                print ('')
    167167
    168                 print '#endif /* need_MESA_remap_table */'
    169                 print ''
     168                print ('#endif /* need_MESA_remap_table */')
     169                print ('')
    170170
    171171                # output remap helpers for DRI drivers
    172172
     
    182182                                        # abi, or have offset -1
    183183                                        funcs.append(f)
    184184
    185                         print '#if defined(need_%s)' % (ext)
     185                        print ('#if defined(need_%s)' % (ext))
    186186                        if remapped:
    187                                 print '/* functions defined in MESA_remap_table_functions are excluded */'
     187                                print ('/* functions defined in MESA_remap_table_functions are excluded */')
    188188
    189189                        # output extension functions that need to be mapped
    190                         print 'static const struct gl_function_remap %s_functions[] = {' % (ext)
     190                        print ('static const struct gl_function_remap %s_functions[] = {' % (ext))
    191191                        for f in funcs:
    192192                                if f.offset >= 0:
    193                                         print '   { %5d, _gloffset_%s },' \
    194                                                         % (pool_indices[f], f.name)
     193                                        print ('   { %5d, _gloffset_%s },' \
     194                                                        % (pool_indices[f], f.name))
    195195                                else:
    196                                         print '   { %5d, -1 }, /* %s */' % \
    197                                                         (pool_indices[f], f.name)
    198                         print '   {    -1, -1 }'
    199                         print '};'
     196                                        print ('   { %5d, -1 }, /* %s */' % \
     197                                                        (pool_indices[f], f.name))
     198                        print ('   {    -1, -1 }')
     199                        print ('};')
    200200
    201                         print '#endif'
    202                         print ''
     201                        print ('#endif')
     202                        print ('')
    203203
    204204                return
    205205
    206206
    207207def show_usage():
    208         print "Usage: %s [-f input_file_name]" % sys.argv[0]
     208        print ("Usage: %s [-f input_file_name]" % sys.argv[0])
    209209        sys.exit(1)
    210210
    211211if __name__ == '__main__':
  • Mesa-7.8.2/src/mesa/glapi/gen/typeexpr.py

    old new  
    287287        create_initial_types()
    288288
    289289        for t in types_to_try:
    290                 print 'Trying "%s"...' % (t)
     290                print ('Trying "%s"...' % (t))
    291291                te = type_expression( t )
    292                 print 'Got "%s" (%u, %u).' % (te.string(), te.get_stack_size(), te.get_element_size())
     292                print ('Got "%s" (%u, %u).' % (te.string(), te.get_stack_size(), te.get_element_size()))