| OLD | NEW |
| 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 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 } | 587 } |
| 588 | 588 |
| 589 // FIXME: Remove the special casing for NodeFilter and XPathNSResolver. | 589 // FIXME: Remove the special casing for NodeFilter and XPathNSResolver. |
| 590 PassRefPtrWillBeRawPtr<NodeFilter> toNodeFilter(v8::Local<v8::Value>, v8::Local<
v8::Object>, ScriptState*); | 590 PassRefPtrWillBeRawPtr<NodeFilter> toNodeFilter(v8::Local<v8::Value>, v8::Local<
v8::Object>, ScriptState*); |
| 591 XPathNSResolver* toXPathNSResolver(ScriptState*, v8::Local<v8::Value>); | 591 XPathNSResolver* toXPathNSResolver(ScriptState*, v8::Local<v8::Value>); |
| 592 | 592 |
| 593 bool toV8Sequence(v8::Local<v8::Value>, uint32_t& length, v8::Isolate*, Exceptio
nState&); | 593 bool toV8Sequence(v8::Local<v8::Value>, uint32_t& length, v8::Isolate*, Exceptio
nState&); |
| 594 | 594 |
| 595 // Converts a JavaScript value to an array as per the Web IDL specification: | 595 // Converts a JavaScript value to an array as per the Web IDL specification: |
| 596 // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-array | 596 // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-array |
| 597 template <class T, class V8T> | 597 template <typename T, typename V8T> |
| 598 Vector<RefPtr<T>> toRefPtrNativeArrayUnchecked(v8::Local<v8::Value> v8Value, uin
t32_t length, v8::Isolate* isolate, ExceptionState& exceptionState) | 598 Vector<RefPtr<T>> toRefPtrNativeArrayUnchecked(v8::Local<v8::Value> v8Value, uin
t32_t length, v8::Isolate* isolate, ExceptionState& exceptionState) |
| 599 { | 599 { |
| 600 Vector<RefPtr<T>> result; | 600 Vector<RefPtr<T>> result; |
| 601 result.reserveInitialCapacity(length); | 601 result.reserveInitialCapacity(length); |
| 602 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value); | 602 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value); |
| 603 v8::TryCatch block; | 603 v8::TryCatch block; |
| 604 for (uint32_t i = 0; i < length; ++i) { | 604 for (uint32_t i = 0; i < length; ++i) { |
| 605 v8::Local<v8::Value> element; | 605 v8::Local<v8::Value> element; |
| 606 if (!v8Call(object->Get(isolate->GetCurrentContext(), i), element, block
)) { | 606 if (!v8Call(object->Get(isolate->GetCurrentContext(), i), element, block
)) { |
| 607 exceptionState.rethrowV8Exception(block.Exception()); | 607 exceptionState.rethrowV8Exception(block.Exception()); |
| 608 return Vector<RefPtr<T>>(); | 608 return Vector<RefPtr<T>>(); |
| 609 } | 609 } |
| 610 if (V8T::hasInstance(element, isolate)) { | 610 if (V8T::hasInstance(element, isolate)) { |
| 611 v8::Local<v8::Object> elementObject = v8::Local<v8::Object>::Cast(el
ement); | 611 v8::Local<v8::Object> elementObject = v8::Local<v8::Object>::Cast(el
ement); |
| 612 result.uncheckedAppend(V8T::toImpl(elementObject)); | 612 result.uncheckedAppend(V8T::toImpl(elementObject)); |
| 613 } else { | 613 } else { |
| 614 exceptionState.throwTypeError("Invalid Array element type"); | 614 exceptionState.throwTypeError("Invalid Array element type"); |
| 615 return Vector<RefPtr<T>>(); | 615 return Vector<RefPtr<T>>(); |
| 616 } | 616 } |
| 617 } | 617 } |
| 618 return result; | 618 return result; |
| 619 } | 619 } |
| 620 | 620 |
| 621 template <class T, class V8T> | 621 template <typename T, typename V8T> |
| 622 Vector<RefPtr<T>> toRefPtrNativeArray(v8::Local<v8::Value> value, int argumentIn
dex, v8::Isolate* isolate, ExceptionState& exceptionState) | 622 Vector<RefPtr<T>> toRefPtrNativeArray(v8::Local<v8::Value> value, int argumentIn
dex, v8::Isolate* isolate, ExceptionState& exceptionState) |
| 623 { | 623 { |
| 624 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); | 624 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); |
| 625 uint32_t length = 0; | 625 uint32_t length = 0; |
| 626 if (value->IsArray()) { | 626 if (value->IsArray()) { |
| 627 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); | 627 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); |
| 628 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { | 628 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { |
| 629 if (!exceptionState.hadException()) | 629 if (!exceptionState.hadException()) |
| 630 exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgum
entOrValue(argumentIndex)); | 630 exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgum
entOrValue(argumentIndex)); |
| 631 return Vector<RefPtr<T>>(); | 631 return Vector<RefPtr<T>>(); |
| 632 } | 632 } |
| 633 return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, except
ionState); | 633 return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, except
ionState); |
| 634 } | 634 } |
| 635 | 635 |
| 636 template <class T, class V8T> | 636 template <typename T, typename V8T> |
| 637 Vector<RefPtr<T>> toRefPtrNativeArray(v8::Local<v8::Value> value, const String&
propertyName, v8::Isolate* isolate, ExceptionState& exceptionState) | 637 Vector<RefPtr<T>> toRefPtrNativeArray(v8::Local<v8::Value> value, const String&
propertyName, v8::Isolate* isolate, ExceptionState& exceptionState) |
| 638 { | 638 { |
| 639 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); | 639 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); |
| 640 uint32_t length = 0; | 640 uint32_t length = 0; |
| 641 if (value->IsArray()) { | 641 if (value->IsArray()) { |
| 642 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); | 642 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); |
| 643 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { | 643 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { |
| 644 if (!exceptionState.hadException()) | 644 if (!exceptionState.hadException()) |
| 645 exceptionState.throwTypeError(ExceptionMessages::notASequenceTypePro
perty(propertyName)); | 645 exceptionState.throwTypeError(ExceptionMessages::notASequenceTypePro
perty(propertyName)); |
| 646 return Vector<RefPtr<T>>(); | 646 return Vector<RefPtr<T>>(); |
| 647 } | 647 } |
| 648 return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, except
ionState); | 648 return toRefPtrNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, except
ionState); |
| 649 } | 649 } |
| 650 | 650 |
| 651 template <class T, class V8T> | 651 template <typename T, typename V8T> |
| 652 WillBeHeapVector<RefPtrWillBeMember<T>> toRefPtrWillBeMemberNativeArray(v8::Loca
l<v8::Value> value, int argumentIndex, v8::Isolate* isolate, ExceptionState& exc
eptionState) | 652 WillBeHeapVector<RefPtrWillBeMember<T>> toRefPtrWillBeMemberNativeArray(v8::Loca
l<v8::Value> value, int argumentIndex, v8::Isolate* isolate, ExceptionState& exc
eptionState) |
| 653 { | 653 { |
| 654 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); | 654 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); |
| 655 uint32_t length = 0; | 655 uint32_t length = 0; |
| 656 if (value->IsArray()) { | 656 if (value->IsArray()) { |
| 657 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); | 657 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); |
| 658 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { | 658 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { |
| 659 if (!exceptionState.hadException()) | 659 if (!exceptionState.hadException()) |
| 660 exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgum
entOrValue(argumentIndex)); | 660 exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgum
entOrValue(argumentIndex)); |
| 661 return WillBeHeapVector<RefPtrWillBeMember<T>>(); | 661 return WillBeHeapVector<RefPtrWillBeMember<T>>(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 675 v8::Local<v8::Object> elementObject = v8::Local<v8::Object>::Cast(el
ement); | 675 v8::Local<v8::Object> elementObject = v8::Local<v8::Object>::Cast(el
ement); |
| 676 result.uncheckedAppend(V8T::toImpl(elementObject)); | 676 result.uncheckedAppend(V8T::toImpl(elementObject)); |
| 677 } else { | 677 } else { |
| 678 exceptionState.throwTypeError("Invalid Array element type"); | 678 exceptionState.throwTypeError("Invalid Array element type"); |
| 679 return WillBeHeapVector<RefPtrWillBeMember<T>>(); | 679 return WillBeHeapVector<RefPtrWillBeMember<T>>(); |
| 680 } | 680 } |
| 681 } | 681 } |
| 682 return result; | 682 return result; |
| 683 } | 683 } |
| 684 | 684 |
| 685 template <class T, class V8T> | 685 template <typename T, typename V8T> |
| 686 WillBeHeapVector<RefPtrWillBeMember<T>> toRefPtrWillBeMemberNativeArray(v8::Loca
l<v8::Value> value, const String& propertyName, v8::Isolate* isolate, ExceptionS
tate& exceptionState) | 686 WillBeHeapVector<RefPtrWillBeMember<T>> toRefPtrWillBeMemberNativeArray(v8::Loca
l<v8::Value> value, const String& propertyName, v8::Isolate* isolate, ExceptionS
tate& exceptionState) |
| 687 { | 687 { |
| 688 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); | 688 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); |
| 689 uint32_t length = 0; | 689 uint32_t length = 0; |
| 690 if (value->IsArray()) { | 690 if (value->IsArray()) { |
| 691 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); | 691 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); |
| 692 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { | 692 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { |
| 693 if (!exceptionState.hadException()) | 693 if (!exceptionState.hadException()) |
| 694 exceptionState.throwTypeError(ExceptionMessages::notASequenceTypePro
perty(propertyName)); | 694 exceptionState.throwTypeError(ExceptionMessages::notASequenceTypePro
perty(propertyName)); |
| 695 return WillBeHeapVector<RefPtrWillBeMember<T>>(); | 695 return WillBeHeapVector<RefPtrWillBeMember<T>>(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 709 v8::Local<v8::Object> elementObject = v8::Local<v8::Object>::Cast(el
ement); | 709 v8::Local<v8::Object> elementObject = v8::Local<v8::Object>::Cast(el
ement); |
| 710 result.uncheckedAppend(V8T::toImpl(elementObject)); | 710 result.uncheckedAppend(V8T::toImpl(elementObject)); |
| 711 } else { | 711 } else { |
| 712 exceptionState.throwTypeError("Invalid Array element type"); | 712 exceptionState.throwTypeError("Invalid Array element type"); |
| 713 return WillBeHeapVector<RefPtrWillBeMember<T>>(); | 713 return WillBeHeapVector<RefPtrWillBeMember<T>>(); |
| 714 } | 714 } |
| 715 } | 715 } |
| 716 return result; | 716 return result; |
| 717 } | 717 } |
| 718 | 718 |
| 719 template <class T, class V8T> | 719 template <typename T, typename V8T> |
| 720 HeapVector<Member<T>> toMemberNativeArray(v8::Local<v8::Value> value, int argume
ntIndex, v8::Isolate* isolate, ExceptionState& exceptionState) | 720 HeapVector<Member<T>> toMemberNativeArray(v8::Local<v8::Value> value, int argume
ntIndex, v8::Isolate* isolate, ExceptionState& exceptionState) |
| 721 { | 721 { |
| 722 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); | 722 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); |
| 723 uint32_t length = 0; | 723 uint32_t length = 0; |
| 724 if (value->IsArray()) { | 724 if (value->IsArray()) { |
| 725 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); | 725 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); |
| 726 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { | 726 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { |
| 727 if (!exceptionState.hadException()) | 727 if (!exceptionState.hadException()) |
| 728 exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgum
entOrValue(argumentIndex)); | 728 exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgum
entOrValue(argumentIndex)); |
| 729 return HeapVector<Member<T>>(); | 729 return HeapVector<Member<T>>(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 745 } else { | 745 } else { |
| 746 exceptionState.throwTypeError("Invalid Array element type"); | 746 exceptionState.throwTypeError("Invalid Array element type"); |
| 747 return HeapVector<Member<T>>(); | 747 return HeapVector<Member<T>>(); |
| 748 } | 748 } |
| 749 } | 749 } |
| 750 return result; | 750 return result; |
| 751 } | 751 } |
| 752 | 752 |
| 753 // Converts a JavaScript value to an array as per the Web IDL specification: | 753 // Converts a JavaScript value to an array as per the Web IDL specification: |
| 754 // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-array | 754 // http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-array |
| 755 template <class T> | 755 template <typename T> |
| 756 Vector<T> toImplArray(v8::Local<v8::Value> value, int argumentIndex, v8::Isolate
* isolate, ExceptionState& exceptionState) | 756 Vector<T> toImplArray(v8::Local<v8::Value> value, int argumentIndex, v8::Isolate
* isolate, ExceptionState& exceptionState) |
| 757 { | 757 { |
| 758 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); | |
| 759 uint32_t length = 0; | 758 uint32_t length = 0; |
| 760 if (value->IsArray()) { | 759 if (value->IsArray()) { |
| 761 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); | 760 length = v8::Local<v8::Array>::Cast(value)->Length(); |
| 762 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { | 761 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { |
| 763 if (!exceptionState.hadException()) | 762 if (!exceptionState.hadException()) |
| 764 exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgum
entOrValue(argumentIndex)); | 763 exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgum
entOrValue(argumentIndex)); |
| 765 return Vector<T>(); | 764 return Vector<T>(); |
| 766 } | 765 } |
| 767 | 766 |
| 768 if (length > WTF::DefaultAllocatorQuantizer::kMaxUnquantizedAllocation / siz
eof(T)) { | 767 if (length > WTF::DefaultAllocatorQuantizer::kMaxUnquantizedAllocation / siz
eof(T)) { |
| 769 exceptionState.throwTypeError("Array length exceeds supported limit."); | 768 exceptionState.throwTypeError("Array length exceeds supported limit."); |
| 770 return Vector<T>(); | 769 return Vector<T>(); |
| 771 } | 770 } |
| 772 | 771 |
| 773 Vector<T> result; | 772 Vector<T> result; |
| 774 result.reserveInitialCapacity(length); | 773 result.reserveInitialCapacity(length); |
| 775 typedef NativeValueTraits<T> TraitsType; | 774 typedef NativeValueTraits<T> TraitsType; |
| 776 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value); | 775 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); |
| 777 v8::TryCatch block; | 776 v8::TryCatch block; |
| 778 for (uint32_t i = 0; i < length; ++i) { | 777 for (uint32_t i = 0; i < length; ++i) { |
| 779 v8::Local<v8::Value> element; | 778 v8::Local<v8::Value> element; |
| 780 if (!v8Call(object->Get(isolate->GetCurrentContext(), i), element, block
)) { | 779 if (!v8Call(object->Get(isolate->GetCurrentContext(), i), element, block
)) { |
| 781 exceptionState.rethrowV8Exception(block.Exception()); | 780 exceptionState.rethrowV8Exception(block.Exception()); |
| 782 return Vector<T>(); | 781 return Vector<T>(); |
| 783 } | 782 } |
| 784 result.uncheckedAppend(TraitsType::nativeValue(isolate, element, excepti
onState)); | 783 result.uncheckedAppend(TraitsType::nativeValue(isolate, element, excepti
onState)); |
| 785 if (exceptionState.hadException()) | 784 if (exceptionState.hadException()) |
| 786 return Vector<T>(); | 785 return Vector<T>(); |
| 787 } | 786 } |
| 788 return result; | 787 return result; |
| 789 } | 788 } |
| 790 | 789 |
| 791 template <typename T> | 790 template <typename T> |
| 791 HeapVector<T> toImplHeapArray(v8::Local<v8::Value> value, int argumentIndex, v8:
:Isolate* isolate, ExceptionState& exceptionState) |
| 792 { |
| 793 uint32_t length = 0; |
| 794 if (value->IsArray()) { |
| 795 length = v8::Local<v8::Array>::Cast(value)->Length(); |
| 796 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { |
| 797 if (!exceptionState.hadException()) |
| 798 exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgum
entOrValue(argumentIndex)); |
| 799 return HeapVector<T>(); |
| 800 } |
| 801 |
| 802 if (length > WTF::DefaultAllocatorQuantizer::kMaxUnquantizedAllocation / siz
eof(T)) { |
| 803 exceptionState.throwTypeError("Array length exceeds supported limit."); |
| 804 return HeapVector<T>(); |
| 805 } |
| 806 |
| 807 HeapVector<T> result; |
| 808 result.reserveInitialCapacity(length); |
| 809 typedef NativeValueTraits<T> TraitsType; |
| 810 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); |
| 811 v8::TryCatch block; |
| 812 for (uint32_t i = 0; i < length; ++i) { |
| 813 v8::Local<v8::Value> element; |
| 814 if (!v8Call(object->Get(isolate->GetCurrentContext(), i), element, block
)) { |
| 815 exceptionState.rethrowV8Exception(block.Exception()); |
| 816 return HeapVector<T>(); |
| 817 } |
| 818 result.uncheckedAppend(TraitsType::nativeValue(isolate, element, excepti
onState)); |
| 819 if (exceptionState.hadException()) |
| 820 return HeapVector<T>(); |
| 821 } |
| 822 return result; |
| 823 } |
| 824 |
| 825 template <typename T> |
| 792 Vector<T> toImplArray(const Vector<ScriptValue>& value, v8::Isolate* isolate, Ex
ceptionState& exceptionState) | 826 Vector<T> toImplArray(const Vector<ScriptValue>& value, v8::Isolate* isolate, Ex
ceptionState& exceptionState) |
| 793 { | 827 { |
| 794 Vector<T> result; | 828 Vector<T> result; |
| 795 result.reserveInitialCapacity(value.size()); | 829 result.reserveInitialCapacity(value.size()); |
| 796 for (unsigned i = 0; i < value.size(); ++i) { | 830 for (unsigned i = 0; i < value.size(); ++i) { |
| 797 result.uncheckedAppend(NativeValueTraits<T>::nativeValue(isolate, value[
i].v8Value(), exceptionState)); | 831 result.uncheckedAppend(NativeValueTraits<T>::nativeValue(isolate, value[
i].v8Value(), exceptionState)); |
| 798 if (exceptionState.hadException()) | 832 if (exceptionState.hadException()) |
| 799 return Vector<T>(); | 833 return Vector<T>(); |
| 800 } | 834 } |
| 801 return result; | 835 return result; |
| 802 } | 836 } |
| 803 | 837 |
| 804 template <class T> | 838 template <typename T> |
| 805 Vector<T> toImplArguments(const v8::FunctionCallbackInfo<v8::Value>& info, int s
tartIndex, ExceptionState& exceptionState) | 839 Vector<T> toImplArguments(const v8::FunctionCallbackInfo<v8::Value>& info, int s
tartIndex, ExceptionState& exceptionState) |
| 806 { | 840 { |
| 807 Vector<T> result; | 841 Vector<T> result; |
| 808 typedef NativeValueTraits<T> TraitsType; | 842 typedef NativeValueTraits<T> TraitsType; |
| 809 int length = info.Length(); | 843 int length = info.Length(); |
| 810 if (startIndex < length) { | 844 if (startIndex < length) { |
| 811 result.reserveInitialCapacity(length - startIndex); | 845 result.reserveInitialCapacity(length - startIndex); |
| 812 for (int i = startIndex; i < length; ++i) { | 846 for (int i = startIndex; i < length; ++i) { |
| 813 result.uncheckedAppend(TraitsType::nativeValue(info.GetIsolate(), in
fo[i], exceptionState)); | 847 result.uncheckedAppend(TraitsType::nativeValue(info.GetIsolate(), in
fo[i], exceptionState)); |
| 814 if (exceptionState.hadException()) | 848 if (exceptionState.hadException()) |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 } | 1004 } |
| 971 v8::Local<v8::Function> getBoundFunction(v8::Local<v8::Function>); | 1005 v8::Local<v8::Function> getBoundFunction(v8::Local<v8::Function>); |
| 972 | 1006 |
| 973 // Attaches |environment| to |function| and returns it. | 1007 // Attaches |environment| to |function| and returns it. |
| 974 inline v8::Local<v8::Function> createClosure(v8::FunctionCallback function, v8::
Local<v8::Value> environment, v8::Isolate* isolate) | 1008 inline v8::Local<v8::Function> createClosure(v8::FunctionCallback function, v8::
Local<v8::Value> environment, v8::Isolate* isolate) |
| 975 { | 1009 { |
| 976 return v8::Function::New(isolate, function, environment); | 1010 return v8::Function::New(isolate, function, environment); |
| 977 } | 1011 } |
| 978 | 1012 |
| 979 // FIXME: This will be soon embedded in the generated code. | 1013 // FIXME: This will be soon embedded in the generated code. |
| 980 template<class Collection> static void indexedPropertyEnumerator(const v8::Prope
rtyCallbackInfo<v8::Array>& info) | 1014 template<typename Collection> static void indexedPropertyEnumerator(const v8::Pr
opertyCallbackInfo<v8::Array>& info) |
| 981 { | 1015 { |
| 982 Collection* collection = toScriptWrappable(info.Holder())->toImpl<Collection
>(); | 1016 Collection* collection = toScriptWrappable(info.Holder())->toImpl<Collection
>(); |
| 983 int length = collection->length(); | 1017 int length = collection->length(); |
| 984 v8::Local<v8::Array> properties = v8::Array::New(info.GetIsolate(), length); | 1018 v8::Local<v8::Array> properties = v8::Array::New(info.GetIsolate(), length); |
| 985 for (int i = 0; i < length; ++i) { | 1019 for (int i = 0; i < length; ++i) { |
| 986 // FIXME: Do we need to check that the item function returns a non-null
value for this index? | 1020 // FIXME: Do we need to check that the item function returns a non-null
value for this index? |
| 987 v8::Local<v8::Integer> integer = v8::Integer::New(info.GetIsolate(), i); | 1021 v8::Local<v8::Integer> integer = v8::Integer::New(info.GetIsolate(), i); |
| 988 properties->Set(integer, integer); | 1022 properties->Set(integer, integer); |
| 989 } | 1023 } |
| 990 v8SetReturnValue(info, properties); | 1024 v8SetReturnValue(info, properties); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(v8::Isol
ate*, ExecutionContext*, v8::Local<v8::Function>); | 1095 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(v8::Isol
ate*, ExecutionContext*, v8::Local<v8::Function>); |
| 1062 | 1096 |
| 1063 // Callback functions used by generated code. | 1097 // Callback functions used by generated code. |
| 1064 CORE_EXPORT void v8ConstructorAttributeGetter(v8::Local<v8::Name> propertyName,
const v8::PropertyCallbackInfo<v8::Value>&); | 1098 CORE_EXPORT void v8ConstructorAttributeGetter(v8::Local<v8::Name> propertyName,
const v8::PropertyCallbackInfo<v8::Value>&); |
| 1065 | 1099 |
| 1066 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso
late*); | 1100 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso
late*); |
| 1067 | 1101 |
| 1068 } // namespace blink | 1102 } // namespace blink |
| 1069 | 1103 |
| 1070 #endif // V8Binding_h | 1104 #endif // V8Binding_h |
| OLD | NEW |