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

Side by Side Diff: Source/build/scripts/make_element_type_helpers.py

Issue 330093002: Add support in generate scripts to handle Conditional (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: sort by alpha Created 6 years, 6 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
« no previous file with comments | « Source/build/scripts/make_element_factory.py ('k') | Source/build/scripts/make_names.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import sys 6 import sys
7 from collections import defaultdict 7 from collections import defaultdict
8 8
9 import hasher 9 import hasher
10 import in_generator 10 import in_generator
11 import name_utilities 11 import name_utilities
12 import template_expander 12 import template_expander
13 13
14 from in_file import InFile 14 from in_file import InFile
15 15
16 16
17 def _symbol(tag): 17 def _symbol(tag):
18 # FIXME: Remove this special case for the ugly x-webkit-foo attributes. 18 # FIXME: Remove this special case for the ugly x-webkit-foo attributes.
19 if tag['name'].startswith('-webkit-'): 19 if tag['name'].startswith('-webkit-'):
20 return tag['name'].replace('-', '_')[1:] 20 return tag['name'].replace('-', '_')[1:]
21 return name_utilities.cpp_name(tag).replace('-', '_') 21 return name_utilities.cpp_name(tag).replace('-', '_')
22 22
23 class MakeElementTypeHelpersWriter(in_generator.Writer): 23 class MakeElementTypeHelpersWriter(in_generator.Writer):
24 defaults = { 24 defaults = {
25 'interfaceName': None, 25 'Conditional': None,
26 'noConstructor': None,
27 'noTypeHelpers': None,
28 'ImplementedAs': None, 26 'ImplementedAs': None,
29 'JSInterfaceName': None, 27 'JSInterfaceName': None,
30 'constructorNeedsCreatedByParser': None, 28 'constructorNeedsCreatedByParser': None,
31 'constructorNeedsFormElement': None, 29 'constructorNeedsFormElement': None,
32 'contextConditional': None, 30 'contextConditional': None,
33 'interfaceName': None, 31 'interfaceName': None,
34 'noConstructor': None, 32 'noConstructor': None,
33 'noConstructor': None,
34 'noTypeHelpers': None,
35 'runtimeEnabled': None, 35 'runtimeEnabled': None,
36 } 36 }
37 default_parameters = { 37 default_parameters = {
38 'attrsNullNamespace': None, 38 'attrsNullNamespace': None,
39 'fallbackInterfaceName': '',
39 'namespace': '', 40 'namespace': '',
40 'namespacePrefix': '', 41 'namespacePrefix': '',
41 'namespaceURI': '', 42 'namespaceURI': '',
42 'fallbackInterfaceName': '',
43 'fallbackJSInterfaceName': '', 43 'fallbackJSInterfaceName': '',
44 } 44 }
45 filters = { 45 filters = {
46 'enable_conditional': name_utilities.enable_conditional_if_endif,
46 'hash': hasher.hash, 47 'hash': hasher.hash,
47 'symbol': _symbol, 48 'symbol': _symbol,
48 } 49 }
49 50
50 def __init__(self, in_file_path): 51 def __init__(self, in_file_path):
51 super(MakeElementTypeHelpersWriter, self).__init__(in_file_path) 52 super(MakeElementTypeHelpersWriter, self).__init__(in_file_path)
52 53
53 self.namespace = self.in_file.parameters['namespace'].strip('"') 54 self.namespace = self.in_file.parameters['namespace'].strip('"')
54 self.fallbackInterface = self.in_file.parameters['fallbackInterfaceName' ].strip('"') 55 self.fallbackInterface = self.in_file.parameters['fallbackInterfaceName' ].strip('"')
55 56
(...skipping 29 matching lines...) Expand all
85 if name == 'HTML': 86 if name == 'HTML':
86 name = 'Html' 87 name = 'Html'
87 dash = name.find('-') 88 dash = name.find('-')
88 while dash != -1: 89 while dash != -1:
89 name = name[:dash] + name[dash + 1].upper() + name[dash + 2:] 90 name = name[:dash] + name[dash + 1].upper() + name[dash + 2:]
90 dash = name.find('-') 91 dash = name.find('-')
91 return '%s%sElement' % (self.namespace, name) 92 return '%s%sElement' % (self.namespace, name)
92 93
93 if __name__ == "__main__": 94 if __name__ == "__main__":
94 in_generator.Maker(MakeElementTypeHelpersWriter).main(sys.argv) 95 in_generator.Maker(MakeElementTypeHelpersWriter).main(sys.argv)
OLDNEW
« no previous file with comments | « Source/build/scripts/make_element_factory.py ('k') | Source/build/scripts/make_names.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698