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" | |
24 #include "{{namespace}}ElementLookupTrie.h" | 23 #include "{{namespace}}ElementLookupTrie.h" |
25 | 24 |
26 #include "{{namespace}}Names.h" | 25 #include "{{namespace}}Names.h" |
27 | 26 |
28 namespace blink { | 27 namespace blink { |
29 | 28 |
30 using namespace {{namespace}}Names; | 29 using namespace {{namespace}}Names; |
31 | 30 |
32 StringImpl* lookup{{namespace}}Tag(const UChar* data, unsigned length) | 31 StringImpl* lookup{{namespace}}Tag(const UChar* data, unsigned length) |
33 { | 32 { |
34 ASSERT(data); | 33 ASSERT(data); |
35 ASSERT(length); | 34 ASSERT(length); |
36 switch (length) { | 35 switch (length) { |
37 {% for length, trie in length_tries %} | 36 {% for length, trie in length_tries %} |
38 case {{length}}: | 37 case {{length}}: |
39 {{trie_switch(trie, 0) | indent(8)}} | 38 {{trie_switch(trie, 0) | indent(8)}} |
40 {% endfor %} | 39 {% endfor %} |
41 } | 40 } |
42 return 0; | 41 return 0; |
43 } | 42 } |
44 | 43 |
45 } // namespace blink | 44 } // namespace blink |
OLD | NEW |