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

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

Issue 220243007: Mojo: Move mojo/public/bindings/lib to mojo/public/cpp/bindings/lib. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 | « mojo/public/bindings/lib/array_internal.h ('k') | mojo/public/bindings/lib/bindings_internal.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "mojo/public/bindings/lib/array_internal.h"
6
7 namespace mojo {
8 namespace internal {
9
10 ArrayDataTraits<bool>::BitRef::~BitRef() {
11 }
12
13 ArrayDataTraits<bool>::BitRef::BitRef(uint8_t* storage, uint8_t mask)
14 : storage_(storage),
15 mask_(mask) {
16 }
17
18 ArrayDataTraits<bool>::BitRef&
19 ArrayDataTraits<bool>::BitRef::operator=(bool value) {
20 if (value) {
21 *storage_ |= mask_;
22 } else {
23 *storage_ &= ~mask_;
24 }
25 return *this;
26 }
27
28 ArrayDataTraits<bool>::BitRef&
29 ArrayDataTraits<bool>::BitRef::operator=(const BitRef& value) {
30 return (*this) = static_cast<bool>(value);
31 }
32
33 ArrayDataTraits<bool>::BitRef::operator bool() const {
34 return (*storage_ & mask_) != 0;
35 }
36
37 // static
38 void ArraySerializationHelper<Handle>::EncodePointersAndHandles(
39 const ArrayHeader* header,
40 ElementType* elements,
41 std::vector<Handle>* handles) {
42 for (uint32_t i = 0; i < header->num_elements; ++i)
43 EncodeHandle(&elements[i], handles);
44 }
45
46 // static
47 bool ArraySerializationHelper<Handle>::DecodePointersAndHandles(
48 const ArrayHeader* header,
49 ElementType* elements,
50 Message* message) {
51 for (uint32_t i = 0; i < header->num_elements; ++i) {
52 if (!DecodeHandle(&elements[i], message->mutable_handles()))
53 return false;
54 }
55 return true;
56 }
57
58 } // namespace internal
59 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/bindings/lib/array_internal.h ('k') | mojo/public/bindings/lib/bindings_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698