2023-09-28 02:21:23 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2024-03-21 09:30:47 -04:00
|
|
|
# SPDX-FileCopyrightText: 2024 Redict Contributors
|
|
|
|
# SPDX-FileCopyrightText: 2024 Salvatore Sanfilippo <antirez at gmail dot com>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
2024-03-21 15:11:44 -04:00
|
|
|
# SPDX-License-Identifier: LGPL-3.0-only
|
2024-03-21 09:30:47 -04:00
|
|
|
|
2023-09-28 02:21:23 -04:00
|
|
|
# Outputs the generated part of src/fmtargs.h
|
|
|
|
MAX_ARGS = 120
|
|
|
|
|
|
|
|
import os
|
|
|
|
print("/* Everything below this line is automatically generated by")
|
|
|
|
print(" * %s. Do not manually edit. */\n" % os.path.basename(__file__))
|
|
|
|
|
|
|
|
print('#define ARG_N(' + ', '.join(['_' + str(i) for i in range(1, MAX_ARGS + 1, 1)]) + ', N, ...) N')
|
|
|
|
|
|
|
|
print('\n#define RSEQ_N() ' + ', '.join([str(i) for i in range(MAX_ARGS, -1, -1)]))
|
|
|
|
|
|
|
|
print('\n#define COMPACT_FMT_2(fmt, value) fmt')
|
|
|
|
for i in range(4, MAX_ARGS + 1, 2):
|
|
|
|
print('#define COMPACT_FMT_{}(fmt, value, ...) fmt COMPACT_FMT_{}(__VA_ARGS__)'.format(i, i - 2))
|
|
|
|
|
|
|
|
print('\n#define COMPACT_VALUES_2(fmt, value) value')
|
|
|
|
for i in range(4, MAX_ARGS + 1, 2):
|
|
|
|
print('#define COMPACT_VALUES_{}(fmt, value, ...) value, COMPACT_VALUES_{}(__VA_ARGS__)'.format(i, i - 2))
|
|
|
|
|
|
|
|
print("\n#endif")
|