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

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

Issue 1111183008: [bindings] Make interface template simplified for getter/setter/deleter while using CallWith=Script… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
11 {% if getter.is_raises_exception %} 11 {% if getter.is_raises_exception %}
12 ExceptionState exceptionState(ExceptionState::IndexedGetterContext, "{{inter face_name}}", info.Holder(), info.GetIsolate()); 12 ExceptionState exceptionState(ExceptionState::IndexedGetterContext, "{{inter face_name}}", info.Holder(), info.GetIsolate());
13 {% endif %} 13 {% endif %}
14 {% if getter.is_call_with_script_state %}
15 ScriptState* scriptState = ScriptState::current(info.GetIsolate());
16 {% endif %}
17 {% set getter_name = getter.name or 'anonymousIndexedGetter' %} 14 {% set getter_name = getter.name or 'anonymousIndexedGetter' %}
18 {% set getter_arguments = ['index'] %} 15 {% set getter_arguments = ['index'] %}
19 {% if getter.is_call_with_script_state %} 16 {% if getter.is_call_with_script_state %}
17 ScriptState* scriptState = ScriptState::current(info.GetIsolate());
20 {% set getter_arguments = ['scriptState'] + getter_arguments %} 18 {% set getter_arguments = ['scriptState'] + getter_arguments %}
21 {% endif %} 19 {% endif %}
22 {% if getter.is_raises_exception %} 20 {% if getter.is_raises_exception %}
23 {% set getter_arguments = getter_arguments + ['exceptionState'] %} 21 {% set getter_arguments = getter_arguments + ['exceptionState'] %}
24 {% endif %} 22 {% endif %}
25 {{getter.cpp_type}} result = impl->{{getter_name}}({{getter_arguments | join (', ')}}); 23 {{getter.cpp_type}} result = impl->{{getter_name}}({{getter_arguments | join (', ')}});
26 {% if getter.is_raises_exception %} 24 {% if getter.is_raises_exception %}
27 if (exceptionState.throwIfNeeded()) 25 if (exceptionState.throwIfNeeded())
28 return; 26 return;
29 {% endif %} 27 {% endif %}
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 {% endif %} 67 {% endif %}
70 {% if setter.has_type_checking_interface %} 68 {% if setter.has_type_checking_interface %}
71 {# Type checking for interface types (if interface not implemented, throw 69 {# Type checking for interface types (if interface not implemented, throw
72 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #} 70 TypeError), per http://www.w3.org/TR/WebIDL/#es-interface #}
73 if (!propertyValue{% if setter.is_nullable %} && !isUndefinedOrNull(v8Value) {% endif %}) { 71 if (!propertyValue{% if setter.is_nullable %} && !isUndefinedOrNull(v8Value) {% endif %}) {
74 exceptionState.throwTypeError("The provided value is not of type '{{sett er.idl_type}}'."); 72 exceptionState.throwTypeError("The provided value is not of type '{{sett er.idl_type}}'.");
75 exceptionState.throwIfNeeded(); 73 exceptionState.throwIfNeeded();
76 return; 74 return;
77 } 75 }
78 {% endif %} 76 {% endif %}
79 {% if setter.is_call_with_script_state %}
80 ScriptState* scriptState = ScriptState::current(info.GetIsolate());
81 {% endif %}
82 {% set setter_name = setter.name or 'anonymousIndexedSetter' %} 77 {% set setter_name = setter.name or 'anonymousIndexedSetter' %}
83 {% set setter_arguments = ['index', 'propertyValue'] %} 78 {% set setter_arguments = ['index', 'propertyValue'] %}
84 {% if setter.is_call_with_script_state %} 79 {% if setter.is_call_with_script_state %}
80 ScriptState* scriptState = ScriptState::current(info.GetIsolate());
85 {% set setter_arguments = ['scriptState'] + setter_arguments %} 81 {% set setter_arguments = ['scriptState'] + setter_arguments %}
86 {% endif %} 82 {% endif %}
87 {% if setter.is_raises_exception %} 83 {% if setter.is_raises_exception %}
88 {% set setter_arguments = setter_arguments + ['exceptionState'] %} 84 {% set setter_arguments = setter_arguments + ['exceptionState'] %}
89 {% endif %} 85 {% endif %}
90 bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}}); 86 bool result = impl->{{setter_name}}({{setter_arguments | join(', ')}});
91 {% if setter.is_raises_exception %} 87 {% if setter.is_raises_exception %}
92 if (exceptionState.throwIfNeeded()) 88 if (exceptionState.throwIfNeeded())
93 return; 89 return;
94 {% endif %} 90 {% endif %}
(...skipping 28 matching lines...) Expand all
123 {##############################################################################} 119 {##############################################################################}
124 {% block indexed_property_deleter %} 120 {% block indexed_property_deleter %}
125 {% if indexed_property_deleter and not indexed_property_deleter.is_custom %} 121 {% if indexed_property_deleter and not indexed_property_deleter.is_custom %}
126 {% set deleter = indexed_property_deleter %} 122 {% set deleter = indexed_property_deleter %}
127 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInf o<v8::Boolean>& info) 123 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInf o<v8::Boolean>& info)
128 { 124 {
129 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); 125 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder());
130 {% if deleter.is_raises_exception %} 126 {% if deleter.is_raises_exception %}
131 ExceptionState exceptionState(ExceptionState::IndexedDeletionContext, "{{int erface_name}}", info.Holder(), info.GetIsolate()); 127 ExceptionState exceptionState(ExceptionState::IndexedDeletionContext, "{{int erface_name}}", info.Holder(), info.GetIsolate());
132 {% endif %} 128 {% endif %}
133 {% if deleter.is_call_with_script_state %}
134 ScriptState* scriptState = ScriptState::current(info.GetIsolate());
135 {% endif %}
136 {% set deleter_name = deleter.name or 'anonymousIndexedDeleter' %} 129 {% set deleter_name = deleter.name or 'anonymousIndexedDeleter' %}
137 {% set deleter_arguments = ['index'] %} 130 {% set deleter_arguments = ['index'] %}
138 {% if deleter.is_call_with_script_state %} 131 {% if deleter.is_call_with_script_state %}
132 ScriptState* scriptState = ScriptState::current(info.GetIsolate());
139 {% set deleter_arguments = ['scriptState'] + deleter_arguments %} 133 {% set deleter_arguments = ['scriptState'] + deleter_arguments %}
140 {% endif %} 134 {% endif %}
141 {% if deleter.is_raises_exception %} 135 {% if deleter.is_raises_exception %}
142 {% set deleter_arguments = deleter_arguments + ['exceptionState'] %} 136 {% set deleter_arguments = deleter_arguments + ['exceptionState'] %}
143 {% endif %} 137 {% endif %}
144 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ' )}}); 138 DeleteResult result = impl->{{deleter_name}}({{deleter_arguments | join(', ' )}});
145 {% if deleter.is_raises_exception %} 139 {% if deleter.is_raises_exception %}
146 if (exceptionState.throwIfNeeded()) 140 if (exceptionState.throwIfNeeded())
147 return; 141 return;
148 {% endif %} 142 {% endif %}
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 } 1036 }
1043 1037
1044 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} 1038 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %}
1045 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) 1039 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&))
1046 { 1040 {
1047 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; 1041 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method;
1048 } 1042 }
1049 {% endfor %} 1043 {% endfor %}
1050 {% endif %} 1044 {% endif %}
1051 {% endblock %} 1045 {% endblock %}
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698