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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8Binding.h

Issue 1853743005: Oilpan: Remove WillBe types (part 13) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Ericsson AB. All rights reserved. 3 * Copyright (C) 2012 Ericsson AB. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 return std::numeric_limits<double>::quiet_NaN(); 585 return std::numeric_limits<double>::quiet_NaN();
586 } 586 }
587 587
588 inline v8::MaybeLocal<v8::Value> v8DateOrNaN(v8::Isolate* isolate, double value) 588 inline v8::MaybeLocal<v8::Value> v8DateOrNaN(v8::Isolate* isolate, double value)
589 { 589 {
590 ASSERT(isolate); 590 ASSERT(isolate);
591 return v8::Date::New(isolate->GetCurrentContext(), std::isfinite(value) ? va lue : std::numeric_limits<double>::quiet_NaN()); 591 return v8::Date::New(isolate->GetCurrentContext(), std::isfinite(value) ? va lue : std::numeric_limits<double>::quiet_NaN());
592 } 592 }
593 593
594 // FIXME: Remove the special casing for NodeFilter and XPathNSResolver. 594 // FIXME: Remove the special casing for NodeFilter and XPathNSResolver.
595 PassRefPtrWillBeRawPtr<NodeFilter> toNodeFilter(v8::Local<v8::Value>, v8::Local< v8::Object>, ScriptState*); 595 RawPtr<NodeFilter> toNodeFilter(v8::Local<v8::Value>, v8::Local<v8::Object>, Scr iptState*);
596 XPathNSResolver* toXPathNSResolver(ScriptState*, v8::Local<v8::Value>); 596 XPathNSResolver* toXPathNSResolver(ScriptState*, v8::Local<v8::Value>);
597 597
598 bool toV8Sequence(v8::Local<v8::Value>, uint32_t& length, v8::Isolate*, Exceptio nState&); 598 bool toV8Sequence(v8::Local<v8::Value>, uint32_t& length, v8::Isolate*, Exceptio nState&);
599 599
600 // Converts a JavaScript value to an array as per the Web IDL specification: 600 // Converts a JavaScript value to an array as per the Web IDL specification:
601 // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-array 601 // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-array
602 template <typename T, typename V8T> 602 template <typename T, typename V8T>
603 Vector<RefPtr<T>> toRefPtrNativeArrayUnchecked(v8::Local<v8::Value> v8Value, uin t32_t length, v8::Isolate* isolate, ExceptionState& exceptionState) 603 Vector<RefPtr<T>> toRefPtrNativeArrayUnchecked(v8::Local<v8::Value> v8Value, uin t32_t length, v8::Isolate* isolate, ExceptionState& exceptionState)
604 { 604 {
605 Vector<RefPtr<T>> result; 605 Vector<RefPtr<T>> result;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); 647 length = v8::Local<v8::Array>::Cast(v8Value)->Length();
648 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { 648 } else if (!toV8Sequence(value, length, isolate, exceptionState)) {
649 if (!exceptionState.hadException()) 649 if (!exceptionState.hadException())
650 exceptionState.throwTypeError(ExceptionMessages::notASequenceTypePro perty(propertyName)); 650 exceptionState.throwTypeError(ExceptionMessages::notASequenceTypePro perty(propertyName));
651 return Vector<RefPtr<T>>(); 651 return Vector<RefPtr<T>>();
652 } 652 }
653 return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, except ionState); 653 return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, except ionState);
654 } 654 }
655 655
656 template <typename T, typename V8T> 656 template <typename T, typename V8T>
657 WillBeHeapVector<RefPtrWillBeMember<T>> toRefPtrWillBeMemberNativeArray(v8::Loca l<v8::Value> value, int argumentIndex, v8::Isolate* isolate, ExceptionState& exc eptionState) 657 HeapVector<Member<T>> toMemberNativeArray(v8::Local<v8::Value> value, int argume ntIndex, v8::Isolate* isolate, ExceptionState& exceptionState)
658 { 658 {
659 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); 659 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value));
660 uint32_t length = 0; 660 uint32_t length = 0;
661 if (value->IsArray()) { 661 if (value->IsArray()) {
662 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); 662 length = v8::Local<v8::Array>::Cast(v8Value)->Length();
663 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { 663 } else if (!toV8Sequence(value, length, isolate, exceptionState)) {
664 if (!exceptionState.hadException()) 664 if (!exceptionState.hadException())
665 exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgum entOrValue(argumentIndex)); 665 exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgum entOrValue(argumentIndex));
666 return WillBeHeapVector<RefPtrWillBeMember<T>>(); 666 return HeapVector<Member<T>>();
667 } 667 }
668 668
669 WillBeHeapVector<RefPtrWillBeMember<T>> result; 669 HeapVector<Member<T>> result;
670 result.reserveInitialCapacity(length); 670 result.reserveInitialCapacity(length);
671 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value); 671 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value);
672 v8::TryCatch block(isolate); 672 v8::TryCatch block(isolate);
673 for (uint32_t i = 0; i < length; ++i) { 673 for (uint32_t i = 0; i < length; ++i) {
674 v8::Local<v8::Value> element; 674 v8::Local<v8::Value> element;
675 if (!v8Call(object->Get(isolate->GetCurrentContext(), i), element, block )) { 675 if (!v8Call(object->Get(isolate->GetCurrentContext(), i), element, block )) {
676 exceptionState.rethrowV8Exception(block.Exception()); 676 exceptionState.rethrowV8Exception(block.Exception());
677 return WillBeHeapVector<RefPtrWillBeMember<T>>(); 677 return HeapVector<Member<T>>();
678 } 678 }
679 if (V8T::hasInstance(element, isolate)) { 679 if (V8T::hasInstance(element, isolate)) {
680 v8::Local<v8::Object> elementObject = v8::Local<v8::Object>::Cast(el ement); 680 v8::Local<v8::Object> elementObject = v8::Local<v8::Object>::Cast(el ement);
681 result.uncheckedAppend(V8T::toImpl(elementObject)); 681 result.uncheckedAppend(V8T::toImpl(elementObject));
682 } else { 682 } else {
683 exceptionState.throwTypeError("Invalid Array element type"); 683 exceptionState.throwTypeError("Invalid Array element type");
684 return WillBeHeapVector<RefPtrWillBeMember<T>>(); 684 return HeapVector<Member<T>>();
685 } 685 }
686 } 686 }
687 return result; 687 return result;
688 } 688 }
689 689
690 template <typename T, typename V8T> 690 template <typename T, typename V8T>
691 WillBeHeapVector<RefPtrWillBeMember<T>> toRefPtrWillBeMemberNativeArray(v8::Loca l<v8::Value> value, const String& propertyName, v8::Isolate* isolate, ExceptionS tate& exceptionState) 691 HeapVector<Member<T>> toMemberNativeArray(v8::Local<v8::Value> value, const Stri ng& propertyName, v8::Isolate* isolate, ExceptionState& exceptionState)
692 { 692 {
693 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); 693 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value));
694 uint32_t length = 0; 694 uint32_t length = 0;
695 if (value->IsArray()) { 695 if (value->IsArray()) {
696 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); 696 length = v8::Local<v8::Array>::Cast(v8Value)->Length();
697 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { 697 } else if (!toV8Sequence(value, length, isolate, exceptionState)) {
698 if (!exceptionState.hadException()) 698 if (!exceptionState.hadException())
699 exceptionState.throwTypeError(ExceptionMessages::notASequenceTypePro perty(propertyName)); 699 exceptionState.throwTypeError(ExceptionMessages::notASequenceTypePro perty(propertyName));
700 return WillBeHeapVector<RefPtrWillBeMember<T>>(); 700 return HeapVector<Member<T>>();
701 } 701 }
702 702
703 WillBeHeapVector<RefPtrWillBeMember<T>> result; 703 HeapVector<Member<T>> result;
704 result.reserveInitialCapacity(length); 704 result.reserveInitialCapacity(length);
705 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value); 705 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value);
706 v8::TryCatch block(isolate); 706 v8::TryCatch block(isolate);
707 for (uint32_t i = 0; i < length; ++i) { 707 for (uint32_t i = 0; i < length; ++i) {
708 v8::Local<v8::Value> element; 708 v8::Local<v8::Value> element;
709 if (!v8Call(object->Get(isolate->GetCurrentContext(), i), element, block )) {
710 exceptionState.rethrowV8Exception(block.Exception());
711 return WillBeHeapVector<RefPtrWillBeMember<T>>();
712 }
713 if (V8T::hasInstance(element, isolate)) {
714 v8::Local<v8::Object> elementObject = v8::Local<v8::Object>::Cast(el ement);
715 result.uncheckedAppend(V8T::toImpl(elementObject));
716 } else {
717 exceptionState.throwTypeError("Invalid Array element type");
718 return WillBeHeapVector<RefPtrWillBeMember<T>>();
719 }
720 }
721 return result;
722 }
723
724 template <typename T, typename V8T>
725 HeapVector<Member<T>> toMemberNativeArray(v8::Local<v8::Value> value, int argume ntIndex, v8::Isolate* isolate, ExceptionState& exceptionState)
726 {
727 uint32_t length = 0;
728 if (value->IsArray()) {
729 length = v8::Local<v8::Array>::Cast(value)->Length();
730 } else if (!toV8Sequence(value, length, isolate, exceptionState)) {
731 if (!exceptionState.hadException())
732 exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgum entOrValue(argumentIndex));
733 return HeapVector<Member<T>>();
734 }
735
736 HeapVector<Member<T>> result;
737 result.reserveInitialCapacity(length);
738 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value);
739 v8::TryCatch block(isolate);
740 for (uint32_t i = 0; i < length; ++i) {
741 v8::Local<v8::Value> element;
742 if (!v8Call(object->Get(isolate->GetCurrentContext(), i), element, block )) { 709 if (!v8Call(object->Get(isolate->GetCurrentContext(), i), element, block )) {
743 exceptionState.rethrowV8Exception(block.Exception()); 710 exceptionState.rethrowV8Exception(block.Exception());
744 return HeapVector<Member<T>>(); 711 return HeapVector<Member<T>>();
745 } 712 }
746 if (V8T::hasInstance(element, isolate)) { 713 if (V8T::hasInstance(element, isolate)) {
747 v8::Local<v8::Object> elementObject = v8::Local<v8::Object>::Cast(el ement); 714 v8::Local<v8::Object> elementObject = v8::Local<v8::Object>::Cast(el ement);
748 result.uncheckedAppend(V8T::toImpl(elementObject)); 715 result.uncheckedAppend(V8T::toImpl(elementObject));
749 } else { 716 } else {
750 exceptionState.throwTypeError("Invalid Array element type"); 717 exceptionState.throwTypeError("Invalid Array element type");
751 return HeapVector<Member<T>>(); 718 return HeapVector<Member<T>>();
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 }; 1005 };
1039 1006
1040 // Callback functions used by generated code. 1007 // Callback functions used by generated code.
1041 CORE_EXPORT void v8ConstructorAttributeGetter(v8::Local<v8::Name> propertyName, const v8::PropertyCallbackInfo<v8::Value>&); 1008 CORE_EXPORT void v8ConstructorAttributeGetter(v8::Local<v8::Name> propertyName, const v8::PropertyCallbackInfo<v8::Value>&);
1042 1009
1043 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso late*); 1010 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso late*);
1044 1011
1045 } // namespace blink 1012 } // namespace blink
1046 1013
1047 #endif // V8Binding_h 1014 #endif // V8Binding_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698