1 {% from "macros.tmpl" import license %}
6 #include "{{namespace}}Names.h"
8 #include "wtf/StaticConstructors.h"
9 #include "wtf/StdLibExtras.h"
12 namespace {{namespace}}Names {
14 using namespace blink;
16 DEFINE_GLOBAL(AtomicString, {{namespace_prefix}}NamespaceURI)
21 void* {{suffix}}TagStorage[{{namespace}}TagsCount * ((sizeof({{namespace}}QualifiedName) + sizeof(void *) - 1) / sizeof(void *))];
22 {% for tag in tags|sort(attribute='name', case_sensitive=True) %}
23 const {{namespace}}QualifiedName& {{tag|symbol}}Tag = reinterpret_cast<{{namespace}}QualifiedName*>(&{{suffix}}TagStorage)[{{loop.index0}}];
27 {% if namespace == 'SVG' %}
28 PassOwnPtr<const {{namespace}}QualifiedName*[]> get{{namespace}}Tags()
30 OwnPtr<const {{namespace}}QualifiedName*[]> tags = adoptArrayPtr(new const {{namespace}}QualifiedName*[{{namespace}}TagsCount]);
31 for (size_t i = 0; i < {{namespace}}TagsCount; i++)
32 tags[i] = reinterpret_cast<{{namespace}}QualifiedName*>(&{{suffix}}TagStorage) + i;
33 return tags.release();
40 void* {{suffix}}AttrStorage[{{namespace}}AttrsCount * ((sizeof(QualifiedName) + sizeof(void *) - 1) / sizeof(void *))];
42 {% for attr in attrs|sort(attribute='name', case_sensitive=True) %}
43 const QualifiedName& {{attr|symbol}}Attr = reinterpret_cast<QualifiedName*>(&{{suffix}}AttrStorage)[{{loop.index0}}];
46 {% if namespace != 'HTML' %}
47 PassOwnPtr<const QualifiedName*[]> get{{namespace}}Attrs()
49 OwnPtr<const QualifiedName*[]> attrs = adoptArrayPtr(new const QualifiedName*[{{namespace}}AttrsCount]);
50 for (size_t i = 0; i < {{namespace}}AttrsCount; i++)
51 attrs[i] = reinterpret_cast<QualifiedName*>(&{{suffix}}AttrStorage) + i;
52 return attrs.release();
67 // Use placement new to initialize the globals.
68 AtomicString {{namespace_prefix}}NS("{{namespace_uri}}", AtomicString::ConstructFromLiteral);
71 new ((void*)&{{namespace_prefix}}NamespaceURI) AtomicString({{namespace_prefix}}NS);
72 {% set tagnames = tags|map(attribute='name')|list() %}
73 {% set attrnames = attrs|map(attribute='name')|list() %}
74 static const NameEntry kNames[] = {
75 {% for name, tag_list in (tags + attrs)|groupby('name')|sort(attribute=0, case_sensitive=True) %}
76 { "{{name}}", {{name|hash}}, {{name|length}}, {{ (name in tagnames)|int }}, {{ (name in attrnames)|int }} },
84 for (size_t i = 0; i < WTF_ARRAY_LENGTH(kNames); i++) {
85 StringImpl* stringImpl = StringImpl::createStatic(kNames[i].name, kNames[i].length, kNames[i].hash);
87 if (kNames[i].isTag) {
88 void* address = reinterpret_cast<{{namespace}}QualifiedName*>(&{{suffix}}TagStorage) + tag_i;
89 QualifiedName::createStatic(address, stringImpl, {{namespace_prefix}}NS);
93 if (!kNames[i].isAttr)
96 void* address = reinterpret_cast<QualifiedName*>(&{{suffix}}AttrStorage) + attr_i;
97 {% if use_namespace_for_attrs %}
98 QualifiedName::createStatic(address, stringImpl, {{namespace_prefix}}NS);
100 QualifiedName::createStatic(address, stringImpl);
105 ASSERT(tag_i == {{namespace}}TagsCount);
107 ASSERT(attr_i == {{namespace}}AttrsCount);