{% 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 <iterator>
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/string_hasher.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}}() {
{% if entries %}
static bool is_loaded = false;
if (is_loaded) return;
is_loaded = true;
struct NameEntry {
const char* name;
unsigned char length;
};
static const NameEntry kNames[] = {
{% for entry in entries|sort(attribute='name', case_sensitive=True) %}
{ "{{entry|cpp_name}}", {{entry|cpp_name|length}} },
{% endfor %}
};
for (size_t i = 0; i < std::size(kNames); ++i) {
StringImpl* impl = StringImpl::CreateStatic(kNames[i].name, kNames[i].length);
void* address = reinterpret_cast<AtomicString*>(&{{suffix|lower}}names_storage) + i;
new (address) AtomicString(impl);
}
{% endif %}
}
} // namespace {{namespace}}
} // namespace blink