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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 } | 64 } |
| 65 | 65 |
| 66 | 66 |
| 67 def generate_attribute_and_includes(interface, attribute): | 67 def generate_attribute_and_includes(interface, attribute): |
| 68 idl_type = attribute.data_type | 68 idl_type = attribute.data_type |
| 69 extended_attributes = attribute.extended_attributes | 69 extended_attributes = attribute.extended_attributes |
| 70 | 70 |
| 71 has_custom_getter = has_extended_attribute(attribute, ('Custom', 'CustomGett er')) | 71 has_custom_getter = has_extended_attribute(attribute, ('Custom', 'CustomGett er')) |
| 72 has_custom_setter = not attribute.is_read_only and has_extended_attribute(at tribute, ('Custom', 'CustomSetter')) | 72 has_custom_setter = not attribute.is_read_only and has_extended_attribute(at tribute, ('Custom', 'CustomSetter')) |
| 73 do_generate_setter = not (attribute.is_read_only or has_custom_setter) # FI XME: need to check [PutForwards], [Reflect], and [Replaceable] | 73 do_generate_setter = not (attribute.is_read_only or has_custom_setter) # FI XME: need to check [PutForwards], [Reflect], and [Replaceable] |
| 74 includes = set() | |
| 74 contents = { | 75 contents = { |
| 75 'access_control_list': access_control_list(attribute), | 76 'access_control_list': access_control_list(attribute), |
| 77 'activity_logging_getter': v8_utilities.has_activity_logging(attribute, includes, 'Getter'), # [ActivityLogging] | |
| 78 'activity_logging_setter': v8_utilities.has_activity_logging(attribute, includes, 'Setter'), # [ActivityLogging] | |
|
haraken
2013/10/21 03:32:53
has_activity_logging => activity_logging_world_lis
Nils Barth (inactive)
2013/10/21 03:42:28
Done! (That's clearer.)
| |
| 76 'cached_attribute_validation_method': extended_attributes.get('CachedAtt ribute'), | 79 'cached_attribute_validation_method': extended_attributes.get('CachedAtt ribute'), |
| 77 'conditional_string': v8_utilities.generate_conditional_string(attribute ), | 80 'conditional_string': v8_utilities.generate_conditional_string(attribute ), |
| 78 'cpp_type': v8_types.cpp_type(idl_type), | 81 'cpp_type': v8_types.cpp_type(idl_type), |
| 79 'do_generate_setter': do_generate_setter, | 82 'do_generate_setter': do_generate_setter, |
| 80 'getter_callback_name': getter_callback_name(interface, attribute), | 83 'getter_callback_name': getter_callback_name(interface, attribute), |
| 81 'getter_callback_name_for_main_world': getter_callback_name_for_main_wor ld(interface, attribute), | 84 'getter_callback_name_for_main_world': getter_callback_name_for_main_wor ld(interface, attribute), |
| 82 'has_custom_getter': has_custom_getter, | 85 'has_custom_getter': has_custom_getter, |
| 83 'has_custom_setter': has_custom_setter, | 86 'has_custom_setter': has_custom_setter, |
| 84 'has_setter_callback': not attribute.is_read_only, # FIXME: need to che ck [Replaceable] | 87 'has_setter_callback': not attribute.is_read_only, # FIXME: need to che ck [Replaceable] |
| 85 'idl_type': idl_type, | 88 'idl_type': idl_type, |
| 86 'is_getter_raises_exception': has_extended_attribute(attribute, ('Getter RaisesException', 'RaisesException')), | 89 'is_getter_raises_exception': has_extended_attribute(attribute, ('Getter RaisesException', 'RaisesException')), |
| 87 'is_keep_alive_for_gc': is_keep_alive_for_gc(attribute), | 90 'is_keep_alive_for_gc': is_keep_alive_for_gc(attribute), |
| 88 'is_nullable': attribute.is_nullable, | 91 'is_nullable': attribute.is_nullable, |
| 89 'is_static': attribute.is_static, | 92 'is_static': attribute.is_static, |
| 90 'name': attribute.name, | 93 'name': attribute.name, |
| 91 'per_context_enabled_function_name': v8_utilities.per_context_enabled_fu nction_name(attribute), # [PerContextEnabled] | 94 'per_context_enabled_function_name': v8_utilities.per_context_enabled_fu nction_name(attribute), # [PerContextEnabled] |
| 92 'property_attributes': property_attributes(attribute), | 95 'property_attributes': property_attributes(attribute), |
| 93 'setter_callback_name': setter_callback_name(interface, attribute), | 96 'setter_callback_name': setter_callback_name(interface, attribute), |
| 94 'setter_callback_name_for_main_world': setter_callback_name_for_main_wor ld(interface, attribute), | 97 'setter_callback_name_for_main_world': setter_callback_name_for_main_wor ld(interface, attribute), |
| 95 'v8_type': v8_types.v8_type(idl_type), | 98 'v8_type': v8_types.v8_type(idl_type), |
| 96 'runtime_enabled_function_name': v8_utilities.runtime_enabled_function_n ame(attribute), # [RuntimeEnabled] | 99 'runtime_enabled_function_name': v8_utilities.runtime_enabled_function_n ame(attribute), # [RuntimeEnabled] |
| 97 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended _attributes else [''], # [PerWorldBindings] | 100 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended _attributes else [''], # [PerWorldBindings] |
| 98 } | 101 } |
| 99 includes = set() | |
| 100 if not has_custom_getter: | 102 if not has_custom_getter: |
| 101 generate_getter(interface, attribute, contents, includes) | 103 generate_getter(interface, attribute, contents, includes) |
| 102 if do_generate_setter: | 104 if do_generate_setter: |
| 103 generate_setter(interface, attribute, contents, includes) | 105 generate_setter(interface, attribute, contents, includes) |
| 104 | 106 |
| 105 return contents, includes | 107 return contents, includes |
| 106 | 108 |
| 107 | 109 |
| 108 def generate_getter(interface, attribute, contents, includes): | 110 def generate_getter(interface, attribute, contents, includes): |
| 109 idl_type = attribute.data_type | 111 idl_type = attribute.data_type |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 includes.add('bindings/v8/BindingSecurity.h') | 145 includes.add('bindings/v8/BindingSecurity.h') |
| 144 v8_utilities.generate_measure_as(attribute, contents, includes) # [MeasureA s] | 146 v8_utilities.generate_measure_as(attribute, contents, includes) # [MeasureA s] |
| 145 | 147 |
| 146 # [DeprecateAs] | 148 # [DeprecateAs] |
| 147 v8_utilities.generate_deprecate_as(attribute, contents, includes) | 149 v8_utilities.generate_deprecate_as(attribute, contents, includes) |
| 148 if is_check_security_for_node or contents['is_getter_raises_exception']: | 150 if is_check_security_for_node or contents['is_getter_raises_exception']: |
| 149 includes.update(set(['bindings/v8/ExceptionMessages.h', | 151 includes.update(set(['bindings/v8/ExceptionMessages.h', |
| 150 'bindings/v8/ExceptionState.h'])) | 152 'bindings/v8/ExceptionState.h'])) |
| 151 | 153 |
| 152 contents.update({ | 154 contents.update({ |
| 153 'activity_logging_getter': v8_utilities.has_activity_logging(attribute, includes, 'Getter'), # [ActivityLogging] | |
| 154 'is_check_security_for_node': is_check_security_for_node, | 155 'is_check_security_for_node': is_check_security_for_node, |
| 155 'is_unforgeable': 'Unforgeable' in extended_attributes, | 156 'is_unforgeable': 'Unforgeable' in extended_attributes, |
| 156 }) | 157 }) |
| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 return 'fastGetAttribute' | 203 return 'fastGetAttribute' |
| 203 | 204 |
| 204 | 205 |
| 205 def generate_setter(interface, attribute, contents, includes): | 206 def generate_setter(interface, attribute, contents, includes): |
| 206 idl_type = attribute.data_type | 207 idl_type = attribute.data_type |
| 207 if v8_types.is_interface_type(idl_type) and not v8_types.array_type(idl_type ): | 208 if v8_types.is_interface_type(idl_type) and not v8_types.array_type(idl_type ): |
| 208 cpp_value = 'WTF::getPtr(cppValue)' | 209 cpp_value = 'WTF::getPtr(cppValue)' |
| 209 else: | 210 else: |
| 210 cpp_value = 'cppValue' | 211 cpp_value = 'cppValue' |
| 211 contents.update({ | 212 contents.update({ |
| 212 '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()'), | |
| 213 'cpp_setter': setter_expression(interface, attribute, contents), | 213 'cpp_setter': setter_expression(interface, attribute, contents), |
| 214 'enum_validation_expression': enum_validation_expression(idl_type), | 214 'enum_validation_expression': enum_validation_expression(idl_type), |
| 215 '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()'), | |
| 215 }) | 216 }) |
| 216 | 217 |
| 217 | 218 |
| 218 def setter_expression(interface, attribute, contents): | 219 def setter_expression(interface, attribute, contents): |
| 219 arguments = v8_utilities.call_with_arguments(attribute, contents) | 220 arguments = v8_utilities.call_with_arguments(attribute, contents) |
| 220 idl_type = attribute.data_type | 221 idl_type = attribute.data_type |
| 221 # FIXME: should be able to eliminate WTF::getPtr in most or all cases | 222 # FIXME: should be able to eliminate WTF::getPtr in most or all cases |
| 222 cpp_value = 'WTF::getPtr(cppValue)' if v8_types.is_interface_type(idl_type) and not v8_types.array_type(idl_type) else 'cppValue' | 223 cpp_value = 'WTF::getPtr(cppValue)' if v8_types.is_interface_type(idl_type) and not v8_types.array_type(idl_type) else 'cppValue' |
| 223 arguments.append(cpp_value) | 224 arguments.append(cpp_value) |
| 224 setter_name = scoped_name(interface, attribute, 'set%s' % capitalize(cpp_nam e(attribute))) | 225 setter_name = scoped_name(interface, attribute, 'set%s' % capitalize(cpp_nam e(attribute))) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 if 'PerWorldBindings' not in attribute.extended_attributes: | 303 if 'PerWorldBindings' not in attribute.extended_attributes: |
| 303 return '0' | 304 return '0' |
| 304 return '%sV8Internal::%sAttributeGetterCallbackForMainWorld' % (cpp_name(int erface), attribute.name) | 305 return '%sV8Internal::%sAttributeGetterCallbackForMainWorld' % (cpp_name(int erface), attribute.name) |
| 305 | 306 |
| 306 | 307 |
| 307 def setter_callback_name_for_main_world(interface, attribute): | 308 def setter_callback_name_for_main_world(interface, attribute): |
| 308 if ('PerWorldBindings' not in attribute.extended_attributes or | 309 if ('PerWorldBindings' not in attribute.extended_attributes or |
| 309 attribute.is_read_only): | 310 attribute.is_read_only): |
| 310 return '0' | 311 return '0' |
| 311 return '%sV8Internal::%sAttributeSetterCallbackForMainWorld' % (cpp_name(int erface), attribute.name) | 312 return '%sV8Internal::%sAttributeSetterCallbackForMainWorld' % (cpp_name(int erface), attribute.name) |
| OLD | NEW |