Chromium Code Reviews| Index: Source/bindings/core/v8/custom/V8InternalsCustom.cpp |
| diff --git a/Source/bindings/core/v8/custom/V8InternalsCustom.cpp b/Source/bindings/core/v8/custom/V8InternalsCustom.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2a8152bea545ea76c76a3de9907932960a8e9448 |
| --- /dev/null |
| +++ b/Source/bindings/core/v8/custom/V8InternalsCustom.cpp |
| @@ -0,0 +1,53 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// FIXME: Remove this file once iterator is correctly handled in the code |
| +// generator. |
|
abarth-chromium
2014/08/20 18:22:42
Please don't introduce any custom bindings for Int
yhirano
2014/08/21 11:55:27
Removed the custom wrapper.
|
| + |
| +#include "config.h" |
| +#include "bindings/core/v8/V8Internals.h" |
| + |
| +#include "bindings/core/v8/V8DOMConfiguration.h" |
| +#include "bindings/core/v8/V8Iterator.h" |
| +#include "core/dom/Iterator.h" |
| +#include "platform/TraceEvent.h" |
| + |
| +namespace blink { |
| + |
| +static void iteratorMethod(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + ExceptionState exceptionState(ExceptionState::ExecutionContext, "read", "ReadableStream", info.Holder(), info.GetIsolate()); |
| + Internals* impl = V8Internals::toNative(info.Holder()); |
| + ScriptState* scriptState = ScriptState::current(info.GetIsolate()); |
| + Iterator* result = impl->iterator(scriptState, exceptionState); |
| + if (exceptionState.hadException()) { |
| + exceptionState.throwIfNeeded(); |
| + return; |
| + } |
| + v8SetReturnValue(info, toV8(result, info.Holder(), info.GetIsolate())); |
| +} |
| + |
| +static void iteratorMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +{ |
| + TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); |
| + iteratorMethod(info); |
| + TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| +} |
| + |
| +static const V8DOMConfiguration::SymbolKeyedMethodConfiguration iteratorConfiguration = { |
| + v8::Symbol::GetIterator, iteratorMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts |
| +}; |
| + |
| +v8::Handle<v8::Object> wrap(Internals* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
| +{ |
| + ASSERT(impl); |
| + v8::Handle<v8::Object> wrapper = V8Internals::createWrapper(impl, creationContext, isolate); |
| + |
| + v8::Local<v8::Signature> signature = v8::Signature::New(isolate, V8Internals::domTemplate(isolate)); |
| + V8DOMConfiguration::installMethod(wrapper, signature, v8::DontDelete, iteratorConfiguration, isolate); |
| + return wrapper; |
| +} |
| + |
| +} // namespace blink |
| + |