| OLD | NEW |
| 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 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 // What follows is code to support the serialization/validation of | 103 // What follows is code to support the serialization/validation of |
| 104 // Array_Data<T>. There are four interesting cases: arrays of primitives, | 104 // Array_Data<T>. There are four interesting cases: arrays of primitives, |
| 105 // arrays of handles/interfaces, arrays of objects and arrays of unions. | 105 // arrays of handles/interfaces, arrays of objects and arrays of unions. |
| 106 // Arrays of objects are represented as arrays of pointers to objects. Arrays | 106 // Arrays of objects are represented as arrays of pointers to objects. Arrays |
| 107 // of unions are inlined so they are not pointers, but comparing with primitives | 107 // of unions are inlined so they are not pointers, but comparing with primitives |
| 108 // they require more work for serialization/validation. | 108 // they require more work for serialization/validation. |
| 109 // | 109 // |
| 110 // TODO(yzshen): Validation code should be organzied in a way similar to | 110 // TODO(yzshen): Validation code should be organzied in a way similar to |
| 111 // Serializer<>, or merged into it. It should be templatized with the mojo | 111 // Serializer<>, or merged into it. It should be templatized with the mojo |
| 112 // wrapper type instead of the data type, that way we can use MojomTypeTraits | 112 // data view type instead of the data type, that way we can use MojomTypeTraits |
| 113 // to determine the categories. | 113 // to determine the categories. |
| 114 | 114 |
| 115 template <typename T, bool is_union, bool is_handle_or_interface> | 115 template <typename T, bool is_union, bool is_handle_or_interface> |
| 116 struct ArraySerializationHelper; | 116 struct ArraySerializationHelper; |
| 117 | 117 |
| 118 template <typename T> | 118 template <typename T> |
| 119 struct ArraySerializationHelper<T, false, false> { | 119 struct ArraySerializationHelper<T, false, false> { |
| 120 using ElementType = typename ArrayDataTraits<T>::StorageType; | 120 using ElementType = typename ArrayDataTraits<T>::StorageType; |
| 121 | 121 |
| 122 static bool ValidateElements(const ArrayHeader* header, | 122 static bool ValidateElements(const ArrayHeader* header, |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 }; | 358 }; |
| 359 static_assert(sizeof(Array_Data<char>) == 8, "Bad sizeof(Array_Data)"); | 359 static_assert(sizeof(Array_Data<char>) == 8, "Bad sizeof(Array_Data)"); |
| 360 | 360 |
| 361 // UTF-8 encoded | 361 // UTF-8 encoded |
| 362 using String_Data = Array_Data<char>; | 362 using String_Data = Array_Data<char>; |
| 363 | 363 |
| 364 } // namespace internal | 364 } // namespace internal |
| 365 } // namespace mojo | 365 } // namespace mojo |
| 366 | 366 |
| 367 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ | 367 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ |
| OLD | NEW |