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:
Edward Welbourne 2024-05-06 16:55:52 +02:00
parent 72a7dddc25
commit 5641b17e2f

View File

@ -65,10 +65,12 @@ class LocaleKeySorter:
return (key[0], self.foreign(key)) + key[1:]
class ByteArrayData:
# Only for use with ASCII data, e.g. IANA IDs.
def __init__(self):
self.data, self.hash = [], {}
def append(self, s):
assert s.isascii(), s
s += '\0'
if s in self.hash:
return self.hash[s]
@ -83,7 +85,7 @@ class ByteArrayData:
def write(self, out, name):
out(f'\nstatic constexpr char {name}[] = {{\n')
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')
class StringDataToken: