| 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 "V8TestInterfaceNamedConstructor.h" | |
| 9 | |
| 10 #include "bindings/core/v8/ExceptionState.h" | |
| 11 #include "bindings/core/v8/V8DOMConfiguration.h" | |
| 12 #include "bindings/core/v8/V8HiddenValue.h" | |
| 13 #include "bindings/core/v8/V8ObjectConstructor.h" | |
| 14 #include "core/dom/ContextFeatures.h" | |
| 15 #include "core/dom/Document.h" | |
| 16 #include "core/frame/LocalDOMWindow.h" | |
| 17 #include "platform/RuntimeEnabledFeatures.h" | |
| 18 #include "platform/TraceEvent.h" | |
| 19 #include "wtf/GetPtr.h" | |
| 20 #include "wtf/RefPtr.h" | |
| 21 | |
| 22 namespace blink { | |
| 23 | |
| 24 const WrapperTypeInfo V8TestInterfaceNamedConstructor::wrapperTypeInfo = { gin::
kEmbedderBlink, V8TestInterfaceNamedConstructor::domTemplate, V8TestInterfaceNam
edConstructor::refObject, V8TestInterfaceNamedConstructor::derefObject, V8TestIn
terfaceNamedConstructor::createPersistentHandle, V8TestInterfaceNamedConstructor
::toActiveDOMObject, 0, 0, V8TestInterfaceNamedConstructor::installConditionally
EnabledMethods, V8TestInterfaceNamedConstructor::installConditionallyEnabledProp
erties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectC
lassId, WrapperTypeInfo::Dependent, WrapperTypeInfo::RefCountedObject }; | |
| 25 | |
| 26 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterfac
eNamedConstructor.h. | |
| 27 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in | |
| 28 // bindings/core/v8/ScriptWrappable.h. | |
| 29 const WrapperTypeInfo& TestInterfaceNamedConstructor::s_wrapperTypeInfo = V8Test
InterfaceNamedConstructor::wrapperTypeInfo; | |
| 30 | |
| 31 namespace TestInterfaceNamedConstructorV8Internal { | |
| 32 | |
| 33 template <typename T> void V8_USE(T) { } | |
| 34 | |
| 35 static void TestInterfaceNamedConstructorConstructorGetter(v8::Local<v8::String>
, const v8::PropertyCallbackInfo<v8::Value>& info) | |
| 36 { | |
| 37 v8::Handle<v8::Value> data = info.Data(); | |
| 38 ASSERT(data->IsExternal()); | |
| 39 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre
ationContext()); | |
| 40 if (!perContextData) | |
| 41 return; | |
| 42 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u
nwrap(data))); | |
| 43 } | |
| 44 | |
| 45 static void TestInterfaceNamedConstructorForceSetAttributeOnThis(v8::Local<v8::S
tring> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>&
info) | |
| 46 { | |
| 47 if (info.This()->IsObject()) | |
| 48 v8::Handle<v8::Object>::Cast(info.This())->ForceSet(name, v8Value); | |
| 49 } | |
| 50 | |
| 51 static void TestInterfaceNamedConstructorForceSetAttributeOnThisCallback(v8::Loc
al<v8::String> name, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInf
o<void>& info) | |
| 52 { | |
| 53 TestInterfaceNamedConstructorV8Internal::TestInterfaceNamedConstructorForceS
etAttributeOnThis(name, v8Value, info); | |
| 54 } | |
| 55 | |
| 56 } // namespace TestInterfaceNamedConstructorV8Internal | |
| 57 | |
| 58 static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceNamedCons
tructorAttributes[] = { | |
| 59 {"testNamedConstructorConstructorAttribute", TestInterfaceNamedConstructorV8
Internal::TestInterfaceNamedConstructorConstructorGetter, TestInterfaceNamedCons
tructorV8Internal::TestInterfaceNamedConstructorForceSetAttributeOnThisCallback,
0, 0, const_cast<WrapperTypeInfo*>(&V8TestNamedConstructor::wrapperTypeInfo), s
tatic_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v
8::DontEnum), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnIns
tance}, | |
| 60 }; | |
| 61 | |
| 62 const WrapperTypeInfo V8TestInterfaceNamedConstructorConstructor::wrapperTypeInf
o = { gin::kEmbedderBlink, V8TestInterfaceNamedConstructorConstructor::domTempla
te, V8TestInterfaceNamedConstructor::refObject, V8TestInterfaceNamedConstructor:
:derefObject, V8TestInterfaceNamedConstructor::createPersistentHandle, V8TestInt
erfaceNamedConstructor::toActiveDOMObject, 0, 0, V8TestInterfaceNamedConstructor
::installConditionallyEnabledMethods, V8TestInterfaceNamedConstructor::installCo
nditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, Wr
apperTypeInfo::ObjectClassId, WrapperTypeInfo::Dependent, WrapperTypeInfo::RefCo
untedObject }; | |
| 63 | |
| 64 static void V8TestInterfaceNamedConstructorConstructorCallback(const v8::Functio
nCallbackInfo<v8::Value>& info) | |
| 65 { | |
| 66 if (!info.IsConstructCall()) { | |
| 67 V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallab
leAsFunction("Audio"), info.GetIsolate()); | |
| 68 return; | |
| 69 } | |
| 70 | |
| 71 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExis
tingObject) { | |
| 72 v8SetReturnValue(info, info.Holder()); | |
| 73 return; | |
| 74 } | |
| 75 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInte
rfaceNamedConstructor", info.Holder(), info.GetIsolate()); | |
| 76 if (UNLIKELY(info.Length() < 1)) { | |
| 77 setMinimumArityTypeError(exceptionState, 1, info.Length()); | |
| 78 exceptionState.throwIfNeeded(); | |
| 79 return; | |
| 80 } | |
| 81 V8StringResource<> stringArg; | |
| 82 bool defaultUndefinedOptionalBooleanArg; | |
| 83 int defaultUndefinedOptionalLongArg; | |
| 84 V8StringResource<> defaultUndefinedOptionalStringArg; | |
| 85 V8StringResource<> defaultNullStringOptionalstringArg; | |
| 86 V8StringResource<> optionalStringArg; | |
| 87 { | |
| 88 v8::TryCatch block; | |
| 89 V8RethrowTryCatchScope rethrow(block); | |
| 90 TOSTRING_VOID_INTERNAL(stringArg, info[0]); | |
| 91 TONATIVE_VOID_INTERNAL(defaultUndefinedOptionalBooleanArg, info[1]->Bool
eanValue()); | |
| 92 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(defaultUndefinedOptionalLongArg, t
oInt32(info[2], exceptionState), exceptionState); | |
| 93 TOSTRING_VOID_INTERNAL(defaultUndefinedOptionalStringArg, info[3]); | |
| 94 if (!info[4]->IsUndefined()) { | |
| 95 TOSTRING_VOID_INTERNAL(defaultNullStringOptionalstringArg, info[4]); | |
| 96 } else { | |
| 97 defaultNullStringOptionalstringArg = nullptr; | |
| 98 } | |
| 99 if (UNLIKELY(info.Length() <= 5)) { | |
| 100 Document& document = *toDocument(currentExecutionContext(info.GetIso
late())); | |
| 101 RefPtr<TestInterfaceNamedConstructor> impl = TestInterfaceNamedConst
ructor::createForJSConstructor(document, stringArg, defaultUndefinedOptionalBool
eanArg, defaultUndefinedOptionalLongArg, defaultUndefinedOptionalStringArg, defa
ultNullStringOptionalstringArg, exceptionState); | |
| 102 if (exceptionState.hadException()) { | |
| 103 exceptionState.throwIfNeeded(); | |
| 104 return; | |
| 105 } | |
| 106 v8::Handle<v8::Object> wrapper = info.Holder(); | |
| 107 impl->associateWithWrapper(&V8TestInterfaceNamedConstructorConstruct
or::wrapperTypeInfo, wrapper, info.GetIsolate()); | |
| 108 v8SetReturnValue(info, wrapper); | |
| 109 return; | |
| 110 } | |
| 111 TOSTRING_VOID_INTERNAL(optionalStringArg, info[5]); | |
| 112 } | |
| 113 Document& document = *toDocument(currentExecutionContext(info.GetIsolate()))
; | |
| 114 RefPtr<TestInterfaceNamedConstructor> impl = TestInterfaceNamedConstructor::
createForJSConstructor(document, stringArg, defaultUndefinedOptionalBooleanArg,
defaultUndefinedOptionalLongArg, defaultUndefinedOptionalStringArg, defaultNullS
tringOptionalstringArg, optionalStringArg, exceptionState); | |
| 115 if (exceptionState.hadException()) { | |
| 116 exceptionState.throwIfNeeded(); | |
| 117 return; | |
| 118 } | |
| 119 v8::Handle<v8::Object> wrapper = info.Holder(); | |
| 120 impl->associateWithWrapper(&V8TestInterfaceNamedConstructorConstructor::wrap
perTypeInfo, wrapper, info.GetIsolate()); | |
| 121 v8SetReturnValue(info, wrapper); | |
| 122 } | |
| 123 | |
| 124 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructorConstructor::dom
Template(v8::Isolate* isolate) | |
| 125 { | |
| 126 static int domTemplateKey; // This address is used for a key to look up the
dom template. | |
| 127 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | |
| 128 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTempl
ateKey); | |
| 129 if (!result.IsEmpty()) | |
| 130 return result; | |
| 131 | |
| 132 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate"); | |
| 133 result = v8::FunctionTemplate::New(isolate, V8TestInterfaceNamedConstructorC
onstructorCallback); | |
| 134 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); | |
| 135 instanceTemplate->SetInternalFieldCount(V8TestInterfaceNamedConstructor::int
ernalFieldCount); | |
| 136 result->SetClassName(v8AtomicString(isolate, "TestInterfaceNamedConstructor"
)); | |
| 137 result->Inherit(V8TestInterfaceNamedConstructor::domTemplate(isolate)); | |
| 138 data->setDOMTemplate(&domTemplateKey, result); | |
| 139 return result; | |
| 140 } | |
| 141 | |
| 142 static void installV8TestInterfaceNamedConstructorTemplate(v8::Handle<v8::Functi
onTemplate> functionTemplate, v8::Isolate* isolate) | |
| 143 { | |
| 144 functionTemplate->ReadOnlyPrototype(); | |
| 145 | |
| 146 v8::Local<v8::Signature> defaultSignature; | |
| 147 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterfaceNamedConstructor", v8::Local<v8::FunctionTemplate>(), V8TestI
nterfaceNamedConstructor::internalFieldCount, | |
| 148 V8TestInterfaceNamedConstructorAttributes, WTF_ARRAY_LENGTH(V8TestInterf
aceNamedConstructorAttributes), | |
| 149 0, 0, | |
| 150 0, 0, | |
| 151 isolate); | |
| 152 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTempla
te->InstanceTemplate(); | |
| 153 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTempl
ate->PrototypeTemplate(); | |
| 154 | |
| 155 // Custom toString template | |
| 156 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:from(isolate)->toStringTemplate()); | |
| 157 } | |
| 158 | |
| 159 v8::Handle<v8::FunctionTemplate> V8TestInterfaceNamedConstructor::domTemplate(v8
::Isolate* isolate) | |
| 160 { | |
| 161 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI
nfo*>(&wrapperTypeInfo), installV8TestInterfaceNamedConstructorTemplate); | |
| 162 } | |
| 163 | |
| 164 bool V8TestInterfaceNamedConstructor::hasInstance(v8::Handle<v8::Value> v8Value,
v8::Isolate* isolate) | |
| 165 { | |
| 166 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu
e); | |
| 167 } | |
| 168 | |
| 169 v8::Handle<v8::Object> V8TestInterfaceNamedConstructor::findInstanceInPrototypeC
hain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) | |
| 170 { | |
| 171 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe
rTypeInfo, v8Value); | |
| 172 } | |
| 173 | |
| 174 TestInterfaceNamedConstructor* V8TestInterfaceNamedConstructor::toImplWithTypeCh
eck(v8::Isolate* isolate, v8::Handle<v8::Value> value) | |
| 175 { | |
| 176 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle
<v8::Object>::Cast(value))->toImpl<TestInterfaceNamedConstructor>() : 0; | |
| 177 } | |
| 178 | |
| 179 ActiveDOMObject* V8TestInterfaceNamedConstructor::toActiveDOMObject(v8::Handle<v
8::Object> wrapper) | |
| 180 { | |
| 181 return toImpl(wrapper); | |
| 182 } | |
| 183 | |
| 184 | |
| 185 void V8TestInterfaceNamedConstructor::refObject(ScriptWrappableBase* internalPoi
nter) | |
| 186 { | |
| 187 internalPointer->toImpl<TestInterfaceNamedConstructor>()->ref(); | |
| 188 } | |
| 189 | |
| 190 void V8TestInterfaceNamedConstructor::derefObject(ScriptWrappableBase* internalP
ointer) | |
| 191 { | |
| 192 internalPointer->toImpl<TestInterfaceNamedConstructor>()->deref(); | |
| 193 } | |
| 194 | |
| 195 WrapperPersistentNode* V8TestInterfaceNamedConstructor::createPersistentHandle(S
criptWrappableBase* internalPointer) | |
| 196 { | |
| 197 ASSERT_NOT_REACHED(); | |
| 198 return 0; | |
| 199 } | |
| 200 | |
| 201 template<> | |
| 202 v8::Handle<v8::Value> toV8NoInline(TestInterfaceNamedConstructor* impl, v8::Hand
le<v8::Object> creationContext, v8::Isolate* isolate) | |
| 203 { | |
| 204 return toV8(impl, creationContext, isolate); | |
| 205 } | |
| 206 | |
| 207 } // namespace blink | |
| OLD | NEW |