| OLD | NEW |
| (Empty) |
| 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 "V8TestSpecialOperationsOverrideBuiltins.h" | |
| 9 | |
| 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" | |
| 20 | |
| 21 namespace WebCore { | |
| 22 | |
| 23 static void initializeScriptWrappableForInterface(TestSpecialOperationsOverrideB
uiltins* object) | |
| 24 { | |
| 25 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) | |
| 26 ScriptWrappable::setTypeInfoInObject(object, &V8TestSpecialOperationsOve
rrideBuiltins::wrapperTypeInfo); | |
| 27 else | |
| 28 ASSERT_NOT_REACHED(); | |
| 29 } | |
| 30 | |
| 31 } // namespace WebCore | |
| 32 | |
| 33 void webCoreInitializeScriptWrappableForInterface(WebCore::TestSpecialOperations
OverrideBuiltins* object) | |
| 34 { | |
| 35 WebCore::initializeScriptWrappableForInterface(object); | |
| 36 } | |
| 37 | |
| 38 namespace WebCore { | |
| 39 const WrapperTypeInfo V8TestSpecialOperationsOverrideBuiltins::wrapperTypeInfo =
{ gin::kEmbedderBlink, V8TestSpecialOperationsOverrideBuiltins::domTemplate, V8
TestSpecialOperationsOverrideBuiltins::derefObject, 0, 0, 0, V8TestSpecialOperat
ionsOverrideBuiltins::installPerContextEnabledMethods, 0, WrapperTypeObjectProto
type, false }; | |
| 40 | |
| 41 namespace TestSpecialOperationsOverrideBuiltinsV8Internal { | |
| 42 | |
| 43 template <typename T> void V8_USE(T) { } | |
| 44 | |
| 45 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCa
llbackInfo<v8::Value>& info) | |
| 46 { | |
| 47 TestSpecialOperationsOverrideBuiltins* impl = V8TestSpecialOperationsOverrid
eBuiltins::toNative(info.Holder()); | |
| 48 AtomicString propertyName = toCoreAtomicString(name); | |
| 49 String result = impl->anonymousNamedGetter(propertyName); | |
| 50 if (result.isNull()) | |
| 51 return; | |
| 52 v8SetReturnValueString(info, result, info.GetIsolate()); | |
| 53 } | |
| 54 | |
| 55 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::Pr
opertyCallbackInfo<v8::Value>& info) | |
| 56 { | |
| 57 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); | |
| 58 TestSpecialOperationsOverrideBuiltinsV8Internal::namedPropertyGetter(name, i
nfo); | |
| 59 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
| 60 } | |
| 61 | |
| 62 static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value>
v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) | |
| 63 { | |
| 64 TestSpecialOperationsOverrideBuiltins* impl = V8TestSpecialOperationsOverrid
eBuiltins::toNative(info.Holder()); | |
| 65 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyName, name)
; | |
| 66 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyValue, v8Va
lue); | |
| 67 bool result = impl->anonymousNamedSetter(propertyName, propertyValue); | |
| 68 if (!result) | |
| 69 return; | |
| 70 v8SetReturnValue(info, v8Value); | |
| 71 } | |
| 72 | |
| 73 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8
::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) | |
| 74 { | |
| 75 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); | |
| 76 TestSpecialOperationsOverrideBuiltinsV8Internal::namedPropertySetter(name, v
8Value, info); | |
| 77 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
| 78 } | |
| 79 | |
| 80 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal
lbackInfo<v8::Integer>& info) | |
| 81 { | |
| 82 TestSpecialOperationsOverrideBuiltins* impl = V8TestSpecialOperationsOverrid
eBuiltins::toNative(info.Holder()); | |
| 83 AtomicString propertyName = toCoreAtomicString(name); | |
| 84 v8::String::Utf8Value namedProperty(name); | |
| 85 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty,
"TestSpecialOperationsOverrideBuiltins", info.Holder(), info.GetIsolate()); | |
| 86 bool result = impl->namedPropertyQuery(propertyName, exceptionState); | |
| 87 if (exceptionState.throwIfNeeded()) | |
| 88 return; | |
| 89 if (!result) | |
| 90 return; | |
| 91 v8SetReturnValueInt(info, v8::None); | |
| 92 } | |
| 93 | |
| 94 static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::Pro
pertyCallbackInfo<v8::Integer>& info) | |
| 95 { | |
| 96 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); | |
| 97 TestSpecialOperationsOverrideBuiltinsV8Internal::namedPropertyQuery(name, in
fo); | |
| 98 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
| 99 } | |
| 100 | |
| 101 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i
nfo) | |
| 102 { | |
| 103 TestSpecialOperationsOverrideBuiltins* impl = V8TestSpecialOperationsOverrid
eBuiltins::toNative(info.Holder()); | |
| 104 v8::Isolate* isolate = info.GetIsolate(); | |
| 105 Vector<String> names; | |
| 106 ExceptionState exceptionState(ExceptionState::EnumerationContext, "TestSpeci
alOperationsOverrideBuiltins", info.Holder(), isolate); | |
| 107 impl->namedPropertyEnumerator(names, exceptionState); | |
| 108 if (exceptionState.throwIfNeeded()) | |
| 109 return; | |
| 110 v8::Handle<v8::Array> v8names = v8::Array::New(isolate, names.size()); | |
| 111 for (size_t i = 0; i < names.size(); ++i) | |
| 112 v8names->Set(v8::Integer::New(isolate, i), v8String(isolate, names[i])); | |
| 113 v8SetReturnValue(info, v8names); | |
| 114 } | |
| 115 | |
| 116 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::A
rray>& info) | |
| 117 { | |
| 118 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); | |
| 119 TestSpecialOperationsOverrideBuiltinsV8Internal::namedPropertyEnumerator(inf
o); | |
| 120 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
| 121 } | |
| 122 | |
| 123 } // namespace TestSpecialOperationsOverrideBuiltinsV8Internal | |
| 124 | |
| 125 static void configureV8TestSpecialOperationsOverrideBuiltinsTemplate(v8::Handle<
v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate) | |
| 126 { | |
| 127 functionTemplate->ReadOnlyPrototype(); | |
| 128 | |
| 129 v8::Local<v8::Signature> defaultSignature; | |
| 130 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestSpecialOperationsOverrideBuiltins", v8::Local<v8::FunctionTemplate>(),
V8TestSpecialOperationsOverrideBuiltins::internalFieldCount, | |
| 131 0, 0, | |
| 132 0, 0, | |
| 133 0, 0, | |
| 134 isolate); | |
| 135 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); | |
| 136 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); | |
| 137 functionTemplate->InstanceTemplate()->SetNamedPropertyHandler(TestSpecialOpe
rationsOverrideBuiltinsV8Internal::namedPropertyGetterCallback, TestSpecialOpera
tionsOverrideBuiltinsV8Internal::namedPropertySetterCallback, TestSpecialOperati
onsOverrideBuiltinsV8Internal::namedPropertyQueryCallback, 0, TestSpecialOperati
onsOverrideBuiltinsV8Internal::namedPropertyEnumeratorCallback); | |
| 138 | |
| 139 // Custom toString template | |
| 140 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:current()->toStringTemplate()); | |
| 141 } | |
| 142 | |
| 143 v8::Handle<v8::FunctionTemplate> V8TestSpecialOperationsOverrideBuiltins::domTem
plate(v8::Isolate* isolate) | |
| 144 { | |
| 145 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | |
| 146 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(const_cas
t<WrapperTypeInfo*>(&wrapperTypeInfo)); | |
| 147 if (!result.IsEmpty()) | |
| 148 return result; | |
| 149 | |
| 150 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | |
| 151 result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidCons
tructorMode); | |
| 152 configureV8TestSpecialOperationsOverrideBuiltinsTemplate(result, isolate); | |
| 153 data->setDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), result)
; | |
| 154 return result; | |
| 155 } | |
| 156 | |
| 157 bool V8TestSpecialOperationsOverrideBuiltins::hasInstance(v8::Handle<v8::Value>
v8Value, v8::Isolate* isolate) | |
| 158 { | |
| 159 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu
e); | |
| 160 } | |
| 161 | |
| 162 v8::Handle<v8::Object> V8TestSpecialOperationsOverrideBuiltins::findInstanceInPr
ototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) | |
| 163 { | |
| 164 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe
rTypeInfo, v8Value); | |
| 165 } | |
| 166 | |
| 167 TestSpecialOperationsOverrideBuiltins* V8TestSpecialOperationsOverrideBuiltins::
toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value) | |
| 168 { | |
| 169 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Obje
ct>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) :
0; | |
| 170 } | |
| 171 | |
| 172 v8::Handle<v8::Object> V8TestSpecialOperationsOverrideBuiltins::createWrapper(Pa
ssRefPtr<TestSpecialOperationsOverrideBuiltins> impl, v8::Handle<v8::Object> cre
ationContext, v8::Isolate* isolate) | |
| 173 { | |
| 174 ASSERT(impl); | |
| 175 ASSERT(!DOMDataStore::containsWrapper<V8TestSpecialOperationsOverrideBuiltin
s>(impl.get(), isolate)); | |
| 176 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { | |
| 177 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl.get()); | |
| 178 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper
TypeInfo. These will both have | |
| 179 // the same object de-ref functions, though, so use that as the basis of
the check. | |
| 180 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction
== wrapperTypeInfo.derefObjectFunction); | |
| 181 } | |
| 182 | |
| 183 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); | |
| 184 if (UNLIKELY(wrapper.IsEmpty())) | |
| 185 return wrapper; | |
| 186 | |
| 187 installPerContextEnabledProperties(wrapper, impl.get(), isolate); | |
| 188 V8DOMWrapper::associateObjectWithWrapper<V8TestSpecialOperationsOverrideBuil
tins>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independen
t); | |
| 189 return wrapper; | |
| 190 } | |
| 191 | |
| 192 void V8TestSpecialOperationsOverrideBuiltins::derefObject(void* object) | |
| 193 { | |
| 194 fromInternalPointer(object)->deref(); | |
| 195 } | |
| 196 | |
| 197 template<> | |
| 198 v8::Handle<v8::Value> toV8NoInline(TestSpecialOperationsOverrideBuiltins* impl,
v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | |
| 199 { | |
| 200 return toV8(impl, creationContext, isolate); | |
| 201 } | |
| 202 | |
| 203 } // namespace WebCore | |
| OLD | NEW |