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