| {% from "templates/macros.tmpl" import license, source_files_for_generated_file %} |
| {{ license() }} |
| |
| {{source_files_for_generated_file(template_file, input_files)}} |
| |
| #include "{{this_include_path}}" |
| |
| #include "base/stl_util.h" // for base::size() |
| #include "third_party/blink/renderer/platform/wtf/std_lib_extras.h" |
| |
| namespace blink { |
| namespace {{namespace}} { |
| |
| void* {{suffix|lower}}names_storage[k{{suffix}}NamesCount * ((sizeof(AtomicString) + sizeof(void *) - 1) / sizeof(void *))]; |
| |
| {% for entry in entries|sort(attribute='name', case_sensitive=True) %} |
| const AtomicString& {{entry|symbol}} = reinterpret_cast<AtomicString*>(&{{suffix|lower}}names_storage)[{{loop.index0}}]; |
| {% endfor %} |
| |
| void Init{{suffix}}() { |
| static bool is_loaded = false; |
| if (is_loaded) return; |
| is_loaded = true; |
| |
| struct NameEntry { |
| const char* name; |
| unsigned hash; |
| unsigned char length; |
| }; |
| |
| static const NameEntry kNames[] = { |
| {% for entry in entries|sort(attribute='name', case_sensitive=True) %} |
| { "{{entry|cpp_name}}", {{entry|cpp_name|hash}}, {{entry|cpp_name|length}} }, |
| {% endfor %} |
| }; |
| |
| for (size_t i = 0; i < base::size(kNames); ++i) { |
| StringImpl* impl = StringImpl::CreateStatic(kNames[i].name, kNames[i].length, kNames[i].hash); |
| void* address = reinterpret_cast<AtomicString*>(&{{suffix|lower}}names_storage) + i; |
| new (address) AtomicString(impl); |
| } |
| } |
| |
| } // namespace {{namespace}} |
| } // namespace blink |