1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
{% from "macros.tmpl" import license -%}
{{ license() }}
#include "config.h"
#ifdef SKIP_STATIC_CONSTRUCTORS_ON_GCC
#define {{namespace|to_macro_style}}_NAMES_HIDE_GLOBALS 1
#else
#define QNAME_DEFAULT_CONSTRUCTOR 1
#endif
#include "{{namespace}}Names.h"
#include "wtf/StaticConstructors.h"
namespace WebCore {
namespace {{namespace}}Names {
using namespace WebCore;
DEFINE_GLOBAL(AtomicString, {{namespace_prefix}}NamespaceURI)
{%- if tags %}
// Tags
{%- for tag in tags|sort %}
DEFINE_GLOBAL(QualifiedName, {{tag|symbol}}Tag)
{%- endfor %}
const WebCore::QualifiedName* const* get{{namespace}}Tags()
{
static const WebCore::QualifiedName* const {{namespace}}Tags[] = {
{%- for tag in tags|sort %}
(WebCore::QualifiedName*)&{{tag|symbol}}Tag,
{%- endfor %}
};
return {{namespace}}Tags;
}
{%- endif %}
// Attributes
{%- for attr in attrs|sort %}
DEFINE_GLOBAL(QualifiedName, {{attr|symbol}}Attr)
{%- endfor %}
const WebCore::QualifiedName* const* get{{namespace}}Attrs()
{
static const WebCore::QualifiedName* const {{namespace}}Attrs[] = {
{%- for attr in attrs|sort %}
(WebCore::QualifiedName*)&{{attr|symbol}}Attr,
{%- endfor %}
};
return {{namespace}}Attrs;
}
void init()
{
// Use placement new to initialize the globals.
AtomicString {{namespace_prefix}}NS("{{namespace_uri}}", AtomicString::ConstructFromLiteral);
// Namespace
new ((void*)&{{namespace_prefix}}NamespaceURI) AtomicString({{namespace_prefix}}NS);
{%- for name, tag_list in (tags + attrs)|groupby('name')|sort %}
StringImpl* {{tag_list[0]|symbol}}Impl = StringImpl::createStatic("{{name}}", {{name|length}}, {{name|hash}});
{%- endfor %}
// Tags
{%- for tag in tags|sort %}
createQualifiedName((void*)&{{tag|symbol}}Tag, {{tag|symbol}}Impl, {{namespace_prefix}}NS);
{%- endfor %}
// Attrs
{%- for attr in attrs|sort %}
{%- if use_namespace_for_attrs %}
createQualifiedName((void*)&{{attr|symbol}}Attr, {{attr|symbol}}Impl, {{namespace_prefix}}NS);
{%- else %}
createQualifiedName((void*)&{{attr|symbol}}Attr, {{attr|symbol}}Impl);
{%- endif %}
{%- endfor %}
}
} // {{namespace}}
} // WebCore
|