1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This file has been auto-generated from the Jinja2 template
6 // third_party/blink/renderer/bindings/templates/partial_interface.cc.tmpl
7 // by the script code_generator_v8.py.
8 // DO NOT MODIFY!
9
10 // clang-format off
11 #include "third_party/blink/renderer/bindings/tests/results/modules/v8_test_interface_partial.h"
12
13 #include <algorithm>
14
15 #include "base/memory/scoped_refptr.h"
16 #include "third_party/blink/renderer/bindings/core/v8/idl_types.h"
17 #include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h"
18 #include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
19 #include "third_party/blink/renderer/bindings/core/v8/v8_document.h"
20 #include "third_party/blink/renderer/bindings/core/v8/v8_dom_configuration.h"
21 #include "third_party/blink/renderer/bindings/core/v8/v8_node.h"
22 #include "third_party/blink/renderer/bindings/core/v8/v8_test_callback_interface.h"
23 #include "third_party/blink/renderer/bindings/core/v8/v8_test_interface.h"
24 #include "third_party/blink/renderer/bindings/tests/idls/modules/test_interface_partial_3_implementation.h"
25 #include "third_party/blink/renderer/bindings/tests/idls/modules/test_interface_partial_4.h"
26 #include "third_party/blink/renderer/core/execution_context/execution_context.h"
27 #include "third_party/blink/renderer/platform/bindings/exception_messages.h"
28 #include "third_party/blink/renderer/platform/bindings/exception_state.h"
29 #include "third_party/blink/renderer/platform/bindings/runtime_call_stats.h"
30 #include "third_party/blink/renderer/platform/bindings/script_state.h"
31 #include "third_party/blink/renderer/platform/bindings/v8_object_constructor.h"
32 #include "third_party/blink/renderer/platform/bindings/v8_per_context_data.h"
33 #include "third_party/blink/renderer/platform/runtime_enabled_features.h"
34 #include "third_party/blink/renderer/platform/scheduler/public/cooperative_scheduling_manager.h"
35 #include "third_party/blink/renderer/platform/wtf/get_ptr.h"
36
37 namespace blink {
38
39 namespace test_interface_implementation_partial_v8_internal {
40
Partial4LongAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value> & info)41 static void Partial4LongAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
42 v8::Local<v8::Object> holder = info.Holder();
43
44 TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder);
45
46 V8SetReturnValueInt(info, TestInterfacePartial4::partial4LongAttribute(*impl));
47 }
48
Partial4LongAttributeAttributeSetter(v8::Local<v8::Value> v8_value,const v8::FunctionCallbackInfo<v8::Value> & info)49 static void Partial4LongAttributeAttributeSetter(
50 v8::Local<v8::Value> v8_value, const v8::FunctionCallbackInfo<v8::Value>& info) {
51 v8::Isolate* isolate = info.GetIsolate();
52 ALLOW_UNUSED_LOCAL(isolate);
53
54 v8::Local<v8::Object> holder = info.Holder();
55 ALLOW_UNUSED_LOCAL(holder);
56
57 TestInterfaceImplementation* impl = V8TestInterface::ToImpl(holder);
58
59 ExceptionState exception_state(isolate, ExceptionState::kSetterContext, "TestInterface", "partial4LongAttribute");
60
61 // Prepare the value to be set.
62 int32_t cpp_value{ NativeValueTraits<IDLLong>::NativeValue(info.GetIsolate(), v8_value, exception_state) };
63 if (exception_state.HadException())
64 return;
65
66 TestInterfacePartial4::setPartial4LongAttribute(*impl, cpp_value);
67 }
68
Partial4StaticLongAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value> & info)69 static void Partial4StaticLongAttributeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
70 V8SetReturnValueInt(info, TestInterfacePartial4::partial4StaticLongAttribute());
71 }
72
Partial4StaticLongAttributeAttributeSetter(v8::Local<v8::Value> v8_value,const v8::FunctionCallbackInfo<v8::Value> & info)73 static void Partial4StaticLongAttributeAttributeSetter(
74 v8::Local<v8::Value> v8_value, const v8::FunctionCallbackInfo<v8::Value>& info) {
75 v8::Isolate* isolate = info.GetIsolate();
76 ALLOW_UNUSED_LOCAL(isolate);
77
78 v8::Local<v8::Object> holder = info.Holder();
79 ALLOW_UNUSED_LOCAL(holder);
80
81 ExceptionState exception_state(isolate, ExceptionState::kSetterContext, "TestInterface", "partial4StaticLongAttribute");
82
83 // Prepare the value to be set.
84 int32_t cpp_value{ NativeValueTraits<IDLLong>::NativeValue(info.GetIsolate(), v8_value, exception_state) };
85 if (exception_state.HadException())
86 return;
87
88 TestInterfacePartial4::setPartial4StaticLongAttribute(cpp_value);
89 }
90
VoidMethodPartialOverload3Method(const v8::FunctionCallbackInfo<v8::Value> & info)91 static void VoidMethodPartialOverload3Method(const v8::FunctionCallbackInfo<v8::Value>& info) {
92 TestInterfaceImplementation* impl = V8TestInterface::ToImpl(info.Holder());
93
94 V8StringResource<> value;
95 value = info[0];
96 if (!value.Prepare())
97 return;
98
99 TestInterfacePartial3Implementation::voidMethodPartialOverload(*impl, value);
100 }
101
VoidMethodPartialOverloadMethod(const v8::FunctionCallbackInfo<v8::Value> & info)102 static void VoidMethodPartialOverloadMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
103 scheduler::CooperativeSchedulingManager::Instance()->Safepoint();
104
105 bool is_arity_error = false;
106
107 switch (std::min(1, info.Length())) {
108 case 0:
109 break;
110 case 1:
111 if (true) {
112 VoidMethodPartialOverload3Method(info);
113 return;
114 }
115 break;
116 default:
117 is_arity_error = true;
118 }
119
120 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface", "voidMethodPartialOverload");
121 if (is_arity_error) {
122 }
123 exception_state.ThrowTypeError("No function was found that matched the signature provided.");
124 }
125
StaticVoidMethodPartialOverload2Method(const v8::FunctionCallbackInfo<v8::Value> & info)126 static void StaticVoidMethodPartialOverload2Method(const v8::FunctionCallbackInfo<v8::Value>& info) {
127 V8StringResource<> value;
128 value = info[0];
129 if (!value.Prepare())
130 return;
131
132 TestInterfacePartial3Implementation::staticVoidMethodPartialOverload(value);
133 }
134
StaticVoidMethodPartialOverloadMethod(const v8::FunctionCallbackInfo<v8::Value> & info)135 static void StaticVoidMethodPartialOverloadMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
136 scheduler::CooperativeSchedulingManager::Instance()->Safepoint();
137
138 bool is_arity_error = false;
139
140 switch (std::min(1, info.Length())) {
141 case 0:
142 break;
143 case 1:
144 if (true) {
145 StaticVoidMethodPartialOverload2Method(info);
146 return;
147 }
148 break;
149 default:
150 is_arity_error = true;
151 }
152
153 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface", "staticVoidMethodPartialOverload");
154 if (is_arity_error) {
155 }
156 exception_state.ThrowTypeError("No function was found that matched the signature provided.");
157 }
158
PromiseMethodPartialOverload3Method(const v8::FunctionCallbackInfo<v8::Value> & info)159 static void PromiseMethodPartialOverload3Method(const v8::FunctionCallbackInfo<v8::Value>& info) {
160 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface", "promiseMethodPartialOverload");
161 ExceptionToRejectPromiseScope reject_promise_scope(info, exception_state);
162
163 // V8DOMConfiguration::kDoNotCheckHolder
164 // Make sure that info.Holder() really points to an instance of the type.
165 if (!V8TestInterface::HasInstance(info.Holder(), info.GetIsolate())) {
166 exception_state.ThrowTypeError("Illegal invocation");
167 return;
168 }
169 TestInterfaceImplementation* impl = V8TestInterface::ToImpl(info.Holder());
170
171 Document* document;
172 document = V8Document::ToImplWithTypeCheck(info.GetIsolate(), info[0]);
173 if (!document) {
174 exception_state.ThrowTypeError(ExceptionMessages::ArgumentNotOfType(0, "Document"));
175 return;
176 }
177
178 V8SetReturnValue(info, TestInterfacePartial3Implementation::promiseMethodPartialOverload(*impl, document).V8Value());
179 }
180
PromiseMethodPartialOverloadMethod(const v8::FunctionCallbackInfo<v8::Value> & info)181 static void PromiseMethodPartialOverloadMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
182 scheduler::CooperativeSchedulingManager::Instance()->Safepoint();
183
184 bool is_arity_error = false;
185
186 switch (std::min(1, info.Length())) {
187 case 0:
188 break;
189 case 1:
190 if (V8Document::HasInstance(info[0], info.GetIsolate())) {
191 PromiseMethodPartialOverload3Method(info);
192 return;
193 }
194 break;
195 default:
196 is_arity_error = true;
197 }
198
199 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface", "promiseMethodPartialOverload");
200 ExceptionToRejectPromiseScope reject_promise_scope(info, exception_state);
201 if (is_arity_error) {
202 }
203 exception_state.ThrowTypeError("No function was found that matched the signature provided.");
204 }
205
StaticPromiseMethodPartialOverload2Method(const v8::FunctionCallbackInfo<v8::Value> & info)206 static void StaticPromiseMethodPartialOverload2Method(const v8::FunctionCallbackInfo<v8::Value>& info) {
207 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface", "staticPromiseMethodPartialOverload");
208 ExceptionToRejectPromiseScope reject_promise_scope(info, exception_state);
209
210 V8StringResource<> value;
211 value = info[0];
212 if (!value.Prepare(exception_state))
213 return;
214
215 V8SetReturnValue(info, TestInterfacePartial3Implementation::staticPromiseMethodPartialOverload(value).V8Value());
216 }
217
StaticPromiseMethodPartialOverloadMethod(const v8::FunctionCallbackInfo<v8::Value> & info)218 static void StaticPromiseMethodPartialOverloadMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
219 scheduler::CooperativeSchedulingManager::Instance()->Safepoint();
220
221 bool is_arity_error = false;
222
223 switch (std::min(1, info.Length())) {
224 case 0:
225 break;
226 case 1:
227 if (true) {
228 StaticPromiseMethodPartialOverload2Method(info);
229 return;
230 }
231 break;
232 default:
233 is_arity_error = true;
234 }
235
236 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface", "staticPromiseMethodPartialOverload");
237 ExceptionToRejectPromiseScope reject_promise_scope(info, exception_state);
238 if (is_arity_error) {
239 }
240 exception_state.ThrowTypeError("No function was found that matched the signature provided.");
241 }
242
Partial2VoidMethod2Method(const v8::FunctionCallbackInfo<v8::Value> & info)243 static void Partial2VoidMethod2Method(const v8::FunctionCallbackInfo<v8::Value>& info) {
244 TestInterfaceImplementation* impl = V8TestInterface::ToImpl(info.Holder());
245
246 V8StringResource<> value;
247 value = info[0];
248 if (!value.Prepare())
249 return;
250
251 TestInterfacePartial3Implementation::partial2VoidMethod(*impl, value);
252 }
253
Partial2VoidMethod3Method(const v8::FunctionCallbackInfo<v8::Value> & info)254 static void Partial2VoidMethod3Method(const v8::FunctionCallbackInfo<v8::Value>& info) {
255 TestInterfaceImplementation* impl = V8TestInterface::ToImpl(info.Holder());
256
257 Node* node;
258 node = V8Node::ToImplWithTypeCheck(info.GetIsolate(), info[0]);
259 if (!node) {
260 V8ThrowException::ThrowTypeError(info.GetIsolate(), ExceptionMessages::FailedToExecute("partial2VoidMethod", "TestInterface", ExceptionMessages::ArgumentNotOfType(0, "Node")));
261 return;
262 }
263
264 TestInterfacePartial3Implementation::partial2VoidMethod(*impl, node);
265 }
266
Partial2VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value> & info)267 static void Partial2VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
268 scheduler::CooperativeSchedulingManager::Instance()->Safepoint();
269
270 bool is_arity_error = false;
271
272 switch (std::min(1, info.Length())) {
273 case 0:
274 break;
275 case 1:
276 if (V8Node::HasInstance(info[0], info.GetIsolate())) {
277 Partial2VoidMethod3Method(info);
278 return;
279 }
280 if (true) {
281 Partial2VoidMethod2Method(info);
282 return;
283 }
284 break;
285 default:
286 is_arity_error = true;
287 }
288
289 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface", "partial2VoidMethod");
290 if (is_arity_error) {
291 }
292 exception_state.ThrowTypeError("No function was found that matched the signature provided.");
293 }
294
PartialVoidTestEnumModulesArgMethodMethod(const v8::FunctionCallbackInfo<v8::Value> & info)295 static void PartialVoidTestEnumModulesArgMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
296 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface", "partialVoidTestEnumModulesArgMethod");
297
298 TestInterfaceImplementation* impl = V8TestInterface::ToImpl(info.Holder());
299
300 if (UNLIKELY(info.Length() < 1)) {
301 exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
302 return;
303 }
304
305 V8StringResource<> arg;
306 arg = info[0];
307 if (!arg.Prepare())
308 return;
309 const char* const kValidArgValues[] = {
310 "EnumModulesValue1",
311 "EnumModulesValue2",
312 };
313 if (!IsValidEnum(arg, kValidArgValues, base::size(kValidArgValues), "TestEnumModules", exception_state)) {
314 return;
315 }
316
317 TestInterfacePartial3Implementation::partialVoidTestEnumModulesArgMethod(*impl, arg);
318 }
319
Partial2StaticVoidMethod2Method(const v8::FunctionCallbackInfo<v8::Value> & info)320 static void Partial2StaticVoidMethod2Method(const v8::FunctionCallbackInfo<v8::Value>& info) {
321 V8StringResource<> value;
322 value = info[0];
323 if (!value.Prepare())
324 return;
325
326 TestInterfacePartial3Implementation::partial2StaticVoidMethod(value);
327 }
328
Partial2StaticVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value> & info)329 static void Partial2StaticVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
330 scheduler::CooperativeSchedulingManager::Instance()->Safepoint();
331
332 bool is_arity_error = false;
333
334 switch (std::min(1, info.Length())) {
335 case 0:
336 break;
337 case 1:
338 if (true) {
339 Partial2StaticVoidMethod2Method(info);
340 return;
341 }
342 break;
343 default:
344 is_arity_error = true;
345 }
346
347 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface", "partial2StaticVoidMethod");
348 if (is_arity_error) {
349 }
350 exception_state.ThrowTypeError("No function was found that matched the signature provided.");
351 }
352
Partial2VoidTestEnumModulesRecordMethodMethod(const v8::FunctionCallbackInfo<v8::Value> & info)353 static void Partial2VoidTestEnumModulesRecordMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
354 ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestInterface", "partial2VoidTestEnumModulesRecordMethod");
355
356 TestInterfaceImplementation* impl = V8TestInterface::ToImpl(info.Holder());
357
358 if (UNLIKELY(info.Length() < 1)) {
359 exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
360 return;
361 }
362
363 Vector<std::pair<String, String>> arg;
364 arg = NativeValueTraits<IDLRecord<IDLString, IDLString>>::NativeValue(info.GetIsolate(), info[0], exception_state);
365 if (exception_state.HadException())
366 return;
367
368 TestInterfacePartial3Implementation::partial2VoidTestEnumModulesRecordMethod(*impl, arg);
369 }
370
UnscopableVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value> & info)371 static void UnscopableVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
372 TestInterfaceImplementation* impl = V8TestInterface::ToImpl(info.Holder());
373
374 TestInterfacePartial3Implementation::unscopableVoidMethod(*impl);
375 }
376
UnionWithTypedefMethodMethod(const v8::FunctionCallbackInfo<v8::Value> & info)377 static void UnionWithTypedefMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
378 TestInterfaceImplementation* impl = V8TestInterface::ToImpl(info.Holder());
379
380 UnsignedLongLongOrBooleanOrTestCallbackInterface result;
381 TestInterfacePartial3Implementation::unionWithTypedefMethod(*impl, result);
382 V8SetReturnValue(info, result);
383 }
384
Partial4VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value> & info)385 static void Partial4VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
386 TestInterfaceImplementation* impl = V8TestInterface::ToImpl(info.Holder());
387
388 TestInterfacePartial4::partial4VoidMethod(*impl);
389 }
390
Partial4StaticVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value> & info)391 static void Partial4StaticVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
392 TestInterfacePartial4::partial4StaticVoidMethod();
393 }
394
395 } // namespace test_interface_implementation_partial_v8_internal
396
Partial4LongAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value> & info)397 void V8TestInterfacePartial::Partial4LongAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
398 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_partial4LongAttribute_Getter");
399
400 test_interface_implementation_partial_v8_internal::Partial4LongAttributeAttributeGetter(info);
401 }
402
Partial4LongAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value> & info)403 void V8TestInterfacePartial::Partial4LongAttributeAttributeSetterCallback(
404 const v8::FunctionCallbackInfo<v8::Value>& info) {
405 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_partial4LongAttribute_Setter");
406
407 v8::Local<v8::Value> v8_value = info[0];
408
409 test_interface_implementation_partial_v8_internal::Partial4LongAttributeAttributeSetter(v8_value, info);
410 }
411
Partial4StaticLongAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value> & info)412 void V8TestInterfacePartial::Partial4StaticLongAttributeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
413 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_partial4StaticLongAttribute_Getter");
414
415 test_interface_implementation_partial_v8_internal::Partial4StaticLongAttributeAttributeGetter(info);
416 }
417
Partial4StaticLongAttributeAttributeSetterCallback(const v8::FunctionCallbackInfo<v8::Value> & info)418 void V8TestInterfacePartial::Partial4StaticLongAttributeAttributeSetterCallback(
419 const v8::FunctionCallbackInfo<v8::Value>& info) {
420 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_partial4StaticLongAttribute_Setter");
421
422 v8::Local<v8::Value> v8_value = info[0];
423
424 test_interface_implementation_partial_v8_internal::Partial4StaticLongAttributeAttributeSetter(v8_value, info);
425 }
426
PartialVoidTestEnumModulesArgMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)427 void V8TestInterfacePartial::PartialVoidTestEnumModulesArgMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
428 BLINK_BINDINGS_TRACE_EVENT("TestInterface.partialVoidTestEnumModulesArgMethod");
429 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_partialVoidTestEnumModulesArgMethod");
430
431 test_interface_implementation_partial_v8_internal::PartialVoidTestEnumModulesArgMethodMethod(info);
432 }
433
Partial2VoidTestEnumModulesRecordMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)434 void V8TestInterfacePartial::Partial2VoidTestEnumModulesRecordMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
435 BLINK_BINDINGS_TRACE_EVENT("TestInterface.partial2VoidTestEnumModulesRecordMethod");
436 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_partial2VoidTestEnumModulesRecordMethod");
437
438 test_interface_implementation_partial_v8_internal::Partial2VoidTestEnumModulesRecordMethodMethod(info);
439 }
440
UnscopableVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)441 void V8TestInterfacePartial::UnscopableVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
442 BLINK_BINDINGS_TRACE_EVENT("TestInterface.unscopableVoidMethod");
443 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_unscopableVoidMethod");
444
445 test_interface_implementation_partial_v8_internal::UnscopableVoidMethodMethod(info);
446 }
447
UnionWithTypedefMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)448 void V8TestInterfacePartial::UnionWithTypedefMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
449 BLINK_BINDINGS_TRACE_EVENT("TestInterface.unionWithTypedefMethod");
450 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_unionWithTypedefMethod");
451
452 test_interface_implementation_partial_v8_internal::UnionWithTypedefMethodMethod(info);
453 }
454
Partial4VoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)455 void V8TestInterfacePartial::Partial4VoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
456 BLINK_BINDINGS_TRACE_EVENT("TestInterface.partial4VoidMethod");
457 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_partial4VoidMethod");
458
459 test_interface_implementation_partial_v8_internal::Partial4VoidMethodMethod(info);
460 }
461
Partial4StaticVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value> & info)462 void V8TestInterfacePartial::Partial4StaticVoidMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
463 BLINK_BINDINGS_TRACE_EVENT("TestInterface.partial4StaticVoidMethod");
464 RUNTIME_CALL_TIMER_SCOPE_DISABLED_BY_DEFAULT(info.GetIsolate(), "Blink_TestInterfaceImplementation_partial4StaticVoidMethod");
465
466 test_interface_implementation_partial_v8_internal::Partial4StaticVoidMethodMethod(info);
467 }
468
469 static constexpr V8DOMConfiguration::MethodConfiguration kV8TestInterfaceMethods[] = {
470 {"partialVoidTestEnumModulesArgMethod", V8TestInterfacePartial::PartialVoidTestEnumModulesArgMethodMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
471 {"partial2VoidTestEnumModulesRecordMethod", V8TestInterfacePartial::Partial2VoidTestEnumModulesRecordMethodMethodCallback, 1, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
472 {"unscopableVoidMethod", V8TestInterfacePartial::UnscopableVoidMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
473 {"unionWithTypedefMethod", V8TestInterfacePartial::UnionWithTypedefMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds},
474 };
475
InstallV8TestInterfaceTemplate(v8::Isolate * isolate,const DOMWrapperWorld & world,v8::Local<v8::FunctionTemplate> interface_template)476 void V8TestInterfacePartial::InstallV8TestInterfaceTemplate(
477 v8::Isolate* isolate,
478 const DOMWrapperWorld& world,
479 v8::Local<v8::FunctionTemplate> interface_template) {
480 // Initialize the interface object's template.
481 V8TestInterface::InstallV8TestInterfaceTemplate(isolate, world, interface_template);
482
483 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interface_template);
484 ALLOW_UNUSED_LOCAL(signature);
485 v8::Local<v8::ObjectTemplate> instance_template = interface_template->InstanceTemplate();
486 ALLOW_UNUSED_LOCAL(instance_template);
487 v8::Local<v8::ObjectTemplate> prototype_template = interface_template->PrototypeTemplate();
488 ALLOW_UNUSED_LOCAL(prototype_template);
489
490 // Register IDL constants, attributes and operations.
491 {
492 static constexpr V8DOMConfiguration::ConstantConfiguration kConstants[] = {
493 {"PARTIAL3_UNSIGNED_SHORT", V8DOMConfiguration::kConstantTypeUnsignedShort, static_cast<int>(0)},
494 };
495 V8DOMConfiguration::InstallConstants(
496 isolate, interface_template, prototype_template,
497 kConstants, base::size(kConstants));
498 }
499 V8DOMConfiguration::InstallMethods(
500 isolate, world, instance_template, prototype_template, interface_template,
501 signature, kV8TestInterfaceMethods, base::size(kV8TestInterfaceMethods));
502
503 // Custom signature
504
505 V8TestInterfacePartial::InstallRuntimeEnabledFeaturesOnTemplate(
506 isolate, world, interface_template);
507 }
508
InstallRuntimeEnabledFeaturesOnTemplate(v8::Isolate * isolate,const DOMWrapperWorld & world,v8::Local<v8::FunctionTemplate> interface_template)509 void V8TestInterfacePartial::InstallRuntimeEnabledFeaturesOnTemplate(
510 v8::Isolate* isolate,
511 const DOMWrapperWorld& world,
512 v8::Local<v8::FunctionTemplate> interface_template) {
513 V8TestInterface::InstallRuntimeEnabledFeaturesOnTemplate(isolate, world, interface_template);
514
515 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interface_template);
516 ALLOW_UNUSED_LOCAL(signature);
517 v8::Local<v8::ObjectTemplate> instance_template = interface_template->InstanceTemplate();
518 ALLOW_UNUSED_LOCAL(instance_template);
519 v8::Local<v8::ObjectTemplate> prototype_template = interface_template->PrototypeTemplate();
520 ALLOW_UNUSED_LOCAL(prototype_template);
521
522 // Register IDL constants, attributes and operations.
523
524 // Custom signature
525 }
526
InstallOriginTrialPartialFeature(v8::Isolate * isolate,const DOMWrapperWorld & world,v8::Local<v8::Object> instance,v8::Local<v8::Object> prototype,v8::Local<v8::Function> interface)527 void V8TestInterfacePartial::InstallOriginTrialPartialFeature(
528 v8::Isolate* isolate,
529 const DOMWrapperWorld& world,
530 v8::Local<v8::Object> instance,
531 v8::Local<v8::Object> prototype,
532 v8::Local<v8::Function> interface) {
533 v8::Local<v8::FunctionTemplate> interface_template =
534 V8TestInterface::GetWrapperTypeInfo()->DomTemplate(isolate, world);
535 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interface_template);
536 ALLOW_UNUSED_LOCAL(signature);
537 ExecutionContext* execution_context = ToExecutionContext(isolate->GetCurrentContext());
538 bool is_secure_context = (execution_context && execution_context->IsSecureContext());
539 if (is_secure_context) {
540 static constexpr V8DOMConfiguration::AccessorConfiguration
541 kAccessorConfigurations[] = {
542 { "partial4LongAttribute", V8TestInterfacePartial::Partial4LongAttributeAttributeGetterCallback, V8TestInterfacePartial::Partial4LongAttributeAttributeSetterCallback, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
543 { "partial4StaticLongAttribute", V8TestInterfacePartial::Partial4StaticLongAttributeAttributeGetterCallback, V8TestInterfacePartial::Partial4StaticLongAttributeAttributeSetterCallback, static_cast<unsigned>(V8PrivateProperty::CachedAccessor::kNone), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::kOnInterface, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds },
544 };
545 V8DOMConfiguration::InstallAccessors(
546 isolate, world, instance, prototype, interface,
547 signature, kAccessorConfigurations,
548 base::size(kAccessorConfigurations));
549 }
550 static constexpr V8DOMConfiguration::ConstantConfiguration
551 kPARTIAL4UNSIGNEDSHORTConfiguration = {"PARTIAL4_UNSIGNED_SHORT", V8DOMConfiguration::kConstantTypeUnsignedShort, static_cast<int>(4)};
552 V8DOMConfiguration::InstallConstant(
553 isolate, interface, prototype, kPARTIAL4UNSIGNEDSHORTConfiguration);
554 if (is_secure_context) {
555 static constexpr V8DOMConfiguration::MethodConfiguration
556 kPartial4StaticVoidMethodConfigurations[] = {
557 {"partial4StaticVoidMethod", V8TestInterfacePartial::Partial4StaticVoidMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnInterface, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds}
558 };
559 for (const auto& config : kPartial4StaticVoidMethodConfigurations) {
560 V8DOMConfiguration::InstallMethod(
561 isolate, world, instance, prototype,
562 interface, signature, config);
563 }
564 }
565 if (is_secure_context) {
566 static constexpr V8DOMConfiguration::MethodConfiguration
567 kPartial4VoidMethodConfigurations[] = {
568 {"partial4VoidMethod", V8TestInterfacePartial::Partial4VoidMethodMethodCallback, 0, v8::None, V8DOMConfiguration::kOnPrototype, V8DOMConfiguration::kCheckHolder, V8DOMConfiguration::kDoNotCheckAccess, V8DOMConfiguration::kHasSideEffect, V8DOMConfiguration::kAllWorlds}
569 };
570 for (const auto& config : kPartial4VoidMethodConfigurations) {
571 V8DOMConfiguration::InstallMethod(
572 isolate, world, instance, prototype,
573 interface, signature, config);
574 }
575 }
576 }
577
InstallOriginTrialPartialFeature(ScriptState * script_state,v8::Local<v8::Object> instance)578 void V8TestInterfacePartial::InstallOriginTrialPartialFeature(
579 ScriptState* script_state, v8::Local<v8::Object> instance) {
580 V8PerContextData* per_context_data = script_state->PerContextData();
581 v8::Local<v8::Object> prototype = per_context_data->PrototypeForType(
582 V8TestInterface::GetWrapperTypeInfo());
583 v8::Local<v8::Function> interface = per_context_data->ConstructorForType(
584 V8TestInterface::GetWrapperTypeInfo());
585 ALLOW_UNUSED_LOCAL(interface);
586 InstallOriginTrialPartialFeature(script_state->GetIsolate(), script_state->World(), instance, prototype, interface);
587 }
588
InstallOriginTrialPartialFeature(ScriptState * script_state)589 void V8TestInterfacePartial::InstallOriginTrialPartialFeature(ScriptState* script_state) {
590 InstallOriginTrialPartialFeature(script_state, v8::Local<v8::Object>());
591 }
592
InstallConditionalFeatures(v8::Local<v8::Context> context,const DOMWrapperWorld & world,v8::Local<v8::Object> instance_object,v8::Local<v8::Object> prototype_object,v8::Local<v8::Function> interface_object,v8::Local<v8::FunctionTemplate> interface_template)593 void V8TestInterfacePartial::InstallConditionalFeatures(
594 v8::Local<v8::Context> context,
595 const DOMWrapperWorld& world,
596 v8::Local<v8::Object> instance_object,
597 v8::Local<v8::Object> prototype_object,
598 v8::Local<v8::Function> interface_object,
599 v8::Local<v8::FunctionTemplate> interface_template) {
600 CHECK(!interface_template.IsEmpty());
601 DCHECK((!prototype_object.IsEmpty() && !interface_object.IsEmpty()) ||
602 !instance_object.IsEmpty());
603 V8TestInterface::InstallConditionalFeatures(
604 context, world, instance_object, prototype_object, interface_object, interface_template);
605
606 v8::Isolate* isolate = context->GetIsolate();
607
608 if (!prototype_object.IsEmpty()) {
609 v8::Local<v8::Name> unscopables_symbol(v8::Symbol::GetUnscopables(isolate));
610 v8::Local<v8::Object> unscopables;
611 bool has_unscopables;
612 if (prototype_object->HasOwnProperty(context, unscopables_symbol)
613 .To(&has_unscopables) && has_unscopables) {
614 unscopables = prototype_object->Get(context, unscopables_symbol)
615 .ToLocalChecked().As<v8::Object>();
616 } else {
617 // Web IDL 3.6.3. Interface prototype object
618 // https://heycam.github.io/webidl/#create-an-interface-prototype-object
619 // step 8.1. Let unscopableObject be the result of performing
620 // ! ObjectCreate(null).
621 unscopables = v8::Object::New(isolate);
622 unscopables->SetPrototype(context, v8::Null(isolate)).ToChecked();
623 }
624 unscopables->CreateDataProperty(
625 context, V8AtomicString(isolate, "unscopableVoidMethod"), v8::True(isolate))
626 .FromJust();
627 prototype_object->CreateDataProperty(
628 context, unscopables_symbol, unscopables).FromJust();
629 }
630 }
631
Initialize()632 void V8TestInterfacePartial::Initialize() {
633 // Should be invoked from ModulesInitializer.
634 V8TestInterface::UpdateWrapperTypeInfo(
635 &V8TestInterfacePartial::InstallV8TestInterfaceTemplate,
636 nullptr,
637 &V8TestInterfacePartial::InstallRuntimeEnabledFeaturesOnTemplate,
638 V8TestInterfacePartial::InstallConditionalFeatures);
639 V8TestInterface::RegisterVoidMethodPartialOverloadMethodForPartialInterface(&test_interface_implementation_partial_v8_internal::VoidMethodPartialOverloadMethod);
640 V8TestInterface::RegisterStaticVoidMethodPartialOverloadMethodForPartialInterface(&test_interface_implementation_partial_v8_internal::StaticVoidMethodPartialOverloadMethod);
641 V8TestInterface::RegisterPromiseMethodPartialOverloadMethodForPartialInterface(&test_interface_implementation_partial_v8_internal::PromiseMethodPartialOverloadMethod);
642 V8TestInterface::RegisterStaticPromiseMethodPartialOverloadMethodForPartialInterface(&test_interface_implementation_partial_v8_internal::StaticPromiseMethodPartialOverloadMethod);
643 V8TestInterface::RegisterPartial2VoidMethodMethodForPartialInterface(&test_interface_implementation_partial_v8_internal::Partial2VoidMethodMethod);
644 V8TestInterface::RegisterPartial2StaticVoidMethodMethodForPartialInterface(&test_interface_implementation_partial_v8_internal::Partial2StaticVoidMethodMethod);
645 }
646
647 } // namespace blink
648