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 TestInterfaceImplementationPartialV8Internal { |
| 33 |
| 34 static void voidMethodPartialOverload3Method(const v8::FunctionCallbackInfo<v8::
Value>& info) |
| 35 { |
| 36 TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); |
| 37 V8StringResource<> value; |
| 38 { |
| 39 TOSTRING_VOID_INTERNAL(value, info[0]); |
| 40 } |
| 41 TestPartialInterfaceImplementation3::voidMethodPartialOverload(*impl, value)
; |
| 42 } |
| 43 |
| 44 static void voidMethodPartialOverloadMethod(const v8::FunctionCallbackInfo<v8::V
alue>& info) |
| 45 { |
| 46 ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodP
artialOverload", "TestInterface", info.Holder(), info.GetIsolate()); |
| 47 switch (std::min(1, info.Length())) { |
| 48 case 0: |
| 49 break; |
| 50 case 1: |
| 51 if (true) { |
| 52 voidMethodPartialOverload3Method(info); |
| 53 return; |
| 54 } |
| 55 break; |
| 56 default: |
| 57 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(0, i
nfo.Length())); |
| 58 exceptionState.throwIfNeeded(); |
| 59 return; |
| 60 } |
| 61 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); |
| 62 exceptionState.throwIfNeeded(); |
| 63 } |
| 64 |
| 65 static void staticVoidMethodPartialOverload2Method(const v8::FunctionCallbackInf
o<v8::Value>& info) |
| 66 { |
| 67 V8StringResource<> value; |
| 68 { |
| 69 TOSTRING_VOID_INTERNAL(value, info[0]); |
| 70 } |
| 71 TestPartialInterfaceImplementation3::staticVoidMethodPartialOverload(value); |
| 72 } |
| 73 |
| 74 static void staticVoidMethodPartialOverloadMethod(const v8::FunctionCallbackInfo
<v8::Value>& info) |
| 75 { |
| 76 ExceptionState exceptionState(ExceptionState::ExecutionContext, "staticVoidM
ethodPartialOverload", "TestInterface", info.Holder(), info.GetIsolate()); |
| 77 switch (std::min(1, info.Length())) { |
| 78 case 0: |
| 79 break; |
| 80 case 1: |
| 81 if (true) { |
| 82 staticVoidMethodPartialOverload2Method(info); |
| 83 return; |
| 84 } |
| 85 break; |
| 86 default: |
| 87 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(0, i
nfo.Length())); |
| 88 exceptionState.throwIfNeeded(); |
| 89 return; |
| 90 } |
| 91 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); |
| 92 exceptionState.throwIfNeeded(); |
| 93 } |
| 94 |
| 95 static void partial2VoidMethod2Method(const v8::FunctionCallbackInfo<v8::Value>&
info) |
| 96 { |
| 97 TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); |
| 98 V8StringResource<> value; |
| 99 { |
| 100 TOSTRING_VOID_INTERNAL(value, info[0]); |
| 101 } |
| 102 TestPartialInterfaceImplementation3::partial2VoidMethod(*impl, value); |
| 103 } |
| 104 |
| 105 static void partial2VoidMethod3Method(const v8::FunctionCallbackInfo<v8::Value>&
info) |
| 106 { |
| 107 TestInterfaceImplementation* impl = V8TestInterface::toImpl(info.Holder()); |
| 108 Node* node; |
| 109 { |
| 110 if (info.Length() > 0 && !V8Node::hasInstance(info[0], info.GetIsolate()
)) { |
| 111 V8ThrowException::throwTypeError(ExceptionMessages::failedToExecute(
"partial2VoidMethod", "TestInterface", "parameter 1 is not of type 'Node'."), in
fo.GetIsolate()); |
| 112 return; |
| 113 } |
| 114 node = V8Node::toImpl(v8::Handle<v8::Object>::Cast(info[0])); |
| 115 } |
| 116 TestPartialInterfaceImplementation3::partial2VoidMethod(*impl, node); |
| 117 } |
| 118 |
| 119 static void partial2VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>&
info) |
| 120 { |
| 121 ExceptionState exceptionState(ExceptionState::ExecutionContext, "partial2Voi
dMethod", "TestInterface", info.Holder(), info.GetIsolate()); |
| 122 switch (std::min(1, info.Length())) { |
| 123 case 0: |
| 124 break; |
| 125 case 1: |
| 126 if (V8Node::hasInstance(info[0], info.GetIsolate())) { |
| 127 partial2VoidMethod3Method(info); |
| 128 return; |
| 129 } |
| 130 if (true) { |
| 131 partial2VoidMethod2Method(info); |
| 132 return; |
| 133 } |
| 134 break; |
| 135 default: |
| 136 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(0, i
nfo.Length())); |
| 137 exceptionState.throwIfNeeded(); |
| 138 return; |
| 139 } |
| 140 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); |
| 141 exceptionState.throwIfNeeded(); |
| 142 } |
| 143 |
| 144 static void partial2StaticVoidMethod2Method(const v8::FunctionCallbackInfo<v8::V
alue>& info) |
| 145 { |
| 146 V8StringResource<> value; |
| 147 { |
| 148 TOSTRING_VOID_INTERNAL(value, info[0]); |
| 149 } |
| 150 TestPartialInterfaceImplementation3::partial2StaticVoidMethod(value); |
| 151 } |
| 152 |
| 153 static void partial2StaticVoidMethodMethod(const v8::FunctionCallbackInfo<v8::Va
lue>& info) |
| 154 { |
| 155 ExceptionState exceptionState(ExceptionState::ExecutionContext, "partial2Sta
ticVoidMethod", "TestInterface", info.Holder(), info.GetIsolate()); |
| 156 switch (std::min(1, info.Length())) { |
| 157 case 0: |
| 158 break; |
| 159 case 1: |
| 160 if (true) { |
| 161 partial2StaticVoidMethod2Method(info); |
| 162 return; |
| 163 } |
| 164 break; |
| 165 default: |
| 166 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(0, i
nfo.Length())); |
| 167 exceptionState.throwIfNeeded(); |
| 168 return; |
| 169 } |
| 170 exceptionState.throwTypeError("No function was found that matched the signat
ure provided."); |
| 171 exceptionState.throwIfNeeded(); |
| 172 } |
| 173 |
| 174 } // namespace TestInterfaceImplementationPartialV8Internal |
| 175 |
| 176 void V8TestInterfacePartial::installV8TestInterfaceTemplate(v8::Handle<v8::Funct
ionTemplate> functionTemplate, v8::Isolate* isolate) |
| 177 { |
| 178 V8TestInterface::installV8TestInterfaceTemplate(functionTemplate, isolate); |
| 179 |
| 180 v8::Local<v8::Signature> defaultSignature; |
| 181 if (!RuntimeEnabledFeatures::featureNameEnabled()) |
| 182 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionT
emplate, "", v8::Local<v8::FunctionTemplate>(), V8TestInterface::internalFieldCo
unt, 0, 0, 0, 0, 0, 0, isolate); |
| 183 else |
| 184 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionT
emplate, "TestInterface", v8::Local<v8::FunctionTemplate>(), V8TestInterface::in
ternalFieldCount, |
| 185 0, 0, |
| 186 0, 0, |
| 187 0, 0, |
| 188 isolate); |
| 189 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceT
emplate(); |
| 190 ALLOW_UNUSED_LOCAL(instanceTemplate); |
| 191 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->Prototyp
eTemplate(); |
| 192 ALLOW_UNUSED_LOCAL(prototypeTemplate); |
| 193 static const V8DOMConfiguration::ConstantConfiguration V8TestInterfaceConsta
nts[] = { |
| 194 {"PARTIAL3_UNSIGNED_SHORT", 0, 0, 0, V8DOMConfiguration::ConstantTypeUns
ignedShort}, |
| 195 }; |
| 196 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, V8
TestInterfaceConstants, WTF_ARRAY_LENGTH(V8TestInterfaceConstants), isolate); |
| 197 functionTemplate->InstanceTemplate()->SetCallAsFunctionHandler(V8TestInterfa
ce::legacyCallCustom); |
| 198 } |
| 199 |
| 200 void V8TestInterfacePartial::installConditionallyEnabledMethods(v8::Handle<v8::O
bject> prototypeObject, v8::Isolate* isolate) |
| 201 { |
| 202 V8TestInterface::installConditionallyEnabledMethods(prototypeObject, isolate
); |
| 203 } |
| 204 |
| 205 bool V8TestInterface::PrivateScript::shortMethodWithShortArgumentImplementedInPr
ivateScriptMethod(LocalFrame* frame, TestInterface* holderImpl, int value, int*
result) |
| 206 { |
| 207 if (!frame) |
| 208 return false; |
| 209 v8::HandleScope handleScope(toIsolate(frame)); |
| 210 ScriptForbiddenScope::AllowUserAgentScript script; |
| 211 v8::Handle<v8::Context> contextInPrivateScript = toV8Context(frame, DOMWrapp
erWorld::privateScriptIsolatedWorld()); |
| 212 if (contextInPrivateScript.IsEmpty()) |
| 213 return false; |
| 214 ScriptState* scriptState = ScriptState::from(contextInPrivateScript); |
| 215 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame); |
| 216 if (!scriptState->executionContext()) |
| 217 return false; |
| 218 |
| 219 ScriptState::Scope scope(scriptState); |
| 220 v8::Handle<v8::Value> holder = toV8(holderImpl, scriptState->context()->Glob
al(), scriptState->isolate()); |
| 221 |
| 222 v8::Handle<v8::Value> valueHandle = v8::Integer::New(scriptState->isolate(),
value); |
| 223 v8::Handle<v8::Value> argv[] = { valueHandle }; |
| 224 ExceptionState exceptionState(ExceptionState::ExecutionContext, "shortMethod
WithShortArgumentImplementedInPrivateScript", "TestInterfaceImplementation", scr
iptState->context()->Global(), scriptState->isolate()); |
| 225 v8::Handle<v8::Value> v8Value = PrivateScriptRunner::runDOMMethod(scriptStat
e, scriptStateInUserScript, "TestInterfaceImplementation", "shortMethodWithShort
ArgumentImplementedInPrivateScript", holder, 1, argv); |
| 226 if (v8Value.IsEmpty()) |
| 227 return false; |
| 228 TONATIVE_DEFAULT_EXCEPTIONSTATE(int, cppValue, toInt16(v8Value, exceptionSta
te), exceptionState, false); |
| 229 *result = cppValue; |
| 230 RELEASE_ASSERT(!exceptionState.hadException()); |
| 231 return true; |
| 232 } |
| 233 |
| 234 void V8TestInterfacePartial::initialize() |
| 235 { |
| 236 // Should be invoked from initModules. |
| 237 V8TestInterface::updateWrapperTypeInfo( |
| 238 &V8TestInterfacePartial::installV8TestInterfaceTemplate, |
| 239 &V8TestInterfacePartial::installConditionallyEnabledMethods); |
| 240 V8TestInterface::registerVoidMethodPartialOverloadMethodForPartialInterface(
&TestInterfaceImplementationPartialV8Internal::voidMethodPartialOverloadMethod); |
| 241 V8TestInterface::registerStaticVoidMethodPartialOverloadMethodForPartialInte
rface(&TestInterfaceImplementationPartialV8Internal::staticVoidMethodPartialOver
loadMethod); |
| 242 V8TestInterface::registerPartial2VoidMethodMethodForPartialInterface(&TestIn
terfaceImplementationPartialV8Internal::partial2VoidMethodMethod); |
| 243 V8TestInterface::registerPartial2StaticVoidMethodMethodForPartialInterface(&
TestInterfaceImplementationPartialV8Internal::partial2StaticVoidMethodMethod); |
| 244 } |
| 245 |
| 246 } // namespace blink |
| 247 #endif // ENABLE(CONDITION) |
OLD | NEW |