| OLD | NEW |
| 1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
| 2 # coding=utf-8 | 2 # coding=utf-8 |
| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 if constructor.name == 'Constructor'] | 213 if constructor.name == 'Constructor'] |
| 214 if len(constructors) > 1: | 214 if len(constructors) > 1: |
| 215 context['constructor_overloads'] = overloads_context(interface, construc
tors) | 215 context['constructor_overloads'] = overloads_context(interface, construc
tors) |
| 216 | 216 |
| 217 # [CustomConstructor] | 217 # [CustomConstructor] |
| 218 custom_constructors = [{ # Only needed for computing interface length | 218 custom_constructors = [{ # Only needed for computing interface length |
| 219 'number_of_required_arguments': | 219 'number_of_required_arguments': |
| 220 number_of_required_arguments(constructor), | 220 number_of_required_arguments(constructor), |
| 221 } for constructor in interface.custom_constructors] | 221 } for constructor in interface.custom_constructors] |
| 222 | 222 |
| 223 # [EventConstructor] | |
| 224 has_event_constructor = 'EventConstructor' in extended_attributes | |
| 225 any_type_attributes = [attribute for attribute in interface.attributes | |
| 226 if attribute.idl_type.name == 'Any'] | |
| 227 if has_event_constructor: | |
| 228 includes.add('bindings/core/v8/Dictionary.h') | |
| 229 if any_type_attributes: | |
| 230 includes.add('bindings/core/v8/SerializedScriptValue.h') | |
| 231 includes.add('bindings/core/v8/SerializedScriptValueFactory.h') | |
| 232 | |
| 233 # [NamedConstructor] | 223 # [NamedConstructor] |
| 234 named_constructor = named_constructor_context(interface) | 224 named_constructor = named_constructor_context(interface) |
| 235 | 225 |
| 236 if constructors or custom_constructors or has_event_constructor or named_con
structor: | 226 if constructors or custom_constructors or named_constructor: |
| 237 if interface.is_partial: | 227 if interface.is_partial: |
| 238 raise Exception('[Constructor] and [NamedConstructor] MUST NOT be' | 228 raise Exception('[Constructor] and [NamedConstructor] MUST NOT be' |
| 239 ' specified on partial interface definitions:' | 229 ' specified on partial interface definitions:' |
| 240 '%s' % interface.name) | 230 '%s' % interface.name) |
| 241 | 231 |
| 242 includes.add('bindings/core/v8/V8ObjectConstructor.h') | 232 includes.add('bindings/core/v8/V8ObjectConstructor.h') |
| 243 includes.add('core/frame/LocalDOMWindow.h') | 233 includes.add('core/frame/LocalDOMWindow.h') |
| 244 | 234 |
| 245 # [Unscopeable] attributes and methods | 235 # [Unscopeable] attributes and methods |
| 246 unscopeables = [] | 236 unscopeables = [] |
| 247 for attribute in interface.attributes: | 237 for attribute in interface.attributes: |
| 248 if 'Unscopeable' in attribute.extended_attributes: | 238 if 'Unscopeable' in attribute.extended_attributes: |
| 249 unscopeables.append((attribute.name, v8_utilities.runtime_enabled_fu
nction_name(attribute))) | 239 unscopeables.append((attribute.name, v8_utilities.runtime_enabled_fu
nction_name(attribute))) |
| 250 for method in interface.operations: | 240 for method in interface.operations: |
| 251 if 'Unscopeable' in method.extended_attributes: | 241 if 'Unscopeable' in method.extended_attributes: |
| 252 unscopeables.append((method.name, v8_utilities.runtime_enabled_funct
ion_name(method))) | 242 unscopeables.append((method.name, v8_utilities.runtime_enabled_funct
ion_name(method))) |
| 253 | 243 |
| 254 context.update({ | 244 context.update({ |
| 255 'any_type_attributes': any_type_attributes, | |
| 256 'constructors': constructors, | 245 'constructors': constructors, |
| 257 'has_custom_constructor': bool(custom_constructors), | 246 'has_custom_constructor': bool(custom_constructors), |
| 258 'has_event_constructor': has_event_constructor, | |
| 259 'interface_length': | 247 'interface_length': |
| 260 interface_length(interface, constructors + custom_constructors), | 248 interface_length(interface, constructors + custom_constructors), |
| 261 'is_constructor_raises_exception': extended_attributes.get('RaisesExcept
ion') == 'Constructor', # [RaisesException=Constructor] | 249 'is_constructor_raises_exception': extended_attributes.get('RaisesExcept
ion') == 'Constructor', # [RaisesException=Constructor] |
| 262 'named_constructor': named_constructor, | 250 'named_constructor': named_constructor, |
| 263 'unscopeables': sorted(unscopeables), | 251 'unscopeables': sorted(unscopeables), |
| 264 }) | 252 }) |
| 265 | 253 |
| 266 constants = [constant_context(constant, interface) for constant in interface
.constants] | 254 constants = [constant_context(constant, interface) for constant in interface
.constants] |
| 267 | 255 |
| 268 special_getter_constants = [] | 256 special_getter_constants = [] |
| (...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 return context | 1234 return context |
| 1247 | 1235 |
| 1248 | 1236 |
| 1249 def number_of_required_arguments(constructor): | 1237 def number_of_required_arguments(constructor): |
| 1250 return len([argument for argument in constructor.arguments | 1238 return len([argument for argument in constructor.arguments |
| 1251 if not argument.is_optional]) | 1239 if not argument.is_optional]) |
| 1252 | 1240 |
| 1253 | 1241 |
| 1254 def interface_length(interface, constructors): | 1242 def interface_length(interface, constructors): |
| 1255 # Docs: http://heycam.github.io/webidl/#es-interface-call | 1243 # Docs: http://heycam.github.io/webidl/#es-interface-call |
| 1256 if 'EventConstructor' in interface.extended_attributes: | |
| 1257 return 1 | |
| 1258 if not constructors: | 1244 if not constructors: |
| 1259 return 0 | 1245 return 0 |
| 1260 return min(constructor['number_of_required_arguments'] | 1246 return min(constructor['number_of_required_arguments'] |
| 1261 for constructor in constructors) | 1247 for constructor in constructors) |
| 1262 | 1248 |
| 1263 | 1249 |
| 1264 ################################################################################ | 1250 ################################################################################ |
| 1265 # Special operations (methods) | 1251 # Special operations (methods) |
| 1266 # http://heycam.github.io/webidl/#idl-special-operations | 1252 # http://heycam.github.io/webidl/#idl-special-operations |
| 1267 ################################################################################ | 1253 ################################################################################ |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1358 | 1344 |
| 1359 extended_attributes = deleter.extended_attributes | 1345 extended_attributes = deleter.extended_attributes |
| 1360 idl_type = deleter.idl_type | 1346 idl_type = deleter.idl_type |
| 1361 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete
r, 'CallWith', 'ScriptState') | 1347 is_call_with_script_state = v8_utilities.has_extended_attribute_value(delete
r, 'CallWith', 'ScriptState') |
| 1362 return { | 1348 return { |
| 1363 'is_call_with_script_state': is_call_with_script_state, | 1349 'is_call_with_script_state': is_call_with_script_state, |
| 1364 'is_custom': 'Custom' in extended_attributes, | 1350 'is_custom': 'Custom' in extended_attributes, |
| 1365 'is_raises_exception': 'RaisesException' in extended_attributes, | 1351 'is_raises_exception': 'RaisesException' in extended_attributes, |
| 1366 'name': cpp_name(deleter), | 1352 'name': cpp_name(deleter), |
| 1367 } | 1353 } |
| OLD | NEW |