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

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

Issue 2620153004: [Bindings] Code cleanup: Early return if funtime enabled interface is false (Closed)
Patch Set: . Created 3 years, 11 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
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 """Uncapitalizes first letter or initial acronym (used in method names). 105 """Uncapitalizes first letter or initial acronym (used in method names).
106 106
107 E.g., 'SetURL' becomes 'setURL', but 'URLFoo' becomes 'urlFoo'. 107 E.g., 'SetURL' becomes 'setURL', but 'URLFoo' becomes 'urlFoo'.
108 """ 108 """
109 for acronym in ACRONYMS: 109 for acronym in ACRONYMS:
110 if name.startswith(acronym): 110 if name.startswith(acronym):
111 return name.replace(acronym, acronym.lower()) 111 return name.replace(acronym, acronym.lower())
112 return name[0].lower() + name[1:] 112 return name[0].lower() + name[1:]
113 113
114 114
115 def runtime_enabled_function(name):
Yuki 2017/01/13 02:38:37 I'm uneasy with this name because "runtime enabled
peria 2017/01/13 05:54:26 I'll make a follow up CL. But I think the prefix "
116 """Returns a function call of a runtime enabled feature."""
117 return 'RuntimeEnabledFeatures::%sEnabled()' % uncapitalize(name)
118
119
115 def unique_by(dict_list, key): 120 def unique_by(dict_list, key):
116 """Returns elements from a list of dictionaries with unique values for the n amed key.""" 121 """Returns elements from a list of dictionaries with unique values for the n amed key."""
117 keys_seen = set() 122 keys_seen = set()
118 filtered_list = [] 123 filtered_list = []
119 for item in dict_list: 124 for item in dict_list:
120 if item.get(key) not in keys_seen: 125 if item.get(key) not in keys_seen:
121 filtered_list.append(item) 126 filtered_list.append(item)
122 keys_seen.add(item.get(key)) 127 keys_seen.add(item.get(key))
123 return filtered_list 128 return filtered_list
124 129
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 return len(self.exposures) 292 return len(self.exposures)
288 293
289 def __iter__(self): 294 def __iter__(self):
290 return self.exposures.__iter__() 295 return self.exposures.__iter__()
291 296
292 @staticmethod 297 @staticmethod
293 def _code(exposure): 298 def _code(exposure):
294 exposed = ('executionContext->%s()' % 299 exposed = ('executionContext->%s()' %
295 EXPOSED_EXECUTION_CONTEXT_METHOD[exposure.exposed]) 300 EXPOSED_EXECUTION_CONTEXT_METHOD[exposure.exposed])
296 if exposure.runtime_enabled is not None: 301 if exposure.runtime_enabled is not None:
297 runtime_enabled = ('RuntimeEnabledFeatures::%sEnabled()' % 302 runtime_enabled = (runtime_enabled_function(exposure.runtime_enabled ))
298 uncapitalize(exposure.runtime_enabled))
299 return '({0} && {1})'.format(exposed, runtime_enabled) 303 return '({0} && {1})'.format(exposed, runtime_enabled)
300 return exposed 304 return exposed
301 305
302 def code(self): 306 def code(self):
303 if len(self.exposures) == 0: 307 if len(self.exposures) == 0:
304 return None 308 return None
305 # We use sorted here to deflake output. 309 # We use sorted here to deflake output.
306 return ' || '.join(sorted(self._code(e) for e in self.exposures)) 310 return ' || '.join(sorted(self._code(e) for e in self.exposures))
307 311
308 312
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 return None 645 return None
642 646
643 647
644 IdlInterface.legacy_caller = property(legacy_caller) 648 IdlInterface.legacy_caller = property(legacy_caller)
645 IdlInterface.indexed_property_getter = property(indexed_property_getter) 649 IdlInterface.indexed_property_getter = property(indexed_property_getter)
646 IdlInterface.indexed_property_setter = property(indexed_property_setter) 650 IdlInterface.indexed_property_setter = property(indexed_property_setter)
647 IdlInterface.indexed_property_deleter = property(indexed_property_deleter) 651 IdlInterface.indexed_property_deleter = property(indexed_property_deleter)
648 IdlInterface.named_property_getter = property(named_property_getter) 652 IdlInterface.named_property_getter = property(named_property_getter)
649 IdlInterface.named_property_setter = property(named_property_setter) 653 IdlInterface.named_property_setter = property(named_property_setter)
650 IdlInterface.named_property_deleter = property(named_property_deleter) 654 IdlInterface.named_property_deleter = property(named_property_deleter)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698