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

Side by Side Diff: Source/bindings/scripts/v8_utilities.py

Issue 340443004: IDL: reuse more code between CG for methods and constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rename scriptContext -> executionContext 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/bindings/scripts/v8_methods.py ('k') | Source/bindings/templates/attributes.cpp » ('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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 151
152 includes.add('bindings/v8/V8DOMActivityLogger.h') 152 includes.add('bindings/v8/V8DOMActivityLogger.h')
153 if 'LogAllWorlds' in extended_attributes: 153 if 'LogAllWorlds' in extended_attributes:
154 return set(['', 'ForMainWorld']) 154 return set(['', 'ForMainWorld'])
155 return set(['']) # At minimum, include isolated worlds. 155 return set(['']) # At minimum, include isolated worlds.
156 156
157 157
158 # [CallWith] 158 # [CallWith]
159 CALL_WITH_ARGUMENTS = { 159 CALL_WITH_ARGUMENTS = {
160 'ScriptState': 'scriptState', 160 'ScriptState': 'scriptState',
161 'ExecutionContext': 'scriptContext', 161 'ExecutionContext': 'executionContext',
162 'ScriptArguments': 'scriptArguments.release()', 162 'ScriptArguments': 'scriptArguments.release()',
163 'ActiveWindow': 'callingDOMWindow(info.GetIsolate())', 163 'ActiveWindow': 'callingDOMWindow(info.GetIsolate())',
164 'FirstWindow': 'enteredDOMWindow(info.GetIsolate())', 164 'FirstWindow': 'enteredDOMWindow(info.GetIsolate())',
165 'Document': 'document',
165 } 166 }
166 # List because key order matters, as we want arguments in deterministic order 167 # List because key order matters, as we want arguments in deterministic order
167 CALL_WITH_VALUES = [ 168 CALL_WITH_VALUES = [
168 'ScriptState', 169 'ScriptState',
169 'ExecutionContext', 170 'ExecutionContext',
170 'ScriptArguments', 171 'ScriptArguments',
171 'ActiveWindow', 172 'ActiveWindow',
172 'FirstWindow', 173 'FirstWindow',
174 'Document',
173 ] 175 ]
174 176
175 177
176 def call_with_arguments(member, call_with_values=None): 178 def call_with_arguments(call_with_values):
177 # Optional parameter so setter can override with [SetterCallWith]
178 call_with_values = call_with_values or member.extended_attributes.get('CallW ith')
179 if not call_with_values: 179 if not call_with_values:
180 return [] 180 return []
181 return [CALL_WITH_ARGUMENTS[value] 181 return [CALL_WITH_ARGUMENTS[value]
182 for value in CALL_WITH_VALUES 182 for value in CALL_WITH_VALUES
183 if extended_attribute_value_contains(call_with_values, value)] 183 if extended_attribute_value_contains(call_with_values, value)]
184 184
185 185
186 # [Conditional] 186 # [Conditional]
187 def conditional_string(definition_or_member): 187 def conditional_string(definition_or_member):
188 extended_attributes = definition_or_member.extended_attributes 188 extended_attributes = definition_or_member.extended_attributes
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 248
249 The returned function checks if a method/attribute is enabled. 249 The returned function checks if a method/attribute is enabled.
250 Given extended attribute RuntimeEnabled=FeatureName, return: 250 Given extended attribute RuntimeEnabled=FeatureName, return:
251 RuntimeEnabledFeatures::{featureName}Enabled 251 RuntimeEnabledFeatures::{featureName}Enabled
252 """ 252 """
253 extended_attributes = definition_or_member.extended_attributes 253 extended_attributes = definition_or_member.extended_attributes
254 if 'RuntimeEnabled' not in extended_attributes: 254 if 'RuntimeEnabled' not in extended_attributes:
255 return None 255 return None
256 feature_name = extended_attributes['RuntimeEnabled'] 256 feature_name = extended_attributes['RuntimeEnabled']
257 return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name) 257 return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name)
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_methods.py ('k') | Source/bindings/templates/attributes.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698