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