Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: Source/bindings/tests/results/V8TestInterfaceCustomConstructor.cpp

Issue 171533006: V8 Binding: Introduce toNativeWithTypeCheck (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ)); 122 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ));
123 return handleScope.Escape(templ); 123 return handleScope.Escape(templ);
124 } 124 }
125 125
126 bool V8TestInterfaceCustomConstructor::hasInstance(v8::Handle<v8::Value> jsValue , v8::Isolate* isolate) 126 bool V8TestInterfaceCustomConstructor::hasInstance(v8::Handle<v8::Value> jsValue , v8::Isolate* isolate)
127 { 127 {
128 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI nfo, jsValue) 128 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI nfo, jsValue)
129 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy peInfo, jsValue); 129 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy peInfo, jsValue);
130 } 130 }
131 131
132 TestInterfaceCustomConstructor* V8TestInterfaceCustomConstructor::toNativeWithTy peCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
133 {
134 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Obje ct>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
135 }
136
132 v8::Handle<v8::Object> V8TestInterfaceCustomConstructor::createWrapper(PassRefPt r<TestInterfaceCustomConstructor> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 137 v8::Handle<v8::Object> V8TestInterfaceCustomConstructor::createWrapper(PassRefPt r<TestInterfaceCustomConstructor> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
133 { 138 {
134 ASSERT(impl); 139 ASSERT(impl);
135 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceCustomConstructor>(impl .get(), isolate)); 140 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceCustomConstructor>(impl .get(), isolate));
136 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { 141 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
137 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get()); 142 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get());
138 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have 143 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have
139 // the same object de-ref functions, though, so use that as the basis of the check. 144 // the same object de-ref functions, though, so use that as the basis of the check.
140 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction); 145 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
141 } 146 }
(...skipping 12 matching lines...) Expand all
154 fromInternalPointer(object)->deref(); 159 fromInternalPointer(object)->deref();
155 } 160 }
156 161
157 template<> 162 template<>
158 v8::Handle<v8::Value> toV8NoInline(TestInterfaceCustomConstructor* impl, v8::Han dle<v8::Object> creationContext, v8::Isolate* isolate) 163 v8::Handle<v8::Value> toV8NoInline(TestInterfaceCustomConstructor* impl, v8::Han dle<v8::Object> creationContext, v8::Isolate* isolate)
159 { 164 {
160 return toV8(impl, creationContext, isolate); 165 return toV8(impl, creationContext, isolate);
161 } 166 }
162 167
163 } // namespace WebCore 168 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698