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

Side by Side Diff: include/v8.h

Issue 2753973002: Make v8::Eternal::Get and IsEmpty const. (Closed)
Patch Set: Created 3 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 /** \mainpage V8 API Reference Guide 5 /** \mainpage V8 API Reference Guide
6 * 6 *
7 * V8 is Google's open source JavaScript engine. 7 * V8 is Google's open source JavaScript engine.
8 * 8 *
9 * This set of documents provides reference material generated from the 9 * This set of documents provides reference material generated from the
10 * V8 header file, include/v8.h. 10 * V8 header file, include/v8.h.
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 359
360 // Eternal handles are set-once handles that live for the life of the isolate. 360 // Eternal handles are set-once handles that live for the life of the isolate.
361 template <class T> class Eternal { 361 template <class T> class Eternal {
362 public: 362 public:
363 V8_INLINE Eternal() : index_(kInitialValue) { } 363 V8_INLINE Eternal() : index_(kInitialValue) { }
364 template<class S> 364 template<class S>
365 V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : index_(kInitialValue) { 365 V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : index_(kInitialValue) {
366 Set(isolate, handle); 366 Set(isolate, handle);
367 } 367 }
368 // Can only be safely called if already set. 368 // Can only be safely called if already set.
369 V8_INLINE Local<T> Get(Isolate* isolate); 369 V8_INLINE Local<T> Get(Isolate* isolate) const;
370 V8_INLINE bool IsEmpty() { return index_ == kInitialValue; } 370 V8_INLINE bool IsEmpty() const { return index_ == kInitialValue; }
371 template<class S> V8_INLINE void Set(Isolate* isolate, Local<S> handle); 371 template<class S> V8_INLINE void Set(Isolate* isolate, Local<S> handle);
372 372
373 private: 373 private:
374 static const int kInitialValue = -1; 374 static const int kInitialValue = -1;
375 int index_; 375 int index_;
376 }; 376 };
377 377
378 378
379 static const int kInternalFieldsInWeakCallback = 2; 379 static const int kInternalFieldsInWeakCallback = 2;
380 380
(...skipping 8249 matching lines...) Expand 10 before | Expand all | Expand 10 after
8630 } 8630 }
8631 8631
8632 8632
8633 template<class T> 8633 template<class T>
8634 template<class S> 8634 template<class S>
8635 void Eternal<T>::Set(Isolate* isolate, Local<S> handle) { 8635 void Eternal<T>::Set(Isolate* isolate, Local<S> handle) {
8636 TYPE_CHECK(T, S); 8636 TYPE_CHECK(T, S);
8637 V8::Eternalize(isolate, reinterpret_cast<Value*>(*handle), &this->index_); 8637 V8::Eternalize(isolate, reinterpret_cast<Value*>(*handle), &this->index_);
8638 } 8638 }
8639 8639
8640 8640 template <class T>
8641 template<class T> 8641 Local<T> Eternal<T>::Get(Isolate* isolate) const {
8642 Local<T> Eternal<T>::Get(Isolate* isolate) {
8643 return Local<T>(reinterpret_cast<T*>(*V8::GetEternal(isolate, index_))); 8642 return Local<T>(reinterpret_cast<T*>(*V8::GetEternal(isolate, index_)));
8644 } 8643 }
8645 8644
8646 8645
8647 template <class T> 8646 template <class T>
8648 Local<T> MaybeLocal<T>::ToLocalChecked() { 8647 Local<T> MaybeLocal<T>::ToLocalChecked() {
8649 if (V8_UNLIKELY(val_ == nullptr)) V8::ToLocalEmpty(); 8648 if (V8_UNLIKELY(val_ == nullptr)) V8::ToLocalEmpty();
8650 return Local<T>(val_); 8649 return Local<T>(val_);
8651 } 8650 }
8652 8651
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after
9831 */ 9830 */
9832 9831
9833 9832
9834 } // namespace v8 9833 } // namespace v8
9835 9834
9836 9835
9837 #undef TYPE_CHECK 9836 #undef TYPE_CHECK
9838 9837
9839 9838
9840 #endif // INCLUDE_V8_H_ 9839 #endif // INCLUDE_V8_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698