1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! 6 7 #include "config.h" 8 #include "V8TestException.h" 9 10 #include "bindings/v8/ExceptionState.h" 11 #include "bindings/v8/V8DOMConfiguration.h" 12 #include "bindings/v8/V8HiddenValue.h" 13 #include "bindings/v8/V8ObjectConstructor.h" 14 #include "core/dom/ContextFeatures.h" 15 #include "core/dom/Document.h" 16 #include "platform/RuntimeEnabledFeatures.h" 17 #include "platform/TraceEvent.h" 18 #include "wtf/GetPtr.h" 19 #include "wtf/RefPtr.h" 20 21 namespace WebCore { 22 23 static void initializeScriptWrappableForInterface(TestException* object) 24 { 25 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) 26 ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestException::wrapperTypeInfo); 27 else 28 ASSERT_NOT_REACHED(); 29 } 30 31 } // namespace WebCore 32 33 void webCoreInitializeScriptWrappableForInterface(WebCore::TestException* object) 34 { 35 WebCore::initializeScriptWrappableForInterface(object); 36 } 37 38 namespace WebCore { 39 const WrapperTypeInfo V8TestException::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestException::domTemplate, V8TestException::derefObject, 0, 0, 0, V8TestException::installPerContextEnabledMethods, 0, WrapperTypeExceptionPrototype, RefCountedObject }; 40 41 namespace TestExceptionV8Internal { 42 43 template <typename T> void V8_USE(T) { } 44 45 static void readonlyUnsignedShortAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 46 { 47 v8::Handle<v8::Object> holder = info.Holder(); 48 TestException* impl = V8TestException::toNative(holder); 49 v8SetReturnValueUnsigned(info, impl->readonlyUnsignedShortAttribute()); 50 } 51 52 static void readonlyUnsignedShortAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 53 { 54 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 55 TestExceptionV8Internal::readonlyUnsignedShortAttributeAttributeGetter(info); 56 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 57 } 58 59 static void readonlyStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 60 { 61 v8::Handle<v8::Object> holder = info.Holder(); 62 TestException* impl = V8TestException::toNative(holder); 63 v8SetReturnValueString(info, impl->readonlyStringAttribute(), info.GetIsolate()); 64 } 65 66 static void readonlyStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 67 { 68 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 69 TestExceptionV8Internal::readonlyStringAttributeAttributeGetter(info); 70 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 71 } 72 73 static void toStringMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 74 { 75 TestException* impl = V8TestException::toNative(info.Holder()); 76 v8SetReturnValueString(info, impl->toString(), info.GetIsolate()); 77 } 78 79 static void toStringMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 80 { 81 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 82 TestExceptionV8Internal::toStringMethod(info); 83 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 84 } 85 86 } // namespace TestExceptionV8Internal 87 88 static const V8DOMConfiguration::AttributeConfiguration V8TestExceptionAttributes[] = { 89 {"readonlyUnsignedShortAttribute", TestExceptionV8Internal::readonlyUnsignedShortAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 90 {"readonlyStringAttribute", TestExceptionV8Internal::readonlyStringAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 91 }; 92 93 static void configureV8TestExceptionTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate) 94 { 95 functionTemplate->ReadOnlyPrototype(); 96 97 v8::Local<v8::Signature> defaultSignature; 98 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestException", v8::Local<v8::FunctionTemplate>(), V8TestException::internalFieldCount, 99 V8TestExceptionAttributes, WTF_ARRAY_LENGTH(V8TestExceptionAttributes), 100 0, 0, 101 0, 0, 102 isolate); 103 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate(); 104 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate(); 105 static const V8DOMConfiguration::ConstantConfiguration V8TestExceptionConstants[] = { 106 {"UNSIGNED_SHORT_CONSTANT", 1}, 107 }; 108 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, V8TestExceptionConstants, WTF_ARRAY_LENGTH(V8TestExceptionConstants), isolate); 109 prototypeTemplate->Set(v8AtomicString(isolate, "toString"), v8::FunctionTemplate::New(isolate, TestExceptionV8Internal::toStringMethodCallback, v8Undefined(), defaultSignature, 0), static_cast<v8::PropertyAttribute>(v8::DontDelete | v8::DontEnum)); 110 111 // Custom toString template 112 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate()); 113 } 114 115 v8::Handle<v8::FunctionTemplate> V8TestException::domTemplate(v8::Isolate* isolate) 116 { 117 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), configureV8TestExceptionTemplate); 118 } 119 120 bool V8TestException::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) 121 { 122 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value); 123 } 124 125 v8::Handle<v8::Object> V8TestException::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) 126 { 127 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value); 128 } 129 130 TestException* V8TestException::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value) 131 { 132 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Object>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0; 133 } 134 135 v8::Handle<v8::Object> wrap(TestException* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 136 { 137 ASSERT(impl); 138 ASSERT(!DOMDataStore::containsWrapper<V8TestException>(impl, isolate)); 139 return V8TestException::createWrapper(impl, creationContext, isolate); 140 } 141 142 v8::Handle<v8::Object> V8TestException::createWrapper(PassRefPtr<TestException> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 143 { 144 ASSERT(impl); 145 ASSERT(!DOMDataStore::containsWrapper<V8TestException>(impl.get(), isolate)); 146 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { 147 const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo(); 148 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have 149 // the same object de-ref functions, though, so use that as the basis of the check. 150 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction); 151 } 152 153 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); 154 if (UNLIKELY(wrapper.IsEmpty())) 155 return wrapper; 156 157 installPerContextEnabledProperties(wrapper, impl.get(), isolate); 158 V8DOMWrapper::associateObjectWithWrapper<V8TestException>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent); 159 return wrapper; 160 } 161 162 void V8TestException::derefObject(void* object) 163 { 164 fromInternalPointer(object)->deref(); 165 } 166 167 template<> 168 v8::Handle<v8::Value> toV8NoInline(TestException* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 169 { 170 return toV8(impl, creationContext, isolate); 171 } 172 173 } // namespace WebCore 174