Chromium Code Reviews| Index: Source/bindings/scripts/v8_attributes.py |
| diff --git a/Source/bindings/scripts/v8_attributes.py b/Source/bindings/scripts/v8_attributes.py |
| index e1c6489078fe98ad7a45cc33c0cbaceb9e01c335..1a4fcc6d6629838e6d1df99d92f4394c50fcf130 100644 |
| --- a/Source/bindings/scripts/v8_attributes.py |
| +++ b/Source/bindings/scripts/v8_attributes.py |
| @@ -71,6 +71,11 @@ def attribute_context(interface, attribute): |
| (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestricted') or |
| has_extended_attribute_value(attribute, 'TypeChecking', 'Unrestricted')) and |
| idl_type.name in ('Float', 'Double')) |
| + # [ImplementedInPrivateScript] |
| + is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_attributes |
| + if is_implemented_in_private_script: |
| + includes.add('bindings/core/v8/PrivateScriptRunner.h') |
| + includes.add('core/frame/LocalFrame.h') |
| if (base_idl_type == 'EventHandler' and |
| interface.name in ['Window', 'WorkerGlobalScope'] and |
| @@ -108,6 +113,7 @@ def attribute_context(interface, attribute): |
| 'is_getter_raises_exception': # [RaisesException] |
| 'RaisesException' in extended_attributes and |
| extended_attributes['RaisesException'] in (None, 'Getter'), |
| + 'is_implemented_in_private_script': is_implemented_in_private_script, |
| 'is_initialized_by_event_constructor': |
| 'InitializedByEventConstructor' in extended_attributes, |
| 'is_keep_alive_for_gc': is_keep_alive_for_gc(interface, attribute), |
| @@ -125,16 +131,19 @@ def attribute_context(interface, attribute): |
| 'measure_as': v8_utilities.measure_as(attribute), # [MeasureAs] |
| 'name': attribute.name, |
| 'per_context_enabled_function': v8_utilities.per_context_enabled_function_name(attribute), # [PerContextEnabled] |
| + 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value( |
| + extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->isolate()', used_in_private_script=True), |
| 'property_attributes': property_attributes(attribute), |
| 'put_forwards': 'PutForwards' in extended_attributes, |
| + 'argument_cpp_type': idl_type.cpp_type_args(used_as_argument=True), |
|
Jens Widell
2014/07/03 11:33:14
Alphabetical order. :-)
haraken
2014/07/03 11:56:09
Done.
|
| 'reflect_empty': extended_attributes.get('ReflectEmpty'), |
| 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), |
| 'reflect_missing': extended_attributes.get('ReflectMissing'), |
| 'reflect_only': extended_attributes['ReflectOnly'].split('|') |
| if 'ReflectOnly' in extended_attributes else None, |
| + 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(attribute), # [RuntimeEnabled] |
| 'setter_callback': setter_callback_name(interface, attribute), |
| 'v8_type': v8_types.v8_type(base_idl_type), |
| - 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(attribute), # [RuntimeEnabled] |
| 'world_suffixes': ['', 'ForMainWorld'] |
| if 'PerWorldBindings' in extended_attributes |
| else [''], # [PerWorldBindings] |
| @@ -179,8 +188,19 @@ def getter_context(interface, attribute, context): |
| context['cpp_value_original'] = cpp_value |
| cpp_value = 'cppValue' |
| # EventHandler has special handling |
| - if base_idl_type != 'EventHandler' and idl_type.is_interface_type: |
| - release = True |
| + if base_idl_type != 'EventHandler': |
| + release = idl_type.release |
| + |
| + if 'ImplementedInPrivateScript' in extended_attributes: |
|
Jens Widell
2014/07/03 11:33:14
Both this branch and the one before it pushes cpp_
haraken
2014/07/03 11:56:09
Yes, changed it to elif.
|
| + if (not idl_type.is_wrapper_type and |
| + not idl_type.is_basic_type): |
| + raise Exception('Private scripts supports only primitive types and DOM wrappers.') |
| + |
| + context['cpp_value_original'] = cpp_value |
| + cpp_value = 'result' |
| + # EventHandler has special handling |
| + if base_idl_type != 'EventHandler': |
| + release = idl_type.release |
| def v8_set_return_value_statement(for_main_world=False): |
| if context['is_keep_alive_for_gc']: |
| @@ -202,6 +222,10 @@ def getter_expression(interface, attribute, context): |
| this_getter_base_name = getter_base_name(interface, attribute, arguments) |
| getter_name = scoped_name(interface, attribute, this_getter_base_name) |
| + if 'ImplementedInPrivateScript' in attribute.extended_attributes: |
| + arguments.append('toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())') |
| + arguments.append('impl') |
| + arguments.append('&result') |
| arguments.extend(v8_utilities.call_with_arguments( |
| attribute.extended_attributes.get('CallWith'))) |
| # Members of IDL partial interface definitions are implemented in C++ as |
| @@ -226,6 +250,10 @@ CONTENT_ATTRIBUTE_GETTER_NAMES = { |
| def getter_base_name(interface, attribute, arguments): |
| extended_attributes = attribute.extended_attributes |
| + |
| + if 'ImplementedInPrivateScript' in extended_attributes: |
| + return '%sAttributeGetterImplementedInPrivateScript' % uncapitalize(cpp_name(attribute)) |
| + |
| if 'Reflect' not in extended_attributes: |
| return uncapitalize(cpp_name(attribute)) |
| @@ -310,6 +338,9 @@ def setter_context(interface, attribute, context): |
| 'is_setter_raises_exception': is_setter_raises_exception, |
| 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value( |
| extended_attributes, 'v8Value', 'cppValue'), |
| + 'cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( |
|
Jens Widell
2014/07/03 11:33:14
This is set to a different value in getter_context
haraken
2014/07/03 11:56:09
Nice catch, renamed it to private_script_cpp_value
|
| + 'cppValue', isolate='scriptState->isolate()', |
| + creation_context='scriptState->context()->Global()'), |
| }) |
| # setter_expression() depends on context values we set above. |
| @@ -332,7 +363,11 @@ def setter_expression(interface, attribute, context): |
| not attribute.is_static): |
| arguments.append('*impl') |
| idl_type = attribute.idl_type |
| - if idl_type.base_type == 'EventHandler': |
| + if 'ImplementedInPrivateScript' in extended_attributes: |
| + arguments.append('toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())') |
| + arguments.append('impl') |
| + arguments.append('cppValue') |
| + elif idl_type.base_type == 'EventHandler': |
| getter_name = scoped_name(interface, attribute, cpp_name(attribute)) |
| context['event_handler_getter_expression'] = '%s(%s)' % ( |
| getter_name, ', '.join(arguments)) |
| @@ -361,6 +396,9 @@ CONTENT_ATTRIBUTE_SETTER_NAMES = { |
| def setter_base_name(interface, attribute, arguments): |
| + if 'ImplementedInPrivateScript' in attribute.extended_attributes: |
| + return '%sAttributeSetterImplementedInPrivateScript' % uncapitalize(cpp_name(attribute)) |
| + |
| if 'Reflect' not in attribute.extended_attributes: |
| return 'set%s' % capitalize(cpp_name(attribute)) |
| arguments.append(scoped_content_attribute_name(interface, attribute)) |