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 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
781 exceptionState.rethrowV8Exception(block.Exception()); | 781 exceptionState.rethrowV8Exception(block.Exception()); |
782 return Vector<T>(); | 782 return Vector<T>(); |
783 } | 783 } |
784 result.uncheckedAppend(TraitsType::nativeValue(isolate, element, excepti onState)); | 784 result.uncheckedAppend(TraitsType::nativeValue(isolate, element, excepti onState)); |
785 if (exceptionState.hadException()) | 785 if (exceptionState.hadException()) |
786 return Vector<T>(); | 786 return Vector<T>(); |
787 } | 787 } |
788 return result; | 788 return result; |
789 } | 789 } |
790 | 790 |
791 template <class T> | |
bashi
2015/05/01 04:31:23
nit: class -> typename
haraken
2015/05/01 05:34:11
Done.
| |
792 HeapVector<T> toImplHeapArray(v8::Local<v8::Value> value, int argumentIndex, v8: :Isolate* isolate, ExceptionState& exceptionState) | |
793 { | |
794 v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); | |
bashi
2015/05/01 04:31:23
Help me understand: why do you create temporary v8
haraken
2015/05/01 05:34:11
Done. (Actually I just copied the code from the ab
| |
795 uint32_t length = 0; | |
796 if (value->IsArray()) { | |
797 length = v8::Local<v8::Array>::Cast(v8Value)->Length(); | |
798 } else if (!toV8Sequence(value, length, isolate, exceptionState)) { | |
799 if (!exceptionState.hadException()) | |
800 exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgum entOrValue(argumentIndex)); | |
801 return HeapVector<T>(); | |
802 } | |
803 | |
804 if (length > WTF::DefaultAllocatorQuantizer::kMaxUnquantizedAllocation / siz eof(T)) { | |
805 exceptionState.throwTypeError("Array length exceeds supported limit."); | |
806 return HeapVector<T>(); | |
807 } | |
808 | |
809 HeapVector<T> result; | |
810 result.reserveInitialCapacity(length); | |
811 typedef NativeValueTraits<T> TraitsType; | |
812 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value); | |
813 v8::TryCatch block; | |
814 for (uint32_t i = 0; i < length; ++i) { | |
815 v8::Local<v8::Value> element; | |
816 if (!v8Call(object->Get(isolate->GetCurrentContext(), i), element, block )) { | |
817 exceptionState.rethrowV8Exception(block.Exception()); | |
818 return HeapVector<T>(); | |
819 } | |
820 result.uncheckedAppend(TraitsType::nativeValue(isolate, element, excepti onState)); | |
821 if (exceptionState.hadException()) | |
822 return HeapVector<T>(); | |
823 } | |
824 return result; | |
825 } | |
826 | |
791 template <typename T> | 827 template <typename T> |
792 Vector<T> toImplArray(const Vector<ScriptValue>& value, v8::Isolate* isolate, Ex ceptionState& exceptionState) | 828 Vector<T> toImplArray(const Vector<ScriptValue>& value, v8::Isolate* isolate, Ex ceptionState& exceptionState) |
793 { | 829 { |
794 Vector<T> result; | 830 Vector<T> result; |
795 result.reserveInitialCapacity(value.size()); | 831 result.reserveInitialCapacity(value.size()); |
796 for (unsigned i = 0; i < value.size(); ++i) { | 832 for (unsigned i = 0; i < value.size(); ++i) { |
797 result.uncheckedAppend(NativeValueTraits<T>::nativeValue(isolate, value[ i].v8Value(), exceptionState)); | 833 result.uncheckedAppend(NativeValueTraits<T>::nativeValue(isolate, value[ i].v8Value(), exceptionState)); |
798 if (exceptionState.hadException()) | 834 if (exceptionState.hadException()) |
799 return Vector<T>(); | 835 return Vector<T>(); |
800 } | 836 } |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1061 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(v8::Isol ate*, ExecutionContext*, v8::Local<v8::Function>); | 1097 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(v8::Isol ate*, ExecutionContext*, v8::Local<v8::Function>); |
1062 | 1098 |
1063 // Callback functions used by generated code. | 1099 // Callback functions used by generated code. |
1064 CORE_EXPORT void v8ConstructorAttributeGetter(v8::Local<v8::Name> propertyName, const v8::PropertyCallbackInfo<v8::Value>&); | 1100 CORE_EXPORT void v8ConstructorAttributeGetter(v8::Local<v8::Name> propertyName, const v8::PropertyCallbackInfo<v8::Value>&); |
1065 | 1101 |
1066 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso late*); | 1102 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso late*); |
1067 | 1103 |
1068 } // namespace blink | 1104 } // namespace blink |
1069 | 1105 |
1070 #endif // V8Binding_h | 1106 #endif // V8Binding_h |
OLD | NEW |