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

Side by Side Diff: bindings/scripts/v8_attributes.py

Issue 959933002: Move IDLs to 39 roll (Closed) Base URL: https://dart.googlecode.com/svn/third_party/WebCore
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « bindings/scripts/utilities.py ('k') | bindings/scripts/v8_dictionary.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 20 matching lines...) Expand all
31 Extends IdlType with property |constructor_type_name|. 31 Extends IdlType with property |constructor_type_name|.
32 32
33 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler 33 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler
34 """ 34 """
35 35
36 import idl_types 36 import idl_types
37 from idl_types import inherits_interface 37 from idl_types import inherits_interface
38 from v8_globals import includes, interfaces 38 from v8_globals import includes, interfaces
39 import v8_types 39 import v8_types
40 import v8_utilities 40 import v8_utilities
41 from v8_utilities import capitalize, cpp_name, has_extended_attribute, has_exten ded_attribute_value, scoped_name, strip_suffix, uncapitalize 41 from v8_utilities import (capitalize, cpp_name, has_extended_attribute,
42 has_extended_attribute_value, scoped_name, strip_suffi x,
43 uncapitalize, extended_attribute_value_as_list)
42 44
43 45
44 def attribute_context(interface, attribute): 46 def attribute_context(interface, attribute):
45 idl_type = attribute.idl_type 47 idl_type = attribute.idl_type
46 base_idl_type = idl_type.base_type 48 base_idl_type = idl_type.base_type
47 extended_attributes = attribute.extended_attributes 49 extended_attributes = attribute.extended_attributes
48 50
49 idl_type.add_includes_for_type() 51 idl_type.add_includes_for_type()
50 52
51 # [CheckSecurity] 53 # [CheckSecurity]
52 is_check_security_for_node = 'CheckSecurity' in extended_attributes 54 is_check_security_for_node = 'CheckSecurity' in extended_attributes
53 if is_check_security_for_node: 55 if is_check_security_for_node:
54 includes.add('bindings/common/BindingSecurity.h') 56 includes.add('bindings/common/BindingSecurity.h')
55 # [CustomElementCallbacks], [Reflect] 57 # [CustomElementCallbacks], [Reflect]
56 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute s 58 is_custom_element_callbacks = 'CustomElementCallbacks' in extended_attribute s
57 is_reflect = 'Reflect' in extended_attributes 59 is_reflect = 'Reflect' in extended_attributes
58 if is_custom_element_callbacks or is_reflect: 60 if is_custom_element_callbacks or is_reflect:
59 includes.add('core/dom/custom/CustomElementCallbackDispatcher.h') 61 includes.add('core/dom/custom/CustomElementProcessingStack.h')
60 # [PerWorldBindings] 62 # [PerWorldBindings]
61 if 'PerWorldBindings' in extended_attributes: 63 if 'PerWorldBindings' in extended_attributes:
62 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) 64 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)
63 # [TypeChecking] 65 # [TypeChecking]
64 has_type_checking_unrestricted = ( 66 has_type_checking_unrestricted = (
65 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestricted') or 67 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestricted') or
66 has_extended_attribute_value(attribute, 'TypeChecking', 'Unrestricted') ) and 68 has_extended_attribute_value(attribute, 'TypeChecking', 'Unrestricted') ) and
67 idl_type.name in ('Float', 'Double')) 69 idl_type.name in ('Float', 'Double'))
68 # [ImplementedInPrivateScript] 70 # [ImplementedInPrivateScript]
69 is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_ attributes 71 is_implemented_in_private_script = 'ImplementedInPrivateScript' in extended_ attributes
70 if is_implemented_in_private_script: 72 if is_implemented_in_private_script:
71 includes.add('bindings/core/v8/PrivateScriptRunner.h') 73 includes.add('bindings/core/v8/PrivateScriptRunner.h')
72 includes.add('core/frame/LocalFrame.h') 74 includes.add('core/frame/LocalFrame.h')
73 includes.add('platform/ScriptForbiddenScope.h') 75 includes.add('platform/ScriptForbiddenScope.h')
74 76
75 # [OnlyExposedToPrivateScript] 77 # [OnlyExposedToPrivateScript]
76 is_only_exposed_to_private_script = 'OnlyExposedToPrivateScript' in extended _attributes 78 is_only_exposed_to_private_script = 'OnlyExposedToPrivateScript' in extended _attributes
77 79
78 if (base_idl_type == 'EventHandler' and 80 if (base_idl_type == 'EventHandler' and
79 interface.name in ['Window', 'WorkerGlobalScope'] and 81 interface.name in ['Window', 'WorkerGlobalScope'] and
80 attribute.name == 'onerror'): 82 attribute.name == 'onerror'):
81 includes.add('bindings/core/v8/V8ErrorHandler.h') 83 includes.add('bindings/core/v8/V8ErrorHandler.h')
82 84
83 context = { 85 context = {
84 'access_control_list': access_control_list(attribute), 86 'access_control_list': access_control_list(attribute),
85 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_ world_list(attribute, 'Getter'), # [ActivityLogging] 87 'activity_logging_world_list_for_getter': v8_utilities.activity_logging_ world_list(attribute, 'Getter'), # [ActivityLogging]
86 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_ world_list(attribute, 'Setter'), # [ActivityLogging] 88 'activity_logging_world_list_for_setter': v8_utilities.activity_logging_ world_list(attribute, 'Setter'), # [ActivityLogging]
87 'activity_logging_include_old_value_for_setter': 'LogPreviousValue' in e xtended_attributes, # [ActivityLogging]
88 'activity_logging_world_check': v8_utilities.activity_logging_world_chec k(attribute), # [ActivityLogging] 89 'activity_logging_world_check': v8_utilities.activity_logging_world_chec k(attribute), # [ActivityLogging]
89 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), 90 'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True),
90 'cached_attribute_validation_method': extended_attributes.get('CachedAtt ribute'), 91 'cached_attribute_validation_method': extended_attributes.get('CachedAtt ribute'),
91 'conditional_string': v8_utilities.conditional_string(attribute), 92 'conditional_string': v8_utilities.conditional_string(attribute),
92 'constructor_type': idl_type.constructor_type_name 93 'constructor_type': idl_type.constructor_type_name
93 if is_constructor_attribute(attribute) else None, 94 if is_constructor_attribute(attribute) else None,
94 'cpp_name': cpp_name(attribute), 95 'cpp_name': cpp_name(attribute),
95 'cpp_type': idl_type.cpp_type, 96 'cpp_type': idl_type.cpp_type,
96 'cpp_type_initializer': idl_type.cpp_type_initializer, 97 'cpp_type_initializer': idl_type.cpp_type_initializer,
97 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs] 98 'deprecate_as': v8_utilities.deprecate_as(attribute), # [DeprecateAs]
(...skipping 30 matching lines...) Expand all
128 'name': attribute.name, 129 'name': attribute.name,
129 'only_exposed_to_private_script': is_only_exposed_to_private_script, 130 'only_exposed_to_private_script': is_only_exposed_to_private_script,
130 'per_context_enabled_function': v8_utilities.per_context_enabled_functio n_name(attribute), # [PerContextEnabled] 131 'per_context_enabled_function': v8_utilities.per_context_enabled_functio n_name(attribute), # [PerContextEnabled]
131 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local _cpp_value( 132 'private_script_v8_value_to_local_cpp_value': idl_type.v8_value_to_local _cpp_value(
132 extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->is olate()', used_in_private_script=True), 133 extended_attributes, 'v8Value', 'cppValue', isolate='scriptState->is olate()', used_in_private_script=True),
133 'property_attributes': property_attributes(attribute), 134 'property_attributes': property_attributes(attribute),
134 'put_forwards': 'PutForwards' in extended_attributes, 135 'put_forwards': 'PutForwards' in extended_attributes,
135 'reflect_empty': extended_attributes.get('ReflectEmpty'), 136 'reflect_empty': extended_attributes.get('ReflectEmpty'),
136 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''), 137 'reflect_invalid': extended_attributes.get('ReflectInvalid', ''),
137 'reflect_missing': extended_attributes.get('ReflectMissing'), 138 'reflect_missing': extended_attributes.get('ReflectMissing'),
138 'reflect_only': extended_attributes['ReflectOnly'].split('|') 139 'reflect_only': extended_attribute_value_as_list(attribute, 'ReflectOnly '),
139 if 'ReflectOnly' in extended_attributes else None,
140 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a ttribute), # [RuntimeEnabled] 140 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(a ttribute), # [RuntimeEnabled]
141 'setter_callback': setter_callback_name(interface, attribute), 141 'setter_callback': setter_callback_name(interface, attribute),
142 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script), 142 'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script),
143 'world_suffixes': ['', 'ForMainWorld'] 143 'world_suffixes': ['', 'ForMainWorld']
144 if 'PerWorldBindings' in extended_attributes 144 if 'PerWorldBindings' in extended_attributes
145 else [''], # [PerWorldBindings] 145 else [''], # [PerWorldBindings]
146 } 146 }
147 147
148 if is_constructor_attribute(attribute): 148 if is_constructor_attribute(attribute):
149 constructor_getter_context(interface, attribute, context) 149 constructor_getter_context(interface, attribute, context)
(...skipping 19 matching lines...) Expand all
169 cpp_value = getter_expression(interface, attribute, context) 169 cpp_value = getter_expression(interface, attribute, context)
170 # Normally we can inline the function call into the return statement to 170 # Normally we can inline the function call into the return statement to
171 # avoid the overhead of using a Ref<> temporary, but for some cases 171 # avoid the overhead of using a Ref<> temporary, but for some cases
172 # (nullable types, EventHandler, [CachedAttribute], or if there are 172 # (nullable types, EventHandler, [CachedAttribute], or if there are
173 # exceptions), we need to use a local variable. 173 # exceptions), we need to use a local variable.
174 # FIXME: check if compilers are smart enough to inline this, and if so, 174 # FIXME: check if compilers are smart enough to inline this, and if so,
175 # always use a local variable (for readability and CG simplicity). 175 # always use a local variable (for readability and CG simplicity).
176 release = False 176 release = False
177 if 'ImplementedInPrivateScript' in extended_attributes: 177 if 'ImplementedInPrivateScript' in extended_attributes:
178 if (not idl_type.is_wrapper_type and 178 if (not idl_type.is_wrapper_type and
179 not idl_type.is_basic_type): 179 not idl_type.is_basic_type and
180 not idl_type.is_enum):
180 raise Exception('Private scripts supports only primitive types and D OM wrappers.') 181 raise Exception('Private scripts supports only primitive types and D OM wrappers.')
181 182
182 context['cpp_value_original'] = cpp_value 183 context['cpp_value_original'] = cpp_value
183 cpp_value = 'result' 184 cpp_value = 'result'
184 # EventHandler has special handling 185 # EventHandler has special handling
185 if base_idl_type != 'EventHandler': 186 if base_idl_type != 'EventHandler':
186 release = idl_type.release 187 release = idl_type.release
187 elif (idl_type.is_explicit_nullable or 188 elif (idl_type.is_explicit_nullable or
188 base_idl_type == 'EventHandler' or 189 base_idl_type == 'EventHandler' or
189 'CachedAttribute' in extended_attributes or 190 'CachedAttribute' in extended_attributes or
190 'LogPreviousValue' in extended_attributes or
191 'ReflectOnly' in extended_attributes or 191 'ReflectOnly' in extended_attributes or
192 context['is_keep_alive_for_gc'] or 192 context['is_keep_alive_for_gc'] or
193 context['is_getter_raises_exception']): 193 context['is_getter_raises_exception']):
194 context['cpp_value_original'] = cpp_value 194 context['cpp_value_original'] = cpp_value
195 cpp_value = 'cppValue' 195 cpp_value = 'cppValue'
196 # EventHandler has special handling 196 # EventHandler has special handling
197 if base_idl_type != 'EventHandler': 197 if base_idl_type != 'EventHandler':
198 release = idl_type.release 198 release = idl_type.release
199 199
200 def v8_set_return_value_statement(for_main_world=False): 200 def v8_set_return_value_statement(for_main_world=False):
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 # [TypeChecking=Interface] 320 # [TypeChecking=Interface]
321 has_type_checking_interface = ( 321 has_type_checking_interface = (
322 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface') or 322 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface') or
323 has_extended_attribute_value(attribute, 'TypeChecking', 'Interface')) a nd 323 has_extended_attribute_value(attribute, 'TypeChecking', 'Interface')) a nd
324 idl_type.is_wrapper_type) 324 idl_type.is_wrapper_type)
325 325
326 context.update({ 326 context.update({
327 'has_setter_exception_state': 327 'has_setter_exception_state':
328 is_setter_raises_exception or has_type_checking_interface or 328 is_setter_raises_exception or has_type_checking_interface or
329 context['has_type_checking_unrestricted'] or 329 context['has_type_checking_unrestricted'] or
330 idl_type.may_raise_exception_on_conversion, 330 idl_type.v8_conversion_needs_exception_state,
331 'has_type_checking_interface': has_type_checking_interface, 331 'has_type_checking_interface': has_type_checking_interface,
332 'is_setter_call_with_execution_context': v8_utilities.has_extended_attri bute_value( 332 'is_setter_call_with_execution_context': v8_utilities.has_extended_attri bute_value(
333 attribute, 'SetterCallWith', 'ExecutionContext'), 333 attribute, 'SetterCallWith', 'ExecutionContext'),
334 'is_setter_raises_exception': is_setter_raises_exception, 334 'is_setter_raises_exception': is_setter_raises_exception,
335 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( 335 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(
336 'cppValue', isolate='scriptState->isolate()', 336 'cppValue', isolate='scriptState->isolate()',
337 creation_context='scriptState->context()->Global()'), 337 creation_context='scriptState->context()->Global()'),
338 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value( 338 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value(
339 extended_attributes, 'v8Value', 'cppValue'), 339 extended_attributes, 'v8Value', 'cppValue'),
340 }) 340 })
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 lambda self: strip_suffix(self.base_type, 'Constructor')) 493 lambda self: strip_suffix(self.base_type, 'Constructor'))
494 494
495 495
496 def is_constructor_attribute(attribute): 496 def is_constructor_attribute(attribute):
497 # FIXME: replace this with [ConstructorAttribute] extended attribute 497 # FIXME: replace this with [ConstructorAttribute] extended attribute
498 return attribute.idl_type.name.endswith('Constructor') 498 return attribute.idl_type.name.endswith('Constructor')
499 499
500 500
501 def constructor_getter_context(interface, attribute, context): 501 def constructor_getter_context(interface, attribute, context):
502 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as'] 502 context['needs_constructor_getter_callback'] = context['measure_as'] or cont ext['deprecate_as']
OLDNEW
« no previous file with comments | « bindings/scripts/utilities.py ('k') | bindings/scripts/v8_dictionary.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698