Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 contents['cpp_value'] = cpp_value | 113 contents['cpp_value'] = cpp_value |
| 114 | 114 |
| 115 if this_is_keep_alive_for_gc: | 115 if this_is_keep_alive_for_gc: |
| 116 v8_set_return_value_statement = 'v8SetReturnValue(info, wrapper)' | 116 v8_set_return_value_statement = 'v8SetReturnValue(info, wrapper)' |
| 117 includes.update(v8_types.includes_for_type(idl_type)) | 117 includes.update(v8_types.includes_for_type(idl_type)) |
| 118 includes.add('bindings/v8/V8HiddenPropertyName.h') | 118 includes.add('bindings/v8/V8HiddenPropertyName.h') |
| 119 else: | 119 else: |
| 120 v8_set_return_value_statement = v8_types.v8_set_return_value(idl_type, c pp_value, includes, callback_info='info', isolate='info.GetIsolate()', extended_ attributes=extended_attributes, script_wrappable='imp') | 120 v8_set_return_value_statement = v8_types.v8_set_return_value(idl_type, c pp_value, includes, callback_info='info', isolate='info.GetIsolate()', extended_ attributes=extended_attributes, script_wrappable='imp') |
| 121 contents['v8_set_return_value'] = v8_set_return_value_statement | 121 contents['v8_set_return_value'] = v8_set_return_value_statement |
| 122 | 122 |
| 123 if (idl_type == 'EventHandler' and | 123 if idl_type == 'EventHandler': |
| 124 interface.name in ['Window', 'WorkerGlobalScope'] and | 124 includes.update(v8_types.includes_for_type('EventHandler')) |
|
haraken
2013/10/19 12:41:29
I guess we should always call includes.update(v8_t
Nils Barth (inactive)
2013/10/21 02:41:38
This would simplify the code.
This involves Perl c
| |
| 125 attribute.name == 'onerror'): | 125 if (interface.name in ['Window', 'WorkerGlobalScope'] and |
| 126 includes.add('bindings/v8/V8ErrorHandler.h') | 126 attribute.name == 'onerror'): |
| 127 includes.add('bindings/v8/V8ErrorHandler.h') | |
| 127 | 128 |
| 128 # [CheckSecurityForNode] | 129 # [CheckSecurityForNode] |
| 129 is_check_security_for_node = 'CheckSecurityForNode' in extended_attributes | 130 is_check_security_for_node = 'CheckSecurityForNode' in extended_attributes |
| 130 if is_check_security_for_node: | 131 if is_check_security_for_node: |
| 131 includes.add('bindings/v8/BindingSecurity.h') | 132 includes.add('bindings/v8/BindingSecurity.h') |
| 132 v8_utilities.generate_measure_as(attribute, contents, includes) # [MeasureA s] | 133 v8_utilities.generate_measure_as(attribute, contents, includes) # [MeasureA s] |
| 133 | 134 |
| 134 # [DeprecateAs] | 135 # [DeprecateAs] |
| 135 v8_utilities.generate_deprecate_as(attribute, contents, includes) | 136 v8_utilities.generate_deprecate_as(attribute, contents, includes) |
| 136 if is_check_security_for_node or is_getter_raises_exception: | 137 if is_check_security_for_node or is_getter_raises_exception: |
| 137 includes.update(set(['bindings/v8/ExceptionMessages.h', | 138 includes.update(set(['bindings/v8/ExceptionMessages.h', |
| 138 'bindings/v8/ExceptionState.h'])) | 139 'bindings/v8/ExceptionState.h'])) |
| 139 | 140 |
| 140 contents.update({ | 141 contents.update({ |
| 141 'activity_logging_getter': v8_utilities.has_activity_logging(attribute, includes, 'Getter'), # [ActivityLogging] | 142 'activity_logging_getter': v8_utilities.has_activity_logging(attribute, includes, 'Getter'), # [ActivityLogging] |
| 142 'is_check_security_for_node': is_check_security_for_node, | 143 'is_check_security_for_node': is_check_security_for_node, |
| 143 'is_getter_raises_exception': is_getter_raises_exception, | 144 'is_getter_raises_exception': is_getter_raises_exception, |
| 144 'is_unforgeable': 'Unforgeable' in extended_attributes, | 145 'is_unforgeable': 'Unforgeable' in extended_attributes, |
| 145 }) | 146 }) |
| 146 | 147 |
| 147 # Setter | 148 # Setter |
| 148 if not has_setter: | 149 if not has_setter: |
| 149 return contents, includes | 150 return contents, includes |
| 150 | 151 |
| 151 contents.update({ | 152 contents.update({ |
| 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()'), | 153 '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()'), |
| 153 'cpp_setter': setter_expression(attribute, contents), | 154 'cpp_setter': setter_expression(attribute, contents, includes), |
| 154 }) | 155 }) |
| 155 | 156 |
| 156 return contents, includes | 157 return contents, includes |
| 157 | 158 |
| 158 | 159 |
| 159 def getter_expression(interface, attribute, contents, includes): | 160 def getter_expression(interface, attribute, contents, includes): |
| 160 arguments = [] | 161 arguments = [] |
| 161 if 'Reflect' in attribute.extended_attributes: | 162 if 'Reflect' in attribute.extended_attributes: |
| 162 getter_base_name = content_attribute_getter_base_name(attribute, include s, arguments) | 163 getter_base_name = content_attribute_getter_base_name(attribute, include s, arguments) |
| 163 else: | 164 else: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 arguments.append(scoped_name) | 199 arguments.append(scoped_name) |
| 199 | 200 |
| 200 idl_type = attribute.data_type | 201 idl_type = attribute.data_type |
| 201 if idl_type in CONTENT_ATTRIBUTE_GETTER_NAMES: | 202 if idl_type in CONTENT_ATTRIBUTE_GETTER_NAMES: |
| 202 return CONTENT_ATTRIBUTE_GETTER_NAMES[idl_type] | 203 return CONTENT_ATTRIBUTE_GETTER_NAMES[idl_type] |
| 203 if 'URL' in attribute.extended_attributes: | 204 if 'URL' in attribute.extended_attributes: |
| 204 return 'getURLAttribute' | 205 return 'getURLAttribute' |
| 205 return 'fastGetAttribute' | 206 return 'fastGetAttribute' |
| 206 | 207 |
| 207 | 208 |
| 208 def setter_expression(attribute, contents): | 209 def setter_expression(attribute, contents, includes): |
| 209 arguments = v8_utilities.call_with_arguments(attribute, contents) | 210 arguments = v8_utilities.call_with_arguments(attribute, contents) |
| 210 idl_type = attribute.data_type | 211 idl_type = attribute.data_type |
| 211 # FIXME: should be able to eliminate WTF::getPtr in most or all cases | 212 if idl_type == 'EventHandler': |
| 212 cpp_value = 'WTF::getPtr(cppValue)' if v8_types.interface_type(idl_type) and not v8_types.array_type(idl_type) else 'cppValue' | 213 includes.add('bindings/v8/V8EventListenerList.h') |
|
haraken
2013/10/19 12:41:29
Ditto. I think we can just always call includes.up
Nils Barth (inactive)
2013/10/21 02:41:38
Will do (in same "includes for type" followup CL)!
| |
| 213 arguments.append(cpp_value) | 214 isolated_world = 'isolatedWorldForIsolate(info.GetIsolate())' |
| 215 arguments.extend(['V8EventListenerList::getEventListener(jsValue, true, ListenerFindOrCreate)', isolated_world]) | |
| 216 contents['event_handler_getter_expression'] = 'imp->%s(%s)' % (cpp_name( attribute), isolated_world) | |
|
haraken
2013/10/19 12:41:29
Not related to your CL, it looks ugly to get an is
Nils Barth (inactive)
2013/10/21 02:41:38
Will do.
| |
| 217 elif v8_types.interface_type(idl_type) and not v8_types.array_type(idl_type) : | |
| 218 # FIXME: should be able to eliminate WTF::getPtr in most or all cases | |
| 219 arguments.append('WTF::getPtr(cppValue)') | |
| 220 else: | |
| 221 arguments.append('cppValue') | |
| 222 | |
| 214 return 'imp->set%s(%s)' % (capitalize(cpp_name(attribute)), ', '.join(argume nts)) | 223 return 'imp->set%s(%s)' % (capitalize(cpp_name(attribute)), ', '.join(argume nts)) |
| 215 | 224 |
| 216 | 225 |
| 217 def is_keep_alive_for_gc(attribute): | 226 def is_keep_alive_for_gc(attribute): |
| 218 idl_type = attribute.data_type | 227 idl_type = attribute.data_type |
| 219 extended_attributes = attribute.extended_attributes | 228 extended_attributes = attribute.extended_attributes |
| 220 return ( | 229 return ( |
| 221 'KeepAttributeAliveForGC' in extended_attributes or | 230 'KeepAttributeAliveForGC' in extended_attributes or |
| 222 # For readonly attributes, for performance reasons we keep the attribute | 231 # For readonly attributes, for performance reasons we keep the attribute |
| 223 # wrapper alive while the owner wrapper is alive, because the attribute | 232 # wrapper alive while the owner wrapper is alive, because the attribute |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 if 'PerWorldBindings' not in attribute.extended_attributes: | 287 if 'PerWorldBindings' not in attribute.extended_attributes: |
| 279 return '0' | 288 return '0' |
| 280 return '%sV8Internal::%sAttributeGetterCallbackForMainWorld' % (cpp_name(int erface), attribute.name) | 289 return '%sV8Internal::%sAttributeGetterCallbackForMainWorld' % (cpp_name(int erface), attribute.name) |
| 281 | 290 |
| 282 | 291 |
| 283 def setter_callback_name_for_main_world(interface, attribute): | 292 def setter_callback_name_for_main_world(interface, attribute): |
| 284 if ('PerWorldBindings' not in attribute.extended_attributes or | 293 if ('PerWorldBindings' not in attribute.extended_attributes or |
| 285 attribute.is_read_only): | 294 attribute.is_read_only): |
| 286 return '0' | 295 return '0' |
| 287 return '%sV8Internal::%sAttributeSetterCallbackForMainWorld' % (cpp_name(int erface), attribute.name) | 296 return '%sV8Internal::%sAttributeSetterCallbackForMainWorld' % (cpp_name(int erface), attribute.name) |
| OLD | NEW |