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

Side by Side Diff: core/scripts/name_macros.py

Issue 22498002: Roll IDL to multivm@1329 (Closed) Base URL: https://dart.googlecode.com/svn/third_party/WebCore
Patch Set: Created 7 years, 4 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 | « core/scripts/make_token_matcher_unittest.py ('k') | core/scripts/rule_bison.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 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 self._entries_by_conditional = {} 74 self._entries_by_conditional = {}
75 self._unconditional_entries = [] 75 self._unconditional_entries = []
76 self._sort_entries_by_conditional() 76 self._sort_entries_by_conditional()
77 self._outputs = {(self.class_name + "Headers.h"): self.generate_headers_ header, 77 self._outputs = {(self.class_name + "Headers.h"): self.generate_headers_ header,
78 (self.class_name + "Interfaces.h"): self.generate_inter faces_header, 78 (self.class_name + "Interfaces.h"): self.generate_inter faces_header,
79 } 79 }
80 80
81 def _sort_entries_by_conditional(self): 81 def _sort_entries_by_conditional(self):
82 unconditional_names = set() 82 unconditional_names = set()
83 for entry in self.in_file.name_dictionaries: 83 for entry in self.in_file.name_dictionaries:
84 conditional = entry['conditional'] 84 conditional = entry['Conditional']
85 if not conditional: 85 if not conditional:
86 name = self._class_name_for_entry(entry) 86 name = self._class_name_for_entry(entry)
87 if name in unconditional_names: 87 if name in unconditional_names:
88 continue 88 continue
89 unconditional_names.add(name) 89 unconditional_names.add(name)
90 self._unconditional_entries.append(entry) 90 self._unconditional_entries.append(entry)
91 continue 91 continue
92 for entry in self.in_file.name_dictionaries: 92 for entry in self.in_file.name_dictionaries:
93 name = self._class_name_for_entry(entry) 93 name = self._class_name_for_entry(entry)
94 if name in unconditional_names: 94 if name in unconditional_names:
95 continue 95 continue
96 conditional = entry['conditional'] 96 conditional = entry['Conditional']
97 if not conditional in self._entries_by_conditional: 97 if not conditional in self._entries_by_conditional:
98 self._entries_by_conditional[conditional] = [] 98 self._entries_by_conditional[conditional] = []
99 self._entries_by_conditional[conditional].append(entry) 99 self._entries_by_conditional[conditional].append(entry)
100 100
101 def _class_name_for_entry(self, entry): 101 def _class_name_for_entry(self, entry):
102 if entry['implementedAs']: 102 if entry['ImplementedAs']:
103 return entry['implementedAs'] 103 return entry['ImplementedAs']
104 return os.path.basename(entry['name']) 104 return os.path.basename(entry['name'])
105 105
106 def _headers_header_include_path(self, entry): 106 def _headers_header_include_path(self, entry):
107 if entry['implementedAs']: 107 if entry['ImplementedAs']:
108 path = os.path.dirname(entry['name']) 108 path = os.path.dirname(entry['name'])
109 if len(path): 109 if len(path):
110 path += '/' 110 path += '/'
111 path += entry['implementedAs'] 111 path += entry['ImplementedAs']
112 else: 112 else:
113 path = entry['name'] 113 path = entry['name']
114 return path + '.h' 114 return path + '.h'
115 115
116 def _headers_header_includes(self, entries): 116 def _headers_header_includes(self, entries):
117 includes = dict() 117 includes = dict()
118 for entry in entries: 118 for entry in entries:
119 class_name = self._class_name_for_entry(entry) 119 class_name = self._class_name_for_entry(entry)
120 # Avoid duplicate includes. 120 # Avoid duplicate includes.
121 if class_name in includes: 121 if class_name in includes:
122 continue 122 continue
123 include = '#include "%(path)s"\n#include "V8%(js_name)s.h"' % { 123 include = '#include "%(path)s"\n#include "V8%(js_name)s.h"' % {
124 'path': self._headers_header_include_path(entry), 124 'path': self._headers_header_include_path(entry),
125 'js_name': os.path.basename(entry['name']), 125 'js_name': os.path.basename(entry['name']),
126 } 126 }
127 includes[class_name] = self.wrap_with_condition(include, entry['cond itional']) 127 includes[class_name] = self.wrap_with_condition(include, entry['Cond itional'])
128 return includes.values() 128 return includes.values()
129 129
130 def generate_headers_header(self): 130 def generate_headers_header(self):
131 return HEADER_TEMPLATE % { 131 return HEADER_TEMPLATE % {
132 'license': license.license_for_generated_cpp(), 132 'license': license.license_for_generated_cpp(),
133 'class_name': self.class_name, 133 'class_name': self.class_name,
134 'includes': '\n'.join(self._headers_header_includes(self.in_file.nam e_dictionaries)), 134 'includes': '\n'.join(self._headers_header_includes(self.in_file.nam e_dictionaries)),
135 } 135 }
136 136
137 def _declare_one_conditional_macro(self, conditional, entries): 137 def _declare_one_conditional_macro(self, conditional, entries):
(...skipping 28 matching lines...) Expand all
166 166
167 def generate_interfaces_header(self): 167 def generate_interfaces_header(self):
168 return INTERFACES_HEADER_TEMPLATE % { 168 return INTERFACES_HEADER_TEMPLATE % {
169 'license': license.license_for_generated_cpp(), 169 'license': license.license_for_generated_cpp(),
170 'class_name': self.class_name, 170 'class_name': self.class_name,
171 'macro_style_name': _to_macro_style(self.class_name), 171 'macro_style_name': _to_macro_style(self.class_name),
172 'declare_conditional_macros': self._declare_conditional_macros(), 172 'declare_conditional_macros': self._declare_conditional_macros(),
173 'unconditional_macros': '\n'.join(sorted(set(map(self._unconditional _macro, self._unconditional_entries)))), 173 'unconditional_macros': '\n'.join(sorted(set(map(self._unconditional _macro, self._unconditional_entries)))),
174 'conditional_macros': '\n'.join(map(self._conditional_macros, self._ entries_by_conditional.keys())), 174 'conditional_macros': '\n'.join(map(self._conditional_macros, self._ entries_by_conditional.keys())),
175 } 175 }
OLDNEW
« no previous file with comments | « core/scripts/make_token_matcher_unittest.py ('k') | core/scripts/rule_bison.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698