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

Side by Side Diff: Source/bindings/tests/results/V8TestObject.cpp

Issue 85263006: Make IDL Callbacks non-refcounted by default (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Refinements Created 7 years 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 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 3528 matching lines...) Expand 10 before | Expand all | Expand 10 after
3539 { 3539 {
3540 if (UNLIKELY(info.Length() < 1)) { 3540 if (UNLIKELY(info.Length() < 1)) {
3541 throwTypeError(ExceptionMessages::failedToExecute("methodWithCallbackArg ", "TestObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info. GetIsolate()); 3541 throwTypeError(ExceptionMessages::failedToExecute("methodWithCallbackArg ", "TestObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info. GetIsolate());
3542 return; 3542 return;
3543 } 3543 }
3544 TestObj* imp = V8TestObject::toNative(info.Holder()); 3544 TestObj* imp = V8TestObject::toNative(info.Holder());
3545 if (info.Length() <= 0 || !info[0]->IsFunction()) { 3545 if (info.Length() <= 0 || !info[0]->IsFunction()) {
3546 throwTypeError(ExceptionMessages::failedToExecute("methodWithCallbackArg ", "TestObject", "The callback provided as parameter 1 is not a function."), inf o.GetIsolate()); 3546 throwTypeError(ExceptionMessages::failedToExecute("methodWithCallbackArg ", "TestObject", "The callback provided as parameter 1 is not a function."), inf o.GetIsolate());
3547 return; 3547 return;
3548 } 3548 }
3549 RefPtr<TestCallback> callback = V8TestCallback::create(info[0], getExecution Context()); 3549 OwnPtr<TestCallback> callback = V8TestCallback::create(info[0], getExecution Context());
3550 imp->methodWithCallbackArg(callback.release()); 3550 imp->methodWithCallbackArg(callback.release());
3551 } 3551 }
3552 3552
3553 static void methodWithCallbackArgMethodCallback(const v8::FunctionCallbackInfo<v 8::Value>& info) 3553 static void methodWithCallbackArgMethodCallback(const v8::FunctionCallbackInfo<v 8::Value>& info)
3554 { 3554 {
3555 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 3555 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
3556 TestObjV8Internal::methodWithCallbackArgMethod(info); 3556 TestObjV8Internal::methodWithCallbackArgMethod(info);
3557 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 3557 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
3558 } 3558 }
3559 3559
3560 static void methodWithNonCallbackArgAndCallbackArgMethod(const v8::FunctionCallb ackInfo<v8::Value>& info) 3560 static void methodWithNonCallbackArgAndCallbackArgMethod(const v8::FunctionCallb ackInfo<v8::Value>& info)
3561 { 3561 {
3562 if (UNLIKELY(info.Length() < 2)) { 3562 if (UNLIKELY(info.Length() < 2)) {
3563 throwTypeError(ExceptionMessages::failedToExecute("methodWithNonCallback ArgAndCallbackArg", "TestObject", ExceptionMessages::notEnoughArguments(2, info. Length())), info.GetIsolate()); 3563 throwTypeError(ExceptionMessages::failedToExecute("methodWithNonCallback ArgAndCallbackArg", "TestObject", ExceptionMessages::notEnoughArguments(2, info. Length())), info.GetIsolate());
3564 return; 3564 return;
3565 } 3565 }
3566 TestObj* imp = V8TestObject::toNative(info.Holder()); 3566 TestObj* imp = V8TestObject::toNative(info.Holder());
3567 V8TRYCATCH_VOID(int, nonCallback, toInt32(info[0])); 3567 V8TRYCATCH_VOID(int, nonCallback, toInt32(info[0]));
3568 if (info.Length() <= 1 || !info[1]->IsFunction()) { 3568 if (info.Length() <= 1 || !info[1]->IsFunction()) {
3569 throwTypeError(ExceptionMessages::failedToExecute("methodWithNonCallback ArgAndCallbackArg", "TestObject", "The callback provided as parameter 2 is not a function."), info.GetIsolate()); 3569 throwTypeError(ExceptionMessages::failedToExecute("methodWithNonCallback ArgAndCallbackArg", "TestObject", "The callback provided as parameter 2 is not a function."), info.GetIsolate());
3570 return; 3570 return;
3571 } 3571 }
3572 RefPtr<TestCallback> callback = V8TestCallback::create(info[1], getExecution Context()); 3572 OwnPtr<TestCallback> callback = V8TestCallback::create(info[1], getExecution Context());
3573 imp->methodWithNonCallbackArgAndCallbackArg(nonCallback, callback.release()) ; 3573 imp->methodWithNonCallbackArgAndCallbackArg(nonCallback, callback.release()) ;
3574 } 3574 }
3575 3575
3576 static void methodWithNonCallbackArgAndCallbackArgMethodCallback(const v8::Funct ionCallbackInfo<v8::Value>& info) 3576 static void methodWithNonCallbackArgAndCallbackArgMethodCallback(const v8::Funct ionCallbackInfo<v8::Value>& info)
3577 { 3577 {
3578 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 3578 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
3579 TestObjV8Internal::methodWithNonCallbackArgAndCallbackArgMethod(info); 3579 TestObjV8Internal::methodWithNonCallbackArgAndCallbackArgMethod(info);
3580 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 3580 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
3581 } 3581 }
3582 3582
3583 static void methodWithCallbackAndOptionalArgMethod(const v8::FunctionCallbackInf o<v8::Value>& info) 3583 static void methodWithCallbackAndOptionalArgMethod(const v8::FunctionCallbackInf o<v8::Value>& info)
3584 { 3584 {
3585 TestObj* imp = V8TestObject::toNative(info.Holder()); 3585 TestObj* imp = V8TestObject::toNative(info.Holder());
3586 RefPtr<TestCallback> callback; 3586 OwnPtr<TestCallback> callback;
3587 if (info.Length() > 0 && !info[0]->IsNull() && !info[0]->IsUndefined()) { 3587 if (info.Length() > 0 && !info[0]->IsNull() && !info[0]->IsUndefined()) {
3588 if (!info[0]->IsFunction()) { 3588 if (!info[0]->IsFunction()) {
3589 throwTypeError(ExceptionMessages::failedToExecute("methodWithCallbac kAndOptionalArg", "TestObject", "The callback provided as parameter 1 is not a f unction."), info.GetIsolate()); 3589 throwTypeError(ExceptionMessages::failedToExecute("methodWithCallbac kAndOptionalArg", "TestObject", "The callback provided as parameter 1 is not a f unction."), info.GetIsolate());
3590 return; 3590 return;
3591 } 3591 }
3592 callback = V8TestCallback::create(info[0], getExecutionContext()); 3592 callback = V8TestCallback::create(info[0], getExecutionContext());
3593 } 3593 }
3594 imp->methodWithCallbackAndOptionalArg(callback.release()); 3594 imp->methodWithCallbackAndOptionalArg(callback.release());
3595 } 3595 }
3596 3596
3597 static void methodWithCallbackAndOptionalArgMethodCallback(const v8::FunctionCal lbackInfo<v8::Value>& info) 3597 static void methodWithCallbackAndOptionalArgMethodCallback(const v8::FunctionCal lbackInfo<v8::Value>& info)
3598 { 3598 {
3599 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 3599 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
3600 TestObjV8Internal::methodWithCallbackAndOptionalArgMethod(info); 3600 TestObjV8Internal::methodWithCallbackAndOptionalArgMethod(info);
3601 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 3601 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
3602 } 3602 }
3603 3603
3604 static void methodWithNullableCallbackArgMethod(const v8::FunctionCallbackInfo<v 8::Value>& info) 3604 static void methodWithNullableCallbackArgMethod(const v8::FunctionCallbackInfo<v 8::Value>& info)
3605 { 3605 {
3606 if (UNLIKELY(info.Length() < 1)) { 3606 if (UNLIKELY(info.Length() < 1)) {
3607 throwTypeError(ExceptionMessages::failedToExecute("methodWithNullableCal lbackArg", "TestObject", ExceptionMessages::notEnoughArguments(1, info.Length()) ), info.GetIsolate()); 3607 throwTypeError(ExceptionMessages::failedToExecute("methodWithNullableCal lbackArg", "TestObject", ExceptionMessages::notEnoughArguments(1, info.Length()) ), info.GetIsolate());
3608 return; 3608 return;
3609 } 3609 }
3610 TestObj* imp = V8TestObject::toNative(info.Holder()); 3610 TestObj* imp = V8TestObject::toNative(info.Holder());
3611 if (info.Length() <= 0 || !(info[0]->IsFunction() || info[0]->IsNull())) { 3611 if (info.Length() <= 0 || !(info[0]->IsFunction() || info[0]->IsNull())) {
3612 throwTypeError(ExceptionMessages::failedToExecute("methodWithNullableCal lbackArg", "TestObject", "The callback provided as parameter 1 is not a function ."), info.GetIsolate()); 3612 throwTypeError(ExceptionMessages::failedToExecute("methodWithNullableCal lbackArg", "TestObject", "The callback provided as parameter 1 is not a function ."), info.GetIsolate());
3613 return; 3613 return;
3614 } 3614 }
3615 RefPtr<TestCallback> callback = info[0]->IsNull() ? 0 : V8TestCallback::crea te(info[0], getExecutionContext()); 3615 OwnPtr<TestCallback> callback = info[0]->IsNull() ? nullptr : V8TestCallback ::create(info[0], getExecutionContext());
3616 imp->methodWithNullableCallbackArg(callback.release()); 3616 imp->methodWithNullableCallbackArg(callback.release());
3617 } 3617 }
3618 3618
3619 static void methodWithNullableCallbackArgMethodCallback(const v8::FunctionCallba ckInfo<v8::Value>& info) 3619 static void methodWithNullableCallbackArgMethodCallback(const v8::FunctionCallba ckInfo<v8::Value>& info)
3620 { 3620 {
3621 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 3621 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
3622 TestObjV8Internal::methodWithNullableCallbackArgMethod(info); 3622 TestObjV8Internal::methodWithNullableCallbackArgMethod(info);
3623 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 3623 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
3624 } 3624 }
3625 3625
3626 static void staticMethodWithCallbackAndOptionalArgMethod(const v8::FunctionCallb ackInfo<v8::Value>& info) 3626 static void staticMethodWithCallbackAndOptionalArgMethod(const v8::FunctionCallb ackInfo<v8::Value>& info)
3627 { 3627 {
3628 RefPtr<TestCallback> callback; 3628 OwnPtr<TestCallback> callback;
3629 if (info.Length() > 0 && !info[0]->IsNull() && !info[0]->IsUndefined()) { 3629 if (info.Length() > 0 && !info[0]->IsNull() && !info[0]->IsUndefined()) {
3630 if (!info[0]->IsFunction()) { 3630 if (!info[0]->IsFunction()) {
3631 throwTypeError(ExceptionMessages::failedToExecute("staticMethodWithC allbackAndOptionalArg", "TestObject", "The callback provided as parameter 1 is n ot a function."), info.GetIsolate()); 3631 throwTypeError(ExceptionMessages::failedToExecute("staticMethodWithC allbackAndOptionalArg", "TestObject", "The callback provided as parameter 1 is n ot a function."), info.GetIsolate());
3632 return; 3632 return;
3633 } 3633 }
3634 callback = V8TestCallback::create(info[0], getExecutionContext()); 3634 callback = V8TestCallback::create(info[0], getExecutionContext());
3635 } 3635 }
3636 TestObj::staticMethodWithCallbackAndOptionalArg(callback.release()); 3636 TestObj::staticMethodWithCallbackAndOptionalArg(callback.release());
3637 } 3637 }
3638 3638
3639 static void staticMethodWithCallbackAndOptionalArgMethodCallback(const v8::Funct ionCallbackInfo<v8::Value>& info) 3639 static void staticMethodWithCallbackAndOptionalArgMethodCallback(const v8::Funct ionCallbackInfo<v8::Value>& info)
3640 { 3640 {
3641 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 3641 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
3642 TestObjV8Internal::staticMethodWithCallbackAndOptionalArgMethod(info); 3642 TestObjV8Internal::staticMethodWithCallbackAndOptionalArgMethod(info);
3643 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 3643 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
3644 } 3644 }
3645 3645
3646 static void staticMethodWithCallbackArgMethod(const v8::FunctionCallbackInfo<v8: :Value>& info) 3646 static void staticMethodWithCallbackArgMethod(const v8::FunctionCallbackInfo<v8: :Value>& info)
3647 { 3647 {
3648 if (UNLIKELY(info.Length() < 1)) { 3648 if (UNLIKELY(info.Length() < 1)) {
3649 throwTypeError(ExceptionMessages::failedToExecute("staticMethodWithCallb ackArg", "TestObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate()); 3649 throwTypeError(ExceptionMessages::failedToExecute("staticMethodWithCallb ackArg", "TestObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate());
3650 return; 3650 return;
3651 } 3651 }
3652 if (info.Length() <= 0 || !info[0]->IsFunction()) { 3652 if (info.Length() <= 0 || !info[0]->IsFunction()) {
3653 throwTypeError(ExceptionMessages::failedToExecute("staticMethodWithCallb ackArg", "TestObject", "The callback provided as parameter 1 is not a function." ), info.GetIsolate()); 3653 throwTypeError(ExceptionMessages::failedToExecute("staticMethodWithCallb ackArg", "TestObject", "The callback provided as parameter 1 is not a function." ), info.GetIsolate());
3654 return; 3654 return;
3655 } 3655 }
3656 RefPtr<TestCallback> callback = V8TestCallback::create(info[0], getExecution Context()); 3656 OwnPtr<TestCallback> callback = V8TestCallback::create(info[0], getExecution Context());
3657 TestObj::staticMethodWithCallbackArg(callback.release()); 3657 TestObj::staticMethodWithCallbackArg(callback.release());
3658 } 3658 }
3659 3659
3660 static void staticMethodWithCallbackArgMethodCallback(const v8::FunctionCallback Info<v8::Value>& info) 3660 static void staticMethodWithCallbackArgMethodCallback(const v8::FunctionCallback Info<v8::Value>& info)
3661 { 3661 {
3662 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 3662 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
3663 TestObjV8Internal::staticMethodWithCallbackArgMethod(info); 3663 TestObjV8Internal::staticMethodWithCallbackArgMethod(info);
3664 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 3664 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
3665 } 3665 }
3666 3666
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
3905 { 3905 {
3906 if (UNLIKELY(info.Length() < 1)) { 3906 if (UNLIKELY(info.Length() < 1)) {
3907 throwTypeError(ExceptionMessages::failedToExecute("overloadedMethod", "T estObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIs olate()); 3907 throwTypeError(ExceptionMessages::failedToExecute("overloadedMethod", "T estObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIs olate());
3908 return; 3908 return;
3909 } 3909 }
3910 TestObj* imp = V8TestObject::toNative(info.Holder()); 3910 TestObj* imp = V8TestObject::toNative(info.Holder());
3911 if (info.Length() <= 0 || !info[0]->IsFunction()) { 3911 if (info.Length() <= 0 || !info[0]->IsFunction()) {
3912 throwTypeError(ExceptionMessages::failedToExecute("overloadedMethod", "T estObject", "The callback provided as parameter 1 is not a function."), info.Get Isolate()); 3912 throwTypeError(ExceptionMessages::failedToExecute("overloadedMethod", "T estObject", "The callback provided as parameter 1 is not a function."), info.Get Isolate());
3913 return; 3913 return;
3914 } 3914 }
3915 RefPtr<TestCallback> callbackArg = V8TestCallback::create(info[0], getExecut ionContext()); 3915 OwnPtr<TestCallback> callbackArg = V8TestCallback::create(info[0], getExecut ionContext());
3916 imp->overloadedMethod(callbackArg.release()); 3916 imp->overloadedMethod(callbackArg.release());
3917 } 3917 }
3918 3918
3919 static void overloadedMethod3Method(const v8::FunctionCallbackInfo<v8::Value>& i nfo) 3919 static void overloadedMethod3Method(const v8::FunctionCallbackInfo<v8::Value>& i nfo)
3920 { 3920 {
3921 if (UNLIKELY(info.Length() < 1)) { 3921 if (UNLIKELY(info.Length() < 1)) {
3922 throwTypeError(ExceptionMessages::failedToExecute("overloadedMethod", "T estObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIs olate()); 3922 throwTypeError(ExceptionMessages::failedToExecute("overloadedMethod", "T estObject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIs olate());
3923 return; 3923 return;
3924 } 3924 }
3925 TestObj* imp = V8TestObject::toNative(info.Holder()); 3925 TestObj* imp = V8TestObject::toNative(info.Holder());
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
4874 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) 4874 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
4875 { 4875 {
4876 if (UNLIKELY(info.Length() < 1)) { 4876 if (UNLIKELY(info.Length() < 1)) {
4877 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TestOb ject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate ()); 4877 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TestOb ject", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate ());
4878 return; 4878 return;
4879 } 4879 }
4880 if (info.Length() <= 0 || !info[0]->IsFunction()) { 4880 if (info.Length() <= 0 || !info[0]->IsFunction()) {
4881 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TestOb ject", "The callback provided as parameter 1 is not a function."), info.GetIsola te()); 4881 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TestOb ject", "The callback provided as parameter 1 is not a function."), info.GetIsola te());
4882 return; 4882 return;
4883 } 4883 }
4884 RefPtr<TestCallback> testCallback = V8TestCallback::create(info[0], getExecu tionContext()); 4884 OwnPtr<TestCallback> testCallback = V8TestCallback::create(info[0], getExecu tionContext());
4885 4885
4886 RefPtr<TestObj> impl = TestObj::create(testCallback); 4886 RefPtr<TestObj> impl = TestObj::create(testCallback);
4887 v8::Handle<v8::Object> wrapper = info.Holder(); 4887 v8::Handle<v8::Object> wrapper = info.Holder();
4888 4888
4889 V8DOMWrapper::associateObjectWithWrapper<V8TestObject>(impl.release(), &V8Te stObject::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dep endent); 4889 V8DOMWrapper::associateObjectWithWrapper<V8TestObject>(impl.release(), &V8Te stObject::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dep endent);
4890 info.GetReturnValue().Set(wrapper); 4890 info.GetReturnValue().Set(wrapper);
4891 } 4891 }
4892 4892
4893 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) 4893 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info)
4894 { 4894 {
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
5356 fromInternalPointer(object)->deref(); 5356 fromInternalPointer(object)->deref();
5357 } 5357 }
5358 5358
5359 template<> 5359 template<>
5360 v8::Handle<v8::Value> toV8NoInline(TestObj* impl, v8::Handle<v8::Object> creatio nContext, v8::Isolate* isolate) 5360 v8::Handle<v8::Value> toV8NoInline(TestObj* impl, v8::Handle<v8::Object> creatio nContext, v8::Isolate* isolate)
5361 { 5361 {
5362 return toV8(impl, creationContext, isolate); 5362 return toV8(impl, creationContext, isolate);
5363 } 5363 }
5364 5364
5365 } // namespace WebCore 5365 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698