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

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

Issue 17031006: Rename DOMWindow interface to Window (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master 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
« no previous file with comments | « Source/core/scripts/make_event_factory.py ('k') | Source/core/testing/Internals.idl » ('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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 def _to_macro_style(name): 65 def _to_macro_style(name):
66 s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) 66 s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
67 return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).upper() 67 return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).upper()
68 68
69 69
70 def _name_for_entry(entry): 70 def _name_for_entry(entry):
71 if entry['interfaceName']: 71 if entry['interfaceName']:
72 return entry['interfaceName'] 72 return entry['interfaceName']
73 return os.path.basename(entry['name']) 73 return os.path.basename(entry['name'])
74 74
75
76 def _js_name_for_entry(entry):
77 if entry['JSInterfaceName']:
78 return entry['JSInterfaceName']
79 return _name_for_entry(entry)
80
75 class Writer(in_generator.Writer): 81 class Writer(in_generator.Writer):
76 def __init__(self, in_file_path, enabled_conditions): 82 def __init__(self, in_file_path, enabled_conditions):
77 super(Writer, self).__init__(in_file_path, enabled_conditions) 83 super(Writer, self).__init__(in_file_path, enabled_conditions)
78 self.class_name = self.in_file.parameters['namespace'].strip('"') 84 self.class_name = self.in_file.parameters['namespace'].strip('"')
79 self._entries_by_conditional = {} 85 self._entries_by_conditional = {}
80 self._unconditional_entries = [] 86 self._unconditional_entries = []
81 self._sort_entries_by_conditional() 87 self._sort_entries_by_conditional()
82 self._outputs = {(self.class_name + "Headers.h"): self.generate_headers_ header, 88 self._outputs = {(self.class_name + "Headers.h"): self.generate_headers_ header,
83 (self.class_name + "Interfaces.h"): self.generate_inter faces_header, 89 (self.class_name + "Interfaces.h"): self.generate_inter faces_header,
84 } 90 }
(...skipping 13 matching lines...) Expand all
98 name = _name_for_entry(entry) 104 name = _name_for_entry(entry)
99 if name in unconditional_names: 105 if name in unconditional_names:
100 continue 106 continue
101 conditional = entry['conditional'] 107 conditional = entry['conditional']
102 if not conditional in self._entries_by_conditional: 108 if not conditional in self._entries_by_conditional:
103 self._entries_by_conditional[conditional] = [] 109 self._entries_by_conditional[conditional] = []
104 self._entries_by_conditional[conditional].append(entry) 110 self._entries_by_conditional[conditional].append(entry)
105 111
106 def _headers_header_include(self, entry): 112 def _headers_header_include(self, entry):
107 path = entry['name'] 113 path = entry['name']
108 name = _name_for_entry(entry) 114 js_name = _js_name_for_entry(entry)
109 if entry['interfaceName']: 115 if entry['interfaceName']:
110 path = entry['interfaceName'] # FIXME: This seems wrong 116 path = entry['interfaceName'] # FIXME: This seems wrong
111 include = '#include "%(path)s.h"\n#include "V8%(name)s.h"' % { 117 include = '#include "%(path)s.h"\n#include "V8%(js_name)s.h"' % {
112 'path': path, 118 'path': path,
113 'name': name, 119 'js_name': js_name,
114 } 120 }
115 return self.wrap_with_condition(include, entry['conditional']) 121 return self.wrap_with_condition(include, entry['conditional'])
116 122
117 def generate_headers_header(self): 123 def generate_headers_header(self):
118 return HEADER_TEMPLATE % { 124 return HEADER_TEMPLATE % {
119 'license': license.license_for_generated_cpp(), 125 'license': license.license_for_generated_cpp(),
120 'class_name': self.class_name, 126 'class_name': self.class_name,
121 'includes': '\n'.join(map(self._headers_header_include, self.in_file .name_dictionaries)), 127 'includes': '\n'.join(map(self._headers_header_include, self.in_file .name_dictionaries)),
122 } 128 }
123 129
(...skipping 29 matching lines...) Expand all
153 159
154 def generate_interfaces_header(self): 160 def generate_interfaces_header(self):
155 return INTERFACES_HEADER_TEMPLATE % { 161 return INTERFACES_HEADER_TEMPLATE % {
156 'license': license.license_for_generated_cpp(), 162 'license': license.license_for_generated_cpp(),
157 'class_name': self.class_name, 163 'class_name': self.class_name,
158 'macro_style_name': _to_macro_style(self.class_name), 164 'macro_style_name': _to_macro_style(self.class_name),
159 'declare_conditional_macros': self._declare_conditional_macros(), 165 'declare_conditional_macros': self._declare_conditional_macros(),
160 'unconditional_macros': '\n'.join(sorted(set(map(self._unconditional _macro, self._unconditional_entries)))), 166 'unconditional_macros': '\n'.join(sorted(set(map(self._unconditional _macro, self._unconditional_entries)))),
161 'conditional_macros': '\n'.join(map(self._conditional_macros, self._ entries_by_conditional.keys())), 167 'conditional_macros': '\n'.join(map(self._conditional_macros, self._ entries_by_conditional.keys())),
162 } 168 }
OLDNEW
« no previous file with comments | « Source/core/scripts/make_event_factory.py ('k') | Source/core/testing/Internals.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698