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

Side by Side Diff: Source/bindings/core/v8/V8Binding.h

Issue 721383003: bindings: Retires ScriptWrappableBase mostly. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Ericsson AB. All rights reserved. 3 * Copyright (C) 2012 Ericsson AB. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 inline void v8SetReturnValueStringOrUndefined(const CallbackInfo& info, const St ring& string, v8::Isolate* isolate) 170 inline void v8SetReturnValueStringOrUndefined(const CallbackInfo& info, const St ring& string, v8::Isolate* isolate)
171 { 171 {
172 if (string.isNull()) { 172 if (string.isNull()) {
173 v8SetReturnValueUndefined(info); 173 v8SetReturnValueUndefined(info);
174 return; 174 return;
175 } 175 }
176 V8PerIsolateData::from(isolate)->stringCache()->setReturnValueFromString(inf o.GetReturnValue(), string.impl()); 176 V8PerIsolateData::from(isolate)->stringCache()->setReturnValueFromString(inf o.GetReturnValue(), string.impl());
177 } 177 }
178 178
179 template<typename CallbackInfo> 179 template<typename CallbackInfo>
180 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, ScriptWrappableBa se* impl, const WrapperTypeInfo* wrapperTypeInfo)
181 {
182 if (UNLIKELY(!impl)) {
183 v8SetReturnValueNull(callbackInfo);
184 return;
185 }
186 if (DOMDataStore::setReturnValue(callbackInfo.GetReturnValue(), impl))
187 return;
188 v8::Handle<v8::Object> wrapper = impl->wrap(callbackInfo.Holder(), callbackI nfo.GetIsolate(), wrapperTypeInfo);
189 v8SetReturnValue(callbackInfo, wrapper);
190 }
191
192 template<typename CallbackInfo>
193 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, ScriptWrappable* impl) 180 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, ScriptWrappable* impl)
194 { 181 {
195 if (UNLIKELY(!impl)) { 182 if (UNLIKELY(!impl)) {
196 v8SetReturnValueNull(callbackInfo); 183 v8SetReturnValueNull(callbackInfo);
197 return; 184 return;
198 } 185 }
199 if (DOMDataStore::setReturnValue(callbackInfo.GetReturnValue(), impl)) 186 if (DOMDataStore::setReturnValue(callbackInfo.GetReturnValue(), impl))
200 return; 187 return;
201 v8::Handle<v8::Object> wrapper = impl->wrap(callbackInfo.Holder(), callbackI nfo.GetIsolate()); 188 v8::Handle<v8::Object> wrapper = impl->wrap(callbackInfo.Holder(), callbackI nfo.GetIsolate());
202 v8SetReturnValue(callbackInfo, wrapper); 189 v8SetReturnValue(callbackInfo, wrapper);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (UNLIKELY(!impl)) { 282 if (UNLIKELY(!impl)) {
296 v8SetReturnValueNull(callbackInfo); 283 v8SetReturnValueNull(callbackInfo);
297 return; 284 return;
298 } 285 }
299 if (DOMDataStore::setReturnValueFast(callbackInfo.GetReturnValue(), impl, ca llbackInfo.Holder(), wrappable)) 286 if (DOMDataStore::setReturnValueFast(callbackInfo.GetReturnValue(), impl, ca llbackInfo.Holder(), wrappable))
300 return; 287 return;
301 v8::Handle<v8::Object> wrapper = ScriptWrappable::fromNode(impl)->wrap(callb ackInfo.Holder(), callbackInfo.GetIsolate()); 288 v8::Handle<v8::Object> wrapper = ScriptWrappable::fromNode(impl)->wrap(callb ackInfo.Holder(), callbackInfo.GetIsolate());
302 v8SetReturnValue(callbackInfo, wrapper); 289 v8SetReturnValue(callbackInfo, wrapper);
303 } 290 }
304 291
305 template<typename CallbackInfo>
306 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, ScriptWrappab le* impl, const ScriptWrappableBase*)
307 {
308 // If the third arg is not ScriptWrappable, there is no fast path.
309 v8SetReturnValue(callbackInfo, impl);
310 }
311
312 template<typename CallbackInfo, typename T, typename Wrappable> 292 template<typename CallbackInfo, typename T, typename Wrappable>
313 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtr<T> impl, const Wrappable* wrappable) 293 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtr<T> impl, const Wrappable* wrappable)
314 { 294 {
315 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); 295 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable);
316 } 296 }
317 297
318 template<typename CallbackInfo, typename T, typename Wrappable> 298 template<typename CallbackInfo, typename T, typename Wrappable>
319 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, RawPtr<T> imp l, const Wrappable* wrappable) 299 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, RawPtr<T> imp l, const Wrappable* wrappable)
320 { 300 {
321 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable); 301 v8SetReturnValueFast(callbackInfo, impl.get(), wrappable);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 { 359 {
380 ASSERT(isolate); 360 ASSERT(isolate);
381 return v8::String::NewFromUtf8(isolate, str, v8::String::kInternalizedString , length); 361 return v8::String::NewFromUtf8(isolate, str, v8::String::kInternalizedString , length);
382 } 362 }
383 363
384 inline v8::Handle<v8::Value> v8Undefined() 364 inline v8::Handle<v8::Value> v8Undefined()
385 { 365 {
386 return v8::Handle<v8::Value>(); 366 return v8::Handle<v8::Value>();
387 } 367 }
388 368
389 inline v8::Handle<v8::Value> toV8(ScriptWrappableBase* impl, v8::Handle<v8::Obje ct> creationContext, v8::Isolate* isolate, const WrapperTypeInfo* wrapperTypeInf o)
390 {
391 if (UNLIKELY(!impl))
392 return v8::Null(isolate);
393 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate);
394 if (!wrapper.IsEmpty())
395 return wrapper;
396
397 return impl->wrap(creationContext, isolate, wrapperTypeInfo);
398 }
399
400 inline v8::Handle<v8::Value> toV8(ScriptWrappable* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 369 inline v8::Handle<v8::Value> toV8(ScriptWrappable* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
401 { 370 {
402 if (UNLIKELY(!impl)) 371 if (UNLIKELY(!impl))
403 return v8::Null(isolate); 372 return v8::Null(isolate);
404 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate); 373 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate);
405 if (!wrapper.IsEmpty()) 374 if (!wrapper.IsEmpty())
406 return wrapper; 375 return wrapper;
407 376
408 return impl->wrap(creationContext, isolate); 377 return impl->wrap(creationContext, isolate);
409 } 378 }
410 379
411 inline v8::Handle<v8::Value> toV8(Node* impl, v8::Handle<v8::Object> creationCon text, v8::Isolate* isolate) 380 inline v8::Handle<v8::Value> toV8(Node* impl, v8::Handle<v8::Object> creationCon text, v8::Isolate* isolate)
412 { 381 {
413 if (UNLIKELY(!impl)) 382 if (UNLIKELY(!impl))
414 return v8::Null(isolate); 383 return v8::Null(isolate);
415 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate); 384 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate);
416 if (!wrapper.IsEmpty()) 385 if (!wrapper.IsEmpty())
417 return wrapper; 386 return wrapper;
418 387
419 return ScriptWrappable::fromNode(impl)->wrap(creationContext, isolate); 388 return ScriptWrappable::fromNode(impl)->wrap(creationContext, isolate);
420 } 389 }
421 390
422 template<typename T> 391 template<typename T>
423 inline v8::Handle<v8::Value> toV8(RefPtr<T>& impl, v8::Handle<v8::Object> creati onContext, v8::Isolate* isolate)
424 {
425 return toV8(impl.get(), creationContext, isolate);
426 }
427
428 template<typename T>
429 inline v8::Handle<v8::Value> toV8(PassRefPtr<T> impl, v8::Handle<v8::Object> cre ationContext, v8::Isolate* isolate) 392 inline v8::Handle<v8::Value> toV8(PassRefPtr<T> impl, v8::Handle<v8::Object> cre ationContext, v8::Isolate* isolate)
430 { 393 {
431 return toV8(impl.get(), creationContext, isolate); 394 return toV8(impl.get(), creationContext, isolate);
432 } 395 }
433 396
434 template<typename T> 397 template<typename T>
435 inline v8::Handle<v8::Value> toV8(RawPtr<T> impl, v8::Handle<v8::Object> creatio nContext, v8::Isolate* isolate) 398 inline v8::Handle<v8::Value> toV8(RawPtr<T> impl, v8::Handle<v8::Object> creatio nContext, v8::Isolate* isolate)
436 { 399 {
437 return toV8(impl.get(), creationContext, isolate); 400 return toV8(impl.get(), creationContext, isolate);
438 } 401 }
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 v8::Local<v8::Value> v8IteratorResult(ScriptState* scriptState, const T& value) 1221 v8::Local<v8::Value> v8IteratorResult(ScriptState* scriptState, const T& value)
1259 { 1222 {
1260 return v8IteratorResult(scriptState->isolate(), V8ValueTraits<T>::toV8Value( value, scriptState->context()->Global(), scriptState->isolate())); 1223 return v8IteratorResult(scriptState->isolate(), V8ValueTraits<T>::toV8Value( value, scriptState->context()->Global(), scriptState->isolate()));
1261 } 1224 }
1262 1225
1263 typedef void (*InstallTemplateFunction)(v8::Handle<v8::FunctionTemplate>, v8::Is olate*); 1226 typedef void (*InstallTemplateFunction)(v8::Handle<v8::FunctionTemplate>, v8::Is olate*);
1264 1227
1265 } // namespace blink 1228 } // namespace blink
1266 1229
1267 #endif // V8Binding_h 1230 #endif // V8Binding_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698