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

Side by Side Diff: Source/core/scripts/make_dom_exceptions.py

Issue 17271002: Clean up *.in files related to DOM exceptions and events (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 108
109 ASSERT_NOT_REACHED(); 109 ASSERT_NOT_REACHED();
110 } 110 }
111 111
112 } // namespace WebCore 112 } // namespace WebCore
113 """ 113 """
114 114
115 115
116 class ExceptionCodeDescriptionWriter(name_macros.Writer): 116 class ExceptionCodeDescriptionWriter(name_macros.Writer):
117 defaults = { 117 defaults = {
118 'JSInterfaceName': None, 118 'implementedAs': None,
119 'interfaceName': None,
120 'conditional': None, 119 'conditional': None,
121 } 120 }
122 default_parameters = { 121 default_parameters = {
123 'namespace': '', 122 'namespace': '',
124 } 123 }
125 124
126 def __init__(self, in_file_path, enabled_conditions): 125 def __init__(self, in_file_path, enabled_conditions):
127 super(ExceptionCodeDescriptionWriter, self).__init__(in_file_path, enabl ed_conditions) 126 super(ExceptionCodeDescriptionWriter, self).__init__(in_file_path, enabl ed_conditions)
128 self._outputs[(self.class_name + ".cpp")] = self.generate_implementation 127 self._outputs[(self.class_name + ".cpp")] = self.generate_implementation
129 self._outputs[(self.class_name + ".h")] = self.generate_header 128 self._outputs[(self.class_name + ".h")] = self.generate_header
130 129
131 def _exceptions(self): 130 def _exceptions(self):
132 return self.in_file.name_dictionaries 131 return self.in_file.name_dictionaries
133 132
133 def _exception_class_name(self, exception):
haraken 2013/06/17 13:38:37 Can't you use _class_name_for_entry in name_macros
134 if exception['implementedAs']:
135 return exception['implementedAs']
136 return os.path.basename(exception['name'])
137
134 def _exception_type(self, exception): 138 def _exception_type(self, exception):
135 name = os.path.basename(exception['name']) 139 return self.wrap_with_condition(' ' + self._exception_class_name(exce ption) + 'Type,', exception['conditional'])
136 return self.wrap_with_condition(' ' + name + 'Type,', exception['cond itional'])
137 140
138 def generate_header(self): 141 def generate_header(self):
139 return HEADER_TEMPLATE % { 142 return HEADER_TEMPLATE % {
140 'license': license.license_for_generated_cpp(), 143 'license': license.license_for_generated_cpp(),
141 'class_name': self.class_name, 144 'class_name': self.class_name,
142 'exception_types': '\n'.join(map(self._exception_type, self._excepti ons())), 145 'exception_types': '\n'.join(map(self._exception_type, self._excepti ons())),
143 } 146 }
144 147
145 def _include(self, exception): 148 def _include(self, exception):
146 include = '#include "' + exception['name'] + '.h"' 149 include = '#include "' + self._headers_header_include_path(exception) + '"'
147 return self.wrap_with_condition(include, exception['conditional']) 150 return self.wrap_with_condition(include, exception['conditional'])
148 151
149 def _description_initalization(self, exception): 152 def _description_initalization(self, exception):
150 name = os.path.basename(exception['name']) 153 name = os.path.basename(exception['name'])
151 if name == 'DOMCoreException': 154 if name == 'DOMException':
152 return '' # DOMCoreException needs to be last because it's a catch- all. 155 return '' # DOMException needs to be last because it's a catch-all.
153 description_initalization = """ if (%(name)s::initializeDescription(e c, this)) 156 description_initalization = """ if (%(name)s::initializeDescription(e c, this))
154 return;""" % {'name': name} 157 return;""" % {'name': name}
155 return self.wrap_with_condition(description_initalization, exception['co nditional']) 158 return self.wrap_with_condition(description_initalization, exception['co nditional'])
156 159
157 def generate_implementation(self): 160 def generate_implementation(self):
158 return IMPLEMENTATION_TEMPLATE % { 161 return IMPLEMENTATION_TEMPLATE % {
159 'license': license.license_for_generated_cpp(), 162 'license': license.license_for_generated_cpp(),
160 'class_name': self.class_name, 163 'class_name': self.class_name,
161 'includes': '\n'.join(map(self._include, self._exceptions())), 164 'includes': '\n'.join(map(self._include, self._exceptions())),
162 'description_initalizations': '\n'.join(map(self._description_inital ization, self._exceptions())), 165 'description_initalizations': '\n'.join(map(self._description_inital ization, self._exceptions())),
163 } 166 }
164 167
165 168
166 if __name__ == "__main__": 169 if __name__ == "__main__":
167 name_macros.Maker(ExceptionCodeDescriptionWriter).main(sys.argv) 170 name_macros.Maker(ExceptionCodeDescriptionWriter).main(sys.argv)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698