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

Side by Side Diff: src/api.h

Issue 1235002: Allow empty handles to escape handle scopes. (Closed)
Patch Set: Created 10 years, 9 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
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 240
241 template <class T> 241 template <class T>
242 static inline T* ToApi(v8::internal::Handle<v8::internal::Object> obj) { 242 static inline T* ToApi(v8::internal::Handle<v8::internal::Object> obj) {
243 return reinterpret_cast<T*>(obj.location()); 243 return reinterpret_cast<T*>(obj.location());
244 } 244 }
245 245
246 246
247 template <class T> 247 template <class T>
248 v8::internal::Handle<T> v8::internal::Handle<T>::EscapeFrom( 248 v8::internal::Handle<T> v8::internal::Handle<T>::EscapeFrom(
249 v8::HandleScope* scope) { 249 v8::HandleScope* scope) {
250 return Utils::OpenHandle(*scope->Close(Utils::ToLocal(*this))); 250 v8::internal::Handle<T> handle;
251 if (!is_null()) {
252 handle = *this;
253 }
254 return Utils::OpenHandle(*scope->Close(Utils::ToLocal(handle)));
251 } 255 }
252 256
253 257
254 // Implementations of ToLocal 258 // Implementations of ToLocal
255 259
256 #define MAKE_TO_LOCAL(Name, From, To) \ 260 #define MAKE_TO_LOCAL(Name, From, To) \
257 Local<v8::To> Utils::Name(v8::internal::Handle<v8::internal::From> obj) { \ 261 Local<v8::To> Utils::Name(v8::internal::Handle<v8::internal::From> obj) { \
258 ASSERT(!obj->IsTheHole()); \ 262 ASSERT(obj.is_null() || !obj->IsTheHole()); \
259 return Local<To>(reinterpret_cast<To*>(obj.location())); \ 263 return Local<To>(reinterpret_cast<To*>(obj.location())); \
260 } 264 }
261 265
262 MAKE_TO_LOCAL(ToLocal, Context, Context) 266 MAKE_TO_LOCAL(ToLocal, Context, Context)
263 MAKE_TO_LOCAL(ToLocal, Object, Value) 267 MAKE_TO_LOCAL(ToLocal, Object, Value)
264 MAKE_TO_LOCAL(ToLocal, JSFunction, Function) 268 MAKE_TO_LOCAL(ToLocal, JSFunction, Function)
265 MAKE_TO_LOCAL(ToLocal, String, String) 269 MAKE_TO_LOCAL(ToLocal, String, String)
266 MAKE_TO_LOCAL(ToLocal, JSObject, Object) 270 MAKE_TO_LOCAL(ToLocal, JSObject, Object)
267 MAKE_TO_LOCAL(ToLocal, JSArray, Array) 271 MAKE_TO_LOCAL(ToLocal, JSArray, Array)
268 MAKE_TO_LOCAL(ToLocal, Proxy, External) 272 MAKE_TO_LOCAL(ToLocal, Proxy, External)
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 #ifdef DEBUG 474 #ifdef DEBUG
471 v8::ImplementationUtilities::ZapHandleRange( 475 v8::ImplementationUtilities::ZapHandleRange(
472 spare_, 476 spare_,
473 &spare_[kHandleBlockSize]); 477 &spare_[kHandleBlockSize]);
474 #endif 478 #endif
475 } 479 }
476 480
477 } } // namespace v8::internal 481 } } // namespace v8::internal
478 482
479 #endif // V8_API_H_ 483 #endif // V8_API_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698