Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / build / scripts / templates / MakeNames.cpp.tmpl
blobc9098ca9fe489eb232575ff8ae690bfe9b296443
1 {% from "macros.tmpl" import license %}
2 {{ license() }}
4 #include "config.h"
6 #include "{{namespace}}{{suffix}}Names.h"
8 #include "wtf/StdLibExtras.h"
10 // Generated from:
11 {% for entry in in_files|sort %}
12 // - {{entry}}
13 {% endfor %}
15 namespace blink {
16 namespace {{namespace}}Names {
18 using namespace WTF;
20 const int k{{suffix}}NameCount = {{entries|length}};
22 void* {{suffix}}NamesStorage[k{{suffix}}NameCount * ((sizeof(AtomicString) + sizeof(void *) - 1) / sizeof(void *))];
24 {% for entry in entries|sort(attribute='name', case_sensitive=True) %}
25 {% filter enable_conditional(entry.Conditional) %}
26 const AtomicString& {{entry|symbol}} = reinterpret_cast<AtomicString*>(&{{suffix}}NamesStorage)[{{loop.index0}}];
27 {% endfilter %}
28 {% endfor %}
30 void init{{suffix}}()
32     struct NameEntry {
33         const char* name;
34         unsigned hash;
35         unsigned char length;
36     };
38     static const NameEntry kNames[] = {
39     {% for entry in entries|sort(attribute='name', case_sensitive=True) %}
40         { "{{entry|cpp_name}}", {{entry|cpp_name|hash}}, {{entry|cpp_name|length}} },
41     {% endfor %}
42     };
44     for (size_t i = 0; i < WTF_ARRAY_LENGTH(kNames); i++) {
45         StringImpl* stringImpl = StringImpl::createStatic(kNames[i].name, kNames[i].length, kNames[i].hash);
46         void* address = reinterpret_cast<AtomicString*>(&{{suffix}}NamesStorage) + i;
47         new (address) AtomicString(stringImpl);
48     }
51 } // {{namespace}}Names
52 } // namespace blink