Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / scripts / v8_attributes.py
index b16b5b7..1ce5249 100644 (file)
@@ -38,7 +38,7 @@ from idl_types import inherits_interface
 from v8_globals import includes, interfaces
 import v8_types
 import v8_utilities
-from v8_utilities import capitalize, cpp_name, has_extended_attribute, scoped_name, strip_suffix, uncapitalize
+from v8_utilities import capitalize, cpp_name, has_extended_attribute, has_extended_attribute_value, scoped_name, strip_suffix, uncapitalize
 
 
 def generate_attribute(interface, attribute):
@@ -63,15 +63,26 @@ def generate_attribute(interface, attribute):
     is_reflect = 'Reflect' in extended_attributes
     if is_custom_element_callbacks or is_reflect:
         includes.add('core/dom/custom/CustomElementCallbackDispatcher.h')
+    # [PerWorldBindings]
+    if 'PerWorldBindings' in extended_attributes:
+        assert idl_type.is_wrapper_type or 'LogActivity' in extended_attributes, '[PerWorldBindings] should only be used with wrapper types: %s.%s' % (interface.name, attribute.name)
     # [RaisesException], [RaisesException=Setter]
     is_setter_raises_exception = (
         'RaisesException' in extended_attributes and
         extended_attributes['RaisesException'] in [None, 'Setter'])
