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

Side by Side Diff: Source/bindings/templates/interface.cpp

Issue 1019773006: use non-masking, string interceptors in generated bindings (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix test Created 5 years, 8 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 {% extends 'interface_base.cpp' %} 1 {% extends 'interface_base.cpp' %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% block indexed_property_getter %} 5 {% block indexed_property_getter %}
6 {% if indexed_property_getter and not indexed_property_getter.is_custom %} 6 {% if indexed_property_getter and not indexed_property_getter.is_custom %}
7 {% set getter = indexed_property_getter %} 7 {% set getter = indexed_property_getter %}
8 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) 8 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info)
9 { 9 {
10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 {% endif %} 172 {% endif %}
173 {% endblock %} 173 {% endblock %}
174 174
175 175
176 {##############################################################################} 176 {##############################################################################}
177 {% block named_property_getter %} 177 {% block named_property_getter %}
178 {% if named_property_getter and not named_property_getter.is_custom %} 178 {% if named_property_getter and not named_property_getter.is_custom %}
179 {% set getter = named_property_getter %} 179 {% set getter = named_property_getter %}
180 static void namedPropertyGetter(v8::Local<v8::Name> name, const v8::PropertyCall backInfo<v8::Value>& info) 180 static void namedPropertyGetter(v8::Local<v8::Name> name, const v8::PropertyCall backInfo<v8::Value>& info)
181 { 181 {
182 if (!name->IsString())
183 return;
184 auto nameString = name.As<v8::String>(); 182 auto nameString = name.As<v8::String>();
185 {% if not is_override_builtins %}
186 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
187 if (v8CallBoolean(info.Holder()->HasRealNamedProperty(context, nameString)))
188 return;
189 v8::Local<v8::Value> namedPropertyValue;
190 if (info.Holder()->GetRealNamedPropertyInPrototypeChain(context, nameString) .ToLocal(&namedPropertyValue))
191 return;
192
193 {% endif %}
194 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 183 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
195 AtomicString propertyName = toCoreAtomicString(nameString); 184 AtomicString propertyName = toCoreAtomicString(nameString);
196 {% if getter.is_raises_exception %} 185 {% if getter.is_raises_exception %}
197 v8::String::Utf8Value namedProperty(nameString); 186 v8::String::Utf8Value namedProperty(nameString);
198 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "{{interface_name}}", info.Holder(), info.GetIsolate()); 187 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "{{interface_name}}", info.Holder(), info.GetIsolate());
199 {% endif %} 188 {% endif %}
200 {% if getter.is_call_with_script_state %} 189 {% if getter.is_call_with_script_state %}
201 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); 190 ScriptState* scriptState = ScriptState::current(info.GetIsolate());
202 {% endif %} 191 {% endif %}
203 {% if getter.use_output_parameter_for_result %} 192 {% if getter.use_output_parameter_for_result %}
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 {% endblock %} 227 {% endblock %}
239 228
240 229
241 {##############################################################################} 230 {##############################################################################}
242 {% block named_property_setter %} 231 {% block named_property_setter %}
243 {% from 'conversions.cpp' import v8_value_to_local_cpp_value %} 232 {% from 'conversions.cpp' import v8_value_to_local_cpp_value %}
244 {% if named_property_setter and not named_property_setter.is_custom %} 233 {% if named_property_setter and not named_property_setter.is_custom %}
245 {% set setter = named_property_setter %} 234 {% set setter = named_property_setter %}
246 static void namedPropertySetter(v8::Local<v8::Name> name, v8::Local<v8::Value> v 8Value, const v8::PropertyCallbackInfo<v8::Value>& info) 235 static void namedPropertySetter(v8::Local<v8::Name> name, v8::Local<v8::Value> v 8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
247 { 236 {
248 if (!name->IsString())
249 return;
250 auto nameString = name.As<v8::String>(); 237 auto nameString = name.As<v8::String>();
251 {% if not is_override_builtins %}
252 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
253 if (v8CallBoolean(info.Holder()->HasRealNamedProperty(context, nameString)))
254 return;
255 v8::Local<v8::Value> namedPropertyValue;
256 if (info.Holder()->GetRealNamedPropertyInPrototypeChain(context, nameString) .ToLocal(&namedPropertyValue))
257 return;
258
259 {% endif %}
260 {% if setter.has_exception_state %} 238 {% if setter.has_exception_state %}
261 v8::String::Utf8Value namedProperty(nameString); 239 v8::String::Utf8Value namedProperty(nameString);
262 ExceptionState exceptionState(ExceptionState::SetterContext, *namedProperty, "{{interface_name}}", info.Holder(), info.GetIsolate()); 240 ExceptionState exceptionState(ExceptionState::SetterContext, *namedProperty, "{{interface_name}}", info.Holder(), info.GetIsolate());
263 {% endif %} 241 {% endif %}
264 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 242 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
265 {# v8_value_to_local_cpp_value('DOMString', 'nameString', 'propertyName') #} 243 {# v8_value_to_local_cpp_value('DOMString', 'nameString', 'propertyName') #}
266 V8StringResource<> propertyName(nameString); 244 V8StringResource<> propertyName(nameString);
267 if (!propertyName.prepare()) 245 if (!propertyName.prepare())
268 return; 246 return;
269 {{v8_value_to_local_cpp_value(setter) | indent}} 247 {{v8_value_to_local_cpp_value(setter) | indent}}
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 299
322 300
323 {##############################################################################} 301 {##############################################################################}
324 {% block named_property_query %} 302 {% block named_property_query %}
325 {% if named_property_getter and named_property_getter.is_enumerable and 303 {% if named_property_getter and named_property_getter.is_enumerable and
326 not named_property_getter.is_custom_property_query %} 304 not named_property_getter.is_custom_property_query %}
327 {# If there is an enumerator, there MUST be a query method to properly 305 {# If there is an enumerator, there MUST be a query method to properly
328 communicate property attributes. #} 306 communicate property attributes. #}
329 static void namedPropertyQuery(v8::Local<v8::Name> name, const v8::PropertyCallb ackInfo<v8::Integer>& info) 307 static void namedPropertyQuery(v8::Local<v8::Name> name, const v8::PropertyCallb ackInfo<v8::Integer>& info)
330 { 308 {
331 if (!name->IsString())
332 return;
333 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 309 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
334 AtomicString propertyName = toCoreAtomicString(name.As<v8::String>()); 310 AtomicString propertyName = toCoreAtomicString(name.As<v8::String>());
335 v8::String::Utf8Value namedProperty(name); 311 v8::String::Utf8Value namedProperty(name);
336 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "{{interface_name}}", info.Holder(), info.GetIsolate()); 312 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "{{interface_name}}", info.Holder(), info.GetIsolate());
337 bool result = impl->namedPropertyQuery(propertyName, exceptionState); 313 bool result = impl->namedPropertyQuery(propertyName, exceptionState);
338 if (exceptionState.throwIfNeeded()) 314 if (exceptionState.throwIfNeeded())
339 return; 315 return;
340 if (!result) 316 if (!result)
341 return; 317 return;
342 v8SetReturnValueInt(info, v8::None); 318 v8SetReturnValueInt(info, v8::None);
(...skipping 21 matching lines...) Expand all
364 {% endif %} 340 {% endif %}
365 {% endblock %} 341 {% endblock %}
366 342
367 343
368 {##############################################################################} 344 {##############################################################################}
369 {% block named_property_deleter %} 345 {% block named_property_deleter %}
370 {% if named_property_deleter and not named_property_deleter.is_custom %} 346 {% if named_property_deleter and not named_property_deleter.is_custom %}
371 {% set deleter = named_property_deleter %} 347 {% set deleter = named_property_deleter %}
372 static void namedPropertyDeleter(v8::Local<v8::Name> name, const v8::PropertyCal lbackInfo<v8::Boolean>& info) 348 static void namedPropertyDeleter(v8::Local<v8::Name> name, const v8::PropertyCal lbackInfo<v8::Boolean>& info)
373 { 349 {
374 if (!name->IsString())
375 return;
376 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 350 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
377 AtomicString propertyName = toCoreAtomicString(name.As<v8::String>()); 351 AtomicString propertyName = toCoreAtomicString(name.As<v8::String>());
378 {% if deleter.is_raises_exception %} 352 {% if deleter.is_raises_exception %}
379 v8::String::Utf8Value namedProperty(name); 353 v8::String::Utf8Value namedProperty(name);
380 ExceptionState exceptionState(ExceptionState::DeletionContext, *namedPropert y, "{{interface_name}}", info.Holder(), info.GetIsolate()); 354 ExceptionState exceptionState(ExceptionState::DeletionContext, *namedPropert y, "{{interface_name}}", info.Holder(), info.GetIsolate());
381 {% endif %} 355 {% endif %}
382 {% if deleter.is_call_with_script_state %} 356 {% if deleter.is_call_with_script_state %}
383 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); 357 ScriptState* scriptState = ScriptState::current(info.GetIsolate());
384 {% endif %} 358 {% endif %}
385 {% set deleter_name = deleter.name or 'anonymousNamedDeleter' %} 359 {% set deleter_name = deleter.name or 'anonymousNamedDeleter' %}
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 } 1008 }
1035 1009
1036 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} 1010 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %}
1037 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) 1011 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&))
1038 { 1012 {
1039 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; 1013 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method;
1040 } 1014 }
1041 {% endfor %} 1015 {% endfor %}
1042 {% endif %} 1016 {% endif %}
1043 {% endblock %} 1017 {% endblock %}
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/security/document-all-expected.txt ('k') | Source/bindings/templates/interface_base.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698