text: // 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.
  
  // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
  
  #include "config.h"
  #include "V8MediaKeyStatusMap.h"
  
  #include "bindings/core/v8/ExceptionState.h"
  #include "bindings/core/v8/ScriptState.h"
  #include "bindings/core/v8/ScriptValue.h"
  #include "bindings/core/v8/V8ArrayBuffer.h"
  #include "bindings/core/v8/V8ArrayBufferView.h"
  #include "bindings/core/v8/V8DOMConfiguration.h"
  #include "bindings/core/v8/V8Iterator.h"
  #include "bindings/core/v8/V8ObjectConstructor.h"
  #include "bindings/modules/v8/UnionTypesModules.h"
  #include "core/dom/ContextFeatures.h"
  #include "core/dom/Document.h"
  #include "platform/RuntimeEnabledFeatures.h"
  #include "platform/TraceEvent.h"
  #include "wtf/GetPtr.h"
  #include "wtf/RefPtr.h"
  
  namespace blink {
  
  // Suppress warning: global constructors, because struct WrapperTypeInfo is trivial
  // and does not depend on another global objects.
  #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
  #pragma clang diagnostic push
  #pragma clang diagnostic ignored "-Wglobal-constructors"
  #endif
  const WrapperTypeInfo V8MediaKeyStatusMap::wrapperTypeInfo = { gin::kEmbedderBlink, V8MediaKeyStatusMap::domTemplate, V8MediaKeyStatusMap::refObject, V8MediaKeyStatusMap::derefObject, V8MediaKeyStatusMap::trace, 0, 0, V8MediaKeyStatusMap::preparePrototypeObject, V8MediaKeyStatusMap::installConditionallyEnabledProperties, "MediaKeyStatusMap", 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::NotInheritFromEventTarget, WrapperTypeInfo::Independent, WrapperTypeInfo::GarbageCollectedObject };
  #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG)
  #pragma clang diagnostic pop
  #endif
  
  // This static member must be declared by DEFINE_WRAPPERTYPEINFO in MediaKeyStatusMap.h.
  // For details, see the comment of DEFINE_WRAPPERTYPEINFO in
  // bindings/core/v8/ScriptWrappable.h.
  const WrapperTypeInfo& MediaKeyStatusMap::s_wrapperTypeInfo = V8MediaKeyStatusMap::wrapperTypeInfo;
  
  namespace MediaKeyStatusMapV8Internal {
  
  static void sizeAttributeGetter(const v8::FunctionCallbackInfo<v8::Value>& info)
  {
      v8::Local<v8::Object> holder = info.Holder();
      MediaKeyStatusMap* impl = V8MediaKeyStatusMap::toImpl(holder);
      v8SetReturnValueUnsigned(info, impl->size());
  }
  
  static void sizeAttributeGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
  {
      TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter");
      MediaKeyStatusMapV8Internal::sizeAttributeGetter(info);
      TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
  }
  
  static void keysMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
  {
      ExceptionState exceptionState(ExceptionState::ExecutionContext, "keys", "MediaKeyStatusMap", info.Holder(), info.GetIsolate());
      MediaKeyStatusMap* impl = V8MediaKeyStatusMap::toImpl(info.Holder());
      ScriptState* scriptState = ScriptState::current(info.GetIsolate());
      RawPtr<Iterator> result = impl->keysForBinding(scriptState, exceptionState);
      if (exceptionState.hadException()) {
          exceptionState.throwIfNeeded();
          return;
      }
      v8SetReturnValue(info, result.release());
  }
  
  static void keysMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
  {
      TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
      MediaKeyStatusMapV8Internal::keysMethod(info);
      TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
  }
  
  static void valuesMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
  {
      ExceptionState exceptionState(ExceptionState::ExecutionContext, "values", "MediaKeyStatusMap", info.Holder(), info.GetIsolate());
      MediaKeyStatusMap* impl = V8MediaKeyStatusMap::toImpl(info.Holder());
      ScriptState* scriptState = ScriptState::current(info.GetIsolate());
      RawPtr<Iterator> result = impl->valuesForBinding(scriptState, exceptionState);
      if (exceptionState.hadException()) {
          exceptionState.throwIfNeeded();
          return;
      }
      v8SetReturnValue(info, result.release());
  }
  
  static void valuesMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
  {
      TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
      MediaKeyStatusMapV8Internal::valuesMethod(info);
      TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
  }
  
  static void entriesMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
  {
      ExceptionState exceptionState(ExceptionState::ExecutionContext, "entries", "MediaKeyStatusMap", info.Holder(), info.GetIsolate());
      MediaKeyStatusMap* impl = V8MediaKeyStatusMap::toImpl(info.Holder());
      ScriptState* scriptState = ScriptState::current(info.GetIsolate());
      RawPtr<Iterator> result = impl->entriesForBinding(scriptState, exceptionState);
      if (exceptionState.hadException()) {
          exceptionState.throwIfNeeded();
          return;
      }
      v8SetReturnValue(info, result.release());
  }
  
  static void entriesMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
  {
      TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
      MediaKeyStatusMapV8Internal::entriesMethod(info);
      TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
  }
  
  static void forEachMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
  {
      ExceptionState exceptionState(ExceptionState::ExecutionContext, "forEach", "MediaKeyStatusMap", info.Holder(), info.GetIsolate());
      if (UNLIKELY(info.Length() < 1)) {
          setMinimumArityTypeError(exceptionState, 1, info.Length());
          exceptionState.throwIfNeeded();
          return;
      }
      MediaKeyStatusMap* impl = V8MediaKeyStatusMap::toImpl(info.Holder());
      ScriptValue callback;
      ScriptValue thisArg;
      {
          if (!info[0]->IsFunction()) {
              exceptionState.throwTypeError("The callback provided as parameter 1 is not a function.");
              exceptionState.throwIfNeeded();
              return;
          }
          callback = ScriptValue(ScriptState::current(info.GetIsolate()), info[0]);
          thisArg = ScriptValue(ScriptState::current(info.GetIsolate()), info[1]);
      }
      ScriptState* scriptState = ScriptState::current(info.GetIsolate());
      impl->forEachForBinding(scriptState, ScriptValue(scriptState, info.This()), callback, thisArg, exceptionState);
      if (exceptionState.hadException()) {
          exceptionState.throwIfNeeded();
          return;
      }
  }
  
  static void forEachMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
  {
      TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
      MediaKeyStatusMapV8Internal::forEachMethod(info);
      TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
  }
  
  static void hasMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
  {
      ExceptionState exceptionState(ExceptionState::ExecutionContext, "has", "MediaKeyStatusMap", info.Holder(), info.GetIsolate());
      if (UNLIKELY(info.Length() < 1)) {
          setMinimumArityTypeError(exceptionState, 1, info.Length());
          exceptionState.throwIfNeeded();
          return;
      }
      MediaKeyStatusMap* impl = V8MediaKeyStatusMap::toImpl(info.Holder());
      ArrayBufferOrArrayBufferView key;
      {
          V8ArrayBufferOrArrayBufferView::toImpl(info.GetIsolate(), info[0], key, exceptionState);
          if (exceptionState.throwIfNeeded())
              return;
      }
      ScriptState* scriptState = ScriptState::current(info.GetIsolate());
      bool result = impl->hasForBinding(scriptState, key, exceptionState);
      if (exceptionState.hadException()) {
          exceptionState.throwIfNeeded();
          return;
      }
      v8SetReturnValueBool(info, result);
  }
  
  static void hasMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
  {
      TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
      MediaKeyStatusMapV8Internal::hasMethod(info);
      TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
  }
  
  static void getMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
  {
      ExceptionState exceptionState(ExceptionState::ExecutionContext, "get", "MediaKeyStatusMap", info.Holder(), info.GetIsolate());
      if (UNLIKELY(info.Length() < 1)) {
          setMinimumArityTypeError(exceptionState, 1, info.Length());
          exceptionState.throwIfNeeded();
          return;
      }
      MediaKeyStatusMap* impl = V8MediaKeyStatusMap::toImpl(info.Holder());
      ArrayBufferOrArrayBufferView key;
      {
          V8ArrayBufferOrArrayBufferView::toImpl(info.GetIsolate(), info[0], key, exceptionState);
          if (exceptionState.throwIfNeeded())
              return;
      }
      ScriptState* scriptState = ScriptState::current(info.GetIsolate());
      ScriptValue result = impl->getForBinding(scriptState, key, exceptionState);
      if (exceptionState.hadException()) {
          exceptionState.throwIfNeeded();
          return;
      }
      v8SetReturnValue(info, result.v8Value());
  }
  
  static void getMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
  {
      TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
      MediaKeyStatusMapV8Internal::getMethod(info);
      TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
  }
  
  static void iteratorMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
  {
      ExceptionState exceptionState(ExceptionState::ExecutionContext, "iterator", "MediaKeyStatusMap", info.Holder(), info.GetIsolate());
      MediaKeyStatusMap* impl = V8MediaKeyStatusMap::toImpl(info.Holder());
      ScriptState* scriptState = ScriptState::current(info.GetIsolate());
      RawPtr<Iterator> result = impl->iterator(scriptState, exceptionState);
      if (exceptionState.hadException()) {
          exceptionState.throwIfNeeded();
          return;
      }
      v8SetReturnValue(info, result.release());
  }
  
  static void iteratorMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
  {
      TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod");
      MediaKeyStatusMapV8Internal::iteratorMethod(info);
      TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution");
  }
  
  } // namespace MediaKeyStatusMapV8Internal
  
  static const V8DOMConfiguration::AccessorConfiguration V8MediaKeyStatusMapAccessors[] = {
      {"size", MediaKeyStatusMapV8Internal::sizeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnPrototype, V8DOMConfiguration::CheckHolder},
  };
  
  static const V8DOMConfiguration::MethodConfiguration V8MediaKeyStatusMapMethods[] = {
      {"keys", MediaKeyStatusMapV8Internal::keysMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
      {"values", MediaKeyStatusMapV8Internal::valuesMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
      {"entries", MediaKeyStatusMapV8Internal::entriesMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts},
      {"forEach", MediaKeyStatusMapV8Internal::forEachMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
      {"has", MediaKeyStatusMapV8Internal::hasMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
      {"get", MediaKeyStatusMapV8Internal::getMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts},
  };
  
  static void installV8MediaKeyStatusMapTemplate(v8::Local<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
  {
      functionTemplate->ReadOnlyPrototype();
  
      v8::Local<v8::Signature> defaultSignature;
      defaultSignature = V8DOMConfiguration::installDOMClassTemplate(isolate, functionTemplate, "MediaKeyStatusMap", v8::Local<v8::FunctionTemplate>(), V8MediaKeyStatusMap::internalFieldCount,
          0, 0,
          V8MediaKeyStatusMapAccessors, WTF_ARRAY_LENGTH(V8MediaKeyStatusMapAccessors),
          V8MediaKeyStatusMapMethods, WTF_ARRAY_LENGTH(V8MediaKeyStatusMapMethods));
      v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceTemplate();
      ALLOW_UNUSED_LOCAL(instanceTemplate);
      v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->PrototypeTemplate();
      ALLOW_UNUSED_LOCAL(prototypeTemplate);
      static const V8DOMConfiguration::SymbolKeyedMethodConfiguration symbolKeyedIteratorConfiguration = { v8::Symbol::GetIterator, MediaKeyStatusMapV8Internal::iteratorMethodCallback, 0, V8DOMConfiguration::ExposedToAllScripts };
      V8DOMConfiguration::installMethod(isolate, prototypeTemplate, defaultSignature, v8::DontDelete, symbolKeyedIteratorConfiguration);
  
      // Custom toString template
      functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
  }
  
  v8::Local<v8::FunctionTemplate> V8MediaKeyStatusMap::domTemplate(v8::Isolate* isolate)
  {
      return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8MediaKeyStatusMapTemplate);
  }
  
  bool V8MediaKeyStatusMap::hasInstance(v8::Local<v8::Value> v8Value, v8::Isolate* isolate)
  {
      return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
  }
  
  v8::Local<v8::Object> V8MediaKeyStatusMap::findInstanceInPrototypeChain(v8::Local<v8::Value> v8Value, v8::Isolate* isolate)
  {
      return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
  }
  
  MediaKeyStatusMap* V8MediaKeyStatusMap::toImplWithTypeCheck(v8::Isolate* isolate, v8::Local<v8::Value> value)
  {
      return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value)) : 0;
  }
  
  void V8MediaKeyStatusMap::refObject(ScriptWrappable* scriptWrappable)
  {
  }
  
  void V8MediaKeyStatusMap::derefObject(ScriptWrappable* scriptWrappable)
  {
  }
  
  } // namespace blink
  