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

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

Issue 141523002: Add null-correctness checking to [StrictTypeChecking] methods (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Last test Created 6 years, 11 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
OLDNEW
1 {##############################################################################} 1 {##############################################################################}
2 {% macro generate_method(method, world_suffix) %} 2 {% macro generate_method(method, world_suffix) %}
3 {% filter conditional(method.conditional_string) %} 3 {% filter conditional(method.conditional_string) %}
4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) 4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info)
5 { 5 {
6 {% if method.has_exception_state %} 6 {% if method.has_exception_state %}
7 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); 7 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate());
8 {% endif %} 8 {% endif %}
9 {% if method.name in ['addEventListener', 'removeEventListener'] %} 9 {% if method.name in ['addEventListener', 'removeEventListener'] %}
10 {{add_remove_event_listener_method(method.name) | indent}} 10 {{add_remove_event_listener_method(method.name) | indent}}
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 fewer arguments if they are omitted. 82 fewer arguments if they are omitted.
83 Optional Dictionary arguments default to empty dictionary. #} 83 Optional Dictionary arguments default to empty dictionary. #}
84 if (UNLIKELY(info.Length() <= {{argument.index}})) { 84 if (UNLIKELY(info.Length() <= {{argument.index}})) {
85 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value) | indent}} 85 {{cpp_method_call(method, argument.v8_set_return_value, argument.cpp_value) | indent}}
86 return; 86 return;
87 } 87 }
88 {% endif %} 88 {% endif %}
89 {% if method.is_strict_type_checking and argument.is_wrapper_type %} 89 {% if method.is_strict_type_checking and argument.is_wrapper_type %}
90 {# Type checking for wrapper interface types (if interface not implemented, 90 {# Type checking for wrapper interface types (if interface not implemented,
91 throw TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} 91 throw TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #}
92 if (info.Length() > {{argument.index}} && !isUndefinedOrNull(info[{{argument.ind ex}}]) && !V8{{argument.idl_type}}::hasInstance(info[{{argument.index}}], info.G etIsolate(), worldType(info.GetIsolate()))) { 92 if (info.Length() > {{argument.index}} && !{% if argument.is_nullable %}isUndefi nedOrNull(info[{{argument.index}}]){% else %}info[{{argument.index}}]->IsUndefin ed(){% endif %} && !V8{{argument.idl_type}}::hasInstance(info[{{argument.index}} ], info.GetIsolate(), worldType(info.GetIsolate()))) {
93 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % 93 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' %
94 (argument.index + 1, argument.idl_type)) | indent }} 94 (argument.index + 1, argument.idl_type)) | indent }}
95 return; 95 return;
96 } 96 }
97 {% endif %} 97 {% endif %}
98 {% if argument.is_callback_interface %} 98 {% if argument.is_callback_interface %}
99 {% if argument.is_optional %} 99 {% if argument.is_optional %}
100 OwnPtr<{{argument.idl_type}}> {{argument.name}}; 100 OwnPtr<{{argument.idl_type}}> {{argument.name}};
101 if (info.Length() > {{argument.index}} && !isUndefinedOrNull(info[{{argument.ind ex}}])) { 101 if (info.Length() > {{argument.index}} && !isUndefinedOrNull(info[{{argument.ind ex}}])) {
102 if (!info[{{argument.index}}]->IsFunction()) { 102 if (!info[{{argument.index}}]->IsFunction()) {
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 v8::Handle<v8::Object> wrapper = info.Holder(); 394 v8::Handle<v8::Object> wrapper = info.Holder();
395 {% if is_constructor_raises_exception %} 395 {% if is_constructor_raises_exception %}
396 if (exceptionState.throwIfNeeded()) 396 if (exceptionState.throwIfNeeded())
397 return; 397 return;
398 {% endif %} 398 {% endif %}
399 399
400 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfigu ration::Dependent); 400 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfigu ration::Dependent);
401 v8SetReturnValue(info, wrapper); 401 v8SetReturnValue(info, wrapper);
402 } 402 }
403 {% endmacro %} 403 {% endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/scripts/unstable/v8_attributes.py ('k') | Source/bindings/tests/idls/TestObjectPython.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698