Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(932)

Side by Side Diff: Source/build/scripts/templates/MakeQualifiedNames.cpp.tmpl

Issue 236673002: Simplify whitespace handling in build/ Jinja templates (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: One more FIXME Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #ifdef SKIP_STATIC_CONSTRUCTORS_ON_GCC 6 #ifdef SKIP_STATIC_CONSTRUCTORS_ON_GCC
7 #define {{namespace|to_macro_style}}_NAMES_HIDE_GLOBALS 1 7 #define {{namespace|to_macro_style}}_NAMES_HIDE_GLOBALS 1
8 #else 8 #else
9 #define QNAME_DEFAULT_CONSTRUCTOR 1 9 #define QNAME_DEFAULT_CONSTRUCTOR 1
10 #endif 10 #endif
11 11
12 #include "{{namespace}}Names.h" 12 #include "{{namespace}}Names.h"
13 13
14 #include "wtf/StaticConstructors.h" 14 #include "wtf/StaticConstructors.h"
15 15
16 namespace WebCore { 16 namespace WebCore {
17 namespace {{namespace}}Names { 17 namespace {{namespace}}Names {
18 18
19 using namespace WebCore; 19 using namespace WebCore;
20 20
21 DEFINE_GLOBAL(AtomicString, {{namespace_prefix}}NamespaceURI) 21 DEFINE_GLOBAL(AtomicString, {{namespace_prefix}}NamespaceURI)
22 22
23 {%- if tags %} 23 {% if tags %}
24
25 // Tags 24 // Tags
26 {%- for tag in tags|sort %} 25 {% for tag in tags|sort %}
27 DEFINE_GLOBAL(QualifiedName, {{tag|symbol}}Tag) 26 DEFINE_GLOBAL(QualifiedName, {{tag|symbol}}Tag)
28 {%- endfor %} 27 {% endfor %}
29 28
30 29
31 PassOwnPtr<const QualifiedName*[]> get{{namespace}}Tags() 30 PassOwnPtr<const QualifiedName*[]> get{{namespace}}Tags()
32 { 31 {
33 OwnPtr<const QualifiedName*[]> tags = adoptArrayPtr(new const QualifiedName* [{{namespace}}TagsCount]); 32 OwnPtr<const QualifiedName*[]> tags = adoptArrayPtr(new const QualifiedName* [{{namespace}}TagsCount]);
34 {%- for tag in tags|sort %} 33 {% for tag in tags|sort %}
35 tags[{{loop.index0}}] = reinterpret_cast<const QualifiedName*>(&{{tag|symbol }}Tag); 34 tags[{{loop.index0}}] = reinterpret_cast<const QualifiedName*>(&{{tag|symbol }}Tag);
36 {%- endfor %} 35 {% endfor %}
37 return tags.release(); 36 return tags.release();
38 } 37 }
39 38
40 {%- endif %} 39 {% endif %}
41
42 // Attributes 40 // Attributes
43 {%- for attr in attrs|sort %} 41 {% for attr in attrs|sort %}
44 DEFINE_GLOBAL(QualifiedName, {{attr|symbol}}Attr) 42 DEFINE_GLOBAL(QualifiedName, {{attr|symbol}}Attr)
45 {%- endfor %} 43 {% endfor %}
46 44
47 PassOwnPtr<const QualifiedName*[]> get{{namespace}}Attrs() 45 PassOwnPtr<const QualifiedName*[]> get{{namespace}}Attrs()
48 { 46 {
49 OwnPtr<const QualifiedName*[]> attrs = adoptArrayPtr(new const QualifiedName *[{{namespace}}AttrsCount]); 47 OwnPtr<const QualifiedName*[]> attrs = adoptArrayPtr(new const QualifiedName *[{{namespace}}AttrsCount]);
50 {%- for attr in attrs|sort %} 48 {% for attr in attrs|sort %}
51 attrs[{{loop.index0}}] = reinterpret_cast<const WebCore::QualifiedName*>(&{{ attr|symbol}}Attr); 49 attrs[{{loop.index0}}] = reinterpret_cast<const WebCore::QualifiedName*>(&{{ attr|symbol}}Attr);
52 {%- endfor %} 50 {% endfor %}
53 return attrs.release(); 51 return attrs.release();
54 } 52 }
55 53
56 void init() 54 void init()
57 { 55 {
58 // Use placement new to initialize the globals. 56 // Use placement new to initialize the globals.
59 AtomicString {{namespace_prefix}}NS("{{namespace_uri}}", AtomicString::Const ructFromLiteral); 57 AtomicString {{namespace_prefix}}NS("{{namespace_uri}}", AtomicString::Const ructFromLiteral);
60 58
61 // Namespace 59 // Namespace
62 new ((void*)&{{namespace_prefix}}NamespaceURI) AtomicString({{namespace_pref ix}}NS); 60 new ((void*)&{{namespace_prefix}}NamespaceURI) AtomicString({{namespace_pref ix}}NS);
63 61 {% for name, tag_list in (tags + attrs)|groupby('name')|sort %}
64 {%- for name, tag_list in (tags + attrs)|groupby('name')|sort %}
65 StringImpl* {{tag_list[0]|symbol}}Impl = StringImpl::createStatic("{{name}}" , {{name|length}}, {{name|hash}}); 62 StringImpl* {{tag_list[0]|symbol}}Impl = StringImpl::createStatic("{{name}}" , {{name|length}}, {{name|hash}});
66 {%- endfor %} 63 {% endfor %}
67 64
68 // Tags 65 // Tags
69 {%- for tag in tags|sort %} 66 {% for tag in tags|sort %}
70 createQualifiedName((void*)&{{tag|symbol}}Tag, {{tag|symbol}}Impl, {{namespa ce_prefix}}NS); 67 createQualifiedName((void*)&{{tag|symbol}}Tag, {{tag|symbol}}Impl, {{namespa ce_prefix}}NS);
71 {%- endfor %} 68 {% endfor %}
72 69
73 // Attrs 70 // Attrs
74 {%- for attr in attrs|sort %} 71 {% for attr in attrs|sort %}
75 {%- if use_namespace_for_attrs %} 72 {% if use_namespace_for_attrs %}
76 createQualifiedName((void*)&{{attr|symbol}}Attr, {{attr|symbol}}Impl, {{name space_prefix}}NS); 73 createQualifiedName((void*)&{{attr|symbol}}Attr, {{attr|symbol}}Impl, {{name space_prefix}}NS);
77 {%- else %} 74 {% else %}
78 createQualifiedName((void*)&{{attr|symbol}}Attr, {{attr|symbol}}Impl); 75 createQualifiedName((void*)&{{attr|symbol}}Attr, {{attr|symbol}}Impl);
79 {%- endif %} 76 {% endif %}
80 {%- endfor %} 77 {% endfor %}
81 } 78 }
82 79
83 } // {{namespace}} 80 } // {{namespace}}
84 } // WebCore 81 } // WebCore
OLDNEW
« no previous file with comments | « Source/build/scripts/templates/MakeNames.h.tmpl ('k') | Source/build/scripts/templates/MakeQualifiedNames.h.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698