Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / build / scripts / templates / ElementLookupTrie.cpp.tmpl
1 {% from 'macros.tmpl' import license %}
2 {{license()}}
3 {% macro trie_switch(trie, index) %}
4 {# FIXME: No need to switch if there's only a single item in the subtrie:
5    can just have an if statement as we're currently doing for leaves. #}
6 switch (data[{{index}}]) {
7 {% for char, subtrie, tag, conditions in trie %}
8 case '{{char}}':
9     {% if subtrie %}{# Recurse on subtrie #}
10     {{trie_switch(subtrie, index + 1) | indent}}
11     {% elif conditions %}{# Check suffix #}
12     if ({{conditions | join(' && ')}})
13         return {{tag}}Tag.localName().impl();
14     return 0;
15     {% else %}{# Terminal node (no suffix) #}
16     return {{tag}}Tag.localName().impl();
17     {% endif %}
18 {% endfor %}
19 }
20 return 0;
21 {% endmacro %}
22
23 #include "config.h"
24 #include "{{namespace}}ElementLookupTrie.h"
25
26 #include "{{namespace}}Names.h"
27
28 namespace blink {
29
30 using namespace {{namespace}}Names;
31
32 StringImpl* lookup{{namespace}}Tag(const UChar* data, unsigned length)
33 {
34     ASSERT(data);
35     ASSERT(length);
36     switch (length) {
37     {% for length, trie in length_tries %}
38     case {{length}}:
39         {{trie_switch(trie, 0) | indent(8)}}
40     {% endfor %}
41     }
42     return 0;
43 }
44
45 } // namespace blink