mirror of
https://github.com/RPCSX/xed.git
synced 2026-01-31 01:05:17 +01:00
ctables: string/bytes confusion. genutil:funcs for idioms I keep replacing
Change-Id: Ic1bce8efd82be80b9911b62d0b932eba0a08ed08 (cherry picked from commit adb6a4f9032feef846f6e81660424963c18cf7da)
This commit is contained in:
@@ -67,7 +67,7 @@ class constant_table_t(object):
|
||||
def dump(self):
|
||||
print("%s(%s)::" % (self.name, self.operand))
|
||||
for (v,p) in self.value_string_pairs:
|
||||
if isinstance(p, bytes):
|
||||
if genutil.is_stringish(p):
|
||||
print("%s '%s'" % (hex(v),p))
|
||||
else:
|
||||
print("%s error" %(hex(v)))
|
||||
@@ -78,7 +78,7 @@ class constant_table_t(object):
|
||||
lines.append('static const char* %s[] = {' % (self.string_table_name))
|
||||
|
||||
for (v,p) in self.value_string_pairs:
|
||||
if isinstance(p, bytes):
|
||||
if genutil.is_stringish(p):
|
||||
lines.append( '/*%s*/ "%s",' % (hex(v),p))
|
||||
else:
|
||||
lines.append( '/*%s*/ 0, /* error */' % (hex(v)))
|
||||
|
||||
@@ -425,3 +425,11 @@ def uniqueify(values):
|
||||
k.sort()
|
||||
return k
|
||||
|
||||
|
||||
def is_stringish(x):
|
||||
return isinstance(x,bytes) or isinstance(x,str)
|
||||
def make_list_of_str(lst):
|
||||
return [ str(x) for x in lst]
|
||||
def open_readlines(fn):
|
||||
return open(f,'r').readlines()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user