OLD | NEW |
1 {% from "macros.tmpl" import license %} | 1 {% from "macros.tmpl" import license %} |
2 {{ license() }} | 2 {{ license() }} |
3 | 3 |
4 #include "{{namespace}}Names.h" | 4 #include "{{namespace}}Names.h" |
5 | 5 |
6 #include "wtf/PtrUtil.h" | |
7 #include "wtf/StaticConstructors.h" | 6 #include "wtf/StaticConstructors.h" |
8 #include "wtf/StdLibExtras.h" | 7 #include "wtf/StdLibExtras.h" |
9 #include <memory> | |
10 | 8 |
11 namespace blink { | 9 namespace blink { |
12 namespace {{namespace}}Names { | 10 namespace {{namespace}}Names { |
13 | 11 |
14 using namespace blink; | 12 using namespace blink; |
15 | 13 |
16 DEFINE_GLOBAL(AtomicString, {{namespace_prefix}}NamespaceURI) | 14 DEFINE_GLOBAL(AtomicString, {{namespace_prefix}}NamespaceURI) |
17 | 15 |
18 {% if tags %} | 16 {% if tags %} |
19 // Tags | 17 // Tags |
20 | 18 |
21 void* {{suffix}}TagStorage[{{namespace}}TagsCount * ((sizeof({{namespace}}Qualif
iedName) + sizeof(void *) - 1) / sizeof(void *))]; | 19 void* {{suffix}}TagStorage[{{namespace}}TagsCount * ((sizeof({{namespace}}Qualif
iedName) + sizeof(void *) - 1) / sizeof(void *))]; |
22 {% for tag in tags|sort(attribute='name', case_sensitive=True) %} | 20 {% for tag in tags|sort(attribute='name', case_sensitive=True) %} |
23 const {{namespace}}QualifiedName& {{tag|symbol}}Tag = reinterpret_cast<{{namespa
ce}}QualifiedName*>(&{{suffix}}TagStorage)[{{loop.index0}}]; | 21 const {{namespace}}QualifiedName& {{tag|symbol}}Tag = reinterpret_cast<{{namespa
ce}}QualifiedName*>(&{{suffix}}TagStorage)[{{loop.index0}}]; |
24 {% endfor %} | 22 {% endfor %} |
25 | 23 |
26 | 24 |
27 std::unique_ptr<const {{namespace}}QualifiedName*[]> get{{namespace}}Tags() | 25 PassOwnPtr<const {{namespace}}QualifiedName*[]> get{{namespace}}Tags() |
28 { | 26 { |
29 std::unique_ptr<const {{namespace}}QualifiedName*[]> tags = wrapArrayUnique(
new const {{namespace}}QualifiedName*[{{namespace}}TagsCount]); | 27 OwnPtr<const {{namespace}}QualifiedName*[]> tags = adoptArrayPtr(new const {
{namespace}}QualifiedName*[{{namespace}}TagsCount]); |
30 for (size_t i = 0; i < {{namespace}}TagsCount; i++) | 28 for (size_t i = 0; i < {{namespace}}TagsCount; i++) |
31 tags[i] = reinterpret_cast<{{namespace}}QualifiedName*>(&{{suffix}}TagSt
orage) + i; | 29 tags[i] = reinterpret_cast<{{namespace}}QualifiedName*>(&{{suffix}}TagSt
orage) + i; |
32 return tags; | 30 return tags; |
33 } | 31 } |
34 | 32 |
35 {% endif %} | 33 {% endif %} |
36 // Attributes | 34 // Attributes |
37 | 35 |
38 void* {{suffix}}AttrStorage[{{namespace}}AttrsCount * ((sizeof(QualifiedName) +
sizeof(void *) - 1) / sizeof(void *))]; | 36 void* {{suffix}}AttrStorage[{{namespace}}AttrsCount * ((sizeof(QualifiedName) +
sizeof(void *) - 1) / sizeof(void *))]; |
39 | 37 |
40 {% for attr in attrs|sort(attribute='name', case_sensitive=True) %} | 38 {% for attr in attrs|sort(attribute='name', case_sensitive=True) %} |
41 const QualifiedName& {{attr|symbol}}Attr = reinterpret_cast<QualifiedName*>(&{{s
uffix}}AttrStorage)[{{loop.index0}}]; | 39 const QualifiedName& {{attr|symbol}}Attr = reinterpret_cast<QualifiedName*>(&{{s
uffix}}AttrStorage)[{{loop.index0}}]; |
42 {% endfor %} | 40 {% endfor %} |
43 | 41 |
44 {% if namespace != 'HTML' %} | 42 {% if namespace != 'HTML' %} |
45 std::unique_ptr<const QualifiedName*[]> get{{namespace}}Attrs() | 43 PassOwnPtr<const QualifiedName*[]> get{{namespace}}Attrs() |
46 { | 44 { |
47 std::unique_ptr<const QualifiedName*[]> attrs = wrapArrayUnique(new const Qu
alifiedName*[{{namespace}}AttrsCount]); | 45 OwnPtr<const QualifiedName*[]> attrs = adoptArrayPtr(new const QualifiedName
*[{{namespace}}AttrsCount]); |
48 for (size_t i = 0; i < {{namespace}}AttrsCount; i++) | 46 for (size_t i = 0; i < {{namespace}}AttrsCount; i++) |
49 attrs[i] = reinterpret_cast<QualifiedName*>(&{{suffix}}AttrStorage) + i; | 47 attrs[i] = reinterpret_cast<QualifiedName*>(&{{suffix}}AttrStorage) + i; |
50 return attrs; | 48 return attrs; |
51 } | 49 } |
52 {% endif %} | 50 {% endif %} |
53 | 51 |
54 | 52 |
55 void init() | 53 void init() |
56 { | 54 { |
57 struct NameEntry { | 55 struct NameEntry { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 attr_i++; | 98 attr_i++; |
101 } | 99 } |
102 {% if tags %} | 100 {% if tags %} |
103 ASSERT(tag_i == {{namespace}}TagsCount); | 101 ASSERT(tag_i == {{namespace}}TagsCount); |
104 {% endif %} | 102 {% endif %} |
105 ASSERT(attr_i == {{namespace}}AttrsCount); | 103 ASSERT(attr_i == {{namespace}}AttrsCount); |
106 } | 104 } |
107 | 105 |
108 } // {{namespace}} | 106 } // {{namespace}} |
109 } // namespace blink | 107 } // namespace blink |
OLD | NEW |