| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 */ | |
| 30 | |
| 31 // This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY! | |
| 32 | |
| 33 #include "config.h" | |
| 34 #include "V8TestInterfaceGarbageCollected.h" | |
| 35 | |
| 36 #include "RuntimeEnabledFeatures.h" | |
| 37 #include "bindings/v8/ExceptionState.h" | |
| 38 #include "bindings/v8/V8DOMConfiguration.h" | |
| 39 #include "bindings/v8/V8ObjectConstructor.h" | |
| 40 #include "core/dom/ContextFeatures.h" | |
| 41 #include "core/dom/Document.h" | |
| 42 #include "platform/TraceEvent.h" | |
| 43 #include "wtf/GetPtr.h" | |
| 44 #include "wtf/RefPtr.h" | |
| 45 | |
| 46 namespace WebCore { | |
| 47 | |
| 48 static void initializeScriptWrappableForInterface(TestInterfaceGarbageCollected*
object) | |
| 49 { | |
| 50 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) | |
| 51 ScriptWrappable::setTypeInfoInObject(object, &V8TestInterfaceGarbageColl
ected::wrapperTypeInfo); | |
| 52 else | |
| 53 ASSERT_NOT_REACHED(); | |
| 54 } | |
| 55 | |
| 56 } // namespace WebCore | |
| 57 | |
| 58 // In ScriptWrappable::init, the use of a local function declaration has an issu
e on Windows: | |
| 59 // the local declaration does not pick up the surrounding namespace. Therefore,
we provide this function | |
| 60 // in the global namespace. | |
| 61 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe
edback/details/664619/the-namespace-of-local-function-declarations-in-c) | |
| 62 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfaceGarbageC
ollected* object) | |
| 63 { | |
| 64 WebCore::initializeScriptWrappableForInterface(object); | |
| 65 } | |
| 66 | |
| 67 namespace WebCore { | |
| 68 const WrapperTypeInfo V8TestInterfaceGarbageCollected::wrapperTypeInfo = { gin::
kEmbedderBlink, V8TestInterfaceGarbageCollected::domTemplate, V8TestInterfaceGar
bageCollected::derefObject, 0, 0, 0, V8TestInterfaceGarbageCollected::installPer
ContextEnabledMethods, 0, WrapperTypeObjectPrototype, true }; | |
| 69 | |
| 70 namespace TestInterfaceGarbageCollectedV8Internal { | |
| 71 | |
| 72 template <typename T> void V8_USE(T) { } | |
| 73 | |
| 74 static void attr1AttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info
) | |
| 75 { | |
| 76 TestInterfaceGarbageCollected* imp = V8TestInterfaceGarbageCollected::toNati
ve(info.Holder()); | |
| 77 v8SetReturnValueFast(info, imp->attr1(), imp); | |
| 78 } | |
| 79 | |
| 80 static void attr1AttributeGetterCallback(v8::Local<v8::String>, const v8::Proper
tyCallbackInfo<v8::Value>& info) | |
| 81 { | |
| 82 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); | |
| 83 TestInterfaceGarbageCollectedV8Internal::attr1AttributeGetter(info); | |
| 84 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
| 85 } | |
| 86 | |
| 87 static void attr1AttributeSetter(v8::Local<v8::Value> jsValue, const v8::Propert
yCallbackInfo<void>& info) | |
| 88 { | |
| 89 TestInterfaceGarbageCollected* imp = V8TestInterfaceGarbageCollected::toNati
ve(info.Holder()); | |
| 90 V8TRYCATCH_VOID(TestInterfaceGarbageCollected*, cppValue, V8TestInterfaceGar
bageCollected::hasInstance(jsValue, info.GetIsolate()) ? V8TestInterfaceGarbageC
ollected::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0); | |
| 91 imp->setAttr1(WTF::getPtr(cppValue)); | |
| 92 } | |
| 93 | |
| 94 static void attr1AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Va
lue> jsValue, const v8::PropertyCallbackInfo<void>& info) | |
| 95 { | |
| 96 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); | |
| 97 TestInterfaceGarbageCollectedV8Internal::attr1AttributeSetter(jsValue, info)
; | |
| 98 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
| 99 } | |
| 100 | |
| 101 static void funcMethod(const v8::FunctionCallbackInfo<v8::Value>& info) | |
| 102 { | |
| 103 if (UNLIKELY(info.Length() < 1)) { | |
| 104 throwTypeError(ExceptionMessages::failedToExecute("func", "TestInterface
GarbageCollected", ExceptionMessages::notEnoughArguments(1, info.Length())), inf
o.GetIsolate()); | |
| 105 return; | |
| 106 } | |
| 107 TestInterfaceGarbageCollected* imp = V8TestInterfaceGarbageCollected::toNati
ve(info.Holder()); | |
| 108 V8TRYCATCH_VOID(TestInterfaceGarbageCollected*, arg, V8TestInterfaceGarbageC
ollected::hasInstance(info[0], info.GetIsolate()) ? V8TestInterfaceGarbageCollec
ted::toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0); | |
| 109 imp->func(arg); | |
| 110 } | |
| 111 | |
| 112 static void funcMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) | |
| 113 { | |
| 114 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | |
| 115 TestInterfaceGarbageCollectedV8Internal::funcMethod(info); | |
| 116 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
| 117 } | |
| 118 | |
| 119 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) | |
| 120 { | |
| 121 if (UNLIKELY(info.Length() < 1)) { | |
| 122 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceGarbag
eCollected", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetI
solate()); | |
| 123 return; | |
| 124 } | |
| 125 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, str, info[0]); | |
| 126 RefPtrWillBeRawPtr<TestInterfaceGarbageCollected> impl = TestInterfaceGarbag
eCollected::create(str); | |
| 127 v8::Handle<v8::Object> wrapper = info.Holder(); | |
| 128 | |
| 129 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceGarbageCollected>(im
pl.release(), &V8TestInterfaceGarbageCollected::wrapperTypeInfo, wrapper, info.G
etIsolate(), WrapperConfiguration::Dependent); | |
| 130 v8SetReturnValue(info, wrapper); | |
| 131 } | |
| 132 | |
| 133 } // namespace TestInterfaceGarbageCollectedV8Internal | |
| 134 | |
| 135 static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceGarbageCo
llectedAttributes[] = { | |
| 136 {"attr1", TestInterfaceGarbageCollectedV8Internal::attr1AttributeGetterCallb
ack, TestInterfaceGarbageCollectedV8Internal::attr1AttributeSetterCallback, 0, 0
, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttrib
ute>(v8::None), 0 /* on instance */}, | |
| 137 }; | |
| 138 | |
| 139 static const V8DOMConfiguration::MethodConfiguration V8TestInterfaceGarbageColle
ctedMethods[] = { | |
| 140 {"func", TestInterfaceGarbageCollectedV8Internal::funcMethodCallback, 0, 1}, | |
| 141 }; | |
| 142 | |
| 143 void V8TestInterfaceGarbageCollected::constructorCallback(const v8::FunctionCall
backInfo<v8::Value>& info) | |
| 144 { | |
| 145 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); | |
| 146 if (!info.IsConstructCall()) { | |
| 147 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceGarbag
eCollected", "Please use the 'new' operator, this DOM object constructor cannot
be called as a function."), info.GetIsolate()); | |
| 148 return; | |
| 149 } | |
| 150 | |
| 151 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { | |
| 152 v8SetReturnValue(info, info.Holder()); | |
| 153 return; | |
| 154 } | |
| 155 | |
| 156 TestInterfaceGarbageCollectedV8Internal::constructor(info); | |
| 157 } | |
| 158 | |
| 159 static void configureV8TestInterfaceGarbageCollectedTemplate(v8::Handle<v8::Func
tionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWorldType currentWo
rldType) | |
| 160 { | |
| 161 functionTemplate->ReadOnlyPrototype(); | |
| 162 | |
| 163 v8::Local<v8::Signature> defaultSignature; | |
| 164 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterfaceGarbageCollected", v8::Local<v8::FunctionTemplate>(), V8TestI
nterfaceGarbageCollected::internalFieldCount, | |
| 165 V8TestInterfaceGarbageCollectedAttributes, WTF_ARRAY_LENGTH(V8TestInterf
aceGarbageCollectedAttributes), | |
| 166 0, 0, | |
| 167 V8TestInterfaceGarbageCollectedMethods, WTF_ARRAY_LENGTH(V8TestInterface
GarbageCollectedMethods), | |
| 168 isolate, currentWorldType); | |
| 169 functionTemplate->SetCallHandler(V8TestInterfaceGarbageCollected::constructo
rCallback); | |
| 170 functionTemplate->SetLength(1); | |
| 171 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); | |
| 172 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); | |
| 173 | |
| 174 // Custom toString template | |
| 175 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:current()->toStringTemplate()); | |
| 176 } | |
| 177 | |
| 178 v8::Handle<v8::FunctionTemplate> V8TestInterfaceGarbageCollected::domTemplate(v8
::Isolate* isolate, WrapperWorldType currentWorldType) | |
| 179 { | |
| 180 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | |
| 181 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); | |
| 182 if (result != data->templateMap(currentWorldType).end()) | |
| 183 return result->value.newLocal(isolate); | |
| 184 | |
| 185 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | |
| 186 v8::EscapableHandleScope handleScope(isolate); | |
| 187 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); | |
| 188 configureV8TestInterfaceGarbageCollectedTemplate(templ, isolate, currentWorl
dType); | |
| 189 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | |
| 190 return handleScope.Escape(templ); | |
| 191 } | |
| 192 | |
| 193 bool V8TestInterfaceGarbageCollected::hasInstance(v8::Handle<v8::Value> jsValue,
v8::Isolate* isolate) | |
| 194 { | |
| 195 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI
nfo, jsValue) | |
| 196 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy
peInfo, jsValue); | |
| 197 } | |
| 198 | |
| 199 v8::Handle<v8::Object> V8TestInterfaceGarbageCollected::createWrapper(PassRefPtr
WillBeRawPtr<TestInterfaceGarbageCollected> impl, v8::Handle<v8::Object> creatio
nContext, v8::Isolate* isolate) | |
| 200 { | |
| 201 ASSERT(impl); | |
| 202 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceGarbageCollected>(impl.
get(), isolate)); | |
| 203 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { | |
| 204 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl.get()); | |
| 205 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper
TypeInfo. These will both have | |
| 206 // the same object de-ref functions, though, so use that as the basis of
the check. | |
| 207 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction
== wrapperTypeInfo.derefObjectFunction); | |
| 208 } | |
| 209 | |
| 210 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); | |
| 211 if (UNLIKELY(wrapper.IsEmpty())) | |
| 212 return wrapper; | |
| 213 | |
| 214 installPerContextEnabledProperties(wrapper, impl.get(), isolate); | |
| 215 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceGarbageCollected>(im
pl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent); | |
| 216 return wrapper; | |
| 217 } | |
| 218 | |
| 219 void V8TestInterfaceGarbageCollected::derefObject(void* object) | |
| 220 { | |
| 221 fromInternalPointer(object)->deref(); | |
| 222 } | |
| 223 | |
| 224 template<> | |
| 225 v8::Handle<v8::Value> toV8NoInline(TestInterfaceGarbageCollected* impl, v8::Hand
le<v8::Object> creationContext, v8::Isolate* isolate) | |
| 226 { | |
| 227 return toV8(impl, creationContext, isolate); | |
| 228 } | |
| 229 | |
| 230 } // namespace WebCore | |
| OLD | NEW |