-    # [StrictTypeChecking]
-    has_strict_type_checking = (
-        ('StrictTypeChecking' in extended_attributes or
-         'StrictTypeChecking' in interface.extended_attributes) and
+    # [TypeChecking]
+    has_type_checking_interface = (
+        (has_extended_attribute_value(interface, 'TypeChecking', 'Interface') or
+         has_extended_attribute_value(attribute, 'TypeChecking', 'Interface')) and
         idl_type.is_wrapper_type)
+    has_type_checking_nullable = (
+        (has_extended_attribute_value(interface, 'TypeChecking', 'Nullable') or
+         has_extended_attribute_value(attribute, 'TypeChecking', 'Nullable')) and
+         idl_type.is_wrapper_type)
+    has_type_checking_unrestricted = (
+        (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestricted') or
+         has_extended_attribute_value(attribute, 'TypeChecking', 'Unrestricted')) and
+         idl_type.name in ('Float', 'Double'))
 
     if (base_idl_type == 'EventHandler' and
         interface.name in ['Window', 'WorkerGlobalScope'] and
@@ -82,39 +93,46 @@ def generate_attribute(interface, attribute):
         'access_control_list': access_control_list(attribute),
         'activity_logging_world_list_for_getter': v8_utilities.activity_logging_world_list(attribute, 'Getter'),  # [ActivityLogging]
         'activity_logging_world_list_for_setter': v8_utilities.activity_logging_world_list(attribute, 'Setter'),  # [ActivityLogging]
+        'activity_logging_include_old_value_for_setter': 'LogPreviousValue' in extended_attributes,  # [ActivityLogging]
         'cached_attribute_validation_method': extended_attributes.get('CachedAttribute'),
         'conditional_string': v8_utilities.conditional_string(attribute),
         'constructor_type': idl_type.constructor_type_name
                             if is_constructor_attribute(attribute) else None,
         'cpp_name': cpp_name(attribute),
         'cpp_type': idl_type.cpp_type,
+        'cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(cpp_value='original', creation_context='info.Holder()'),
         'deprecate_as': v8_utilities.deprecate_as(attribute),  # [DeprecateAs]
         'enum_validation_expression': idl_type.enum_validation_expression,
         'has_custom_getter': has_custom_getter,
         'has_custom_setter': has_custom_setter,
-        'has_strict_type_checking': has_strict_type_checking,
+        'has_setter_exception_state':
+            is_setter_raises_exception or has_type_checking_interface or
+            has_type_checking_nullable or has_type_checking_unrestricted or
+            idl_type.is_integer_type,
+        'has_type_checking_interface': has_type_checking_interface,
+        'has_type_checking_nullable': has_type_checking_nullable,
+        'has_type_checking_unrestricted': has_type_checking_unrestricted,
         'idl_type': str(idl_type),  # need trailing [] on array for Dictionary::ConversionContext::setConversionType
         'is_call_with_execution_context': v8_utilities.has_extended_attribute_value(attribute, 'CallWith', 'ExecutionContext'),
+        'is_call_with_script_state': v8_utilities.has_extended_attribute_value(attribute, 'CallWith', 'ScriptState'),
         'is_check_security_for_node': is_check_security_for_node,
         'is_custom_element_callbacks': is_custom_element_callbacks,
         'is_expose_js_accessors': 'ExposeJSAccessors' in extended_attributes,
-        'is_getter_raises_exception':  # [RaisesException]
+        'is_getter_raises_exception':  # [RaisesException]
             'RaisesException' in extended_attributes and
-            extended_attributes['RaisesException'] in [None, 'Getter']),
-        'is_implemented_by': 'ImplementedBy' in extended_attributes,
+            extended_attributes['RaisesException'] in (None, 'Getter'),
         'is_initialized_by_event_constructor':
             'InitializedByEventConstructor' in extended_attributes,
         'is_keep_alive_for_gc': is_keep_alive_for_gc(interface, attribute),
         'is_nullable': attribute.idl_type.is_nullable,
+        'is_partial_interface_member':
+            'PartialInterfaceImplementedAs' in extended_attributes,
         'is_per_world_bindings': 'PerWorldBindings' in extended_attributes,
         'is_read_only': attribute.is_read_only,
         'is_reflect': is_reflect,
         'is_replaceable': 'Replaceable' in attribute.extended_attributes,
         'is_setter_call_with_execution_context': v8_utilities.has_extended_attribute_value(attribute, 'SetterCallWith', 'ExecutionContext'),
         'is_setter_raises_exception': is_setter_raises_exception,
-        'has_setter_exception_state': (
-            is_setter_raises_exception or has_strict_type_checking or
-            idl_type.is_integer_type),
         'is_static': attribute.is_static,
         'is_url': 'URL' in extended_attributes,
         'is_unforgeable': 'Unforgeable' in extended_attributes,
@@ -123,7 +141,6 @@ def generate_attribute(interface, attribute):
         'per_context_enabled_function': v8_utilities.per_context_enabled_function_name(attribute),  # [PerContextEnabled]
         'property_attributes': property_attributes(attribute),
         'put_forwards': 'PutForwards' in extended_attributes,
-        'ref_ptr': 'RefPtrWillBeRawPtr' if idl_type.is_will_be_garbage_collected else 'RefPtr',
         'reflect_empty': extended_attributes.get('ReflectEmpty'),
         'reflect_invalid': extended_attributes.get('ReflectInvalid', ''),
         'reflect_missing': extended_attributes.get('ReflectMissing'),
@@ -195,10 +212,13 @@ def getter_expression(interface, attribute, contents):
     getter_name = scoped_name(interface, attribute, this_getter_base_name)
 
     arguments.extend(v8_utilities.call_with_arguments(attribute))
-    if ('ImplementedBy' in attribute.extended_attributes and
+    # Members of IDL partial interface definitions are implemented in C++ as
+    # static member functions, which for instance members (non-static members)
+    # take *impl as their first argument
+    if ('PartialInterfaceImplementedAs' in attribute.extended_attributes and
         not attribute.is_static):
         arguments.append('*impl')
-    if attribute.idl_type.is_nullable:
+    if attribute.idl_type.is_nullable and not contents['has_type_checking_nullable']:
         arguments.append('isNull')
     if contents['is_getter_raises_exception']:
         arguments.append('exceptionState')
@@ -291,7 +311,10 @@ def setter_expression(interface, attribute, contents):
     this_setter_base_name = setter_base_name(interface, attribute, arguments)
     setter_name = scoped_name(interface, attribute, this_setter_base_name)
 
-    if ('ImplementedBy' in extended_attributes and
+    # Members of IDL partial interface definitions are implemented in C++ as
+    # static member functions, which for instance members (non-static members)
+    # take *impl as their first argument
+    if ('PartialInterfaceImplementedAs' in extended_attributes and
         not attribute.is_static):
         arguments.append('*impl')
     idl_type = attribute.idl_type