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. |
| 6 // DO NOT MODIFY! |
| 7 |
| 8 // This file has been generated from the Jinja2 template in |
| 9 // third_party/WebKit/Source/bindings/templates/interface.cpp.tmpl |
| 10 |
| 11 // clang-format off |
| 12 #include "V8TestSubObject.h" |
| 13 |
| 14 #include "bindings/core/v8/ExceptionState.h" |
| 15 #include "bindings/core/v8/IDLTypes.h" |
| 16 #include "bindings/core/v8/NativeValueTraitsImpl.h" |
| 17 #include "bindings/core/v8/V8DOMConfiguration.h" |
| 18 #include "core/dom/ExecutionContext.h" |
| 19 #include "platform/bindings/V8ObjectConstructor.h" |
| 20 #include "platform/wtf/GetPtr.h" |
| 21 #include "platform/wtf/RefPtr.h" |
| 22 |
| 23 namespace blink { |
| 24 |
| 25 // Suppress warning: global constructors, because struct WrapperTypeInfo is triv
ial |
| 26 // and does not depend on another global objects. |
| 27 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) |
| 28 #pragma clang diagnostic push |
| 29 #pragma clang diagnostic ignored "-Wglobal-constructors" |
| 30 #endif |
| 31 const WrapperTypeInfo V8TestSubObject::wrapperTypeInfo = { gin::kEmbedderBlink,
V8TestSubObject::domTemplate, V8TestSubObject::Trace, V8TestSubObject::TraceWrap
pers, nullptr, "TestSubObject", &V8TestObject::wrapperTypeInfo, WrapperTypeInfo:
:kWrapperTypeObjectPrototype, WrapperTypeInfo::kObjectClassId, WrapperTypeInfo::
kNotInheritFromActiveScriptWrappable, WrapperTypeInfo::kIndependent }; |
| 32 #if defined(COMPONENT_BUILD) && defined(WIN32) && COMPILER(CLANG) |
| 33 #pragma clang diagnostic pop |
| 34 #endif |
| 35 |
| 36 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestSubObjec
t.h. |
| 37 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in |
| 38 // platform/bindings/ScriptWrappable.h. |
| 39 const WrapperTypeInfo& TestSubObject::wrapper_type_info_ = V8TestSubObject::wrap
perTypeInfo; |
| 40 |
| 41 // not [ActiveScriptWrappable] |
| 42 static_assert( |
| 43 !std::is_base_of<ActiveScriptWrappableBase, TestSubObject>::value, |
| 44 "TestSubObject inherits from ActiveScriptWrappable<>, but is not specifying
" |
| 45 "[ActiveScriptWrappable] extended attribute in the IDL file. " |
| 46 "Be consistent."); |
| 47 static_assert( |
| 48 std::is_same<decltype(&TestSubObject::HasPendingActivity), |
| 49 decltype(&ScriptWrappable::HasPendingActivity)>::value, |
| 50 "TestSubObject is overriding hasPendingActivity(), but is not specifying " |
| 51 "[ActiveScriptWrappable] extended attribute in the IDL file. " |
| 52 "Be consistent."); |
| 53 |
| 54 namespace TestSubObjectV8Internal { |
| 55 |
| 56 static void unforgeableStringAttributeAttributeGetter(const v8::FunctionCallback
Info<v8::Value>& info) { |
| 57 v8::Local<v8::Object> holder = info.Holder(); |
| 58 |
| 59 TestSubObject* impl = V8TestSubObject::toImpl(holder); |
| 60 |
| 61 V8SetReturnValueString(info, impl->unforgeableStringAttribute(), info.GetIsola
te()); |
| 62 } |
| 63 |
| 64 static void unforgeableStringAttributeAttributeSetter(v8::Local<v8::Value> v8Val
ue, const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 65 v8::Isolate* isolate = info.GetIsolate(); |
| 66 ALLOW_UNUSED_LOCAL(isolate); |
| 67 |
| 68 v8::Local<v8::Object> holder = info.Holder(); |
| 69 ALLOW_UNUSED_LOCAL(holder); |
| 70 |
| 71 TestSubObject* impl = V8TestSubObject::toImpl(holder); |
| 72 |
| 73 // Prepare the value to be set. |
| 74 V8StringResource<> cppValue = v8Value; |
| 75 if (!cppValue.Prepare()) |
| 76 return; |
| 77 |
| 78 impl->setUnforgeableStringAttribute(cppValue); |
| 79 } |
| 80 |
| 81 static void unforgeableLongAttributeAttributeGetter(const v8::FunctionCallbackIn
fo<v8::Value>& info) { |
| 82 v8::Local<v8::Object> holder = info.Holder(); |
| 83 |
| 84 TestSubObject* impl = V8TestSubObject::toImpl(holder); |
| 85 |
| 86 V8SetReturnValueInt(info, impl->unforgeableLongAttribute()); |
| 87 } |
| 88 |
| 89 static void unforgeableLongAttributeAttributeSetter(v8::Local<v8::Value> v8Value
, const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 90 v8::Isolate* isolate = info.GetIsolate(); |
| 91 ALLOW_UNUSED_LOCAL(isolate); |
| 92 |
| 93 v8::Local<v8::Object> holder = info.Holder(); |
| 94 ALLOW_UNUSED_LOCAL(holder); |
| 95 |
| 96 TestSubObject* impl = V8TestSubObject::toImpl(holder); |
| 97 |
| 98 ExceptionState exceptionState(isolate, ExceptionState::kSetterContext, "TestSu
bObject", "unforgeableLongAttribute"); |
| 99 |
| 100 // Prepare the value to be set. |
| 101 int32_t cppValue = NativeValueTraits<IDLLong>::NativeValue(info.GetIsolate(),
v8Value, exceptionState, kNormalConversion); |
| 102 if (exceptionState.HadException()) |
| 103 return; |
| 104 |
| 105 impl->setUnforgeableLongAttribute(cppValue); |
| 106 } |
| 107 |
| 108 } // namespace TestSubObjectV8Internal |
| 109 |
| 110 void V8TestSubObject::unforgeableStringAttributeAttributeGetterCallback(const v8
::FunctionCallbackInfo<v8::Value>& info) { |
| 111 TestSubObjectV8Internal::unforgeableStringAttributeAttributeGetter(info); |
| 112 } |
| 113 |
| 114 void V8TestSubObject::unforgeableStringAttributeAttributeSetterCallback(const v8
::FunctionCallbackInfo<v8::Value>& info) { |
| 115 v8::Local<v8::Value> v8Value = info[0]; |
| 116 |
| 117 TestSubObjectV8Internal::unforgeableStringAttributeAttributeSetter(v8Value, in
fo); |
| 118 } |
| 119 |
| 120 void V8TestSubObject::unforgeableLongAttributeAttributeGetterCallback(const v8::
FunctionCallbackInfo<v8::Value>& info) { |
| 121 TestSubObjectV8Internal::unforgeableLongAttributeAttributeGetter(info); |
| 122 } |
| 123 |
| 124 void V8TestSubObject::unforgeableLongAttributeAttributeSetterCallback(const v8::
FunctionCallbackInfo<v8::Value>& info) { |
| 125 v8::Local<v8::Value> v8Value = info[0]; |
| 126 |
| 127 TestSubObjectV8Internal::unforgeableLongAttributeAttributeSetter(v8Value, info
); |
| 128 } |
| 129 |
| 130 static const V8DOMConfiguration::AccessorConfiguration V8TestSubObjectAccessors[
] = { |
| 131 { "unforgeableStringAttribute", V8TestSubObject::unforgeableStringAttribut
eAttributeGetterCallback, V8TestSubObject::unforgeableStringAttributeAttributeSe
tterCallback, nullptr, nullptr, static_cast<v8::PropertyAttribute>(v8::DontDelet
e), V8DOMConfiguration::kOnInstance, V8DOMConfiguration::kCheckHolder, V8DOMConf
iguration::kAllWorlds } |
| 132 , |
| 133 |
| 134 { "unforgeableLongAttribute", V8TestSubObject::unforgeableLongAttributeAtt
ributeGetterCallback, V8TestSubObject::unforgeableLongAttributeAttributeSetterCa
llback, nullptr, nullptr, static_cast<v8::PropertyAttribute>(v8::DontDelete), V8
DOMConfiguration::kOnInstance, V8DOMConfiguration::kCheckHolder, V8DOMConfigurat
ion::kAllWorlds } |
| 135 , |
| 136 }; |
| 137 |
| 138 static void installV8TestSubObjectTemplate(v8::Isolate* isolate, const DOMWrappe
rWorld& world, v8::Local<v8::FunctionTemplate> interfaceTemplate) { |
| 139 // Initialize the interface object's template. |
| 140 V8DOMConfiguration::InitializeDOMInterfaceTemplate(isolate, interfaceTemplate,
V8TestSubObject::wrapperTypeInfo.interface_name, V8TestObject::domTemplate(isol
ate, world), V8TestSubObject::internalFieldCount); |
| 141 |
| 142 v8::Local<v8::Signature> signature = v8::Signature::New(isolate, interfaceTemp
late); |
| 143 ALLOW_UNUSED_LOCAL(signature); |
| 144 v8::Local<v8::ObjectTemplate> instanceTemplate = interfaceTemplate->InstanceTe
mplate(); |
| 145 ALLOW_UNUSED_LOCAL(instanceTemplate); |
| 146 v8::Local<v8::ObjectTemplate> prototypeTemplate = interfaceTemplate->Prototype
Template(); |
| 147 ALLOW_UNUSED_LOCAL(prototypeTemplate); |
| 148 |
| 149 // Register DOM constants, attributes and operations. |
| 150 V8DOMConfiguration::InstallAccessors(isolate, world, instanceTemplate, prototy
peTemplate, interfaceTemplate, signature, V8TestSubObjectAccessors, WTF_ARRAY_LE
NGTH(V8TestSubObjectAccessors)); |
| 151 } |
| 152 |
| 153 v8::Local<v8::FunctionTemplate> V8TestSubObject::domTemplate(v8::Isolate* isolat
e, const DOMWrapperWorld& world) { |
| 154 return V8DOMConfiguration::DomClassTemplate(isolate, world, const_cast<Wrapper
TypeInfo*>(&wrapperTypeInfo), installV8TestSubObjectTemplate); |
| 155 } |
| 156 |
| 157 bool V8TestSubObject::hasInstance(v8::Local<v8::Value> v8Value, v8::Isolate* iso
late) { |
| 158 return V8PerIsolateData::From(isolate)->HasInstance(&wrapperTypeInfo, v8Value)
; |
| 159 } |
| 160 |
| 161 v8::Local<v8::Object> V8TestSubObject::findInstanceInPrototypeChain(v8::Local<v8
::Value> v8Value, v8::Isolate* isolate) { |
| 162 return V8PerIsolateData::From(isolate)->FindInstanceInPrototypeChain(&wrapperT
ypeInfo, v8Value); |
| 163 } |
| 164 |
| 165 TestSubObject* V8TestSubObject::toImplWithTypeCheck(v8::Isolate* isolate, v8::Lo
cal<v8::Value> value) { |
| 166 return hasInstance(value, isolate) ? toImpl(v8::Local<v8::Object>::Cast(value)
) : nullptr; |
| 167 } |
| 168 |
| 169 TestSubObject* NativeValueTraits<TestSubObject>::NativeValue(v8::Isolate* isolat
e, v8::Local<v8::Value> value, ExceptionState& exceptionState) { |
| 170 TestSubObject* nativeValue = V8TestSubObject::toImplWithTypeCheck(isolate, val
ue); |
| 171 if (!nativeValue) { |
| 172 exceptionState.ThrowTypeError(ExceptionMessages::FailedToConvertJSValue( |
| 173 "TestSubObject")); |
| 174 } |
| 175 return nativeValue; |
| 176 } |
| 177 |
| 178 } // namespace blink |
OLD | NEW |