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 #if ENABLE(CONDITION) |
| 9 #include "V8TestInterfacePartial.h" |
| 10 |
| 11 #include "bindings/core/v8/ExceptionState.h" |
| 12 #include "bindings/core/v8/PrivateScriptRunner.h" |
| 13 #include "bindings/core/v8/ScriptValue.h" |
| 14 #include "bindings/core/v8/V8DOMConfiguration.h" |
| 15 #include "bindings/core/v8/V8HiddenValue.h" |
| 16 #include "bindings/core/v8/V8Node.h" |
| 17 #include "bindings/core/v8/V8ObjectConstructor.h" |
| 18 #include "bindings/core/v8/V8TestInterface.h" |
| 19 #include "bindings/core/v8/V8TestInterfaceEmpty.h" |
| 20 #include "bindings/tests/idls/modules/TestPartialInterfaceImplementation3.h" |
| 21 #include "core/dom/ContextFeatures.h" |
| 22 #include "core/dom/Document.h" |
| 23 #include "core/frame/LocalFrame.h" |
| 24 #include "platform/RuntimeEnabledFeatures.h" |
| 25 #include "platform/ScriptForbiddenScope.h" |
| 26 #include "platform/TraceEvent.h" |
| 27 #include "wtf/GetPtr.h" |
| 28 #include "wtf/RefPtr.h" |
| 29 |
| 30 namespace blink { |
| 31 |
| 32 namespace TestPartialInterfaceImplementation3PartialV8Internal { |
| 33 |
| 34 static void partial3LongAttributeAttributeGetter(const v8::PropertyCallbackInfo<
v8::Value>& info) |
| 35 { |
| 36 v8::Handle<v8::Object> holder = info.Holder(); |
| 37 TestPartialInterfaceImplementation3* impl = V8TestInterface::toImpl(holder); |
| 38 v8SetReturnValueInt(info, TestPartialInterfaceImplementation3::partial3LongA
ttribute(*impl)); |
| 39 } |
| 40 |
| 41 static void partial3LongAttributeAttributeGetterCallback(v8::Local<v8::String>,
const v8::PropertyCallbackInfo<v8::Value>& info) |
| 42 { |
| 43 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); |
| 44 TestPartialInterfaceImplementation3PartialV8Internal::partial3LongAttributeA
ttributeGetter(info); |
| 45 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| 46 } |
| 47 |
| 48 static void partial3LongAttributeAttributeSetter(v8::Local<v8::Value> v8Value, c
onst v8::PropertyCallbackInfo<void>& info) |
| 49 { |
| 50 v8::Handle<v8::Object> holder = info.Holder(); |
| 51 ExceptionState exceptionState(ExceptionState::SetterContext, "partial3LongAt
tribute", "TestInterface", holder, info.GetIsolate()); |
| 52 TestPartialInterfaceImplementation3* impl = V8TestInterface::toImpl(holder); |
| 53 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState)
, exceptionState); |
| 54 TestPartialInterfaceImplementation3::setPartial3LongAttribute(*impl, cppValu
e); |
| 55 } |
| 56 |
| 57 static void partial3LongAttributeAttributeSetterCallback(v8::Local<v8::String>,
v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) |
| 58 { |
| 59 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); |
| 60 TestPartialInterfaceImplementation3PartialV8Internal::partial3LongAttributeA
ttributeSetter(v8Value, info); |
| 61 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| 62 } |
| 63 |
| 64 static void partial3StaticLongAttributeAttributeGetter(const v8::PropertyCallbac
kInfo<v8::Value>& info) |
| 65 { |
| 66 v8SetReturnValueInt(info, TestPartialInterfaceImplementation3::partial3Stati
cLongAttribute()); |
| 67 } |
| 68 |
| 69 static void partial3StaticLongAttributeAttributeGetterCallback(v8::Local<v8::Str
ing>, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 70 { |
| 71 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); |
| 72 TestPartialInterfaceImplementation3PartialV8Internal::partial3StaticLongAttr
ibuteAttributeGetter(info); |
| 73 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| 74 } |
| 75 |
| 76 static void partial3StaticLongAttributeAttributeSetter(v8::Local<v8::Value> v8Va
lue, const v8::PropertyCallbackInfo<void>& info) |
| 77 { |
| 78 ExceptionState exceptionState(ExceptionState::SetterContext, "partial3Static
LongAttribute", "TestInterface", holder, info.GetIsolate()); |
| 79 TONATIVE_VOID_EXCEPTIONSTATE(int, cppValue, toInt32(v8Value, exceptionState)
, exceptionState); |
| 80 TestPartialInterfaceImplementation3::setPartial3StaticLongAttribute(cppValue
); |
| 81 } |
| 82 |
| 83 static void partial3StaticLongAttributeAttributeSetterCallback(v8::Local<v8::Str
ing>, v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info) |
| 84 { |
| 85 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMSetter"); |
| 86 TestPartialInterfaceImplementation3PartialV8Internal::partial3StaticLongAttr
ibuteAttributeSetter(v8Value, info); |
| 87 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| 88 } |
| 89 |
| 90 static void voidMethodPartialOverload3Method(const v8::FunctionCallbackInfo<v8::
Value>& info) |
| 91 { |
| 92 TestPartialInterfaceImplementation3* impl = V8TestInterface::toImpl(info.Hol
der()); |
| 93 V8StringResource<> value; |
| 94 { |
| 95 TOSTRING_VOID_INTERNAL(value, info[0]); |
| 96 } |
| 97 TestPartialInterfaceImplementation3::voidMethodPartialOverload(*impl, value)
; |
| 98 } |
| 99 |
| 100 static void voidMethodPartialOverloadMethod(const v8::FunctionCallbackInfo<v8::V
alue>& info) |
| 101 { |
| 102 ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodP
artialOverload", "TestInterface", info.Holder(), info.GetIsolate()); |
| 103 switch (std::min(1, info.Length())) { |
| 104 case 0: |
| 105 break; |
| 106 case 1: |
| 107 if (true) { |
| 108 voidMethodPartialOverload3Method(info); |
| 109 return; |
| 110 } |
| 111 break; |
| 112 default: |
| 113 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(0, i
nfo.Length())); |
| 114 exceptionState.throwIfNeeded(); |
| 115 return; |
| 116 } |
| 117 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); |
| 118 exceptionState.throwIfNeeded(); |
| 119 } |
| 120 |
| 121 static void staticVoidMethodPartialOverload2Method(const v8::FunctionCallbackInf
o<v8::Value>& info) |
| 122 { |
| 123 V8StringResource<> value; |
| 124 { |
| 125 TOSTRING_VOID_INTERNAL(value, info[0]); |
| 126 } |
| 127 TestPartialInterfaceImplementation3::staticVoidMethodPartialOverload(value); |
| 128 } |
| 129 |
| 130 static void staticVoidMethodPartialOverloadMethod(const v8::FunctionCallbackInfo
<v8::Value>& info) |
| 131 { |
| 132 ExceptionState exceptionState(ExceptionState::ExecutionContext, "staticVoidM
ethodPartialOverload", "TestInterface", info.Holder(), info.GetIsolate()); |
| 133 switch (std::min(1, info.Length())) { |
| 134 case 0: |
| 135 break; |
| 136 case 1: |
| 137 if (true) { |
| 138 staticVoidMethodPartialOverload2Method(info); |
| 139 return; |
| 140 } |
| 141 break; |
| 142 default: |
| 143 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(0, i
nfo.Length())); |
| 144 exceptionState.throwIfNeeded(); |
| 145 return; |
| 146 } |
| 147 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); |
| 148 exceptionState.throwIfNeeded(); |
| 149 } |
| 150 |
| 151 static void partial2VoidMethod2Method(const v8::FunctionCallbackInfo<v8::Value>&
info) |
| 152 { |
| 153 TestPartialInterfaceImplementation3* impl = V8TestInterface::toImpl(info.Hol
der()); |
| 154 V8StringResource<> value; |
| 155 { |
| 156 TOSTRING_VOID_INTERNAL(value, info[0]); |
| 157 } |
| 158 TestPartialInterfaceImplementation3::partial2VoidMethod(*impl, value); |
| 159 } |
| 160 |
| 161 static void partial2VoidMethod3Method(const v8::FunctionCallbackInfo<v8::Value>&
info) |
| 162 { |
| 163 TestPartialInterfaceImplementation3* impl = V8TestInterface::toImpl(info.Hol
der()); |
| 164 Node* node; |
| 165 { |
| 166 if (info.Length() > 0 && !V8Node::hasInstance(info[0], info.GetIsolate()
)) { |
| 167 V8ThrowException::throwTypeError(ExceptionMessages::failedToExecute(
"partial2VoidMethod", "TestInterface", "parameter 1 is not of type 'Node'."), in
fo.GetIsolate()); |
| 168 return; |
| 169 } |
| 170 node = V8Node::toImplWithTypeCheck(info.GetIsolate(), info[0]); |
| 171 } |
| 172 TestPartialInterfaceImplementation3::partial2VoidMethod(*impl, node); |
| 173 } |
| 174 |
| 175 static void partial2VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>&
info) |
| 176 { |
| 177 ExceptionState exceptionState(ExceptionState::ExecutionContext, "partial2Voi
dMethod", "TestInterface", info.Holder(), info.GetIsolate()); |
| 178 switch (std::min(1, info.Length())) { |
| 179 case 0: |
| 180 break; |
| 181 case 1: |
| 182 if (V8Node::hasInstance(info[0], info.GetIsolate())) { |
| 183 partial2VoidMethod3Method(info); |
| 184 return; |
| 185 } |
| 186 if (true) { |
| 187 partial2VoidMethod2Method(info); |
| 188 return; |
| 189 } |
| 190 break; |
| 191 default: |
| 192 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(0, i
nfo.Length())); |
| 193 exceptionState.throwIfNeeded(); |
| 194 return; |
| 195 } |
| 196 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); |
| 197 exceptionState.throwIfNeeded(); |
| 198 } |
| 199 |
| 200 static void partial2StaticVoidMethod2Method(const v8::FunctionCallbackInfo<v8::V
alue>& info) |
| 201 { |
| 202 V8StringResource<> value; |
| 203 { |
| 204 TOSTRING_VOID_INTERNAL(value, info[0]); |
| 205 } |
| 206 TestPartialInterfaceImplementation3::partial2StaticVoidMethod(value); |
| 207 } |
| 208 |
| 209 static void partial2StaticVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Va
lue>& info) |
| 210 { |
| 211 ExceptionState exceptionState(ExceptionState::ExecutionContext, "partial2Sta
ticVoidMethod", "TestInterface", info.Holder(), info.GetIsolate()); |
| 212 switch (std::min(1, info.Length())) { |
| 213 case 0: |
| 214 break; |
| 215 case 1: |
| 216 if (true) { |
| 217 partial2StaticVoidMethod2Method(info); |
| 218 return; |
| 219 } |
| 220 break; |
| 221 default: |
| 222 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(0, i
nfo.Length())); |
| 223 exceptionState.throwIfNeeded(); |
| 224 return; |
| 225 } |
| 226 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); |
| 227 exceptionState.throwIfNeeded(); |
| 228 } |
| 229 |
| 230 } // namespace TestPartialInterfaceImplementation3PartialV8Internal |
| 231 |
| 232 void V8TestInterfacePartial::installV8TestInterfaceTemplate(v8::Handle<v8::Funct
ionTemplate> functionTemplate, v8::Isolate* isolate) |
| 233 { |
| 234 V8TestInterface::installV8TestInterfaceTemplate(functionTemplate, isolate); |
| 235 |
| 236 v8::Local<v8::Signature> defaultSignature; |
| 237 if (!RuntimeEnabledFeatures::featureNameEnabled()) |
| 238 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionT
emplate, "", v8::Local<v8::FunctionTemplate>(), V8TestInterface::internalFieldCo
unt, 0, 0, 0, 0, 0, 0, isolate); |
| 239 else |
| 240 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionT
emplate, "TestInterface", v8::Local<v8::FunctionTemplate>(), V8TestInterface::in
ternalFieldCount, |
| 241 0, 0, |
| 242 0, 0, |
| 243 0, 0, |
| 244 isolate); |
| 245 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceT
emplate(); |
| 246 ALLOW_UNUSED_LOCAL(instanceTemplate); |
| 247 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->Prototyp
eTemplate(); |
| 248 ALLOW_UNUSED_LOCAL(prototypeTemplate); |
| 249 static const V8DOMConfiguration::ConstantConfiguration V8TestInterfaceConsta
nts[] = { |
| 250 {"PARTIAL3_UNSIGNED_SHORT", 0, 0, 0, V8DOMConfiguration::ConstantTypeUns
ignedShort}, |
| 251 }; |
| 252 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, V8
TestInterfaceConstants, WTF_ARRAY_LENGTH(V8TestInterfaceConstants), isolate); |
| 253 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler(V8TestInterfa
ce::legacyCallCustom); |
| 254 functionTemplate->SetNativeDataProperty(v8AtomicString(isolate, "partial3Sta
ticLongAttribute"), TestPartialInterfaceImplementation3V8Internal::partial3Stati
cLongAttributeAttributeGetterCallback, TestPartialInterfaceImplementation3Partia
lV8Internal::partial3StaticLongAttributeAttributeSetterCallback, v8::External::N
ew(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::Acc
essorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); |
| 255 } |
| 256 |
| 257 void V8TestInterfacePartial::installConditionallyEnabledProperties(v8::Handle<v8
::Object> instanceObject, v8::Isolate* isolate) |
| 258 { |
| 259 V8TestInterface::installConditionallyEnabledProperties(instanceObject, isola
te); |
| 260 v8::Local<v8::Object> prototypeObject = v8::Local<v8::Object>::Cast(instance
Object->GetPrototype()); |
| 261 ExecutionContext* context = toExecutionContext(prototypeObject->CreationCont
ext()); |
| 262 |
| 263 if (context && context->isDocument() && ContextFeatures::partialContextName3
Enabled(toDocument(context))) { |
| 264 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu
ration =\ |
| 265 {"partial3LongAttribute", TestPartialInterfaceImplementation3PartialV8In
ternal::partial3LongAttributeAttributeGetterCallback, TestPartialInterfaceImplem
entation3PartialV8Internal::partial3LongAttributeAttributeSetterCallback, 0, 0,
0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribut
e>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMConfiguration::OnIns
tance}; |
| 266 V8DOMConfiguration::installAttribute(instanceObject, prototypeObject, at
tributeConfiguration, isolate); |
| 267 } |
| 268 if (context && context->isDocument() && ContextFeatures::partialContextName3
Enabled(toDocument(context))) { |
| 269 static const V8DOMConfiguration::AttributeConfiguration attributeConfigu
ration =\ |
| 270 {"partial3StaticLongAttribute", TestPartialInterfaceImplementation3Parti
alV8Internal::partial3StaticLongAttributeAttributeGetterCallback, TestPartialInt
erfaceImplementation3PartialV8Internal::partial3StaticLongAttributeAttributeSett
erCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8
::PropertyAttribute>(v8::None), V8DOMConfiguration::ExposedToAllScripts, V8DOMCo
nfiguration::OnInstance}; |
| 271 V8DOMConfiguration::installAttribute(instanceObject, prototypeObject, at
tributeConfiguration, isolate); |
| 272 } |
| 273 } |
| 274 |
| 275 void V8TestInterfacePartial::installConditionallyEnabledMethods(v8::Handle<v8::O
bject> prototypeObject, v8::Isolate* isolate) |
| 276 { |
| 277 V8TestInterface::installConditionallyEnabledMethods(prototypeObject, isolate
); |
| 278 } |
| 279 |
| 280 bool V8TestInterface::PrivateScript::shortMethodWithShortArgumentImplementedInPr
ivateScriptMethod(LocalFrame* frame, TestInterface* holderImpl, int value, int*
result) |
| 281 { |
| 282 if (!frame) |
| 283 return false; |
| 284 v8::HandleScope handleScope(toIsolate(frame)); |
| 285 ScriptForbiddenScope::AllowUserAgentScript script; |
| 286 v8::Handle<v8::Context> contextInPrivateScript = toV8Context(frame, DOMWrapp
erWorld::privateScriptIsolatedWorld()); |
| 287 if (contextInPrivateScript.IsEmpty()) |
| 288 return false; |
| 289 ScriptState* scriptState = ScriptState::from(contextInPrivateScript); |
| 290 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame); |
| 291 if (!scriptState->executionContext()) |
| 292 return false; |
| 293 |
| 294 ScriptState::Scope scope(scriptState); |
| 295 v8::Handle<v8::Value> holder = toV8(holderImpl, scriptState->context()->Glob
al(), scriptState->isolate()); |
| 296 |
| 297 v8::Handle<v8::Value> valueHandle = v8::Integer::New(scriptState->isolate(),
value); |
| 298 v8::Handle<v8::Value> argv[] = { valueHandle }; |
| 299 ExceptionState exceptionState(ExceptionState::ExecutionContext, "shortMethod
WithShortArgumentImplementedInPrivateScript", "TestPartialInterfaceImplementatio
n3", scriptState->context()->Global(), scriptState->isolate()); |
| 300 v8::Handle<v8::Value> v8Value = PrivateScriptRunner::runDOMMethod(scriptStat
e, scriptStateInUserScript, "TestPartialInterfaceImplementation3", "shortMethodW
ithShortArgumentImplementedInPrivateScript", holder, 1, argv); |
| 301 if (v8Value.IsEmpty()) |
| 302 return false; |
| 303 TONATIVE_DEFAULT_EXCEPTIONSTATE(int, cppValue, toInt16(v8Value, exceptionSta
te), exceptionState, false); |
| 304 *result = cppValue; |
| 305 RELEASE_ASSERT(!exceptionState.hadException()); |
| 306 return true; |
| 307 } |
| 308 |
| 309 void V8TestInterfacePartial::initialize() |
| 310 { |
| 311 // Should be invoked from initModules. |
| 312 V8TestInterface::updateWrapperTypeInfo( |
| 313 &V8TestInterfacePartial::installV8TestInterfaceTemplate, |
| 314 &V8TestInterfacePartial::installConditionallyEnabledMethods); |
| 315 V8TestInterface::registerVoidMethodPartialOverloadMethodForPartialInterface(
&TestPartialInterfaceImplementation3PartialV8Internal::voidMethodPartialOverload
Method); |
| 316 V8TestInterface::registerStaticVoidMethodPartialOverloadMethodForPartialInte
rface(&TestPartialInterfaceImplementation3PartialV8Internal::staticVoidMethodPar
tialOverloadMethod); |
| 317 V8TestInterface::registerPartial2VoidMethodMethodForPartialInterface(&TestPa
rtialInterfaceImplementation3PartialV8Internal::partial2VoidMethodMethod); |
| 318 V8TestInterface::registerPartial2StaticVoidMethodMethodForPartialInterface(&
TestPartialInterfaceImplementation3PartialV8Internal::partial2StaticVoidMethodMe
thod); |
| 319 } |
| 320 |
| 321 } // namespace blink |
| 322 #endif // ENABLE(CONDITION) |
OLD | NEW |