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.
5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
8 #include "V8TestSpecialOperationsInt.h"
10 #include "RuntimeEnabledFeatures.h"
11 #include "bindings/v8/ExceptionState.h"
12 #include "bindings/v8/V8DOMConfiguration.h"
13 #include "bindings/v8/V8HiddenValue.h"
14 #include "bindings/v8/V8ObjectConstructor.h"
15 #include "core/dom/ContextFeatures.h"
16 #include "core/dom/Document.h"
17 #include "platform/TraceEvent.h"
18 #include "wtf/GetPtr.h"
19 #include "wtf/RefPtr.h"
23 static void initializeScriptWrappableForInterface(TestSpecialOperationsInt* object)
25 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
26 ScriptWrappable::setTypeInfoInObject(object, &V8TestSpecialOperationsInt::wrapperTypeInfo);
31 } // namespace WebCore
33 void webCoreInitializeScriptWrappableForInterface(WebCore::TestSpecialOperationsInt* object)
35 WebCore::initializeScriptWrappableForInterface(object);
39 const WrapperTypeInfo V8TestSpecialOperationsInt::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestSpecialOperationsInt::domTemplate, V8TestSpecialOperationsInt::derefObject, 0, 0, 0, V8TestSpecialOperationsInt::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype, false };
41 namespace TestSpecialOperationsIntV8Internal {
43 template <typename T> void V8_USE(T) { }
45 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
47 TestSpecialOperationsInt* impl = V8TestSpecialOperationsInt::toNative(info.Holder());
48 int result = impl->anonymousIndexedGetter(index);
51 v8SetReturnValueInt(info, result);
54 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
56 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty");
57 TestSpecialOperationsIntV8Internal::indexedPropertyGetter(index, info);
58 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
61 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
63 TestSpecialOperationsInt* impl = V8TestSpecialOperationsInt::toNative(info.Holder());
64 V8TRYCATCH_EXCEPTION_VOID(unsigned, propertyValue, toUInt32(v8Value, exceptionState), exceptionState);
65 ExceptionState exceptionState(ExceptionState::IndexedSetterContext, "TestSpecialOperationsInt", info.Holder(), info.GetIsolate());
66 bool result = impl->anonymousIndexedSetter(index, propertyValue);
69 v8SetReturnValue(info, v8Value);
72 static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
74 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty");
75 TestSpecialOperationsIntV8Internal::indexedPropertySetter(index, v8Value, info);
76 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
79 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
81 if (info.Holder()->HasRealNamedProperty(name))
83 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty())
86 TestSpecialOperationsInt* impl = V8TestSpecialOperationsInt::toNative(info.Holder());
87 AtomicString propertyName = toCoreAtomicString(name);
88 int result = impl->anonymousNamedGetter(propertyName);
91 v8SetReturnValueInt(info, result);
94 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
96 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
97 TestSpecialOperationsIntV8Internal::namedPropertyGetter(name, info);
98 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
101 static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
103 if (info.Holder()->HasRealNamedProperty(name))
105 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty())
108 TestSpecialOperationsInt* impl = V8TestSpecialOperationsInt::toNative(info.Holder());
109 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyName, name);
110 V8TRYCATCH_EXCEPTION_VOID(unsigned, propertyValue, toUInt32(v8Value, exceptionState), exceptionState);
111 v8::String::Utf8Value namedProperty(name);
112 ExceptionState exceptionState(ExceptionState::SetterContext, *namedProperty, "TestSpecialOperationsInt", info.Holder(), info.GetIsolate());
113 bool result = impl->anonymousNamedSetter(propertyName, propertyValue);
116 v8SetReturnValue(info, v8Value);
119 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info)
121 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
122 TestSpecialOperationsIntV8Internal::namedPropertySetter(name, v8Value, info);
123 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
126 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
128 TestSpecialOperationsInt* impl = V8TestSpecialOperationsInt::toNative(info.Holder());
129 AtomicString propertyName = toCoreAtomicString(name);
130 v8::String::Utf8Value namedProperty(name);
131 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "TestSpecialOperationsInt", info.Holder(), info.GetIsolate());
132 bool result = impl->namedPropertyQuery(propertyName, exceptionState);
133 if (exceptionState.throwIfNeeded())
137 v8SetReturnValueInt(info, v8::None);
140 static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info)
142 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
143 TestSpecialOperationsIntV8Internal::namedPropertyQuery(name, info);
144 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
147 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info)
149 TestSpecialOperationsInt* impl = V8TestSpecialOperationsInt::toNative(info.Holder());
150 v8::Isolate* isolate = info.GetIsolate();
151 Vector<String> names;
152 ExceptionState exceptionState(ExceptionState::EnumerationContext, "TestSpecialOperationsInt", info.Holder(), isolate);
153 impl->namedPropertyEnumerator(names, exceptionState);
154 if (exceptionState.throwIfNeeded())
156 v8::Handle<v8::Array> v8names = v8::Array::New(isolate, names.size());
157 for (size_t i = 0; i < names.size(); ++i)
158 v8names->Set(v8::Integer::New(isolate, i), v8String(isolate, names[i]));
159 v8SetReturnValue(info, v8names);
162 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>& info)
164 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
165 TestSpecialOperationsIntV8Internal::namedPropertyEnumerator(info);
166 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
169 } // namespace TestSpecialOperationsIntV8Internal
171 static void configureV8TestSpecialOperationsIntTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
173 functionTemplate->ReadOnlyPrototype();
175 v8::Local<v8::Signature> defaultSignature;
176 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestSpecialOperationsInt", v8::Local<v8::FunctionTemplate>(), V8TestSpecialOperationsInt::internalFieldCount,
181 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTemplate->InstanceTemplate();
182 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTemplate->PrototypeTemplate();
183 functionTemplate->InstanceTemplate()->SetIndexedPropertyHandler(TestSpecialOperationsIntV8Internal::indexedPropertyGetterCallback, TestSpecialOperationsIntV8Internal::indexedPropertySetterCallback, 0, 0, indexedPropertyEnumerator<TestSpecialOperationsInt>);
184 functionTemplate->InstanceTemplate()->SetNamedPropertyHandler(TestSpecialOperationsIntV8Internal::namedPropertyGetterCallback, TestSpecialOperationsIntV8Internal::namedPropertySetterCallback, TestSpecialOperationsIntV8Internal::namedPropertyQueryCallback, 0, TestSpecialOperationsIntV8Internal::namedPropertyEnumeratorCallback);
186 // Custom toString template
187 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::current()->toStringTemplate());
190 v8::Handle<v8::FunctionTemplate> V8TestSpecialOperationsInt::domTemplate(v8::Isolate* isolate)
192 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
193 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo));
194 if (!result.IsEmpty())
197 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
198 result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidConstructorMode);
199 configureV8TestSpecialOperationsIntTemplate(result, isolate);
200 data->setDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), result);
204 bool V8TestSpecialOperationsInt::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
206 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
209 v8::Handle<v8::Object> V8TestSpecialOperationsInt::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
211 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
214 TestSpecialOperationsInt* V8TestSpecialOperationsInt::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
216 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Object>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
219 v8::Handle<v8::Object> V8TestSpecialOperationsInt::createWrapper(PassRefPtr<TestSpecialOperationsInt> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
222 ASSERT(!DOMDataStore::containsWrapper<V8TestSpecialOperationsInt>(impl.get(), isolate));
223 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
224 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObject(impl.get());
225 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
226 // the same object de-ref functions, though, so use that as the basis of the check.
227 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
230 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
231 if (UNLIKELY(wrapper.IsEmpty()))
234 installPerContextEnabledProperties(wrapper, impl.get(), isolate);
235 V8DOMWrapper::associateObjectWithWrapper<V8TestSpecialOperationsInt>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
239 void V8TestSpecialOperationsInt::derefObject(void* object)
241 fromInternalPointer(object)->deref();
245 v8::Handle<v8::Value> toV8NoInline(TestSpecialOperationsInt* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
247 return toV8(impl, creationContext, isolate);
250 } // namespace WebCore