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

Side by Side Diff: mojo/public/cpp/bindings/lib/array_internal.cc

Issue 294833002: Mojo: more idiomatic C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix windows bustage 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "mojo/public/cpp/bindings/lib/array_internal.h" 5 #include "mojo/public/cpp/bindings/lib/array_internal.h"
6 6
7 namespace mojo { 7 namespace mojo {
8 namespace internal { 8 namespace internal {
9 9
10 ArrayDataTraits<bool>::BitRef::~BitRef() { 10 ArrayDataTraits<bool>::BitRef::~BitRef() {
(...skipping 17 matching lines...) Expand all
28 ArrayDataTraits<bool>::BitRef& 28 ArrayDataTraits<bool>::BitRef&
29 ArrayDataTraits<bool>::BitRef::operator=(const BitRef& value) { 29 ArrayDataTraits<bool>::BitRef::operator=(const BitRef& value) {
30 return (*this) = static_cast<bool>(value); 30 return (*this) = static_cast<bool>(value);
31 } 31 }
32 32
33 ArrayDataTraits<bool>::BitRef::operator bool() const { 33 ArrayDataTraits<bool>::BitRef::operator bool() const {
34 return (*storage_ & mask_) != 0; 34 return (*storage_ & mask_) != 0;
35 } 35 }
36 36
37 // static 37 // static
38 void ArraySerializationHelper<Handle, true>::ClearHandles(
39 const ArrayHeader* header,
40 ElementType* elements) {
41 for (uint32_t i = 0; i < header->num_elements; ++i)
42 elements[i].set_value(MOJO_HANDLE_INVALID);
43 }
44
45 // static
46 void ArraySerializationHelper<Handle, true>::CloseHandles(
47 const ArrayHeader* header,
48 ElementType* elements) {
49 for (uint32_t i = 0; i < header->num_elements; ++i) {
50 if (elements[i].is_valid())
51 CloseRaw(elements[i]);
52 }
53 }
54
55 // static
56 void ArraySerializationHelper<Handle, true>::EncodePointersAndHandles( 38 void ArraySerializationHelper<Handle, true>::EncodePointersAndHandles(
57 const ArrayHeader* header, 39 const ArrayHeader* header,
58 ElementType* elements, 40 ElementType* elements,
59 std::vector<Handle>* handles) { 41 std::vector<Handle>* handles) {
60 for (uint32_t i = 0; i < header->num_elements; ++i) 42 for (uint32_t i = 0; i < header->num_elements; ++i)
61 EncodeHandle(&elements[i], handles); 43 EncodeHandle(&elements[i], handles);
62 } 44 }
63 45
64 // static 46 // static
65 bool ArraySerializationHelper<Handle, true>::DecodePointersAndHandles( 47 bool ArraySerializationHelper<Handle, true>::DecodePointersAndHandles(
66 const ArrayHeader* header, 48 const ArrayHeader* header,
67 ElementType* elements, 49 ElementType* elements,
68 Message* message) { 50 Message* message) {
69 for (uint32_t i = 0; i < header->num_elements; ++i) { 51 for (uint32_t i = 0; i < header->num_elements; ++i) {
70 if (!DecodeHandle(&elements[i], message->mutable_handles())) 52 if (!DecodeHandle(&elements[i], message->mutable_handles()))
71 return false; 53 return false;
72 } 54 }
73 return true; 55 return true;
74 } 56 }
75 57
76 } // namespace internal 58 } // namespace internal
77 } // namespace mojo 59 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698