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

Side by Side Diff: src/handles.h

Issue 223573002: Return MaybeHandle from NewRaw???String. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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
« no previous file with comments | « src/factory.cc ('k') | src/json-parser.h » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 USE(a); 65 USE(a);
66 #endif 66 #endif
67 location_ = reinterpret_cast<T**>(maybe_handle.location_); 67 location_ = reinterpret_cast<T**>(maybe_handle.location_);
68 } 68 }
69 69
70 INLINE(Handle<T> ToHandleChecked()) { 70 INLINE(Handle<T> ToHandleChecked()) {
71 CHECK(location_ != NULL); 71 CHECK(location_ != NULL);
72 return Handle<T>(location_); 72 return Handle<T>(location_);
73 } 73 }
74 74
75 INLINE(bool ToHandle(Handle<T>* out)) { 75 // Convert to a Handle with a type that can be upcasted to.
76 template <class S> INLINE(bool ToHandle(Handle<S>* out)) {
76 if (location_ == NULL) { 77 if (location_ == NULL) {
77 *out = Handle<T>::null(); 78 *out = Handle<T>::null();
78 return false; 79 return false;
79 } else { 80 } else {
80 *out = Handle<T>(location_); 81 *out = Handle<T>(location_);
81 return true; 82 return true;
82 } 83 }
83 } 84 }
84 85
86 bool is_null() const { return location_ == NULL; }
87
85 protected: 88 protected:
86 T** location_; 89 T** location_;
87 90
88 // MaybeHandles of different classes are allowed to access each 91 // MaybeHandles of different classes are allowed to access each
89 // other's location_. 92 // other's location_.
90 template<class S> friend class MaybeHandle; 93 template<class S> friend class MaybeHandle;
91 }; 94 };
92 95
93 // ---------------------------------------------------------------------------- 96 // ----------------------------------------------------------------------------
94 // A Handle provides a reference to an object that survives relocation by 97 // A Handle provides a reference to an object that survives relocation by
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 382
380 void Initialize() { 383 void Initialize() {
381 next = limit = NULL; 384 next = limit = NULL;
382 level = 0; 385 level = 0;
383 } 386 }
384 }; 387 };
385 388
386 } } // namespace v8::internal 389 } } // namespace v8::internal
387 390
388 #endif // V8_HANDLES_H_ 391 #endif // V8_HANDLES_H_
OLDNEW
« no previous file with comments | « src/factory.cc ('k') | src/json-parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698