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

Side by Side Diff: Source/bindings/tests/results/V8TestInterfaceWillBeGarbageCollected.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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 static void attr1AttributeGetterCallback(v8::Local<v8::String>, const v8::Proper tyCallbackInfo<v8::Value>& info) 80 static void attr1AttributeGetterCallback(v8::Local<v8::String>, const v8::Proper tyCallbackInfo<v8::Value>& info)
81 { 81 {
82 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 82 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
83 TestInterfaceWillBeGarbageCollectedV8Internal::attr1AttributeGetter(info); 83 TestInterfaceWillBeGarbageCollectedV8Internal::attr1AttributeGetter(info);
84 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 84 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
85 } 85 }
86 86
87 static void attr1AttributeSetter(v8::Local<v8::Value> jsValue, const v8::Propert yCallbackInfo<void>& info) 87 static void attr1AttributeSetter(v8::Local<v8::Value> jsValue, const v8::Propert yCallbackInfo<void>& info)
88 { 88 {
89 TestInterfaceWillBeGarbageCollected* imp = V8TestInterfaceWillBeGarbageColle cted::toNative(info.Holder()); 89 TestInterfaceWillBeGarbageCollected* imp = V8TestInterfaceWillBeGarbageColle cted::toNative(info.Holder());
90 V8TRYCATCH_VOID(TestInterfaceWillBeGarbageCollected*, cppValue, V8TestInterf aceWillBeGarbageCollected::hasInstance(jsValue, info.GetIsolate()) ? V8TestInter faceWillBeGarbageCollected::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0) ; 90 V8TRYCATCH_VOID(TestInterfaceWillBeGarbageCollected*, cppValue, V8TestInterf aceWillBeGarbageCollected::toNativeWithTypeCheck(info.GetIsolate(), jsValue));
91 imp->setAttr1(WTF::getPtr(cppValue)); 91 imp->setAttr1(WTF::getPtr(cppValue));
92 } 92 }
93 93
94 static void attr1AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Va lue> jsValue, const v8::PropertyCallbackInfo<void>& info) 94 static void attr1AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Va lue> jsValue, const v8::PropertyCallbackInfo<void>& info)
95 { 95 {
96 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 96 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter");
97 TestInterfaceWillBeGarbageCollectedV8Internal::attr1AttributeSetter(jsValue, info); 97 TestInterfaceWillBeGarbageCollectedV8Internal::attr1AttributeSetter(jsValue, info);
98 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 98 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
99 } 99 }
100 100
101 static void funcMethod(const v8::FunctionCallbackInfo<v8::Value>& info) 101 static void funcMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
102 { 102 {
103 if (UNLIKELY(info.Length() < 1)) { 103 if (UNLIKELY(info.Length() < 1)) {
104 throwTypeError(ExceptionMessages::failedToExecute("func", "TestInterface WillBeGarbageCollected", ExceptionMessages::notEnoughArguments(1, info.Length()) ), info.GetIsolate()); 104 throwTypeError(ExceptionMessages::failedToExecute("func", "TestInterface WillBeGarbageCollected", ExceptionMessages::notEnoughArguments(1, info.Length()) ), info.GetIsolate());
105 return; 105 return;
106 } 106 }
107 TestInterfaceWillBeGarbageCollected* imp = V8TestInterfaceWillBeGarbageColle cted::toNative(info.Holder()); 107 TestInterfaceWillBeGarbageCollected* imp = V8TestInterfaceWillBeGarbageColle cted::toNative(info.Holder());
108 V8TRYCATCH_VOID(TestInterfaceWillBeGarbageCollected*, arg, V8TestInterfaceWi llBeGarbageCollected::hasInstance(info[0], info.GetIsolate()) ? V8TestInterfaceW illBeGarbageCollected::toNative(v8::Handle<v8::Object>::Cast(info[0])) : 0); 108 V8TRYCATCH_VOID(TestInterfaceWillBeGarbageCollected*, arg, V8TestInterfaceWi llBeGarbageCollected::toNativeWithTypeCheck(info.GetIsolate(), info[0]));
109 imp->func(arg); 109 imp->func(arg);
110 } 110 }
111 111
112 static void funcMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 112 static void funcMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
113 { 113 {
114 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 114 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
115 TestInterfaceWillBeGarbageCollectedV8Internal::funcMethod(info); 115 TestInterfaceWillBeGarbageCollectedV8Internal::funcMethod(info);
116 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 116 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
117 } 117 }
118 118
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ)); 189 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ));
190 return handleScope.Escape(templ); 190 return handleScope.Escape(templ);
191 } 191 }
192 192
193 bool V8TestInterfaceWillBeGarbageCollected::hasInstance(v8::Handle<v8::Value> js Value, v8::Isolate* isolate) 193 bool V8TestInterfaceWillBeGarbageCollected::hasInstance(v8::Handle<v8::Value> js Value, v8::Isolate* isolate)
194 { 194 {
195 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI nfo, jsValue) 195 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI nfo, jsValue)
196 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy peInfo, jsValue); 196 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy peInfo, jsValue);
197 } 197 }
198 198
199 TestInterfaceWillBeGarbageCollected* V8TestInterfaceWillBeGarbageCollected::toNa tiveWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
200 {
201 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Obje ct>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
202 }
203
199 EventTarget* V8TestInterfaceWillBeGarbageCollected::toEventTarget(v8::Handle<v8: :Object> object) 204 EventTarget* V8TestInterfaceWillBeGarbageCollected::toEventTarget(v8::Handle<v8: :Object> object)
200 { 205 {
201 return toNative(object); 206 return toNative(object);
202 } 207 }
203 208
204 v8::Handle<v8::Object> V8TestInterfaceWillBeGarbageCollected::createWrapper(Pass RefPtrWillBeRawPtr<TestInterfaceWillBeGarbageCollected> impl, v8::Handle<v8::Obj ect> creationContext, v8::Isolate* isolate) 209 v8::Handle<v8::Object> V8TestInterfaceWillBeGarbageCollected::createWrapper(Pass RefPtrWillBeRawPtr<TestInterfaceWillBeGarbageCollected> impl, v8::Handle<v8::Obj ect> creationContext, v8::Isolate* isolate)
205 { 210 {
206 ASSERT(impl); 211 ASSERT(impl);
207 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceWillBeGarbageCollected> (impl.get(), isolate)); 212 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceWillBeGarbageCollected> (impl.get(), isolate));
208 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { 213 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
(...skipping 19 matching lines...) Expand all
228 #endif // !ENABLE(OILPAN) 233 #endif // !ENABLE(OILPAN)
229 } 234 }
230 235
231 template<> 236 template<>
232 v8::Handle<v8::Value> toV8NoInline(TestInterfaceWillBeGarbageCollected* impl, v8 ::Handle<v8::Object> creationContext, v8::Isolate* isolate) 237 v8::Handle<v8::Value> toV8NoInline(TestInterfaceWillBeGarbageCollected* impl, v8 ::Handle<v8::Object> creationContext, v8::Isolate* isolate)
233 { 238 {
234 return toV8(impl, creationContext, isolate); 239 return toV8(impl, creationContext, isolate);
235 } 240 }
236 241
237 } // namespace WebCore 242 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/V8TestInterfaceWillBeGarbageCollected.h ('k') | Source/bindings/tests/results/V8TestNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698