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

Side by Side Diff: mojo/public/cpp/bindings/struct_ptr.h

Issue 613053002: Mojo: NULL -> nullptr in mojo/public/cpp/bindings and also for the bindings generator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium 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 MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_
7 7
8 #include <new> 8 #include <new>
9 9
10 #include "mojo/public/cpp/environment/logging.h" 10 #include "mojo/public/cpp/environment/logging.h"
(...skipping 10 matching lines...) Expand all
21 }; 21 };
22 22
23 } // namespace internal 23 } // namespace internal
24 24
25 template <typename Struct> 25 template <typename Struct>
26 class StructPtr { 26 class StructPtr {
27 MOJO_MOVE_ONLY_TYPE_FOR_CPP_03(StructPtr, RValue); 27 MOJO_MOVE_ONLY_TYPE_FOR_CPP_03(StructPtr, RValue);
28 public: 28 public:
29 typedef typename Struct::Data_ Data_; 29 typedef typename Struct::Data_ Data_;
30 30
31 StructPtr() : ptr_(NULL) {} 31 StructPtr() : ptr_(nullptr) {}
32 ~StructPtr() { 32 ~StructPtr() {
33 delete ptr_; 33 delete ptr_;
34 } 34 }
35 35
36 StructPtr(RValue other) : ptr_(NULL) { Take(other.object); } 36 StructPtr(RValue other) : ptr_(nullptr) { Take(other.object); }
37 StructPtr& operator=(RValue other) { 37 StructPtr& operator=(RValue other) {
38 Take(other.object); 38 Take(other.object);
39 return *this; 39 return *this;
40 } 40 }
41 41
42 template <typename U> 42 template <typename U>
43 U To() const { 43 U To() const {
44 return TypeConverter<U, StructPtr>::Convert(*this); 44 return TypeConverter<U, StructPtr>::Convert(*this);
45 } 45 }
46 46
47 void reset() { 47 void reset() {
48 if (ptr_) { 48 if (ptr_) {
49 delete ptr_; 49 delete ptr_;
50 ptr_ = NULL; 50 ptr_ = nullptr;
51 } 51 }
52 } 52 }
53 53
54 bool is_null() const { return ptr_ == NULL; } 54 bool is_null() const { return ptr_ == nullptr; }
55 55
56 Struct& operator*() const { 56 Struct& operator*() const {
57 MOJO_DCHECK(ptr_); 57 MOJO_DCHECK(ptr_);
58 return *ptr_; 58 return *ptr_;
59 } 59 }
60 Struct* operator->() const { 60 Struct* operator->() const {
61 MOJO_DCHECK(ptr_); 61 MOJO_DCHECK(ptr_);
62 return ptr_; 62 return ptr_;
63 } 63 }
64 Struct* get() const { return ptr_; } 64 Struct* get() const { return ptr_; }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 Swap(other); 147 Swap(other);
148 } 148 }
149 149
150 mutable Struct value_; 150 mutable Struct value_;
151 bool is_null_; 151 bool is_null_;
152 }; 152 };
153 153
154 } // namespace mojo 154 } // namespace mojo
155 155
156 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_ 156 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRUCT_PTR_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/no_interface.h ('k') | mojo/public/cpp/bindings/tests/buffer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698