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 "V8TestSpecialOperationsAnonymous.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(TestSpecialOperationsAnonymous
* object) |
| 24 { |
| 25 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) |
| 26 ScriptWrappable::setTypeInfoInObject(object, &V8TestSpecialOperationsAno
nymous::wrapperTypeInfo); |
| 27 else |
| 28 ASSERT_NOT_REACHED(); |
| 29 } |
| 30 |
| 31 } // namespace WebCore |
| 32 |
| 33 void webCoreInitializeScriptWrappableForInterface(WebCore::TestSpecialOperations
Anonymous* object) |
| 34 { |
| 35 WebCore::initializeScriptWrappableForInterface(object); |
| 36 } |
| 37 |
| 38 namespace WebCore { |
| 39 const WrapperTypeInfo V8TestSpecialOperationsAnonymous::wrapperTypeInfo = { gin:
:kEmbedderBlink, V8TestSpecialOperationsAnonymous::domTemplate, V8TestSpecialOpe
rationsAnonymous::derefObject, 0, 0, 0, V8TestSpecialOperationsAnonymous::instal
lPerContextEnabledMethods, 0, WrapperTypeObjectPrototype, false }; |
| 40 |
| 41 namespace TestSpecialOperationsAnonymousV8Internal { |
| 42 |
| 43 template <typename T> void V8_USE(T) { } |
| 44 |
| 45 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo
<v8::Value>& info) |
| 46 { |
| 47 TestSpecialOperationsAnonymous* impl = V8TestSpecialOperationsAnonymous::toN
ative(info.Holder()); |
| 48 String result = impl->anonymousIndexedGetter(index); |
| 49 if (result.isNull()) |
| 50 return; |
| 51 v8SetReturnValueString(info, result, info.GetIsolate()); |
| 52 } |
| 53 |
| 54 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCall
backInfo<v8::Value>& info) |
| 55 { |
| 56 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); |
| 57 TestSpecialOperationsAnonymousV8Internal::indexedPropertyGetter(index, info)
; |
| 58 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 59 } |
| 60 |
| 61 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value,
const v8::PropertyCallbackInfo<v8::Value>& info) |
| 62 { |
| 63 TestSpecialOperationsAnonymous* impl = V8TestSpecialOperationsAnonymous::toN
ative(info.Holder()); |
| 64 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyValue, v8Va
lue); |
| 65 bool result = impl->anonymousIndexedSetter(index, propertyValue); |
| 66 if (!result) |
| 67 return; |
| 68 v8SetReturnValue(info, v8Value); |
| 69 } |
| 70 |
| 71 static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v
8Value, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 72 { |
| 73 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); |
| 74 TestSpecialOperationsAnonymousV8Internal::indexedPropertySetter(index, v8Val
ue, info); |
| 75 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 76 } |
| 77 |
| 78 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInf
o<v8::Boolean>& info) |
| 79 { |
| 80 TestSpecialOperationsAnonymous* impl = V8TestSpecialOperationsAnonymous::toN
ative(info.Holder()); |
| 81 DeleteResult result = impl->anonymousIndexedDeleter(index); |
| 82 if (result != DeleteUnknownProperty) |
| 83 return v8SetReturnValueBool(info, result == DeleteSuccess); |
| 84 } |
| 85 |
| 86 static void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCal
lbackInfo<v8::Boolean>& info) |
| 87 { |
| 88 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); |
| 89 TestSpecialOperationsAnonymousV8Internal::indexedPropertyDeleter(index, info
); |
| 90 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 91 } |
| 92 |
| 93 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCa
llbackInfo<v8::Value>& info) |
| 94 { |
| 95 if (info.Holder()->HasRealNamedProperty(name)) |
| 96 return; |
| 97 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) |
| 98 return; |
| 99 |
| 100 TestSpecialOperationsAnonymous* impl = V8TestSpecialOperationsAnonymous::toN
ative(info.Holder()); |
| 101 AtomicString propertyName = toCoreAtomicString(name); |
| 102 String result = impl->anonymousNamedGetter(propertyName); |
| 103 if (result.isNull()) |
| 104 return; |
| 105 v8SetReturnValueString(info, result, info.GetIsolate()); |
| 106 } |
| 107 |
| 108 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::Pr
opertyCallbackInfo<v8::Value>& info) |
| 109 { |
| 110 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); |
| 111 TestSpecialOperationsAnonymousV8Internal::namedPropertyGetter(name, info); |
| 112 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 113 } |
| 114 |
| 115 static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value>
v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 116 { |
| 117 if (info.Holder()->HasRealNamedProperty(name)) |
| 118 return; |
| 119 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) |
| 120 return; |
| 121 |
| 122 TestSpecialOperationsAnonymous* impl = V8TestSpecialOperationsAnonymous::toN
ative(info.Holder()); |
| 123 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyName, name)
; |
| 124 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyValue, v8Va
lue); |
| 125 bool result = impl->anonymousNamedSetter(propertyName, propertyValue); |
| 126 if (!result) |
| 127 return; |
| 128 v8SetReturnValue(info, v8Value); |
| 129 } |
| 130 |
| 131 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8
::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 132 { |
| 133 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); |
| 134 TestSpecialOperationsAnonymousV8Internal::namedPropertySetter(name, v8Value,
info); |
| 135 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 136 } |
| 137 |
| 138 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal
lbackInfo<v8::Integer>& info) |
| 139 { |
| 140 TestSpecialOperationsAnonymous* impl = V8TestSpecialOperationsAnonymous::toN
ative(info.Holder()); |
| 141 AtomicString propertyName = toCoreAtomicString(name); |
| 142 v8::String::Utf8Value namedProperty(name); |
| 143 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty,
"TestSpecialOperationsAnonymous", info.Holder(), info.GetIsolate()); |
| 144 bool result = impl->namedPropertyQuery(propertyName, exceptionState); |
| 145 if (exceptionState.throwIfNeeded()) |
| 146 return; |
| 147 if (!result) |
| 148 return; |
| 149 v8SetReturnValueInt(info, v8::None); |
| 150 } |
| 151 |
| 152 static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::Pro
pertyCallbackInfo<v8::Integer>& info) |
| 153 { |
| 154 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); |
| 155 TestSpecialOperationsAnonymousV8Internal::namedPropertyQuery(name, info); |
| 156 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 157 } |
| 158 |
| 159 static void namedPropertyDeleter(v8::Local<v8::String> name, const v8::PropertyC
allbackInfo<v8::Boolean>& info) |
| 160 { |
| 161 TestSpecialOperationsAnonymous* impl = V8TestSpecialOperationsAnonymous::toN
ative(info.Holder()); |
| 162 AtomicString propertyName = toCoreAtomicString(name); |
| 163 DeleteResult result = impl->anonymousNamedDeleter(propertyName); |
| 164 if (result != DeleteUnknownProperty) |
| 165 return v8SetReturnValueBool(info, result == DeleteSuccess); |
| 166 } |
| 167 |
| 168 static void namedPropertyDeleterCallback(v8::Local<v8::String> name, const v8::P
ropertyCallbackInfo<v8::Boolean>& info) |
| 169 { |
| 170 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); |
| 171 TestSpecialOperationsAnonymousV8Internal::namedPropertyDeleter(name, info); |
| 172 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 173 } |
| 174 |
| 175 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i
nfo) |
| 176 { |
| 177 TestSpecialOperationsAnonymous* impl = V8TestSpecialOperationsAnonymous::toN
ative(info.Holder()); |
| 178 v8::Isolate* isolate = info.GetIsolate(); |
| 179 Vector<String> names; |
| 180 ExceptionState exceptionState(ExceptionState::EnumerationContext, "TestSpeci
alOperationsAnonymous", info.Holder(), isolate); |
| 181 impl->namedPropertyEnumerator(names, exceptionState); |
| 182 if (exceptionState.throwIfNeeded()) |
| 183 return; |
| 184 v8::Handle<v8::Array> v8names = v8::Array::New(isolate, names.size()); |
| 185 for (size_t i = 0; i < names.size(); ++i) |
| 186 v8names->Set(v8::Integer::New(isolate, i), v8String(isolate, names[i])); |
| 187 v8SetReturnValue(info, v8names); |
| 188 } |
| 189 |
| 190 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::A
rray>& info) |
| 191 { |
| 192 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); |
| 193 TestSpecialOperationsAnonymousV8Internal::namedPropertyEnumerator(info); |
| 194 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
| 195 } |
| 196 |
| 197 } // namespace TestSpecialOperationsAnonymousV8Internal |
| 198 |
| 199 static void configureV8TestSpecialOperationsAnonymousTemplate(v8::Handle<v8::Fun
ctionTemplate> functionTemplate, v8::Isolate* isolate) |
| 200 { |
| 201 functionTemplate->ReadOnlyPrototype(); |
| 202 |
| 203 v8::Local<v8::Signature> defaultSignature; |
| 204 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestSpecialOperationsAnonymous", v8::Local<v8::FunctionTemplate>(), V8Test
SpecialOperationsAnonymous::internalFieldCount, |
| 205 0, 0, |
| 206 0, 0, |
| 207 0, 0, |
| 208 isolate); |
| 209 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); |
| 210 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); |
| 211 functionTemplate->InstanceTemplate()->SetIndexedPropertyHandler(TestSpecialO
perationsAnonymousV8Internal::indexedPropertyGetterCallback, TestSpecialOperatio
nsAnonymousV8Internal::indexedPropertySetterCallback, 0, TestSpecialOperationsAn
onymousV8Internal::indexedPropertyDeleterCallback, indexedPropertyEnumerator<Tes
tSpecialOperationsAnonymous>); |
| 212 functionTemplate->InstanceTemplate()->SetNamedPropertyHandler(TestSpecialOpe
rationsAnonymousV8Internal::namedPropertyGetterCallback, TestSpecialOperationsAn
onymousV8Internal::namedPropertySetterCallback, TestSpecialOperationsAnonymousV8
Internal::namedPropertyQueryCallback, TestSpecialOperationsAnonymousV8Internal::
namedPropertyDeleterCallback, TestSpecialOperationsAnonymousV8Internal::namedPro
pertyEnumeratorCallback); |
| 213 |
| 214 // Custom toString template |
| 215 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:current()->toStringTemplate()); |
| 216 } |
| 217 |
| 218 v8::Handle<v8::FunctionTemplate> V8TestSpecialOperationsAnonymous::domTemplate(v
8::Isolate* isolate) |
| 219 { |
| 220 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 221 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(const_cas
t<WrapperTypeInfo*>(&wrapperTypeInfo)); |
| 222 if (!result.IsEmpty()) |
| 223 return result; |
| 224 |
| 225 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 226 result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidCons
tructorMode); |
| 227 configureV8TestSpecialOperationsAnonymousTemplate(result, isolate); |
| 228 data->setDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), result)
; |
| 229 return result; |
| 230 } |
| 231 |
| 232 bool V8TestSpecialOperationsAnonymous::hasInstance(v8::Handle<v8::Value> v8Value
, v8::Isolate* isolate) |
| 233 { |
| 234 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu
e); |
| 235 } |
| 236 |
| 237 v8::Handle<v8::Object> V8TestSpecialOperationsAnonymous::findInstanceInPrototype
Chain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) |
| 238 { |
| 239 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe
rTypeInfo, v8Value); |
| 240 } |
| 241 |
| 242 TestSpecialOperationsAnonymous* V8TestSpecialOperationsAnonymous::toNativeWithTy
peCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value) |
| 243 { |
| 244 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Obje
ct>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) :
0; |
| 245 } |
| 246 |
| 247 v8::Handle<v8::Object> V8TestSpecialOperationsAnonymous::createWrapper(PassRefPt
r<TestSpecialOperationsAnonymous> impl, v8::Handle<v8::Object> creationContext,
v8::Isolate* isolate) |
| 248 { |
| 249 ASSERT(impl); |
| 250 ASSERT(!DOMDataStore::containsWrapper<V8TestSpecialOperationsAnonymous>(impl
.get(), isolate)); |
| 251 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { |
| 252 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl.get()); |
| 253 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper
TypeInfo. These will both have |
| 254 // the same object de-ref functions, though, so use that as the basis of
the check. |
| 255 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction
== wrapperTypeInfo.derefObjectFunction); |
| 256 } |
| 257 |
| 258 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); |
| 259 if (UNLIKELY(wrapper.IsEmpty())) |
| 260 return wrapper; |
| 261 |
| 262 installPerContextEnabledProperties(wrapper, impl.get(), isolate); |
| 263 V8DOMWrapper::associateObjectWithWrapper<V8TestSpecialOperationsAnonymous>(i
mpl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent); |
| 264 return wrapper; |
| 265 } |
| 266 |
| 267 void V8TestSpecialOperationsAnonymous::derefObject(void* object) |
| 268 { |
| 269 fromInternalPointer(object)->deref(); |
| 270 } |
| 271 |
| 272 template<> |
| 273 v8::Handle<v8::Value> toV8NoInline(TestSpecialOperationsAnonymous* impl, v8::Han
dle<v8::Object> creationContext, v8::Isolate* isolate) |
| 274 { |
| 275 return toV8(impl, creationContext, isolate); |
| 276 } |
| 277 |
| 278 } // namespace WebCore |
OLD | NEW |