OLD | NEW |
(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 #ifndef MOJO_PUBLIC_BINDINGS_LIB_BINDINGS_INTERNAL_H_ |
| 6 #define MOJO_PUBLIC_BINDINGS_LIB_BINDINGS_INTERNAL_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 namespace mojo { |
| 11 template <typename T> class Array; |
| 12 |
| 13 namespace internal { |
| 14 |
| 15 struct StructHeader { |
| 16 uint32_t num_bytes; |
| 17 uint32_t num_fields; |
| 18 }; |
| 19 |
| 20 struct ArrayHeader { |
| 21 uint32_t num_bytes; |
| 22 uint32_t num_elements; |
| 23 }; |
| 24 |
| 25 template <typename T> |
| 26 union StructPointer { |
| 27 uint64_t offset; |
| 28 T* ptr; |
| 29 }; |
| 30 |
| 31 template <typename T> |
| 32 union ArrayPointer { |
| 33 uint64_t offset; |
| 34 Array<T>* ptr; |
| 35 }; |
| 36 |
| 37 union StringPointer { |
| 38 uint64_t offset; |
| 39 Array<char>* ptr; |
| 40 }; |
| 41 |
| 42 template <typename T> |
| 43 struct ArrayTraits { |
| 44 typedef T StorageType; |
| 45 |
| 46 static T& ToRef(StorageType& e) { return e; } |
| 47 static T const& ToConstRef(const StorageType& e) { return e; } |
| 48 }; |
| 49 |
| 50 template <typename P> |
| 51 struct ArrayTraits<P*> { |
| 52 typedef StructPointer<P> StorageType; |
| 53 |
| 54 static P*& ToRef(StorageType& e) { return e.ptr; } |
| 55 static P* const& ToConstRef(const StorageType& e) { return e.ptr; } |
| 56 }; |
| 57 |
| 58 template <typename T> class ObjectTraits {}; |
| 59 |
| 60 } // namespace internal |
| 61 } // namespace mojo |
| 62 |
| 63 #endif // MOJO_PUBLIC_BINDINGS_LIB_BINDINGS_INTERNAL_H_ |
OLD | NEW |