# Authors:
# Ian Romanick <idr@us.ibm.com>
+from __future__ import print_function
+
from collections import OrderedDict
from decimal import Decimal
import xml.etree.ElementTree as ET
-import re, sys, string
+import re, sys
import os.path
import typeexpr
import static_data
def printHeader(self):
"""Print the header associated with all files and call the printRealHeader method."""
- print '/* DO NOT EDIT - This file generated automatically by %s script */' \
- % (self.name)
- print ''
- print '/*'
- print (' * ' + self.license.replace('\n', '\n * ')).replace(' \n', '\n')
- print ' */'
- print ''
+ print('/* DO NOT EDIT - This file generated automatically by %s script */' \
+ % (self.name))
+ print('')
+ print('/*')
+ print((' * ' + self.license.replace('\n', '\n * ')).replace(' \n', '\n'))
+ print(' */')
+ print('')
if self.header_tag:
- print '#if !defined( %s )' % (self.header_tag)
- print '# define %s' % (self.header_tag)
- print ''
+ print('#if !defined( %s )' % (self.header_tag))
+ print('# define %s' % (self.header_tag))
+ print('')
self.printRealHeader();
return
self.printRealFooter()
if self.undef_list:
- print ''
+ print('')
for u in self.undef_list:
- print "# undef %s" % (u)
+ print("# undef %s" % (u))
if self.header_tag:
- print ''
- print '#endif /* !defined( %s ) */' % (self.header_tag)
+ print('')
+ print('#endif /* !defined( %s ) */' % (self.header_tag))
def printRealHeader(self):
The name is also added to the file's undef_list.
"""
self.undef_list.append("PURE")
- print """# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
+ print("""# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
# define PURE __attribute__((pure))
# else
# define PURE
-# endif"""
+# endif""")
return
"""
self.undef_list.append("FASTCALL")
- print """# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__)
+ print("""# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__)
# define FASTCALL __attribute__((fastcall))
# else
# define FASTCALL
-# endif"""
+# endif""")
return
"""
self.undef_list.append(S)
- print """# if defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__)
+ print("""# if defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__)
# define %s __attribute__((visibility("%s")))
# else
# define %s
-# endif""" % (S, s, S)
+# endif""" % (S, s, S))
return
"""
self.undef_list.append("NOINLINE")
- print """# if defined(__GNUC__)
+ print("""# if defined(__GNUC__)
# define NOINLINE __attribute__((noinline))
# else
# define NOINLINE
-# endif"""
+# endif""")
return
try:
core_version = float(name)
- except Exception,e:
+ except Exception:
core_version = 0.0
if core_version > 0.0:
if len(list) == 0: list = ["void"]
- return string.join(list, ", ")
+ return ", ".join(list)
class gl_item(object):
else:
try:
c = int(temp)
- except Exception,e:
+ except Exception:
raise RuntimeError('Invalid count value "%s" for enum "%s" in function "%s" when an integer was expected.' % (temp, self.name, n))
self.default_count = c
count = int(c)
self.count = count
self.counter = None
- except Exception,e:
+ except Exception:
count = 1
self.count = 0
self.counter = c
list.append( str(s) )
if len(list) > 1 and use_parens :
- return "safe_mul(%s)" % (string.join(list, ", "))
+ return "safe_mul(%s)" % ", ".join(list)
else:
- return string.join(list, " * ")
+ return " * ".join(list)
elif self.is_image():
return "compsize"
temp_name = child.get( "name" )
self.category_dict[ temp_name ] = [cat_name, cat_number]
- if self.functions_by_name.has_key( func_name ):
+ if func_name in self.functions_by_name:
func = self.functions_by_name[ func_name ]
func.process_element( child )
else:
if (cat == None) or (cat == cat_name):
[func_cat_type, key] = classify_category(cat_name, cat_number)
- if not lists[func_cat_type].has_key(key):
+ if key not in lists[func_cat_type]:
lists[func_cat_type][key] = {}
lists[func_cat_type][key][func.name] = func
def get_category_for_name( self, name ):
- if self.category_dict.has_key(name):
+ if name in self.category_dict:
return self.category_dict[name]
else:
return ["<unknown category>", None]
if type_name in self.types_by_name:
return self.types_by_name[ type_name ].type_expr
else:
- print "Unable to find base type matching \"%s\"." % (type_name)
+ print("Unable to find base type matching \"%s\"." % (type_name))
return None