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

Side by Side Diff: Source/bindings/tests/results/V8TestException.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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ)); 153 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ));
154 return handleScope.Escape(templ); 154 return handleScope.Escape(templ);
155 } 155 }
156 156
157 bool V8TestException::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* is olate) 157 bool V8TestException::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* is olate)
158 { 158 {
159 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI nfo, jsValue) 159 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI nfo, jsValue)
160 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy peInfo, jsValue); 160 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy peInfo, jsValue);
161 } 161 }
162 162
163 TestException* V8TestException::toNativeWithTypeCheck(v8::Isolate* isolate, v8:: Handle<v8::Value> value)
164 {
165 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Obje ct>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
166 }
167
163 v8::Handle<v8::Object> V8TestException::createWrapper(PassRefPtr<TestException> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 168 v8::Handle<v8::Object> V8TestException::createWrapper(PassRefPtr<TestException> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
164 { 169 {
165 ASSERT(impl); 170 ASSERT(impl);
166 ASSERT(!DOMDataStore::containsWrapper<V8TestException>(impl.get(), isolate)) ; 171 ASSERT(!DOMDataStore::containsWrapper<V8TestException>(impl.get(), isolate)) ;
167 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { 172 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
168 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get()); 173 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get());
169 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have 174 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have
170 // the same object de-ref functions, though, so use that as the basis of the check. 175 // the same object de-ref functions, though, so use that as the basis of the check.
171 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction); 176 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
172 } 177 }
(...skipping 12 matching lines...) Expand all
185 fromInternalPointer(object)->deref(); 190 fromInternalPointer(object)->deref();
186 } 191 }
187 192
188 template<> 193 template<>
189 v8::Handle<v8::Value> toV8NoInline(TestException* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) 194 v8::Handle<v8::Value> toV8NoInline(TestException* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate)
190 { 195 {
191 return toV8(impl, creationContext, isolate); 196 return toV8(impl, creationContext, isolate);
192 } 197 }
193 198
194 } // namespace WebCore 199 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/V8TestException.h ('k') | Source/bindings/tests/results/V8TestInterface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698