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 "V8CSSPageRule.h"
  
  #include "bindings/core/v8/V8CSSStyleDeclaration.h"
  #include "bindings/v8/ExceptionState.h"
  #include "bindings/v8/V8DOMConfiguration.h"
  #include "bindings/v8/V8HiddenValue.h"
  #include "bindings/v8/V8ObjectConstructor.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 WebCore {
  
  static void initializeScriptWrappableForInterface(CSSPageRule* object)
  {
      if (ScriptWrappable::wrapperCanBeStoredInObject(object))
          ScriptWrappable::fromObject(object)->setTypeInfo(&V8CSSPageRule::wrapperTypeInfo);
      else
          ASSERT_NOT_REACHED();
  }
  
  } // namespace WebCore
  
  void webCoreInitializeScriptWrappableForInterface(WebCore::CSSPageRule* object)
  {
      WebCore::initializeScriptWrappableForInterface(object);
  }
  
  namespace WebCore {
  const WrapperTypeInfo V8CSSPageRule::wrapperTypeInfo = { gin::kEmbedderBlink, V8CSSPageRule::domTemplate, V8CSSPageRule::derefObject, 0, 0, 0, V8CSSPageRule::installPerContextEnabledMethods, &V8CSSRule::wrapperTypeInfo, WrapperTypeObjectPrototype, WillBeGarbageCollectedObject };
  
  namespace CSSPageRuleV8Internal {
  
  template <typename T> void V8_USE(T) { }
  
  static void selectorTextAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
  {
      v8::Handle<v8::Object> holder = info.Holder();
      CSSPageRule* impl = V8CSSPageRule::toNative(holder);
      v8SetReturnValueString(info, impl->selectorText(), info.GetIsolate());
  }
  
  static void selectorTextAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
  {
      TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
      CSSPageRuleV8Internal::selectorTextAttributeGetter(info);
      TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
  }
  
  static void selectorTextAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
  {
      v8::Handle<v8::Object> holder = info.Holder();
      CSSPageRule* impl = V8CSSPageRule::toNative(holder);
      TOSTRING_VOID(V8StringResource<>, cppValue, v8Value);
      impl->setSelectorText(cppValue);
  }
  
  static void selectorTextAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
  {
      TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
      CSSPageRuleV8Internal::selectorTextAttributeSetter(v8Value, info);
      TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
  }
  
  static void styleAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info)
  {
      v8::Handle<v8::Object> holder = info.Holder();
      CSSPageRule* impl = V8CSSPageRule::toNative(holder);
      RefPtrWillBeRawPtr<CSSStyleDeclaration> result(impl->style());
      if (result && DOMDataStore::setReturnValueFromWrapper<V8CSSStyleDeclaration>(info.GetReturnValue(), result.get()))
          return;
      v8::Handle<v8::Value> wrapper = toV8(result.get(), holder, info.GetIsolate());
      if (!wrapper.IsEmpty()) {
          V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, v8AtomicString(info.GetIsolate(), "style"), wrapper);
          v8SetReturnValue(info, wrapper);
      }
  }
  
  static void styleAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
  {
      TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
      CSSPageRuleV8Internal::styleAttributeGetter(info);
      TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
  }
  
  } // namespace CSSPageRuleV8Internal
  
  static const V8DOMConfiguration::AttributeConfiguration V8CSSPageRuleAttributes[] = {
      {"selectorText", CSSPageRuleV8Internal::selectorTextAttributeGetterCallback, CSSPageRuleV8Internal::selectorTextAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
      {"style", CSSPageRuleV8Internal::styleAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
  };
  
  static void configureV8CSSPageRuleTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
  {
      functionTemplate->ReadOnlyPrototype();
  
      v8::Local<v8::Signature> defaultSignature;
      defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "CSSPageRule", V8CSSRule::domTemplate(isolate), V8CSSPageRule::internalFieldCount,
          V8CSSPageRuleAttributes, WTF_ARRAY_LENGTH(V8CSSPageRuleAttributes),
          0, 0,
          0, 0,
          isolate);
      v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
      v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
  
      // Custom toString template
      functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
  }
  
  v8::Handle<v8::FunctionTemplate> V8CSSPageRule::domTemplate(v8::Isolate* isolate)
  {
      return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), configureV8CSSPageRuleTemplate);
  }
  
  bool V8CSSPageRule::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
  {
      return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
  }
  
  v8::Handle<v8::Object> V8CSSPageRule::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
  {
      return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
  }
  
  CSSPageRule* V8CSSPageRule::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
  {
      return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Object>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
  }
  
  v8::Handle<v8::Object> wrap(CSSPageRule* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
  {
      ASSERT(impl);
      ASSERT(!DOMDataStore::containsWrapper<V8CSSPageRule>(impl, isolate));
      return V8CSSPageRule::createWrapper(impl, creationContext, isolate);
  }
  
  v8::Handle<v8::Object> V8CSSPageRule::createWrapper(PassRefPtrWillBeRawPtr<CSSPageRule> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
  {
      ASSERT(impl);
      ASSERT(!DOMDataStore::containsWrapper<V8CSSPageRule>(impl.get(), isolate));
      if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
          const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo();
          // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
          // the same object de-ref functions, though, so use that as the basis of the check.
          RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
      }
  
      v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
      if (UNLIKELY(wrapper.IsEmpty()))
          return wrapper;
  
      installPerContextEnabledProperties(wrapper, impl.get(), isolate);
      V8DOMWrapper::associateObjectWithWrapper<V8CSSPageRule>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Dependent);
      return wrapper;
  }
  
  void V8CSSPageRule::derefObject(void* object)
  {
  #if !ENABLE(OILPAN)
      fromInternalPointer(object)->deref();
  #endif // !ENABLE(OILPAN)
  }
  
  template<>
  v8::Handle<v8::Value> toV8NoInline(CSSPageRule* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
  {
      return toV8(impl, creationContext, isolate);
  }
  
  } // namespace WebCore
  