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