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

Side by Side Diff: third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl

Issue 2802223002: bindings: Throw a type error if converting an interface or callback function fails. (Closed)
Patch Set: Created 3 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.tmpl' %} 1 {% extends 'interface_base.cpp.tmpl' %}
2 2
3 {##############################################################################} 3 {##############################################################################}
4 {% block indexed_property_getter %} 4 {% block indexed_property_getter %}
5 {% if indexed_property_getter and not indexed_property_getter.is_custom %} 5 {% if indexed_property_getter and not indexed_property_getter.is_custom %}
6 {% set getter = indexed_property_getter %} 6 {% set getter = indexed_property_getter %}
7 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) { 7 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) {
8 {% if getter.is_raises_exception %} 8 {% if getter.is_raises_exception %}
9 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedGetter Context, "{{interface_name}}"); 9 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedGetter Context, "{{interface_name}}");
10 {% endif %} 10 {% endif %}
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value) ) : nullptr; 885 return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value) ) : nullptr;
886 {% endif %} 886 {% endif %}
887 } 887 }
888 888
889 {% endblock %} 889 {% endblock %}
890 890
891 891
892 {##############################################################################} 892 {##############################################################################}
893 {% block native_value_traits %} 893 {% block native_value_traits %}
894 {{cpp_class}}* NativeValueTraits<{{cpp_class}}>::nativeValue(v8::Isolate* isolat e, v8::Local<v8::Value> value, ExceptionState& exceptionState) { 894 {{cpp_class}}* NativeValueTraits<{{cpp_class}}>::nativeValue(v8::Isolate* isolat e, v8::Local<v8::Value> value, ExceptionState& exceptionState) {
895 return {{v8_class}}::toImplWithTypeCheck(isolate, value); 895 {{cpp_class}}* nativeValue = {{v8_class}}::toImplWithTypeCheck(isolate, value) ;
896 if (!nativeValue)
897 exceptionState.throwTypeError("Unable to convert value to {{cpp_class}}.");
Yuki 2017/04/07 13:37:21 nit: Can we use {{interface_name}} instead? This i
898 return nativeValue;
896 } 899 }
897 900
898 {% endblock %} 901 {% endblock %}
899 902
900 903
901 {##############################################################################} 904 {##############################################################################}
902 {% block partial_interface %} 905 {% block partial_interface %}
903 {% if has_partial_interface %} 906 {% if has_partial_interface %}
904 {% if needs_runtime_enabled_installer %} 907 {% if needs_runtime_enabled_installer %}
905 InstallRuntimeEnabledFunction {{v8_class}}::install{{v8_class}}RuntimeEnabledFun ction = 908 InstallRuntimeEnabledFunction {{v8_class}}::install{{v8_class}}RuntimeEnabledFun ction =
(...skipping 23 matching lines...) Expand all
929 } 932 }
930 933
931 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} 934 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %}
932 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) { 935 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) {
933 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; 936 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method;
934 } 937 }
935 938
936 {% endfor %} 939 {% endfor %}
937 {% endif %} 940 {% endif %}
938 {% endblock %} 941 {% endblock %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698