| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(s
tringArg); | 79 RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(s
tringArg); |
| 80 v8::Handle<v8::Object> wrapper = info.Holder(); | 80 v8::Handle<v8::Object> wrapper = info.Holder(); |
| 81 | 81 |
| 82 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor2>(impl.r
elease(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, info.GetIsolat
e(), WrapperConfiguration::Dependent); | 82 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor2>(impl.r
elease(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, info.GetIsolat
e(), WrapperConfiguration::Dependent); |
| 83 v8SetReturnValue(info, wrapper); | 83 v8SetReturnValue(info, wrapper); |
| 84 } | 84 } |
| 85 | 85 |
| 86 static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info) | 86 static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 87 { | 87 { |
| 88 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInte
rfaceConstructor2", info.Holder(), info.GetIsolate()); | 88 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInte
rfaceConstructor2", info.Holder(), info.GetIsolate()); |
| 89 V8TRYCATCH_VOID(TestInterfaceEmpty*, testInterfaceEmptyArg, V8TestInterfaceE
mpty::hasInstance(info[0], info.GetIsolate()) ? V8TestInterfaceEmpty::toNative(v
8::Handle<v8::Object>::Cast(info[0])) : 0); | 89 V8TRYCATCH_VOID(TestInterfaceEmpty*, testInterfaceEmptyArg, V8TestInterfaceE
mpty::toNativeWithTypeCheck(info.GetIsolate(), info[0])); |
| 90 V8TRYCATCH_EXCEPTION_VOID(int, longArg, toInt32(info[1], exceptionState), ex
ceptionState); | 90 V8TRYCATCH_EXCEPTION_VOID(int, longArg, toInt32(info[1], exceptionState), ex
ceptionState); |
| 91 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, defaultUndefinedOpt
ionalStringArg, info[2]); | 91 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, defaultUndefinedOpt
ionalStringArg, info[2]); |
| 92 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, defaultNullStringOp
tionalStringArg, argumentOrNull(info, 3)); | 92 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, defaultNullStringOp
tionalStringArg, argumentOrNull(info, 3)); |
| 93 V8TRYCATCH_VOID(Dictionary, defaultUndefinedOptionalDictionaryArg, Dictionar
y(info[4], info.GetIsolate())); | 93 V8TRYCATCH_VOID(Dictionary, defaultUndefinedOptionalDictionaryArg, Dictionar
y(info[4], info.GetIsolate())); |
| 94 if (!defaultUndefinedOptionalDictionaryArg.isUndefinedOrNull() && !defaultUn
definedOptionalDictionaryArg.isObject()) { | 94 if (!defaultUndefinedOptionalDictionaryArg.isUndefinedOrNull() && !defaultUn
definedOptionalDictionaryArg.isObject()) { |
| 95 exceptionState.throwTypeError("parameter 5 ('defaultUndefinedOptionalDic
tionaryArg') is not an object."); | 95 exceptionState.throwTypeError("parameter 5 ('defaultUndefinedOptionalDic
tionaryArg') is not an object."); |
| 96 exceptionState.throwIfNeeded(); | 96 exceptionState.throwIfNeeded(); |
| 97 return; | 97 return; |
| 98 } | 98 } |
| 99 RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(t
estInterfaceEmptyArg, longArg, defaultUndefinedOptionalStringArg, defaultNullStr
ingOptionalStringArg, defaultUndefinedOptionalDictionaryArg); | 99 RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(t
estInterfaceEmptyArg, longArg, defaultUndefinedOptionalStringArg, defaultNullStr
ingOptionalStringArg, defaultUndefinedOptionalDictionaryArg); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | 174 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); |
| 175 return handleScope.Escape(templ); | 175 return handleScope.Escape(templ); |
| 176 } | 176 } |
| 177 | 177 |
| 178 bool V8TestInterfaceConstructor2::hasInstance(v8::Handle<v8::Value> jsValue, v8:
:Isolate* isolate) | 178 bool V8TestInterfaceConstructor2::hasInstance(v8::Handle<v8::Value> jsValue, v8:
:Isolate* isolate) |
| 179 { | 179 { |
| 180 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI
nfo, jsValue) | 180 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI
nfo, jsValue) |
| 181 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy
peInfo, jsValue); | 181 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy
peInfo, jsValue); |
| 182 } | 182 } |
| 183 | 183 |
| 184 TestInterfaceConstructor2* V8TestInterfaceConstructor2::toNativeWithTypeCheck(v8
::Isolate* isolate, v8::Handle<v8::Value> value) |
| 185 { |
| 186 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Obje
ct>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) :
0; |
| 187 } |
| 188 |
| 184 v8::Handle<v8::Object> V8TestInterfaceConstructor2::createWrapper(PassRefPtr<Tes
tInterfaceConstructor2> impl, v8::Handle<v8::Object> creationContext, v8::Isolat
e* isolate) | 189 v8::Handle<v8::Object> V8TestInterfaceConstructor2::createWrapper(PassRefPtr<Tes
tInterfaceConstructor2> impl, v8::Handle<v8::Object> creationContext, v8::Isolat
e* isolate) |
| 185 { | 190 { |
| 186 ASSERT(impl); | 191 ASSERT(impl); |
| 187 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor2>(impl.get(
), isolate)); | 192 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor2>(impl.get(
), isolate)); |
| 188 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { | 193 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { |
| 189 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl.get()); | 194 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl.get()); |
| 190 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper
TypeInfo. These will both have | 195 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper
TypeInfo. These will both have |
| 191 // the same object de-ref functions, though, so use that as the basis of
the check. | 196 // the same object de-ref functions, though, so use that as the basis of
the check. |
| 192 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction
== wrapperTypeInfo.derefObjectFunction); | 197 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction
== wrapperTypeInfo.derefObjectFunction); |
| 193 } | 198 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 206 fromInternalPointer(object)->deref(); | 211 fromInternalPointer(object)->deref(); |
| 207 } | 212 } |
| 208 | 213 |
| 209 template<> | 214 template<> |
| 210 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor2* impl, v8::Handle<v
8::Object> creationContext, v8::Isolate* isolate) | 215 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor2* impl, v8::Handle<v
8::Object> creationContext, v8::Isolate* isolate) |
| 211 { | 216 { |
| 212 return toV8(impl, creationContext, isolate); | 217 return toV8(impl, creationContext, isolate); |
| 213 } | 218 } |
| 214 | 219 |
| 215 } // namespace WebCore | 220 } // namespace WebCore |
| OLD | NEW |