(file_name, out, js_map, just_declare, utf8)
| 76 | |
| 77 | |
| 78 | def generate_header(file_name, out, js_map, just_declare, utf8): |
| 79 | define_guard = "WEBDRIVER_{}".format(os.path.basename(file_name.upper()).replace(".", "_")) |
| 80 | include_stddef = "" if utf8 else "\n#include <stddef.h> // For wchar_t." |
| 81 | out.write( |
| 82 | f"""{_copyright} |
| 83 | |
| 84 | /* AUTO GENERATED - DO NOT EDIT BY HAND */ |
| 85 | #ifndef {define_guard} |
| 86 | #define {define_guard} |
| 87 | {include_stddef} |
| 88 | #include <string> // For std::(w)string. |
| 89 | |
| 90 | namespace webdriver {{ |
| 91 | namespace atoms {{ |
| 92 | |
| 93 | """ |
| 94 | ) |
| 95 | |
| 96 | string_type = "std::string" if utf8 else "std::wstring" |
| 97 | char_type = "char" if utf8 else "wchar_t" |
| 98 | |
| 99 | for name, file in js_map.items(): |
| 100 | if just_declare: |
| 101 | out.write(f"extern const {char_type}* const {name.upper()}[];\n") |
| 102 | else: |
| 103 | contents = open(file).read() |
| 104 | write_atom_literal(out, name, contents, "hh", utf8) |
| 105 | |
| 106 | out.write( |
| 107 | f""" |
| 108 | static inline {string_type} asString(const {char_type}* const atom[]) {{ |
| 109 | {string_type} source; |
| 110 | for (int i = 0; atom[i] != NULL; i++) {{ |
| 111 | source += atom[i]; |
| 112 | }} |
| 113 | return source; |
| 114 | }} |
| 115 | |
| 116 | }} // namespace atoms |
| 117 | }} // namespace webdriver |
| 118 | |
| 119 | #endif // {define_guard} |
| 120 | """ |
| 121 | ) |
| 122 | |
| 123 | |
| 124 | def generate_cc_source(out, js_map, utf8): |
no test coverage detected