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

Side by Side Diff: src/smart-pointer.h

Issue 7519: Added first shot at a development shell (Closed)
Patch Set: Factored js code out of d8.cc. Created 12 years, 2 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
« src/d8.js ('K') | « src/natives.h ('k') | tools/js2c.py » ('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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 T* temp = p; 79 T* temp = p;
80 p = NULL; 80 p = NULL;
81 return temp; 81 return temp;
82 } 82 }
83 83
84 84
85 // Assignment requires an empty (NULL) SmartPointer as the receiver. Like 85 // Assignment requires an empty (NULL) SmartPointer as the receiver. Like
86 // the copy constructor it removes the pointer in the original to avoid 86 // the copy constructor it removes the pointer in the original to avoid
87 // double freeing. 87 // double freeing.
88 inline SmartPointer& operator=(const SmartPointer<T>& rhs) { 88 inline SmartPointer& operator=(const SmartPointer<T>& rhs) {
89 ASSERT(p == NULL); 89 ASSERT(is_empty());
90 T* tmp = rhs.p; // swap to handle self-assignment 90 T* tmp = rhs.p; // swap to handle self-assignment
91 const_cast<SmartPointer<T>&>(rhs).p = NULL; 91 const_cast<SmartPointer<T>&>(rhs).p = NULL;
92 p = tmp; 92 p = tmp;
93 return *this; 93 return *this;
94 } 94 }
95 95
96 96
97 inline bool is_empty() {
98 return p == NULL;
99 }
100
101
97 private: 102 private:
98 T* p; 103 T* p;
99 }; 104 };
100 105
101 } } // namespace v8::internal 106 } } // namespace v8::internal
102 107
103 #endif // V8_SMART_POINTER_H_ 108 #endif // V8_SMART_POINTER_H_
OLDNEW
« src/d8.js ('K') | « src/natives.h ('k') | tools/js2c.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698