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

Side by Side Diff: include/v8-util.h

Issue 321123002: Make presubmit script happy again. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 6 years, 6 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 | « no previous file | samples/process.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_UTIL_H_ 5 #ifndef V8_UTIL_H_
6 #define V8_UTIL_H_ 6 #define V8_UTIL_H_
7 7
8 #include "v8.h" 8 #include "v8.h"
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 bool Contains(const K& key) { 147 bool Contains(const K& key) {
148 return Traits::Get(&impl_, key) != kPersistentContainerNotFound; 148 return Traits::Get(&impl_, key) != kPersistentContainerNotFound;
149 } 149 }
150 150
151 /** 151 /**
152 * Get value stored in map and set it in returnValue. 152 * Get value stored in map and set it in returnValue.
153 * Return true if a value was found. 153 * Return true if a value was found.
154 */ 154 */
155 bool SetReturnValue(const K& key, 155 bool SetReturnValue(const K& key,
156 ReturnValue<Value> returnValue) { 156 ReturnValue<Value> returnValue) {
157 return SetReturnValueFromVal(returnValue, Traits::Get(&impl_, key)); 157 return SetReturnValueFromVal(&returnValue, Traits::Get(&impl_, key));
158 } 158 }
159 159
160 /** 160 /**
161 * Call Isolate::SetReference with the given parent and the map value. 161 * Call Isolate::SetReference with the given parent and the map value.
162 */ 162 */
163 void SetReference(const K& key, 163 void SetReference(const K& key,
164 const Persistent<Object>& parent) { 164 const Persistent<Object>& parent) {
165 GetIsolate()->SetReference( 165 GetIsolate()->SetReference(
166 reinterpret_cast<internal::Object**>(parent.val_), 166 reinterpret_cast<internal::Object**>(parent.val_),
167 reinterpret_cast<internal::Object**>(FromVal(Traits::Get(&impl_, key)))); 167 reinterpret_cast<internal::Object**>(FromVal(Traits::Get(&impl_, key))));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 : value_(other.value_) { } 220 : value_(other.value_) { }
221 221
222 Local<V> NewLocal(Isolate* isolate) const { 222 Local<V> NewLocal(Isolate* isolate) const {
223 return Local<V>::New(isolate, FromVal(value_)); 223 return Local<V>::New(isolate, FromVal(value_));
224 } 224 }
225 bool IsEmpty() const { 225 bool IsEmpty() const {
226 return value_ == kPersistentContainerNotFound; 226 return value_ == kPersistentContainerNotFound;
227 } 227 }
228 template<typename T> 228 template<typename T>
229 bool SetReturnValue(ReturnValue<T> returnValue) { 229 bool SetReturnValue(ReturnValue<T> returnValue) {
230 return SetReturnValueFromVal(returnValue, value_); 230 return SetReturnValueFromVal(&returnValue, value_);
231 } 231 }
232 void Reset() { 232 void Reset() {
233 value_ = kPersistentContainerNotFound; 233 value_ = kPersistentContainerNotFound;
234 } 234 }
235 void operator=(const PersistentValueReference& other) { 235 void operator=(const PersistentValueReference& other) {
236 value_ = other.value_; 236 value_ = other.value_;
237 } 237 }
238 238
239 private: 239 private:
240 friend class PersistentValueMap; 240 friend class PersistentValueMap;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 persistentValueMap->Remove(key).Pass(), key); 302 persistentValueMap->Remove(key).Pass(), key);
303 Traits::DisposeCallbackData(data.GetParameter()); 303 Traits::DisposeCallbackData(data.GetParameter());
304 } 304 }
305 } 305 }
306 306
307 static V* FromVal(PersistentContainerValue v) { 307 static V* FromVal(PersistentContainerValue v) {
308 return reinterpret_cast<V*>(v); 308 return reinterpret_cast<V*>(v);
309 } 309 }
310 310
311 static bool SetReturnValueFromVal( 311 static bool SetReturnValueFromVal(
312 ReturnValue<Value>& returnValue, PersistentContainerValue value) { 312 ReturnValue<Value>* returnValue, PersistentContainerValue value) {
313 bool hasValue = value != kPersistentContainerNotFound; 313 bool hasValue = value != kPersistentContainerNotFound;
314 if (hasValue) { 314 if (hasValue) {
315 returnValue.SetInternal( 315 returnValue->SetInternal(
316 *reinterpret_cast<internal::Object**>(FromVal(value))); 316 *reinterpret_cast<internal::Object**>(FromVal(value)));
317 } 317 }
318 return hasValue; 318 return hasValue;
319 } 319 }
320 320
321 static PersistentContainerValue ClearAndLeak( 321 static PersistentContainerValue ClearAndLeak(
322 UniquePersistent<V>* persistent) { 322 UniquePersistent<V>* persistent) {
323 V* v = persistent->val_; 323 V* v = persistent->val_;
324 persistent->val_ = 0; 324 persistent->val_ = 0;
325 return reinterpret_cast<PersistentContainerValue>(v); 325 return reinterpret_cast<PersistentContainerValue>(v);
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 return reinterpret_cast<V*>(v); 478 return reinterpret_cast<V*>(v);
479 } 479 }
480 480
481 Isolate* isolate_; 481 Isolate* isolate_;
482 typename Traits::Impl impl_; 482 typename Traits::Impl impl_;
483 }; 483 };
484 484
485 } // namespace v8 485 } // namespace v8
486 486
487 #endif // V8_UTIL_H_ 487 #endif // V8_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | samples/process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698