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

Side by Side Diff: third_party/WebKit/Source/bindings/scripts/v8_dictionary.py

Issue 2587383002: Add [PrefixGet] extended attribute (Closed)
Patch Set: Created 3 years, 12 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
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Generate template contexts of dictionaries for both v8 bindings and 5 """Generate template contexts of dictionaries for both v8 bindings and
6 implementation classes that are used by blink's core/modules. 6 implementation classes that are used by blink's core/modules.
7 """ 7 """
8 8
9 import operator 9 import operator
10 from idl_types import IdlType 10 from idl_types import IdlType
11 from v8_globals import includes 11 from v8_globals import includes
12 import v8_types 12 import v8_types
13 import v8_utilities 13 import v8_utilities
14 from v8_utilities import has_extended_attribute_value 14 from v8_utilities import has_extended_attribute_value
15 15
16 16
17 DICTIONARY_H_INCLUDES = frozenset([ 17 DICTIONARY_H_INCLUDES = frozenset([
18 'bindings/core/v8/ToV8.h', 18 'bindings/core/v8/ToV8.h',
19 'bindings/core/v8/V8Binding.h', 19 'bindings/core/v8/V8Binding.h',
20 'platform/heap/Handle.h', 20 'platform/heap/Handle.h',
21 ]) 21 ])
22 22
23 DICTIONARY_CPP_INCLUDES = frozenset([ 23 DICTIONARY_CPP_INCLUDES = frozenset([
24 'bindings/core/v8/ExceptionState.h', 24 'bindings/core/v8/ExceptionState.h',
25 ]) 25 ])
26 26
27 27
28 def getter_name_for_dictionary_member(member):
29 name = v8_utilities.cpp_name(member)
30 if 'PrefixGet' in member.extended_attributes:
31 return 'get%s' % v8_utilities.capitalize(name)
32 return name
33
34
28 def setter_name_for_dictionary_member(member): 35 def setter_name_for_dictionary_member(member):
29 name = v8_utilities.cpp_name(member) 36 name = v8_utilities.cpp_name(member)
30 return 'set%s' % v8_utilities.capitalize(name) 37 return 'set%s' % v8_utilities.capitalize(name)
31 38
32 39
33 def null_setter_name_for_dictionary_member(member): 40 def null_setter_name_for_dictionary_member(member):
34 if member.idl_type.is_nullable: 41 if member.idl_type.is_nullable:
35 name = v8_utilities.cpp_name(member) 42 name = v8_utilities.cpp_name(member)
36 return 'set%sToNull' % v8_utilities.capitalize(name) 43 return 'set%sToNull' % v8_utilities.capitalize(name)
37 return None 44 return None
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 return None, 'v8::Null(isolate)' 114 return None, 'v8::Null(isolate)'
108 cpp_default_value = unwrapped_idl_type.literal_cpp_value( 115 cpp_default_value = unwrapped_idl_type.literal_cpp_value(
109 member.default_value) 116 member.default_value)
110 v8_default_value = unwrapped_idl_type.cpp_value_to_v8_value( 117 v8_default_value = unwrapped_idl_type.cpp_value_to_v8_value(
111 cpp_value=cpp_default_value, isolate='isolate', 118 cpp_value=cpp_default_value, isolate='isolate',
112 creation_context='creationContext') 119 creation_context='creationContext')
113 return cpp_default_value, v8_default_value 120 return cpp_default_value, v8_default_value
114 121
115 cpp_default_value, v8_default_value = default_values() 122 cpp_default_value, v8_default_value = default_values()
116 cpp_name = v8_utilities.cpp_name(member) 123 cpp_name = v8_utilities.cpp_name(member)
124 getter_name = getter_name_for_dictionary_member(member)
117 is_deprecated_dictionary = unwrapped_idl_type.name == 'Dictionary' 125 is_deprecated_dictionary = unwrapped_idl_type.name == 'Dictionary'
118 126
119 return { 127 return {
120 'cpp_default_value': cpp_default_value, 128 'cpp_default_value': cpp_default_value,
121 'cpp_name': cpp_name, 129 'cpp_name': cpp_name,
122 'cpp_type': unwrapped_idl_type.cpp_type, 130 'cpp_type': unwrapped_idl_type.cpp_type,
123 'cpp_value_to_v8_value': unwrapped_idl_type.cpp_value_to_v8_value( 131 'cpp_value_to_v8_value': unwrapped_idl_type.cpp_value_to_v8_value(
124 cpp_value='impl.%s()' % cpp_name, isolate='isolate', 132 cpp_value='impl.%s()' % getter_name, isolate='isolate',
125 creation_context='creationContext', 133 creation_context='creationContext',
126 extended_attributes=extended_attributes), 134 extended_attributes=extended_attributes),
127 'deprecate_as': v8_utilities.deprecate_as(member), 135 'deprecate_as': v8_utilities.deprecate_as(member),
128 'enum_type': idl_type.enum_type, 136 'enum_type': idl_type.enum_type,
129 'enum_values': unwrapped_idl_type.enum_values, 137 'enum_values': unwrapped_idl_type.enum_values,
138 'getter_name': getter_name,
130 'has_method_name': has_method_name_for_dictionary_member(member), 139 'has_method_name': has_method_name_for_dictionary_member(member),
131 'idl_type': idl_type.base_type, 140 'idl_type': idl_type.base_type,
132 'is_interface_type': idl_type.is_interface_type and not is_deprecated_di ctionary, 141 'is_interface_type': idl_type.is_interface_type and not is_deprecated_di ctionary,
133 'is_nullable': idl_type.is_nullable, 142 'is_nullable': idl_type.is_nullable,
134 'is_object': unwrapped_idl_type.name == 'Object' or is_deprecated_dictio nary, 143 'is_object': unwrapped_idl_type.name == 'Object' or is_deprecated_dictio nary,
135 'is_required': member.is_required, 144 'is_required': member.is_required,
136 'name': member.name, 145 'name': member.name,
137 'runtime_enabled_feature_name': v8_utilities.runtime_enabled_feature_nam e(member), # [RuntimeEnabled] 146 'runtime_enabled_feature_name': v8_utilities.runtime_enabled_feature_nam e(member), # [RuntimeEnabled]
138 'setter_name': setter_name_for_dictionary_member(member), 147 'setter_name': setter_name_for_dictionary_member(member),
139 'null_setter_name': null_setter_name_for_dictionary_member(member), 148 'null_setter_name': null_setter_name_for_dictionary_member(member),
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 if forward_decl_name: 225 if forward_decl_name:
217 includes.update(idl_type.impl_includes_for_type(interfaces_info)) 226 includes.update(idl_type.impl_includes_for_type(interfaces_info))
218 header_forward_decls.add(forward_decl_name) 227 header_forward_decls.add(forward_decl_name)
219 else: 228 else:
220 header_includes.update(idl_type.impl_includes_for_type(interfaces_info)) 229 header_includes.update(idl_type.impl_includes_for_type(interfaces_info))
221 230
222 return { 231 return {
223 'cpp_default_value': cpp_default_value, 232 'cpp_default_value': cpp_default_value,
224 'cpp_name': cpp_name, 233 'cpp_name': cpp_name,
225 'getter_expression': 'm_' + cpp_name, 234 'getter_expression': 'm_' + cpp_name,
235 'getter_name': getter_name_for_dictionary_member(member),
226 'has_method_expression': has_method_expression(), 236 'has_method_expression': has_method_expression(),
227 'has_method_name': has_method_name_for_dictionary_member(member), 237 'has_method_name': has_method_name_for_dictionary_member(member),
228 'is_nullable': idl_type.is_nullable, 238 'is_nullable': idl_type.is_nullable,
229 'is_traceable': idl_type.is_traceable, 239 'is_traceable': idl_type.is_traceable,
230 'member_cpp_type': idl_type.cpp_type_args(used_in_cpp_sequence=True), 240 'member_cpp_type': idl_type.cpp_type_args(used_in_cpp_sequence=True),
231 'null_setter_name': null_setter_name_for_dictionary_member(member), 241 'null_setter_name': null_setter_name_for_dictionary_member(member),
232 'nullable_indicator_name': nullable_indicator_name, 242 'nullable_indicator_name': nullable_indicator_name,
233 'rvalue_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True), 243 'rvalue_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True),
234 'setter_name': setter_name_for_dictionary_member(member), 244 'setter_name': setter_name_for_dictionary_member(member),
235 } 245 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698