| 939 | # Emit a block of constants. |
| 940 | # |
| 941 | def emit_constants(out, consts): |
| 942 | lines = [] |
| 943 | |
| 944 | # Fix up overzealous parses. This could be done inside the |
| 945 | # parsers but as there are several, it's easiest to do it here. |
| 946 | ws = re.compile(r'\s+') |
| 947 | for const in consts: |
| 948 | name = ws.sub('', const['name']) |
| 949 | value = ws.sub('', str(const['value'])) # Can be a number. |
| 950 | lines.append('V8_EXPORT int v8dbg_%s = %s;' % (name, value)) |
| 951 | |
| 952 | # Generate without duplicates and with preserved order. |
| 953 | out.write('\n'.join(dict.fromkeys(lines))) |
| 954 | out.write('\n'); |
| 955 | |
| 956 | # |
| 957 | # Emit the whole output file. |