OLD | NEW |
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 includes.update(['bindings/v8/Dictionary.h', | 107 includes.update(['bindings/v8/Dictionary.h', |
108 'bindings/v8/V8ObjectConstructor.h']) | 108 'bindings/v8/V8ObjectConstructor.h']) |
109 if any_type_attributes: | 109 if any_type_attributes: |
110 includes.add('bindings/v8/SerializedScriptValue.h') | 110 includes.add('bindings/v8/SerializedScriptValue.h') |
111 | 111 |
112 template_contents = { | 112 template_contents = { |
113 'any_type_attributes': any_type_attributes, | 113 'any_type_attributes': any_type_attributes, |
114 'conditional_string': conditional_string(interface), # [Conditional] | 114 'conditional_string': conditional_string(interface), # [Conditional] |
115 'constructor_argument_list': constructor_argument_list(interface), | 115 'constructor_argument_list': constructor_argument_list(interface), |
116 'constructor_arguments': constructor_arguments(interface), | 116 'constructor_arguments': constructor_arguments(interface), |
117 'constructor_method': {}, # stub for generating arguments | 117 'constructor_method': { |
| 118 'is_constructor': True, |
| 119 }, |
118 'cpp_class': cpp_name(interface), | 120 'cpp_class': cpp_name(interface), |
119 'generate_visit_dom_wrapper_function': generate_visit_dom_wrapper_functi
on, | 121 'generate_visit_dom_wrapper_function': generate_visit_dom_wrapper_functi
on, |
120 'has_constructor': has_constructor, | 122 'has_constructor': has_constructor, |
121 'has_custom_legacy_call_as_function': has_extended_attribute_value(inter
face, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction] | 123 'has_custom_legacy_call_as_function': has_extended_attribute_value(inter
face, 'Custom', 'LegacyCallAsFunction'), # [Custom=LegacyCallAsFunction] |
122 'has_custom_to_v8': has_extended_attribute_value(interface, 'Custom', 'T
oV8'), # [Custom=ToV8] | 124 'has_custom_to_v8': has_extended_attribute_value(interface, 'Custom', 'T
oV8'), # [Custom=ToV8] |
123 'has_custom_wrap': has_extended_attribute_value(interface, 'Custom', 'Wr
ap'), # [Custom=Wrap] | 125 'has_custom_wrap': has_extended_attribute_value(interface, 'Custom', 'Wr
ap'), # [Custom=Wrap] |
124 'has_event_constructor': has_event_constructor, | 126 'has_event_constructor': has_event_constructor, |
125 'has_visit_dom_wrapper': ( | 127 'has_visit_dom_wrapper': ( |
126 # [Custom=Wrap], [GenerateVisitDOMWrapper] | 128 # [Custom=Wrap], [GenerateVisitDOMWrapper] |
127 has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper')
or | 129 has_extended_attribute_value(interface, 'Custom', 'VisitDOMWrapper')
or |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 if interface.extended_attributes.get('RaisesException') == 'Constructor': | 334 if interface.extended_attributes.get('RaisesException') == 'Constructor': |
333 arguments.append('exceptionState') | 335 arguments.append('exceptionState') |
334 | 336 |
335 return arguments | 337 return arguments |
336 | 338 |
337 | 339 |
338 def constructor_arguments(interface): | 340 def constructor_arguments(interface): |
339 if not interface.constructors: | 341 if not interface.constructors: |
340 return [] | 342 return [] |
341 constructor = interface.constructors[0] # FIXME: support overloading | 343 constructor = interface.constructors[0] # FIXME: support overloading |
342 return [{'v8_value_to_local_cpp_value': | 344 return [constructor_argument(argument, index) |
343 v8_methods.v8_value_to_local_cpp_value(argument, index), | |
344 } | |
345 for index, argument in enumerate(constructor.arguments)] | 345 for index, argument in enumerate(constructor.arguments)] |
346 | 346 |
347 | 347 |
| 348 def constructor_argument(argument, index): |
| 349 return { |
| 350 'idl_type': argument.idl_type, |
| 351 'index': index, |
| 352 'name': argument.name, |
| 353 'v8_value_to_local_cpp_value': |
| 354 v8_methods.v8_value_to_local_cpp_value(argument, index), |
| 355 } |
| 356 |
| 357 |
348 def interface_length(interface): | 358 def interface_length(interface): |
349 # Docs: http://heycam.github.io/webidl/#es-interface-call | 359 # Docs: http://heycam.github.io/webidl/#es-interface-call |
350 if 'EventConstructor' in interface.extended_attributes: | 360 if 'EventConstructor' in interface.extended_attributes: |
351 return 1 | 361 return 1 |
352 if not interface.constructors: | 362 if not interface.constructors: |
353 return 0 | 363 return 0 |
354 constructor = interface.constructors[0] # FIXME: support overloading | 364 constructor = interface.constructors[0] # FIXME: support overloading |
355 return len(constructor.arguments) # FIXME: support optional arguments | 365 return len(constructor.arguments) # FIXME: support optional arguments |
OLD | NEW |