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 "V8TestInterface2.h" 9 10#include "bindings/core/v8/ExceptionState.h" 11#include "bindings/core/v8/V8DOMConfiguration.h" 12#include "bindings/core/v8/V8GCController.h" 13#include "bindings/core/v8/V8HiddenValue.h" 14#include "bindings/core/v8/V8ObjectConstructor.h" 15#include "bindings/core/v8/V8TestInterface.h" 16#include "bindings/core/v8/V8TestInterfaceEmpty.h" 17#include "core/dom/ContextFeatures.h" 18#include "core/dom/Document.h" 19#include "core/dom/Element.h" 20#include "core/frame/LocalDOMWindow.h" 21#include "platform/RuntimeEnabledFeatures.h" 22#include "platform/TraceEvent.h" 23#include "wtf/GetPtr.h" 24#include "wtf/RefPtr.h" 25 26namespace blink { 27 28const WrapperTypeInfo V8TestInterface2::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterface2::domTemplate, V8TestInterface2::refObject, V8TestInterface2::derefObject, V8TestInterface2::createPersistentHandle, 0, 0, V8TestInterface2::visitDOMWrapper, V8TestInterface2::installConditionallyEnabledMethods, V8TestInterface2::installConditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Dependent, WrapperTypeInfo::RefCountedObject }; 29 30// This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterface2.h. 31// For details, see the comment of DEFINE_WRAPPERTYPEINFO in 32// bindings/core/v8/ScriptWrappable.h. 33const WrapperTypeInfo& TestInterface2::s_wrapperTypeInfo = V8TestInterface2::wrapperTypeInfo; 34 35namespace TestInterface2V8Internal { 36 37template <typename T> void V8_USE(T) { } 38 39static void itemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 40{ 41 ExceptionState exceptionState(ExceptionState::ExecutionContext, "item", "TestInterface2", info.Holder(), info.GetIsolate()); 42 if (UNLIKELY(info.Length() < 1)) { 43 setMinimumArityTypeError(exceptionState, 1, info.Length()); 44 exceptionState.throwIfNeeded(); 45 return; 46 } 47 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 48 unsigned index; 49 { 50 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(index, toUInt32(info[0], exceptionState), exceptionState); 51 } 52 RefPtr<TestInterfaceEmpty> result = impl->item(index, exceptionState); 53 if (exceptionState.hadException()) { 54 exceptionState.throwIfNeeded(); 55 return; 56 } 57 v8SetReturnValue(info, result.release()); 58} 59 60static void itemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 61{ 62 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 63 TestInterface2V8Internal::itemMethod(info); 64 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 65} 66 67static void setItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 68{ 69 ExceptionState exceptionState(ExceptionState::ExecutionContext, "setItem", "TestInterface2", info.Holder(), info.GetIsolate()); 70 if (UNLIKELY(info.Length() < 2)) { 71 setMinimumArityTypeError(exceptionState, 2, info.Length()); 72 exceptionState.throwIfNeeded(); 73 return; 74 } 75 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 76 unsigned index; 77 V8StringResource<> value; 78 { 79 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(index, toUInt32(info[0], exceptionState), exceptionState); 80 TOSTRING_VOID_INTERNAL(value, info[1]); 81 } 82 String result = impl->setItem(index, value, exceptionState); 83 if (exceptionState.hadException()) { 84 exceptionState.throwIfNeeded(); 85 return; 86 } 87 v8SetReturnValueString(info, result, info.GetIsolate()); 88} 89 90static void setItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 91{ 92 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 93 TestInterface2V8Internal::setItemMethod(info); 94 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 95} 96 97static void deleteItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 98{ 99 ExceptionState exceptionState(ExceptionState::ExecutionContext, "deleteItem", "TestInterface2", info.Holder(), info.GetIsolate()); 100 if (UNLIKELY(info.Length() < 1)) { 101 setMinimumArityTypeError(exceptionState, 1, info.Length()); 102 exceptionState.throwIfNeeded(); 103 return; 104 } 105 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 106 unsigned index; 107 { 108 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(index, toUInt32(info[0], exceptionState), exceptionState); 109 } 110 bool result = impl->deleteItem(index, exceptionState); 111 if (exceptionState.hadException()) { 112 exceptionState.throwIfNeeded(); 113 return; 114 } 115 v8SetReturnValueBool(info, result); 116} 117 118static void deleteItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 119{ 120 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 121 TestInterface2V8Internal::deleteItemMethod(info); 122 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 123} 124 125static void namedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 126{ 127 ExceptionState exceptionState(ExceptionState::ExecutionContext, "namedItem", "TestInterface2", info.Holder(), info.GetIsolate()); 128 if (UNLIKELY(info.Length() < 1)) { 129 setMinimumArityTypeError(exceptionState, 1, info.Length()); 130 exceptionState.throwIfNeeded(); 131 return; 132 } 133 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 134 V8StringResource<> name; 135 { 136 TOSTRING_VOID_INTERNAL(name, info[0]); 137 } 138 RefPtr<TestInterfaceEmpty> result = impl->namedItem(name, exceptionState); 139 if (exceptionState.hadException()) { 140 exceptionState.throwIfNeeded(); 141 return; 142 } 143 v8SetReturnValue(info, result.release()); 144} 145 146static void namedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 147{ 148 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 149 TestInterface2V8Internal::namedItemMethod(info); 150 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 151} 152 153static void setNamedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 154{ 155 ExceptionState exceptionState(ExceptionState::ExecutionContext, "setNamedItem", "TestInterface2", info.Holder(), info.GetIsolate()); 156 if (UNLIKELY(info.Length() < 2)) { 157 setMinimumArityTypeError(exceptionState, 2, info.Length()); 158 exceptionState.throwIfNeeded(); 159 return; 160 } 161 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 162 V8StringResource<> name; 163 V8StringResource<> value; 164 { 165 TOSTRING_VOID_INTERNAL(name, info[0]); 166 TOSTRING_VOID_INTERNAL(value, info[1]); 167 } 168 String result = impl->setNamedItem(name, value, exceptionState); 169 if (exceptionState.hadException()) { 170 exceptionState.throwIfNeeded(); 171 return; 172 } 173 v8SetReturnValueString(info, result, info.GetIsolate()); 174} 175 176static void setNamedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 177{ 178 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 179 TestInterface2V8Internal::setNamedItemMethod(info); 180 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 181} 182 183static void deleteNamedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 184{ 185 ExceptionState exceptionState(ExceptionState::ExecutionContext, "deleteNamedItem", "TestInterface2", info.Holder(), info.GetIsolate()); 186 if (UNLIKELY(info.Length() < 1)) { 187 setMinimumArityTypeError(exceptionState, 1, info.Length()); 188 exceptionState.throwIfNeeded(); 189 return; 190 } 191 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 192 V8StringResource<> name; 193 { 194 TOSTRING_VOID_INTERNAL(name, info[0]); 195 } 196 bool result = impl->deleteNamedItem(name, exceptionState); 197 if (exceptionState.hadException()) { 198 exceptionState.throwIfNeeded(); 199 return; 200 } 201 v8SetReturnValueBool(info, result); 202} 203 204static void deleteNamedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 205{ 206 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 207 TestInterface2V8Internal::deleteNamedItemMethod(info); 208 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 209} 210 211static void stringifierMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 212{ 213 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 214 v8SetReturnValueString(info, impl->stringifierMethod(), info.GetIsolate()); 215} 216 217static void stringifierMethodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 218{ 219 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 220 TestInterface2V8Internal::stringifierMethodMethod(info); 221 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 222} 223 224static void toStringMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 225{ 226 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 227 v8SetReturnValueString(info, impl->stringifierMethod(), info.GetIsolate()); 228} 229 230static void toStringMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 231{ 232 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMMethod"); 233 TestInterface2V8Internal::toStringMethod(info); 234 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 235} 236 237static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) 238{ 239 RefPtr<TestInterface2> impl = TestInterface2::create(); 240 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), info.GetIsolate()); 241 v8SetReturnValue(info, wrapper); 242} 243 244static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) 245{ 246 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 247 ExceptionState exceptionState(ExceptionState::IndexedGetterContext, "TestInterface2", info.Holder(), info.GetIsolate()); 248 RefPtr<TestInterfaceEmpty> result = impl->item(index, exceptionState); 249 if (exceptionState.throwIfNeeded()) 250 return; 251 if (!result) 252 return; 253 v8SetReturnValueFast(info, WTF::getPtr(result.release()), impl); 254} 255 256static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) 257{ 258 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMIndexedProperty"); 259 TestInterface2V8Internal::indexedPropertyGetter(index, info); 260 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 261} 262 263static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) 264{ 265 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 266 TOSTRING_VOID(V8StringResource<>, propertyValue, v8Value); 267 ExceptionState exceptionState(ExceptionState::IndexedSetterContext, "TestInterface2", info.Holder(), info.GetIsolate()); 268 bool result = impl->setItem(index, propertyValue, exceptionState); 269 if (exceptionState.throwIfNeeded()) 270 return; 271 if (!result) 272 return; 273 v8SetReturnValue(info, v8Value); 274} 275 276static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) 277{ 278 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMIndexedProperty"); 279 TestInterface2V8Internal::indexedPropertySetter(index, v8Value, info); 280 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 281} 282 283static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info) 284{ 285 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 286 ExceptionState exceptionState(ExceptionState::IndexedDeletionContext, "TestInterface2", info.Holder(), info.GetIsolate()); 287 DeleteResult result = impl->deleteItem(index, exceptionState); 288 if (exceptionState.throwIfNeeded()) 289 return; 290 if (result != DeleteUnknownProperty) 291 return v8SetReturnValueBool(info, result == DeleteSuccess); 292} 293 294static void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info) 295{ 296 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMIndexedProperty"); 297 TestInterface2V8Internal::indexedPropertyDeleter(index, info); 298 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 299} 300 301static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) 302{ 303 if (info.Holder()->HasRealNamedProperty(name)) 304 return; 305 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) 306 return; 307 308 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 309 AtomicString propertyName = toCoreAtomicString(name); 310 v8::String::Utf8Value namedProperty(name); 311 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "TestInterface2", info.Holder(), info.GetIsolate()); 312 RefPtr<TestInterfaceEmpty> result = impl->namedItem(propertyName, exceptionState); 313 if (exceptionState.throwIfNeeded()) 314 return; 315 if (!result) 316 return; 317 v8SetReturnValueFast(info, WTF::getPtr(result.release()), impl); 318} 319 320static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) 321{ 322 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty"); 323 TestInterface2V8Internal::namedPropertyGetter(name, info); 324 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 325} 326 327static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) 328{ 329 if (info.Holder()->HasRealNamedProperty(name)) 330 return; 331 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) 332 return; 333 334 v8::String::Utf8Value namedProperty(name); 335 ExceptionState exceptionState(ExceptionState::SetterContext, *namedProperty, "TestInterface2", info.Holder(), info.GetIsolate()); 336 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 337 TOSTRING_VOID(V8StringResource<>, propertyName, name); 338 TOSTRING_VOID(V8StringResource<>, propertyValue, v8Value); 339 bool result = impl->setNamedItem(propertyName, propertyValue, exceptionState); 340 if (exceptionState.throwIfNeeded()) 341 return; 342 if (!result) 343 return; 344 v8SetReturnValue(info, v8Value); 345} 346 347static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) 348{ 349 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty"); 350 TestInterface2V8Internal::namedPropertySetter(name, v8Value, info); 351 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 352} 353 354static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info) 355{ 356 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 357 AtomicString propertyName = toCoreAtomicString(name); 358 v8::String::Utf8Value namedProperty(name); 359 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty, "TestInterface2", info.Holder(), info.GetIsolate()); 360 bool result = impl->namedPropertyQuery(propertyName, exceptionState); 361 if (exceptionState.throwIfNeeded()) 362 return; 363 if (!result) 364 return; 365 v8SetReturnValueInt(info, v8::None); 366} 367 368static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info) 369{ 370 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty"); 371 TestInterface2V8Internal::namedPropertyQuery(name, info); 372 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 373} 374 375static void namedPropertyDeleter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) 376{ 377 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 378 AtomicString propertyName = toCoreAtomicString(name); 379 v8::String::Utf8Value namedProperty(name); 380 ExceptionState exceptionState(ExceptionState::DeletionContext, *namedProperty, "TestInterface2", info.Holder(), info.GetIsolate()); 381 DeleteResult result = impl->deleteNamedItem(propertyName, exceptionState); 382 if (exceptionState.throwIfNeeded()) 383 return; 384 if (result != DeleteUnknownProperty) 385 return v8SetReturnValueBool(info, result == DeleteSuccess); 386} 387 388static void namedPropertyDeleterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Boolean>& info) 389{ 390 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty"); 391 TestInterface2V8Internal::namedPropertyDeleter(name, info); 392 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 393} 394 395static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info) 396{ 397 TestInterface2* impl = V8TestInterface2::toImpl(info.Holder()); 398 Vector<String> names; 399 ExceptionState exceptionState(ExceptionState::EnumerationContext, "TestInterface2", info.Holder(), info.GetIsolate()); 400 impl->namedPropertyEnumerator(names, exceptionState); 401 if (exceptionState.throwIfNeeded()) 402 return; 403 v8::Handle<v8::Array> v8names = v8::Array::New(info.GetIsolate(), names.size()); 404 for (size_t i = 0; i < names.size(); ++i) 405 v8names->Set(v8::Integer::New(info.GetIsolate(), i), v8String(info.GetIsolate(), names[i])); 406 v8SetReturnValue(info, v8names); 407} 408 409static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>& info) 410{ 411 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMNamedProperty"); 412 TestInterface2V8Internal::namedPropertyEnumerator(info); 413 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); 414} 415 416} // namespace TestInterface2V8Internal 417 418void V8TestInterface2::visitDOMWrapper(ScriptWrappableBase* internalPointer, const v8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate) 419{ 420 TestInterface2* impl = internalPointer->toImpl<TestInterface2>(); 421 // The ownerNode() method may return a reference or a pointer. 422 if (Node* owner = WTF::getPtr(impl->ownerNode())) { 423 Node* root = V8GCController::opaqueRootForGC(owner, isolate); 424 isolate->SetReferenceFromGroup(v8::UniqueId(reinterpret_cast<intptr_t>(root)), wrapper); 425 return; 426 } 427 setObjectGroup(internalPointer, wrapper, isolate); 428} 429 430static const V8DOMConfiguration::MethodConfiguration V8TestInterface2Methods[] = { 431 {"item", TestInterface2V8Internal::itemMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts}, 432 {"setItem", TestInterface2V8Internal::setItemMethodCallback, 0, 2, V8DOMConfiguration::ExposedToAllScripts}, 433 {"deleteItem", TestInterface2V8Internal::deleteItemMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts}, 434 {"namedItem", TestInterface2V8Internal::namedItemMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts}, 435 {"setNamedItem", TestInterface2V8Internal::setNamedItemMethodCallback, 0, 2, V8DOMConfiguration::ExposedToAllScripts}, 436 {"deleteNamedItem", TestInterface2V8Internal::deleteNamedItemMethodCallback, 0, 1, V8DOMConfiguration::ExposedToAllScripts}, 437 {"stringifierMethod", TestInterface2V8Internal::stringifierMethodMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts}, 438 {"toString", TestInterface2V8Internal::toStringMethodCallback, 0, 0, V8DOMConfiguration::ExposedToAllScripts}, 439}; 440 441void V8TestInterface2::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 442{ 443 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMConstructor"); 444 if (!info.IsConstructCall()) { 445 V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("TestInterface2"), info.GetIsolate()); 446 return; 447 } 448 449 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) { 450 v8SetReturnValue(info, info.Holder()); 451 return; 452 } 453 454 TestInterface2V8Internal::constructor(info); 455} 456 457static void installV8TestInterface2Template(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate) 458{ 459 functionTemplate->ReadOnlyPrototype(); 460 461 v8::Local<v8::Signature> defaultSignature; 462 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterface2", v8::Local<v8::FunctionTemplate>(), V8TestInterface2::internalFieldCount, 463 0, 0, 464 0, 0, 465 V8TestInterface2Methods, WTF_ARRAY_LENGTH(V8TestInterface2Methods), 466 isolate); 467 functionTemplate->SetCallHandler(V8TestInterface2::constructorCallback); 468 functionTemplate->SetLength(0); 469 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate(); 470 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate(); 471 if (RuntimeEnabledFeatures::featureNameEnabled()) { 472 static const V8DOMConfiguration::ConstantConfiguration constantConfiguration = {"CONST_VALUE_1", 1, 0, 0, V8DOMConfiguration::ConstantTypeUnsignedShort}; 473 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, &constantConfiguration, 1, isolate); 474 } 475 COMPILE_ASSERT(1 == TestInterface2::CONST_VALUE_1, TheValueOfTestInterface2_CONST_VALUE_1DoesntMatchWithImplementation); 476 functionTemplate->InstanceTemplate()->SetIndexedPropertyHandler(TestInterface2V8Internal::indexedPropertyGetterCallback, TestInterface2V8Internal::indexedPropertySetterCallback, 0, TestInterface2V8Internal::indexedPropertyDeleterCallback, indexedPropertyEnumerator<TestInterface2>); 477 functionTemplate->InstanceTemplate()->SetNamedPropertyHandler(TestInterface2V8Internal::namedPropertyGetterCallback, TestInterface2V8Internal::namedPropertySetterCallback, TestInterface2V8Internal::namedPropertyQueryCallback, TestInterface2V8Internal::namedPropertyDeleterCallback, TestInterface2V8Internal::namedPropertyEnumeratorCallback); 478 479 // Custom toString template 480 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate()); 481} 482 483v8::Handle<v8::FunctionTemplate> V8TestInterface2::domTemplate(v8::Isolate* isolate) 484{ 485 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterface2Template); 486} 487 488bool V8TestInterface2::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) 489{ 490 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value); 491} 492 493v8::Handle<v8::Object> V8TestInterface2::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) 494{ 495 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value); 496} 497 498TestInterface2* V8TestInterface2::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value) 499{ 500 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle<v8::Object>::Cast(value))->toImpl<TestInterface2>() : 0; 501} 502 503 504void V8TestInterface2::refObject(ScriptWrappableBase* internalPointer) 505{ 506 internalPointer->toImpl<TestInterface2>()->ref(); 507} 508 509void V8TestInterface2::derefObject(ScriptWrappableBase* internalPointer) 510{ 511 internalPointer->toImpl<TestInterface2>()->deref(); 512} 513 514WrapperPersistentNode* V8TestInterface2::createPersistentHandle(ScriptWrappableBase* internalPointer) 515{ 516 ASSERT_NOT_REACHED(); 517 return 0; 518} 519 520template<> 521v8::Handle<v8::Value> toV8NoInline(TestInterface2* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 522{ 523 return toV8(impl, creationContext, isolate); 524} 525 526} // namespace blink 527