diff options
author | Adriaan de Groot <groot@kde.org> | 2019-05-10 12:41:35 +0200 |
---|---|---|
committer | Adriaan de Groot <groot@kde.org> | 2019-05-10 13:14:51 +0200 |
commit | 07a9052fcadd29e6e26c8d5c965598f1c71c8646 (patch) | |
tree | 2aa59835f4d751c9b9beebf10fb90776f45459ed | |
parent | bf5ce44bd1b5ecab1d7b9bb77431a53ff2475d5b (diff) |
[libcalamares] Also output size of locale-tables
-rw-r--r-- | src/libcalamares/locale/cldr-extractor.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/libcalamares/locale/cldr-extractor.py b/src/libcalamares/locale/cldr-extractor.py index 06fb69e3b..4e279337b 100644 --- a/src/libcalamares/locale/cldr-extractor.py +++ b/src/libcalamares/locale/cldr-extractor.py @@ -251,7 +251,6 @@ def make_identifier(classname): else: identifier.append(c) - identifier.append("_table") return "".join(identifier) @@ -260,17 +259,27 @@ def export_class(cls, data): Given a @p cls and a list of @p data objects from that class, print (to stdout) a C++ file for that data. """ + identifier = make_identifier(cls.cpp_classname) + with open("{!s}_p.cpp".format(cls.cpp_classname), "wt", encoding="UTF-8") as f: f.write(cpp_header_comment) f.write(cls.cpp_declaration) - f.write("\nstatic const {!s} {!s}[] = {!s}\n".format( + f.write("\nstatic constexpr int const {!s}_size = {!s};\n".format( + identifier, + len(data))) + f.write("\nstatic const {!s} {!s}_table[] = {!s}\n".format( cls.cpp_classname, - make_identifier(cls.cpp_classname), + identifier, "{")) for d in data: f.write(str(d)) f.write("\n") f.write("};\n\n"); + f.write("static_assert( (sizeof({!s}_table) / sizeof({!s})) == {!s}_size, \"Table size mismatch for {!s}\" );\n\n".format( + identifier, + cls.cpp_classname, + identifier, + cls.cpp_classname)) f.write(cpp_footer_comment) |