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: Source/bindings/scripts/unstable/v8_attributes.py

Issue 29153007: IDL compiler: [CallWith] for setters (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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 | « no previous file | Source/bindings/templates/attributes.cpp » ('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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 'activity_logging_getter': v8_utilities.has_activity_logging(attribute, includes, 'Getter'), # [ActivityLogging] 141 'activity_logging_getter': v8_utilities.has_activity_logging(attribute, includes, 'Getter'), # [ActivityLogging]
142 'is_check_security_for_node': is_check_security_for_node, 142 'is_check_security_for_node': is_check_security_for_node,
143 'is_getter_raises_exception': is_getter_raises_exception, 143 'is_getter_raises_exception': is_getter_raises_exception,
144 'is_unforgeable': 'Unforgeable' in extended_attributes, 144 'is_unforgeable': 'Unforgeable' in extended_attributes,
145 }) 145 })
146 146
147 # Setter 147 # Setter
148 if not has_setter: 148 if not has_setter:
149 return contents, includes 149 return contents, includes
150 150
151 if v8_types.interface_type(idl_type) and not v8_types.array_type(idl_type):
152 cpp_value = 'WTF::getPtr(cppValue)'
153 else:
154 cpp_value = 'cppValue'
155 contents.update({ 151 contents.update({
156 'v8_value_to_local_cpp_value': v8_types.v8_value_to_local_cpp_value(idl_ type, attribute.extended_attributes, 'jsValue', 'cppValue', includes, 'info.GetI solate()'), 152 'v8_value_to_local_cpp_value': v8_types.v8_value_to_local_cpp_value(idl_ type, attribute.extended_attributes, 'jsValue', 'cppValue', includes, 'info.GetI solate()'),
157 'cpp_setter': 'imp->set%s(%s)' % (capitalize(cpp_name(attribute)), cpp_v alue), 153 'cpp_setter': setter_expression(attribute, contents),
158 }) 154 })
159 155
160 return contents, includes 156 return contents, includes
161 157
162 158
163 def getter_expression(interface, attribute, contents, includes): 159 def getter_expression(interface, attribute, contents, includes):
164 arguments = [] 160 arguments = []
165 if 'Reflect' in attribute.extended_attributes: 161 if 'Reflect' in attribute.extended_attributes:
166 getter_base_name = content_attribute_getter_base_name(attribute, include s, arguments) 162 getter_base_name = content_attribute_getter_base_name(attribute, include s, arguments)
167 else: 163 else:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 arguments.append(scoped_name) 198 arguments.append(scoped_name)
203 199
204 idl_type = attribute.data_type 200 idl_type = attribute.data_type
205 if idl_type in CONTENT_ATTRIBUTE_GETTER_NAMES: 201 if idl_type in CONTENT_ATTRIBUTE_GETTER_NAMES:
206 return CONTENT_ATTRIBUTE_GETTER_NAMES[idl_type] 202 return CONTENT_ATTRIBUTE_GETTER_NAMES[idl_type]
207 if 'URL' in attribute.extended_attributes: 203 if 'URL' in attribute.extended_attributes:
208 return 'getURLAttribute' 204 return 'getURLAttribute'
209 return 'fastGetAttribute' 205 return 'fastGetAttribute'
210 206
211 207
208 def setter_expression(attribute, contents):
209 arguments = v8_utilities.call_with_arguments(attribute, contents)
210 idl_type = attribute.data_type
211 # FIXME: should be able to eliminate WTF::getPtr in most or all cases
212 cpp_value = 'WTF::getPtr(cppValue)' if v8_types.interface_type(idl_type) and not v8_types.array_type(idl_type) else 'cppValue'
213 arguments.append(cpp_value)
214 return 'imp->set%s(%s)' % (capitalize(cpp_name(attribute)), ', '.join(argume nts))
215
216
212 def is_keep_alive_for_gc(attribute): 217 def is_keep_alive_for_gc(attribute):
213 idl_type = attribute.data_type 218 idl_type = attribute.data_type
214 extended_attributes = attribute.extended_attributes 219 extended_attributes = attribute.extended_attributes
215 return ( 220 return (
216 'KeepAttributeAliveForGC' in extended_attributes or 221 'KeepAttributeAliveForGC' in extended_attributes or
217 # For readonly attributes, for performance reasons we keep the attribute 222 # For readonly attributes, for performance reasons we keep the attribute
218 # wrapper alive while the owner wrapper is alive, because the attribute 223 # wrapper alive while the owner wrapper is alive, because the attribute
219 # never changes. 224 # never changes.
220 (attribute.is_read_only and 225 (attribute.is_read_only and
221 v8_types.wrapper_type(idl_type) and 226 v8_types.wrapper_type(idl_type) and
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 if 'PerWorldBindings' not in attribute.extended_attributes: 278 if 'PerWorldBindings' not in attribute.extended_attributes:
274 return '0' 279 return '0'
275 return '%sV8Internal::%sAttributeGetterCallbackForMainWorld' % (cpp_name(int erface), attribute.name) 280 return '%sV8Internal::%sAttributeGetterCallbackForMainWorld' % (cpp_name(int erface), attribute.name)
276 281
277 282
278 def setter_callback_name_for_main_world(interface, attribute): 283 def setter_callback_name_for_main_world(interface, attribute):
279 if ('PerWorldBindings' not in attribute.extended_attributes or 284 if ('PerWorldBindings' not in attribute.extended_attributes or
280 attribute.is_read_only): 285 attribute.is_read_only):
281 return '0' 286 return '0'
282 return '%sV8Internal::%sAttributeSetterCallbackForMainWorld' % (cpp_name(int erface), attribute.name) 287 return '%sV8Internal::%sAttributeSetterCallbackForMainWorld' % (cpp_name(int erface), attribute.name)
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/templates/attributes.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698