| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 WebCore::initializeScriptWrappableForInterface(object); | 65 WebCore::initializeScriptWrappableForInterface(object); |
| 66 } | 66 } |
| 67 | 67 |
| 68 namespace WebCore { | 68 namespace WebCore { |
| 69 const WrapperTypeInfo V8TestInterfaceConstructor::wrapperTypeInfo = { gin::kEmbe
dderBlink, V8TestInterfaceConstructor::domTemplate, V8TestInterfaceConstructor::
derefObject, 0, 0, 0, V8TestInterfaceConstructor::installPerContextEnabledMethod
s, 0, WrapperTypeObjectPrototype }; | 69 const WrapperTypeInfo V8TestInterfaceConstructor::wrapperTypeInfo = { gin::kEmbe
dderBlink, V8TestInterfaceConstructor::domTemplate, V8TestInterfaceConstructor::
derefObject, 0, 0, 0, V8TestInterfaceConstructor::installPerContextEnabledMethod
s, 0, WrapperTypeObjectPrototype }; |
| 70 | 70 |
| 71 namespace TestInterfaceConstructorV8Internal { | 71 namespace TestInterfaceConstructorV8Internal { |
| 72 | 72 |
| 73 template <typename T> void V8_USE(T) { } | 73 template <typename T> void V8_USE(T) { } |
| 74 | 74 |
| 75 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) | 75 static void constructor1(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 76 { | 76 { |
| 77 if (UNLIKELY(info.Length() < 5)) { | 77 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInte
rfaceConstructor", info.Holder(), info.GetIsolate()); |
| 78 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TestIn
terfaceConstructor", ExceptionMessages::notEnoughArguments(5, info.Length())), i
nfo.GetIsolate()); | 78 ExecutionContext* context = getExecutionContext(); |
| 79 Document& document = *toDocument(getExecutionContext()); |
| 80 RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::create(con
text, document, exceptionState); |
| 81 v8::Handle<v8::Object> wrapper = info.Holder(); |
| 82 if (exceptionState.throwIfNeeded()) |
| 79 return; | 83 return; |
| 80 } | 84 |
| 85 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor>(impl.re
lease(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(
), WrapperConfiguration::Dependent); |
| 86 v8SetReturnValue(info, wrapper); |
| 87 } |
| 88 |
| 89 static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 90 { |
| 81 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInte
rfaceConstructor", info.Holder(), info.GetIsolate()); | 91 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInte
rfaceConstructor", info.Holder(), info.GetIsolate()); |
| 82 V8TRYCATCH_VOID(double, doubleArg, static_cast<double>(info[0]->NumberValue(
))); | 92 V8TRYCATCH_VOID(double, doubleArg, static_cast<double>(info[0]->NumberValue(
))); |
| 83 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, stringArg, info[1])
; | 93 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, stringArg, info[1])
; |
| 84 V8TRYCATCH_VOID(TestInterfaceEmpty*, testInterfaceEmptyArg, V8TestInterfaceE
mpty::hasInstance(info[2], info.GetIsolate(), worldType(info.GetIsolate())) ? V8
TestInterfaceEmpty::toNative(v8::Handle<v8::Object>::Cast(info[2])) : 0); | 94 V8TRYCATCH_VOID(TestInterfaceEmpty*, testInterfaceEmptyArg, V8TestInterfaceE
mpty::hasInstance(info[2], info.GetIsolate(), worldType(info.GetIsolate())) ? V8
TestInterfaceEmpty::toNative(v8::Handle<v8::Object>::Cast(info[2])) : 0); |
| 85 V8TRYCATCH_VOID(Dictionary, dictionaryArg, Dictionary(info[3], info.GetIsola
te())); | 95 V8TRYCATCH_VOID(Dictionary, dictionaryArg, Dictionary(info[3], info.GetIsola
te())); |
| 86 if (!dictionaryArg.isUndefinedOrNull() && !dictionaryArg.isObject()) { | 96 if (!dictionaryArg.isUndefinedOrNull() && !dictionaryArg.isObject()) { |
| 87 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstr
uctor", "parameter 4 ('dictionaryArg') is not an object."), info.GetIsolate()); | 97 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstr
uctor", "parameter 4 ('dictionaryArg') is not an object."), info.GetIsolate()); |
| 88 return; | 98 return; |
| 89 } | 99 } |
| 90 V8TRYCATCH_VOID(Vector<String>, sequenceStringArg, toNativeArray<String>(inf
o[4], 5, info.GetIsolate())); | 100 V8TRYCATCH_VOID(Vector<String>, sequenceStringArg, toNativeArray<String>(inf
o[4], 5, info.GetIsolate())); |
| 91 V8TRYCATCH_VOID(Dictionary, optionalDictionaryArg, Dictionary(info[5], info.
GetIsolate())); | 101 V8TRYCATCH_VOID(Dictionary, optionalDictionaryArg, Dictionary(info[5], info.
GetIsolate())); |
| 92 if (!optionalDictionaryArg.isUndefinedOrNull() && !optionalDictionaryArg.isO
bject()) { | 102 if (!optionalDictionaryArg.isUndefinedOrNull() && !optionalDictionaryArg.isO
bject()) { |
| 93 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstr
uctor", "parameter 6 ('optionalDictionaryArg') is not an object."), info.GetIsol
ate()); | 103 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstr
uctor", "parameter 6 ('optionalDictionaryArg') is not an object."), info.GetIsol
ate()); |
| 94 return; | 104 return; |
| 95 } | 105 } |
| 96 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, defaultUndefinedOpt
ionalStringArg, info[6]); | 106 V8TRYCATCH_VOID(TestInterfaceEmpty*, optionalTestInterfaceEmptyArg, V8TestIn
terfaceEmpty::hasInstance(info[6], info.GetIsolate(), worldType(info.GetIsolate(
))) ? V8TestInterfaceEmpty::toNative(v8::Handle<v8::Object>::Cast(info[6])) : 0)
; |
| 97 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, defaultNullStringOp
tionalStringArg, argumentOrNull(info, 7)); | |
| 98 V8TRYCATCH_VOID(TestInterfaceEmpty*, optionalTestInterfaceEmptyArg, V8TestIn
terfaceEmpty::hasInstance(info[8], info.GetIsolate(), worldType(info.GetIsolate(
))) ? V8TestInterfaceEmpty::toNative(v8::Handle<v8::Object>::Cast(info[8])) : 0)
; | |
| 99 V8TRYCATCH_VOID(Dictionary, defaultUndefinedOptionalDictionaryArg, Dictionar
y(info[9], info.GetIsolate())); | |
| 100 if (!defaultUndefinedOptionalDictionaryArg.isUndefinedOrNull() && !defaultUn
definedOptionalDictionaryArg.isObject()) { | |
| 101 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstr
uctor", "parameter 10 ('defaultUndefinedOptionalDictionaryArg') is not an object
."), info.GetIsolate()); | |
| 102 return; | |
| 103 } | |
| 104 ExecutionContext* context = getExecutionContext(); | 107 ExecutionContext* context = getExecutionContext(); |
| 105 Document& document = *toDocument(getExecutionContext()); | 108 Document& document = *toDocument(getExecutionContext()); |
| 106 RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::create(con
text, document, doubleArg, stringArg, testInterfaceEmptyArg, dictionaryArg, sequ
enceStringArg, optionalDictionaryArg, defaultUndefinedOptionalStringArg, default
NullStringOptionalStringArg, optionalTestInterfaceEmptyArg, defaultUndefinedOpti
onalDictionaryArg, exceptionState); | 109 RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::create(con
text, document, doubleArg, stringArg, testInterfaceEmptyArg, dictionaryArg, sequ
enceStringArg, optionalDictionaryArg, optionalTestInterfaceEmptyArg, exceptionSt
ate); |
| 107 v8::Handle<v8::Object> wrapper = info.Holder(); | 110 v8::Handle<v8::Object> wrapper = info.Holder(); |
| 108 if (exceptionState.throwIfNeeded()) | 111 if (exceptionState.throwIfNeeded()) |
| 109 return; | 112 return; |
| 110 | 113 |
| 111 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor>(impl.re
lease(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(
), WrapperConfiguration::Dependent); | 114 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor>(impl.re
lease(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(
), WrapperConfiguration::Dependent); |
| 112 v8SetReturnValue(info, wrapper); | 115 v8SetReturnValue(info, wrapper); |
| 113 } | 116 } |
| 114 | 117 |
| 118 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 119 { |
| 120 if (((info.Length() == 0))) { |
| 121 TestInterfaceConstructorV8Internal::constructor1(info); |
| 122 return; |
| 123 } |
| 124 if (((info.Length() == 5) && (V8TestInterfaceEmpty::hasInstance(info[2], inf
o.GetIsolate(), worldType(info.GetIsolate()))) && (info[4]->IsArray())) || ((inf
o.Length() == 6) && (V8TestInterfaceEmpty::hasInstance(info[2], info.GetIsolate(
), worldType(info.GetIsolate()))) && (info[4]->IsArray())) || ((info.Length() ==
7) && (V8TestInterfaceEmpty::hasInstance(info[2], info.GetIsolate(), worldType(
info.GetIsolate()))) && (info[4]->IsArray()) && (V8TestInterfaceEmpty::hasInstan
ce(info[6], info.GetIsolate(), worldType(info.GetIsolate()))))) { |
| 125 TestInterfaceConstructorV8Internal::constructor2(info); |
| 126 return; |
| 127 } |
| 128 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstructo
r", "No matching constructor signature."), info.GetIsolate()); |
| 129 } |
| 130 |
| 115 } // namespace TestInterfaceConstructorV8Internal | 131 } // namespace TestInterfaceConstructorV8Internal |
| 116 | 132 |
| 117 void V8TestInterfaceConstructor::constructorCallback(const v8::FunctionCallbackI
nfo<v8::Value>& info) | 133 void V8TestInterfaceConstructor::constructorCallback(const v8::FunctionCallbackI
nfo<v8::Value>& info) |
| 118 { | 134 { |
| 119 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); | 135 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); |
| 120 UseCounter::count(activeDOMWindow(), UseCounter::TestFeature); | 136 UseCounter::count(activeDOMWindow(), UseCounter::TestFeature); |
| 121 if (!info.IsConstructCall()) { | 137 if (!info.IsConstructCall()) { |
| 122 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstr
uctor", "Please use the 'new' operator, this DOM object constructor cannot be ca
lled as a function."), info.GetIsolate()); | 138 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstr
uctor", "Please use the 'new' operator, this DOM object constructor cannot be ca
lled as a function."), info.GetIsolate()); |
| 123 return; | 139 return; |
| 124 } | 140 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 135 { | 151 { |
| 136 functionTemplate->ReadOnlyPrototype(); | 152 functionTemplate->ReadOnlyPrototype(); |
| 137 | 153 |
| 138 v8::Local<v8::Signature> defaultSignature; | 154 v8::Local<v8::Signature> defaultSignature; |
| 139 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterfaceConstructor", v8::Local<v8::FunctionTemplate>(), V8TestInterf
aceConstructor::internalFieldCount, | 155 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterfaceConstructor", v8::Local<v8::FunctionTemplate>(), V8TestInterf
aceConstructor::internalFieldCount, |
| 140 0, 0, | 156 0, 0, |
| 141 0, 0, | 157 0, 0, |
| 142 0, 0, | 158 0, 0, |
| 143 isolate, currentWorldType); | 159 isolate, currentWorldType); |
| 144 functionTemplate->SetCallHandler(V8TestInterfaceConstructor::constructorCall
back); | 160 functionTemplate->SetCallHandler(V8TestInterfaceConstructor::constructorCall
back); |
| 145 functionTemplate->SetLength(5); | 161 functionTemplate->SetLength(0); |
| 146 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); | 162 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); |
| 147 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); | 163 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); |
| 148 | 164 |
| 149 // Custom toString template | 165 // Custom toString template |
| 150 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin
g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate()); | 166 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin
g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate()); |
| 151 return functionTemplate; | 167 return functionTemplate; |
| 152 } | 168 } |
| 153 | 169 |
| 154 v8::Handle<v8::FunctionTemplate> V8TestInterfaceConstructor::domTemplate(v8::Iso
late* isolate, WrapperWorldType currentWorldType) | 170 v8::Handle<v8::FunctionTemplate> V8TestInterfaceConstructor::domTemplate(v8::Iso
late* isolate, WrapperWorldType currentWorldType) |
| 155 { | 171 { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 fromInternalPointer(object)->deref(); | 219 fromInternalPointer(object)->deref(); |
| 204 } | 220 } |
| 205 | 221 |
| 206 template<> | 222 template<> |
| 207 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor* impl, v8::Handle<v8
::Object> creationContext, v8::Isolate* isolate) | 223 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor* impl, v8::Handle<v8
::Object> creationContext, v8::Isolate* isolate) |
| 208 { | 224 { |
| 209 return toV8(impl, creationContext, isolate); | 225 return toV8(impl, creationContext, isolate); |
| 210 } | 226 } |
| 211 | 227 |
| 212 } // namespace WebCore | 228 } // namespace WebCore |
| OLD | NEW |