From 14718f10dcda487178690de9a51cc5acdf21e468 Mon Sep 17 00:00:00 2001 From: marha Date: Wed, 25 Sep 2013 09:36:22 +0200 Subject: fontconfig mesa git update 25 Sep 2013 fontconfig commit 102864d0dba46c99b22c912454c1f58731287405 mesa commit 59157d1c96f33ca56d9aba6cff75145d732dbbab --- mesalib/src/mapi/glapi/gen/gl_enums.py | 96 +++++++++------------------------- 1 file changed, 25 insertions(+), 71 deletions(-) (limited to 'mesalib/src/mapi/glapi/gen') diff --git a/mesalib/src/mapi/glapi/gen/gl_enums.py b/mesalib/src/mapi/glapi/gen/gl_enums.py index 806d38445..0214932b6 100644 --- a/mesalib/src/mapi/glapi/gen/gl_enums.py +++ b/mesalib/src/mapi/glapi/gen/gl_enums.py @@ -47,8 +47,8 @@ class PrintGlEnums(gl_XML.gl_print_base): print '#include "main/imports.h"' print '#include "main/mtypes.h"' print '' - print 'typedef struct {' - print ' size_t offset;' + print 'typedef struct PACKED {' + print ' uint16_t offset;' print ' int n;' print '} enum_elt;' print '' @@ -59,33 +59,18 @@ class PrintGlEnums(gl_XML.gl_print_base): typedef int (*cfunc)(const void *, const void *); /** - * Compare a key name to an element in the \c all_enums array. + * Compare a key enum value to an element in the \c enum_string_table_offsets array. * * \c bsearch always passes the key as the first parameter and the pointer * to the array element as the second parameter. We can elimiate some * extra work by taking advantage of that fact. * * \param a Pointer to the desired enum name. - * \param b Pointer to an element of the \c all_enums array. + * \param b Pointer into the \c enum_string_table_offsets array. */ -static int compar_name( const char *a, const enum_elt *b ) +static int compar_nr( const int *a, enum_elt *b ) { - return strcmp( a, & enum_string_table[ b->offset ] ); -} - -/** - * Compare a key enum value to an element in the \c all_enums array. - * - * \c bsearch always passes the key as the first parameter and the pointer - * to the array element as the second parameter. We can elimiate some - * extra work by taking advantage of that fact. - * - * \param a Pointer to the desired enum name. - * \param b Pointer to an index into the \c all_enums array. - */ -static int compar_nr( const int *a, const unsigned *b ) -{ - return a[0] - all_enums[*b].n; + return a[0] - b->n; } @@ -93,15 +78,17 @@ static char token_tmp[20]; const char *_mesa_lookup_enum_by_nr( int nr ) { - unsigned * i; + enum_elt *elt; + + STATIC_ASSERT(sizeof(enum_string_table) < (1 << 16)); - i = (unsigned *) _mesa_bsearch(& nr, reduced_enums, - Elements(reduced_enums), - sizeof(reduced_enums[0]), - (cfunc) compar_nr); + elt = _mesa_bsearch(& nr, enum_string_table_offsets, + Elements(enum_string_table_offsets), + sizeof(enum_string_table_offsets[0]), + (cfunc) compar_nr); - if ( i != NULL ) { - return & enum_string_table[ all_enums[ *i ].offset ]; + if (elt != NULL) { + return &enum_string_table[elt->offset]; } else { /* this is not re-entrant safe, no big deal here */ @@ -147,20 +134,6 @@ _mesa_lookup_prim_by_nr(GLuint nr) } -int _mesa_lookup_enum_by_name( const char *symbol ) -{ - enum_elt * f = NULL; - - if ( symbol != NULL ) { - f = (enum_elt *) _mesa_bsearch(symbol, all_enums, - Elements(all_enums), - sizeof( enum_elt ), - (cfunc) compar_name); - } - - return (f != NULL) ? f->n : -1; -} - """ return @@ -170,56 +143,37 @@ int _mesa_lookup_enum_by_name( const char *symbol ) for api in api_list: self.process_enums( api ) - keys = self.enum_table.keys() - keys.sort() - - name_table = [] - enum_table = {} + enum_table = [] - for enum in keys: + for enum in sorted(self.enum_table.keys()): low_pri = 9 + best_name = '' for [name, pri] in self.enum_table[ enum ]: - name_table.append( [name, enum] ) - if pri < low_pri: low_pri = pri - enum_table[enum] = name - + best_name = name - name_table.sort() + enum_table.append((enum, best_name)) string_offsets = {} i = 0; print 'LONGSTRING static const char enum_string_table[] = ' - for [name, enum] in name_table: + for enum, name in enum_table: print ' "%s\\0"' % (name) - string_offsets[ name ] = i + string_offsets[ enum ] = i i += len(name) + 1 print ' ;' print '' - print 'static const enum_elt all_enums[%u] =' % (len(name_table)) + print 'static const enum_elt enum_string_table_offsets[%u] =' % (len(enum_table)) print '{' - for [name, enum] in name_table: - print ' { %5u, 0x%08X }, /* %s */' % (string_offsets[name], enum, name) + for enum, name in enum_table: + print ' { %5u, 0x%08X }, /* %s */' % (string_offsets[enum], enum, name) print '};' print '' - print 'static const unsigned reduced_enums[%u] =' % (len(keys)) - print '{' - for enum in keys: - name = enum_table[ enum ] - if [name, enum] not in name_table: - print ' /* Error! %s, 0x%04x */ 0,' % (name, enum) - else: - i = name_table.index( [name, enum] ) - - print ' %4u, /* %s */' % (i, name) - print '};' - - self.print_code() return -- cgit v1.2.3