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.
5 #include "mojo/public/cpp/bindings/lib/array_internal.h"
12 std::string
MakeMessageWithArrayIndex(const char* message
,
15 std::ostringstream stream
;
16 stream
<< message
<< ": array size - " << size
<< "; index - " << index
;
20 std::string
MakeMessageWithExpectedArraySize(const char* message
,
22 size_t expected_size
) {
23 std::ostringstream stream
;
24 stream
<< message
<< ": array size - " << size
<< "; expected size - "
29 ArrayDataTraits
<bool>::BitRef::~BitRef() {
32 ArrayDataTraits
<bool>::BitRef::BitRef(uint8_t* storage
, uint8_t mask
)
37 ArrayDataTraits
<bool>::BitRef
&
38 ArrayDataTraits
<bool>::BitRef::operator=(bool value
) {
47 ArrayDataTraits
<bool>::BitRef
&
48 ArrayDataTraits
<bool>::BitRef::operator=(const BitRef
& value
) {
49 return (*this) = static_cast<bool>(value
);
52 ArrayDataTraits
<bool>::BitRef::operator bool() const {
53 return (*storage_
& mask_
) != 0;
57 void ArraySerializationHelper
<Handle
, true>::EncodePointersAndHandles(
58 const ArrayHeader
* header
,
59 ElementType
* elements
,
60 std::vector
<Handle
>* handles
) {
61 for (uint32_t i
= 0; i
< header
->num_elements
; ++i
)
62 EncodeHandle(&elements
[i
], handles
);
66 void ArraySerializationHelper
<Handle
, true>::DecodePointersAndHandles(
67 const ArrayHeader
* header
,
68 ElementType
* elements
,
69 std::vector
<Handle
>* handles
) {
70 for (uint32_t i
= 0; i
< header
->num_elements
; ++i
)
71 DecodeHandle(&elements
[i
], handles
);
74 } // namespace internal