| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, stringArg, info[0])
; | 76 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, stringArg, info[0])
; |
| 77 RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(s
tringArg); | 77 RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(s
tringArg); |
| 78 v8::Handle<v8::Object> wrapper = info.Holder(); | 78 v8::Handle<v8::Object> wrapper = info.Holder(); |
| 79 | 79 |
| 80 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor2>(impl.r
elease(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, info.GetIsolat
e(), WrapperConfiguration::Dependent); | 80 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor2>(impl.r
elease(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, info.GetIsolat
e(), WrapperConfiguration::Dependent); |
| 81 v8SetReturnValue(info, wrapper); | 81 v8SetReturnValue(info, wrapper); |
| 82 } | 82 } |
| 83 | 83 |
| 84 static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info) | 84 static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 85 { | 85 { |
| 86 V8TRYCATCH_VOID(TestInterfaceEmpty*, testInterfaceEmptyArg, V8TestInterfaceE
mpty::hasInstance(info[0], info.GetIsolate(), worldType(info.GetIsolate())) ? V8
TestInterfaceEmpty::toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0); | 86 V8TRYCATCH_VOID(TestInterfaceEmpty*, testInterfaceEmptyArg, V8TestInterfaceE
mpty::hasInstance(info[0], info.GetIsolate()) ? V8TestInterfaceEmpty::toNative(v
8::Handle<v8::Object>::Cast(info[0])) : 0); |
| 87 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, defaultUndefinedOpt
ionalStringArg, info[1]); | 87 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, defaultUndefinedOpt
ionalStringArg, info[1]); |
| 88 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, defaultNullStringOp
tionalStringArg, argumentOrNull(info, 2)); | 88 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, defaultNullStringOp
tionalStringArg, argumentOrNull(info, 2)); |
| 89 V8TRYCATCH_VOID(Dictionary, defaultUndefinedOptionalDictionaryArg, Dictionar
y(info[3], info.GetIsolate())); | 89 V8TRYCATCH_VOID(Dictionary, defaultUndefinedOptionalDictionaryArg, Dictionar
y(info[3], info.GetIsolate())); |
| 90 if (!defaultUndefinedOptionalDictionaryArg.isUndefinedOrNull() && !defaultUn
definedOptionalDictionaryArg.isObject()) { | 90 if (!defaultUndefinedOptionalDictionaryArg.isUndefinedOrNull() && !defaultUn
definedOptionalDictionaryArg.isObject()) { |
| 91 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstr
uctor2", "parameter 4 ('defaultUndefinedOptionalDictionaryArg') is not an object
."), info.GetIsolate()); | 91 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstr
uctor2", "parameter 4 ('defaultUndefinedOptionalDictionaryArg') is not an object
."), info.GetIsolate()); |
| 92 return; | 92 return; |
| 93 } | 93 } |
| 94 RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(t
estInterfaceEmptyArg, defaultUndefinedOptionalStringArg, defaultNullStringOption
alStringArg, defaultUndefinedOptionalDictionaryArg); | 94 RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(t
estInterfaceEmptyArg, defaultUndefinedOptionalStringArg, defaultNullStringOption
alStringArg, defaultUndefinedOptionalDictionaryArg); |
| 95 v8::Handle<v8::Object> wrapper = info.Holder(); | 95 v8::Handle<v8::Object> wrapper = info.Holder(); |
| 96 | 96 |
| 97 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor2>(impl.r
elease(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, info.GetIsolat
e(), WrapperConfiguration::Dependent); | 97 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor2>(impl.r
elease(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, info.GetIsolat
e(), WrapperConfiguration::Dependent); |
| 98 v8SetReturnValue(info, wrapper); | 98 v8SetReturnValue(info, wrapper); |
| 99 } | 99 } |
| 100 | 100 |
| 101 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) | 101 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 102 { | 102 { |
| 103 if (((info.Length() == 1))) { | 103 if (((info.Length() == 1))) { |
| 104 TestInterfaceConstructor2V8Internal::constructor1(info); | 104 TestInterfaceConstructor2V8Internal::constructor1(info); |
| 105 return; | 105 return; |
| 106 } | 106 } |
| 107 if (((info.Length() == 1) && (V8TestInterfaceEmpty::hasInstance(info[0], inf
o.GetIsolate(), worldType(info.GetIsolate())))) || ((info.Length() == 2) && (V8T
estInterfaceEmpty::hasInstance(info[0], info.GetIsolate(), worldType(info.GetIso
late())))) || ((info.Length() == 3) && (V8TestInterfaceEmpty::hasInstance(info[0
], info.GetIsolate(), worldType(info.GetIsolate())))) || ((info.Length() == 4) &
& (V8TestInterfaceEmpty::hasInstance(info[0], info.GetIsolate(), worldType(info.
GetIsolate()))) && (info[3]->IsObject()))) { | 107 if (((info.Length() == 1) && (V8TestInterfaceEmpty::hasInstance(info[0], inf
o.GetIsolate()))) || ((info.Length() == 2) && (V8TestInterfaceEmpty::hasInstance
(info[0], info.GetIsolate()))) || ((info.Length() == 3) && (V8TestInterfaceEmpty
::hasInstance(info[0], info.GetIsolate()))) || ((info.Length() == 4) && (V8TestI
nterfaceEmpty::hasInstance(info[0], info.GetIsolate())) && (info[3]->IsObject())
)) { |
| 108 TestInterfaceConstructor2V8Internal::constructor2(info); | 108 TestInterfaceConstructor2V8Internal::constructor2(info); |
| 109 return; | 109 return; |
| 110 } | 110 } |
| 111 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInte
rfaceConstructor2", info.Holder(), info.GetIsolate()); | 111 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInte
rfaceConstructor2", info.Holder(), info.GetIsolate()); |
| 112 if (UNLIKELY(info.Length() < 1)) { | 112 if (UNLIKELY(info.Length() < 1)) { |
| 113 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); | 113 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); |
| 114 exceptionState.throwIfNeeded(); | 114 exceptionState.throwIfNeeded(); |
| 115 return; | 115 return; |
| 116 } | 116 } |
| 117 exceptionState.throwTypeError("No matching constructor signature."); | 117 exceptionState.throwTypeError("No matching constructor signature."); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 return result->value.newLocal(isolate); | 163 return result->value.newLocal(isolate); |
| 164 | 164 |
| 165 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | 165 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 166 v8::EscapableHandleScope handleScope(isolate); | 166 v8::EscapableHandleScope handleScope(isolate); |
| 167 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); | 167 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V
8ObjectConstructor::isValidConstructorMode); |
| 168 configureV8TestInterfaceConstructor2Template(templ, isolate, currentWorldTyp
e); | 168 configureV8TestInterfaceConstructor2Template(templ, isolate, currentWorldTyp
e); |
| 169 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | 169 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); |
| 170 return handleScope.Escape(templ); | 170 return handleScope.Escape(templ); |
| 171 } | 171 } |
| 172 | 172 |
| 173 bool V8TestInterfaceConstructor2::hasInstance(v8::Handle<v8::Value> jsValue, v8:
:Isolate* isolate, WrapperWorldType currentWorldType) | 173 bool V8TestInterfaceConstructor2::hasInstance(v8::Handle<v8::Value> jsValue, v8:
:Isolate* isolate) |
| 174 { | 174 { |
| 175 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, currentWorldType); | 175 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI
nfo, jsValue) |
| 176 } | 176 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy
peInfo, jsValue); |
| 177 | |
| 178 bool V8TestInterfaceConstructor2::hasInstanceInAnyWorld(v8::Handle<v8::Value> js
Value, v8::Isolate* isolate) | |
| 179 { | |
| 180 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, MainWorld) | |
| 181 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, IsolatedWorld) | |
| 182 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, WorkerWorld); | |
| 183 } | 177 } |
| 184 | 178 |
| 185 v8::Handle<v8::Object> V8TestInterfaceConstructor2::createWrapper(PassRefPtr<Tes
tInterfaceConstructor2> impl, v8::Handle<v8::Object> creationContext, v8::Isolat
e* isolate) | 179 v8::Handle<v8::Object> V8TestInterfaceConstructor2::createWrapper(PassRefPtr<Tes
tInterfaceConstructor2> impl, v8::Handle<v8::Object> creationContext, v8::Isolat
e* isolate) |
| 186 { | 180 { |
| 187 ASSERT(impl); | 181 ASSERT(impl); |
| 188 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor2>(impl.get(
), isolate)); | 182 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor2>(impl.get(
), isolate)); |
| 189 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { | 183 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { |
| 190 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl.get()); | 184 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl.get()); |
| 191 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper
TypeInfo. These will both have | 185 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper
TypeInfo. These will both have |
| 192 // the same object de-ref functions, though, so use that as the basis of
the check. | 186 // the same object de-ref functions, though, so use that as the basis of
the check. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 207 fromInternalPointer(object)->deref(); | 201 fromInternalPointer(object)->deref(); |
| 208 } | 202 } |
| 209 | 203 |
| 210 template<> | 204 template<> |
| 211 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor2* impl, v8::Handle<v
8::Object> creationContext, v8::Isolate* isolate) | 205 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor2* impl, v8::Handle<v
8::Object> creationContext, v8::Isolate* isolate) |
| 212 { | 206 { |
| 213 return toV8(impl, creationContext, isolate); | 207 return toV8(impl, creationContext, isolate); |
| 214 } | 208 } |
| 215 | 209 |
| 216 } // namespace WebCore | 210 } // namespace WebCore |
| OLD | NEW |