Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / build / scripts / templates / MakeNames.cpp.tmpl
1 {% from "macros.tmpl" import license %}
2 {{ license() }}
3
4 #include "config.h"
5
6 #include "{{namespace}}{{suffix}}Names.h"
7
8 #include "wtf/StdLibExtras.h"
9
10 namespace blink {
11 namespace {{namespace}}Names {
12
13 using namespace WTF;
14
15 const int k{{suffix}}NameCount = {{entries|length}};
16
17 void* {{suffix}}NamesStorage[k{{suffix}}NameCount * ((sizeof(AtomicString) + sizeof(void *) - 1) / sizeof(void *))];
18
19 {% for entry in entries|sort(attribute='name', case_sensitive=True) %}
20 {% filter enable_conditional(entry.Conditional) %}
21 const AtomicString& {{entry|symbol}} = reinterpret_cast<AtomicString*>(&{{suffix}}NamesStorage)[{{loop.index0}}];
22 {% endfilter %}
23 {% endfor %}
24
25 void init{{suffix}}()
26 {
27     struct NameEntry {
28         const char* name;
29         unsigned hash;
30         unsigned char length;
31     };
32
33     static const NameEntry kNames[] = {
34     {% for entry in entries|sort(attribute='name', case_sensitive=True) %}
35         { "{{entry|cpp_name}}", {{entry|cpp_name|hash}}, {{entry|cpp_name|length}} },
36     {% endfor %}
37     };
38
39     for (size_t i = 0; i < WTF_ARRAY_LENGTH(kNames); i++) {
40         StringImpl* stringImpl = StringImpl::createStatic(kNames[i].name, kNames[i].length, kNames[i].hash);
41         void* address = reinterpret_cast<AtomicString*>(&{{suffix}}NamesStorage) + i;
42         new (address) AtomicString(stringImpl);
43     }
44 }
45
46 } // {{namespace}}Names
47 } // namespace blink