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

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

Issue 26785002: IDL compiler: [GetterRaisesException], [RaisesException] for getter (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 'is_nullable': attribute.is_nullable, 78 'is_nullable': attribute.is_nullable,
79 'is_static': attribute.is_static, 79 'is_static': attribute.is_static,
80 'name': attribute.name, 80 'name': attribute.name,
81 'v8_type': v8_types.v8_type(idl_type), 81 'v8_type': v8_types.v8_type(idl_type),
82 } 82 }
83 if has_extended_attribute(attribute, ('Custom', 'CustomGetter')): 83 if has_extended_attribute(attribute, ('Custom', 'CustomGetter')):
84 contents['is_custom_getter'] = True 84 contents['is_custom_getter'] = True
85 return contents, set() 85 return contents, set()
86 86
87 cpp_value = getter_expression(interface, attribute, contents) 87 cpp_value = getter_expression(interface, attribute, contents)
88 # [GetterRaisesException], [RaisesException]
89 is_getter_raises_exception = has_extended_attribute(attribute, ('GetterRaise sException', 'RaisesException'))
88 # Normally we can inline the function call into the return statement to 90 # Normally we can inline the function call into the return statement to
89 # avoid the overhead of using a Ref<> temporary, but for some cases 91 # avoid the overhead of using a Ref<> temporary, but for some cases
90 # (nullable types, EventHandler, CachedAttribute, or if there are 92 # (nullable types, EventHandler, [CachedAttribute], or if there are
91 # exceptions), we need to use a local variable. 93 # exceptions), we need to use a local variable.
92 # FIXME: check if compilers are smart enough to inline this, and if so, 94 # FIXME: check if compilers are smart enough to inline this, and if so,
93 # always use a local variable (for readability and CG simplicity). 95 # always use a local variable (for readability and CG simplicity).
94 if (attribute.is_nullable or 96 if (attribute.is_nullable or
95 idl_type == 'EventHandler' or 97 idl_type == 'EventHandler' or
96 'CachedAttribute' in extended_attributes): 98 'CachedAttribute' in extended_attributes or
99 is_getter_raises_exception):
97 contents['cpp_value_original'] = cpp_value 100 contents['cpp_value_original'] = cpp_value
98 cpp_value = 'value' 101 cpp_value = 'value'
99 contents['cpp_value'] = cpp_value 102 contents['cpp_value'] = cpp_value
100 103
101 if this_is_keep_alive_for_gc: 104 if this_is_keep_alive_for_gc:
102 return_v8_value_statement = 'v8SetReturnValue(info, wrapper);' 105 return_v8_value_statement = 'v8SetReturnValue(info, wrapper);'
103 includes = v8_types.includes_for_type(idl_type) 106 includes = v8_types.includes_for_type(idl_type)
104 includes.add('bindings/v8/V8HiddenPropertyName.h') 107 includes.add('bindings/v8/V8HiddenPropertyName.h')
105 else: 108 else:
106 return_v8_value_statement, includes = v8_types.v8_set_return_value(idl_t ype, cpp_value, callback_info='info', isolate='info.GetIsolate()', extended_attr ibutes=extended_attributes, script_wrappable='imp') 109 return_v8_value_statement, includes = v8_types.v8_set_return_value(idl_t ype, cpp_value, callback_info='info', isolate='info.GetIsolate()', extended_attr ibutes=extended_attributes, script_wrappable='imp')
107 contents['return_v8_value_statement'] = return_v8_value_statement 110 contents['return_v8_value_statement'] = return_v8_value_statement
108 111
109 if (idl_type == 'EventHandler' and 112 if (idl_type == 'EventHandler' and
110 interface.name in ['Window', 'WorkerGlobalScope'] and 113 interface.name in ['Window', 'WorkerGlobalScope'] and
111 attribute.name == 'onerror'): 114 attribute.name == 'onerror'):
112 includes.add('bindings/v8/V8ErrorHandler.h') 115 includes.add('bindings/v8/V8ErrorHandler.h')
113 116
114 # [CheckSecurityForNode] 117 # [CheckSecurityForNode]
115 is_check_security_for_node = 'CheckSecurityForNode' in extended_attributes 118 is_check_security_for_node = 'CheckSecurityForNode' in extended_attributes
116 if is_check_security_for_node: 119 if is_check_security_for_node:
117 includes.update(set(['bindings/v8/BindingSecurity.h',
118 # FIXME: these should be added if [CheckSecurityForNode], [GetterRaisesE xception], or [RaisesException]
119 'bindings/v8/ExceptionMessages.h',
120 'bindings/v8/ExceptionState.h']))
121
122 includes.add('bindings/v8/BindingSecurity.h') 120 includes.add('bindings/v8/BindingSecurity.h')
123 # [DeprecateAs] 121 # [DeprecateAs]
124 v8_utilities.generate_deprecate_as(attribute, contents, includes) 122 v8_utilities.generate_deprecate_as(attribute, contents, includes)
123 if is_check_security_for_node or is_getter_raises_exception:
124 includes.update(set(['bindings/v8/ExceptionMessages.h',
125 'bindings/v8/ExceptionState.h']))
125 126
126 contents.update({ 127 contents.update({
127 'is_activity_logging_getter': v8_utilities.has_activity_logging(attribut e, includes, 'Getter'), # [ActivityLogging=Access|Getter] 128 'is_activity_logging_getter': v8_utilities.has_activity_logging(attribut e, includes, 'Getter'), # [ActivityLogging=Access|Getter]
128 'is_check_security_for_node': is_check_security_for_node, 129 'is_check_security_for_node': is_check_security_for_node,
130 'is_getter_raises_exception': is_getter_raises_exception,
129 }) 131 })
130 132
131 return contents, includes 133 return contents, includes
132 134
133 135
134 def getter_expression(interface, attribute, contents): 136 def getter_expression(interface, attribute, contents):
135 this_getter_name = getter_name(interface, attribute) 137 this_getter_name = getter_name(interface, attribute)
136 arguments = v8_utilities.call_with_arguments(attribute, contents) 138 arguments = v8_utilities.call_with_arguments(attribute, contents)
137 if attribute.is_nullable: 139 if attribute.is_nullable:
138 arguments.append('isNull') 140 arguments.append('isNull')
141 if has_extended_attribute(attribute, ('GetterRaisesException', 'RaisesExcept ion')):
142 arguments.append('es')
139 if attribute.data_type == 'EventHandler': 143 if attribute.data_type == 'EventHandler':
140 arguments.append('isolatedWorldForIsolate(info.GetIsolate())') 144 arguments.append('isolatedWorldForIsolate(info.GetIsolate())')
141 return '%s(%s)' % (this_getter_name, ', '.join(arguments)) 145 return '%s(%s)' % (this_getter_name, ', '.join(arguments))
142 146
143 147
144 def getter_name(interface, attribute): 148 def getter_name(interface, attribute):
145 getter_method_name = uncapitalize(attribute.name) 149 getter_method_name = uncapitalize(attribute.name)
146 if attribute.is_static: 150 if attribute.is_static:
147 return '%s::%s' % (interface.name, getter_method_name) 151 return '%s::%s' % (interface.name, getter_method_name)
148 return 'imp->%s' % getter_method_name 152 return 'imp->%s' % getter_method_name
(...skipping 26 matching lines...) Expand all
175 if 'DoNotCheckSecurity' in extended_attributes: 179 if 'DoNotCheckSecurity' in extended_attributes:
176 access_control = ['v8::ALL_CAN_READ'] 180 access_control = ['v8::ALL_CAN_READ']
177 if not attribute.is_read_only: 181 if not attribute.is_read_only:
178 access_control.append('v8::ALL_CAN_WRITE') 182 access_control.append('v8::ALL_CAN_WRITE')
179 return access_control 183 return access_control
180 if 'DoNotCheckSecurityOnSetter' in extended_attributes: 184 if 'DoNotCheckSecurityOnSetter' in extended_attributes:
181 return ['v8::ALL_CAN_WRITE'] 185 return ['v8::ALL_CAN_WRITE']
182 if 'DoNotCheckSecurityOnGetter' in extended_attributes: 186 if 'DoNotCheckSecurityOnGetter' in extended_attributes:
183 return ['v8::ALL_CAN_READ'] 187 return ['v8::ALL_CAN_READ']
184 return ['v8::DEFAULT'] 188 return ['v8::DEFAULT']
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