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

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

Issue 27009005: Generate HTMLElementFactory with Python (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Actually use the code Created 7 years, 2 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
« no previous file with comments | « Source/build/scripts/make_names.pl ('k') | Source/build/scripts/name_utilities.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 (C) 2013 Google Inc. All rights reserved. 2 # Copyright (C) 2013 Google Inc. All rights reserved.
3 # 3 #
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 'hash': hasher.hash, 53 'hash': hasher.hash,
54 'to_macro_style': name_utilities.to_macro_style, 54 'to_macro_style': name_utilities.to_macro_style,
55 'symbol': _symbol, 55 'symbol': _symbol,
56 } 56 }
57 57
58 def __init__(self, in_file_paths, enabled_conditions): 58 def __init__(self, in_file_paths, enabled_conditions):
59 super(MakeQualifiedNamesWriter, self).__init__(None, enabled_conditions) 59 super(MakeQualifiedNamesWriter, self).__init__(None, enabled_conditions)
60 assert len(in_file_paths) <= 2, 'MakeQualifiedNamesWriter requires at mo st 2 in files, got %d.' % len(in_file_paths) 60 assert len(in_file_paths) <= 2, 'MakeQualifiedNamesWriter requires at mo st 2 in files, got %d.' % len(in_file_paths)
61 61
62 if len(in_file_paths) == 2: 62 if len(in_file_paths) == 2:
63 tags_in_file = InFile.load_from_files([in_file_paths.pop(0)], self.d efaults, self.valid_values, self.default_parameters) 63 self.tags_in_file = InFile.load_from_files([in_file_paths.pop(0)], s elf.defaults, self.valid_values, self.default_parameters)
64 else: 64 else:
65 tags_in_file = None 65 self.tags_in_file = None
66 66
67 attrs_in_file = InFile.load_from_files([in_file_paths.pop()], self.defau lts, self.valid_values, self.default_parameters) 67 self.attrs_in_file = InFile.load_from_files([in_file_paths.pop()], self. defaults, self.valid_values, self.default_parameters)
68 68
69 namespace = attrs_in_file.parameters['namespace'].strip('"') 69 self.namespace = self.attrs_in_file.parameters['namespace'].strip('"')
70 if tags_in_file: 70 if self.tags_in_file:
71 assert namespace == tags_in_file.parameters['namespace'].strip('"'), 'Both in files must have the same namespace.' 71 assert self.namespace == self.tags_in_file.parameters['namespace'].s trip('"'), 'Both in files must have the same namespace.'
72 72
73 namespace_uri = attrs_in_file.parameters['namespaceURI'].strip('"') 73 namespace_uri = self.attrs_in_file.parameters['namespaceURI'].strip('"')
74 if tags_in_file: 74 if self.tags_in_file:
75 assert namespace_uri == tags_in_file.parameters['namespaceURI'].stri p('"'), 'Both in files must have the same namespaceURI.' 75 assert namespace_uri == self.tags_in_file.parameters['namespaceURI'] .strip('"'), 'Both in files must have the same namespaceURI.'
76 76
77 use_namespace_for_attrs = attrs_in_file.parameters['attrsNullNamespace'] is None 77 use_namespace_for_attrs = self.attrs_in_file.parameters['attrsNullNamesp ace'] is None
78 78
79 self._outputs = { 79 self._outputs = {
80 (namespace + "Names.h"): self.generate_header, 80 (self.namespace + "Names.h"): self.generate_header,
81 (namespace + "Names.cpp"): self.generate_implementation, 81 (self.namespace + "Names.cpp"): self.generate_implementation,
82 } 82 }
83 self._template_context = { 83 self._template_context = {
84 'namespace': namespace, 84 'namespace': self.namespace,
85 'namespace_uri': namespace_uri, 85 'namespace_uri': namespace_uri,
86 'use_namespace_for_attrs': use_namespace_for_attrs, 86 'use_namespace_for_attrs': use_namespace_for_attrs,
87 'tags': tags_in_file.name_dictionaries if tags_in_file else [], 87 'tags': self.tags_in_file.name_dictionaries if self.tags_in_file els e [],
88 'attrs': attrs_in_file.name_dictionaries, 88 'attrs': self.attrs_in_file.name_dictionaries,
89 } 89 }
90 90
91 @template_expander.use_jinja("MakeQualifiedNames.h.tmpl", filters=filters) 91 @template_expander.use_jinja('MakeQualifiedNames.h.tmpl', filters=filters)
92 def generate_header(self): 92 def generate_header(self):
93 return self._template_context 93 return self._template_context
94 94
95 @template_expander.use_jinja("MakeQualifiedNames.cpp.tmpl", filters=filters) 95 @template_expander.use_jinja('MakeQualifiedNames.cpp.tmpl', filters=filters)
96 def generate_implementation(self): 96 def generate_implementation(self):
97 return self._template_context 97 return self._template_context
98 98
99 99
100 if __name__ == "__main__": 100 if __name__ == "__main__":
101 in_generator.Maker(MakeQualifiedNamesWriter).main(sys.argv) 101 in_generator.Maker(MakeQualifiedNamesWriter).main(sys.argv)
OLDNEW
« no previous file with comments | « Source/build/scripts/make_names.pl ('k') | Source/build/scripts/name_utilities.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698