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

Side by Side Diff: Source/bindings/tests/results/V8TestInterfaceConstructor3.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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ)); 136 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ));
137 return handleScope.Escape(templ); 137 return handleScope.Escape(templ);
138 } 138 }
139 139
140 bool V8TestInterfaceConstructor3::hasInstance(v8::Handle<v8::Value> jsValue, v8: :Isolate* isolate) 140 bool V8TestInterfaceConstructor3::hasInstance(v8::Handle<v8::Value> jsValue, v8: :Isolate* isolate)
141 { 141 {
142 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI nfo, jsValue) 142 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI nfo, jsValue)
143 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy peInfo, jsValue); 143 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy peInfo, jsValue);
144 } 144 }
145 145
146 TestInterfaceConstructor3* V8TestInterfaceConstructor3::toNativeWithTypeCheck(v8 ::Isolate* isolate, v8::Handle<v8::Value> value)
147 {
148 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Obje ct>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
149 }
150
146 v8::Handle<v8::Object> V8TestInterfaceConstructor3::createWrapper(PassRefPtr<Tes tInterfaceConstructor3> impl, v8::Handle<v8::Object> creationContext, v8::Isolat e* isolate) 151 v8::Handle<v8::Object> V8TestInterfaceConstructor3::createWrapper(PassRefPtr<Tes tInterfaceConstructor3> impl, v8::Handle<v8::Object> creationContext, v8::Isolat e* isolate)
147 { 152 {
148 ASSERT(impl); 153 ASSERT(impl);
149 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor3>(impl.get( ), isolate)); 154 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor3>(impl.get( ), isolate));
150 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { 155 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
151 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get()); 156 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get());
152 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have 157 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have
153 // the same object de-ref functions, though, so use that as the basis of the check. 158 // the same object de-ref functions, though, so use that as the basis of the check.
154 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction); 159 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
155 } 160 }
(...skipping 12 matching lines...) Expand all
168 fromInternalPointer(object)->deref(); 173 fromInternalPointer(object)->deref();
169 } 174 }
170 175
171 template<> 176 template<>
172 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor3* impl, v8::Handle<v 8::Object> creationContext, v8::Isolate* isolate) 177 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor3* impl, v8::Handle<v 8::Object> creationContext, v8::Isolate* isolate)
173 { 178 {
174 return toV8(impl, creationContext, isolate); 179 return toV8(impl, creationContext, isolate);
175 } 180 }
176 181
177 } // namespace WebCore 182 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698