| 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 "V8TestInterfacePython2.h" | |
| 9 | |
| 10 #include "RuntimeEnabledFeatures.h" | |
| 11 #include "V8Interface1.h" | |
| 12 #include "V8Interface2.h" | |
| 13 #include "bindings/v8/ExceptionState.h" | |
| 14 #include "bindings/v8/V8DOMConfiguration.h" | |
| 15 #include "bindings/v8/V8GCController.h" | |
| 16 #include "bindings/v8/V8HiddenValue.h" | |
| 17 #include "bindings/v8/V8ObjectConstructor.h" | |
| 18 #include "core/dom/ContextFeatures.h" | |
| 19 #include "core/dom/Document.h" | |
| 20 #include "core/dom/Element.h" | |
| 21 #include "core/frame/DOMWindow.h" | |
| 22 #include "platform/TraceEvent.h" | |
| 23 #include "wtf/GetPtr.h" | |
| 24 #include "wtf/RefPtr.h" | |
| 25 | |
| 26 namespace WebCore { | |
| 27 | |
| 28 static void initializeScriptWrappableForInterface(TestInterfacePython2* object) | |
| 29 { | |
| 30 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) | |
| 31 ScriptWrappable::setTypeInfoInObject(object, &V8TestInterfacePython2::wr
apperTypeInfo); | |
| 32 else | |
| 33 ASSERT_NOT_REACHED(); | |
| 34 } | |
| 35 | |
| 36 } // namespace WebCore | |
| 37 | |
| 38 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfacePython2*
object) | |
| 39 { | |
| 40 WebCore::initializeScriptWrappableForInterface(object); | |
| 41 } | |
| 42 | |
| 43 namespace WebCore { | |
| 44 const WrapperTypeInfo V8TestInterfacePython2::wrapperTypeInfo = { gin::kEmbedder
Blink, V8TestInterfacePython2::domTemplate, V8TestInterfacePython2::derefObject,
0, 0, V8TestInterfacePython2::visitDOMWrapper, V8TestInterfacePython2::installP
erContextEnabledMethods, 0, WrapperTypeObjectPrototype, false }; | |
| 45 | |
| 46 namespace TestInterfacePython2V8Internal { | |
| 47 | |
| 48 template <typename T> void V8_USE(T) { } | |
| 49 | |
| 50 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) | |
| 51 { | |
| 52 v8::Isolate* isolate = info.GetIsolate(); | |
| 53 RefPtr<TestInterfacePython2> impl = TestInterfacePython2::create(); | |
| 54 | |
| 55 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), isolate); | |
| 56 v8SetReturnValue(info, wrapper); | |
| 57 } | |
| 58 | |
| 59 } // namespace TestInterfacePython2V8Internal | |
| 60 | |
| 61 void V8TestInterfacePython2::visitDOMWrapper(void* object, const v8::Persistent<
v8::Object>& wrapper, v8::Isolate* isolate) | |
| 62 { | |
| 63 TestInterfacePython2* impl = fromInternalPointer(object); | |
| 64 // The ownerNode() method may return a reference or a pointer. | |
| 65 if (Node* owner = WTF::getPtr(impl->ownerNode())) { | |
| 66 Node* root = V8GCController::opaqueRootForGC(owner, isolate); | |
| 67 isolate->SetReferenceFromGroup(v8::UniqueId(reinterpret_cast<intptr_t>(r
oot)), wrapper); | |
| 68 return; | |
| 69 } | |
| 70 setObjectGroup(object, wrapper, isolate); | |
| 71 } | |
| 72 | |
| 73 void V8TestInterfacePython2::constructorCallback(const v8::FunctionCallbackInfo<
v8::Value>& info) | |
| 74 { | |
| 75 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); | |
| 76 if (!info.IsConstructCall()) { | |
| 77 throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("Test
InterfacePython2"), info.GetIsolate()); | |
| 78 return; | |
| 79 } | |
| 80 | |
| 81 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { | |
| 82 v8SetReturnValue(info, info.Holder()); | |
| 83 return; | |
| 84 } | |
| 85 | |
| 86 TestInterfacePython2V8Internal::constructor(info); | |
| 87 } | |
| 88 | |
| 89 static void configureV8TestInterfacePython2Template(v8::Handle<v8::FunctionTempl
ate> functionTemplate, v8::Isolate* isolate) | |
| 90 { | |
| 91 functionTemplate->ReadOnlyPrototype(); | |
| 92 | |
| 93 v8::Local<v8::Signature> defaultSignature; | |
| 94 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterfacePython2", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceP
ython2::internalFieldCount, | |
| 95 0, 0, | |
| 96 0, 0, | |
| 97 0, 0, | |
| 98 isolate); | |
| 99 functionTemplate->SetCallHandler(V8TestInterfacePython2::constructorCallback
); | |
| 100 functionTemplate->SetLength(0); | |
| 101 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); | |
| 102 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); | |
| 103 | |
| 104 // Custom toString template | |
| 105 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:current()->toStringTemplate()); | |
| 106 } | |
| 107 | |
| 108 v8::Handle<v8::FunctionTemplate> V8TestInterfacePython2::domTemplate(v8::Isolate
* isolate) | |
| 109 { | |
| 110 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | |
| 111 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(const_cas
t<WrapperTypeInfo*>(&wrapperTypeInfo)); | |
| 112 if (!result.IsEmpty()) | |
| 113 return result; | |
| 114 | |
| 115 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | |
| 116 result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidCons
tructorMode); | |
| 117 configureV8TestInterfacePython2Template(result, isolate); | |
| 118 data->setDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), result)
; | |
| 119 return result; | |
| 120 } | |
| 121 | |
| 122 bool V8TestInterfacePython2::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isol
ate* isolate) | |
| 123 { | |
| 124 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu
e); | |
| 125 } | |
| 126 | |
| 127 v8::Handle<v8::Object> V8TestInterfacePython2::findInstanceInPrototypeChain(v8::
Handle<v8::Value> v8Value, v8::Isolate* isolate) | |
| 128 { | |
| 129 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe
rTypeInfo, v8Value); | |
| 130 } | |
| 131 | |
| 132 TestInterfacePython2* V8TestInterfacePython2::toNativeWithTypeCheck(v8::Isolate*
isolate, v8::Handle<v8::Value> value) | |
| 133 { | |
| 134 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Obje
ct>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) :
0; | |
| 135 } | |
| 136 | |
| 137 v8::Handle<v8::Object> wrap(TestInterfacePython2* impl, v8::Handle<v8::Object> c
reationContext, v8::Isolate* isolate) | |
| 138 { | |
| 139 ASSERT(impl); | |
| 140 if (impl->isInterface1()) | |
| 141 return wrap(toInterface1(impl), creationContext, isolate); | |
| 142 if (impl->isInterface2()) | |
| 143 return wrap(toInterface2(impl), creationContext, isolate); | |
| 144 v8::Handle<v8::Object> wrapper = V8TestInterfacePython2::createWrapper(impl,
creationContext, isolate); | |
| 145 return wrapper; | |
| 146 } | |
| 147 | |
| 148 v8::Handle<v8::Object> V8TestInterfacePython2::createWrapper(PassRefPtr<TestInte
rfacePython2> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate
) | |
| 149 { | |
| 150 ASSERT(impl); | |
| 151 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfacePython2>(impl.get(), is
olate)); | |
| 152 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { | |
| 153 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl.get()); | |
| 154 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper
TypeInfo. These will both have | |
| 155 // the same object de-ref functions, though, so use that as the basis of
the check. | |
| 156 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction
== wrapperTypeInfo.derefObjectFunction); | |
| 157 } | |
| 158 | |
| 159 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); | |
| 160 if (UNLIKELY(wrapper.IsEmpty())) | |
| 161 return wrapper; | |
| 162 | |
| 163 installPerContextEnabledProperties(wrapper, impl.get(), isolate); | |
| 164 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfacePython2>(impl, &wrap
perTypeInfo, wrapper, isolate, WrapperConfiguration::Dependent); | |
| 165 return wrapper; | |
| 166 } | |
| 167 | |
| 168 void V8TestInterfacePython2::derefObject(void* object) | |
| 169 { | |
| 170 fromInternalPointer(object)->deref(); | |
| 171 } | |
| 172 | |
| 173 template<> | |
| 174 v8::Handle<v8::Value> toV8NoInline(TestInterfacePython2* impl, v8::Handle<v8::Ob
ject> creationContext, v8::Isolate* isolate) | |
| 175 { | |
| 176 return toV8(impl, creationContext, isolate); | |
| 177 } | |
| 178 | |
| 179 } // namespace WebCore | |
| OLD | NEW |