Chromium Code Reviews| Index: Source/bindings/v8/V8Binding.h |
| diff --git a/Source/bindings/v8/V8Binding.h b/Source/bindings/v8/V8Binding.h |
| index a3ab1040f43a920baf63d275895f8946986b5699..4ddf082101a1f30510271177355595d186c49577 100644 |
| --- a/Source/bindings/v8/V8Binding.h |
| +++ b/Source/bindings/v8/V8Binding.h |
| @@ -500,6 +500,28 @@ namespace WebCore { |
| return result; |
| } |
| + template <class T, class V8T> |
| + WillBeHeapVector<RefPtrWillBeMember<T> > toRefPtrWillBeMemberNativeArrayUnchecked(v8::Local<v8::Value> v8Value, uint32_t length, v8::Isolate* isolate, bool* success = 0) |
|
haraken
2014/02/21 10:47:05
Instead of adding a method for WillBeHeapVector<Re
keishi
2014/02/26 06:14:59
If I prepare two versions of toRefPtrNativeArray()
|
| + { |
| + WillBeHeapVector<RefPtrWillBeMember<T> > result; |
| + result.reserveInitialCapacity(length); |
| + v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value); |
| + for (uint32_t i = 0; i < length; ++i) { |
| + v8::Handle<v8::Value> element = object->Get(i); |
| + |
| + if (V8T::hasInstance(element, isolate)) { |
| + v8::Handle<v8::Object> elementObject = v8::Handle<v8::Object>::Cast(element); |
| + result.uncheckedAppend(V8T::toNative(elementObject)); |
| + } else { |
| + if (success) |
| + *success = false; |
| + throwTypeError("Invalid Array element type", isolate); |
| + return WillBeHeapVector<RefPtrWillBeMember<T> >(); |
| + } |
| + } |
| + return result; |
| + } |
| + |
| v8::Handle<v8::Value> toV8Sequence(v8::Handle<v8::Value>, uint32_t& length, v8::Isolate*); |
| template <class T, class V8T> |
| @@ -521,6 +543,24 @@ namespace WebCore { |
| } |
| template <class T, class V8T> |
| + WillBeHeapVector<RefPtrWillBeMember<T> > toRefPtrWillBeMemberNativeArray(v8::Handle<v8::Value> value, int argumentIndex, v8::Isolate* isolate, bool* success = 0) |
|
haraken
2014/02/21 10:47:05
Ditto. You can add a method for HeapVector<Member>
|
| + { |
| + if (success) |
| + *success = true; |
| + |
| + v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(isolate, value)); |
| + uint32_t length = 0; |
| + if (value->IsArray()) { |
| + length = v8::Local<v8::Array>::Cast(v8Value)->Length(); |
| + } else if (toV8Sequence(value, length, isolate).IsEmpty()) { |
| + throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argumentIndex), isolate); |
| + return WillBeHeapVector<RefPtrWillBeMember<T> >(); |
| + } |
| + |
| + return toRefPtrWillBeMemberNativeArrayUnchecked<T, V8T>(v8Value, length, isolate, success); |
| + } |
| + |
| + template <class T, class V8T> |
| Vector<RefPtr<T> > toRefPtrNativeArray(v8::Handle<v8::Value> value, const String& propertyName, v8::Isolate* isolate, bool* success = 0) |
| { |
| if (success) |