Revert "makeqstrdata.py: Add support for conditionally defined qstrs."
This reverts commit acb133d1b1
.
Conditionals will be suported using C preprocessor.
This commit is contained in:
parent
1184094839
commit
6ea0e928d8
|
@ -29,7 +29,6 @@ def do_work(infiles):
|
||||||
for infile in infiles:
|
for infile in infiles:
|
||||||
with open(infile, 'rt') as f:
|
with open(infile, 'rt') as f:
|
||||||
line_number = 0
|
line_number = 0
|
||||||
conditional = None
|
|
||||||
for line in f:
|
for line in f:
|
||||||
line_number += 1
|
line_number += 1
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
|
@ -38,18 +37,6 @@ def do_work(infiles):
|
||||||
if len(line) == 0 or line.startswith('//'):
|
if len(line) == 0 or line.startswith('//'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if line[0] == '#':
|
|
||||||
if conditional == "<endif>":
|
|
||||||
assert line == "#endif"
|
|
||||||
conditional = None
|
|
||||||
else:
|
|
||||||
assert conditional is None
|
|
||||||
conditional = line
|
|
||||||
continue
|
|
||||||
|
|
||||||
if conditional == "<endif>":
|
|
||||||
assert False, "#endif expected before '%s'" % line
|
|
||||||
|
|
||||||
# verify line is of the correct form
|
# verify line is of the correct form
|
||||||
match = re.match(r'Q\((.+)\)$', line)
|
match = re.match(r'Q\((.+)\)$', line)
|
||||||
if not match:
|
if not match:
|
||||||
|
@ -65,21 +52,15 @@ def do_work(infiles):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# add the qstr to the list, with order number to retain original order in file
|
# add the qstr to the list, with order number to retain original order in file
|
||||||
qstrs[ident] = (len(qstrs), ident, qstr, conditional)
|
qstrs[ident] = (len(qstrs), ident, qstr)
|
||||||
if conditional is not None:
|
|
||||||
conditional = "<endif>"
|
|
||||||
|
|
||||||
# process the qstrs, printing out the generated C header file
|
# process the qstrs, printing out the generated C header file
|
||||||
print('// This file was automatically generated by makeqstrdata.py')
|
print('// This file was automatically generated by makeqstrdata.py')
|
||||||
print('')
|
print('')
|
||||||
for order, ident, qstr, conditional in sorted(qstrs.values(), key=lambda x: x[0]):
|
for order, ident, qstr in sorted(qstrs.values(), key=lambda x: x[0]):
|
||||||
qhash = compute_hash(qstr)
|
qhash = compute_hash(qstr)
|
||||||
qlen = len(qstr)
|
qlen = len(qstr)
|
||||||
if conditional:
|
|
||||||
print(conditional)
|
|
||||||
print('Q({}, (const byte*)"\\x{:02x}\\x{:02x}\\x{:02x}\\x{:02x}" "{}")'.format(ident, qhash & 0xff, (qhash >> 8) & 0xff, qlen & 0xff, (qlen >> 8) & 0xff, qstr))
|
print('Q({}, (const byte*)"\\x{:02x}\\x{:02x}\\x{:02x}\\x{:02x}" "{}")'.format(ident, qhash & 0xff, (qhash >> 8) & 0xff, qlen & 0xff, (qlen >> 8) & 0xff, qstr))
|
||||||
if conditional:
|
|
||||||
print('#endif')
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue