qlocalexml2cpp.py: Make clear that ByteArrayData is always ASCII
The container would be unsuitable otherwise. Change-Id: I0b0aa22625fbd638bf8409c5ee257f62332d8e05 Reviewed-by: Mate Barany <mate.barany@qt.io>
This commit is contained in:
parent
72a7dddc25
commit
5641b17e2f
@ -65,10 +65,12 @@ class LocaleKeySorter:
|
|||||||
return (key[0], self.foreign(key)) + key[1:]
|
return (key[0], self.foreign(key)) + key[1:]
|
||||||
|
|
||||||
class ByteArrayData:
|
class ByteArrayData:
|
||||||
|
# Only for use with ASCII data, e.g. IANA IDs.
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.data, self.hash = [], {}
|
self.data, self.hash = [], {}
|
||||||
|
|
||||||
def append(self, s):
|
def append(self, s):
|
||||||
|
assert s.isascii(), s
|
||||||
s += '\0'
|
s += '\0'
|
||||||
if s in self.hash:
|
if s in self.hash:
|
||||||
return self.hash[s]
|
return self.hash[s]
|
||||||
@ -83,7 +85,7 @@ class ByteArrayData:
|
|||||||
def write(self, out, name):
|
def write(self, out, name):
|
||||||
out(f'\nstatic constexpr char {name}[] = {{\n')
|
out(f'\nstatic constexpr char {name}[] = {{\n')
|
||||||
out(wrap_list(self.data, 16)) # 16 == 100 // len('0xhh, ')
|
out(wrap_list(self.data, 16)) # 16 == 100 // len('0xhh, ')
|
||||||
# Will over-spill 100-col if some 4-digit hex show up, but none do (yet).
|
# All data is ASCII, so only two-digit hex is ever needed.
|
||||||
out('\n};\n')
|
out('\n};\n')
|
||||||
|
|
||||||
class StringDataToken:
|
class StringDataToken:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user