| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // This file contains structs used for constructing type descriptors for | 5 // This file contains structs used for constructing type descriptors for |
| 6 // generated mojom types. A type descriptor for a mojom struct is a table | 6 // generated mojom types. A type descriptor for a mojom struct is a table |
| 7 // describing the byte-offsets of all the pointers and handles in the struct, | 7 // describing the byte-offsets of all the pointers and handles in the struct, |
| 8 // and has references to the type descriptorss that further describe the | 8 // and has references to the type descriptorss that further describe the |
| 9 // pointers. The table is used for doing all computations for the struct -- | 9 // pointers. The table is used for doing all computations for the struct -- |
| 10 // determining serialized size, encoding and decoding recursively, etc. A type | 10 // determining serialized size, encoding and decoding recursively, etc. A type |
| 11 // descriptor is generated for each struct, union, array and map. Mojom maps are | 11 // descriptor is generated for each struct, union, array and map. Mojom maps are |
| 12 // just mojom structs with two mojom arrays. We denote it as a separate type, | 12 // just mojom structs with two mojom arrays. We denote it as a separate type, |
| 13 // but it is described the same way as a mojom struct. | 13 // but it is described the same way as a mojom struct. |
| 14 // | 14 // |
| 15 // The user is not expected to construct type descriptors -- a bindings | 15 // The user is not expected to construct type descriptors -- a bindings |
| 16 // generator will do this when it generates bindings for a mojom file. | 16 // generator will do this when it generates bindings for a mojom file. |
| 17 // | 17 // |
| 18 // A type descriptor for a mojom struct is a |MojomTypeDescriptorStruct| | 18 // A type descriptor for a mojom struct is a |MojomTypeDescriptorStruct| |
| 19 // containing an array of entries of types of |MojomTypeDescriptorStructEntry|. | 19 // containing an array of entries of types of |MojomTypeDescriptorStructEntry|. |
| 20 // Similarly, unions are described with |MojomTypeDescriptorUnion| with entries | 20 // Similarly, unions are described with |MojomTypeDescriptorUnion| with entries |
| 21 // of |MojomTypeDescriptorUnionEntry|. Arrays are described with | 21 // of |MojomTypeDescriptorUnionEntry|. Arrays are described with |
| 22 // |MojomTypeDescriptorArray|. | 22 // |MojomTypeDescriptorArray|. |
| 23 | 23 |
| 24 #ifndef MOJO_PUBLIC_C_BINDINGS_LIB_TYPE_DESCRIPTOR_H_ | 24 #ifndef MOJO_PUBLIC_C_INCLUDE_MOJO_BINDINGS_INTERNAL_TYPE_DESCRIPTOR_H_ |
| 25 #define MOJO_PUBLIC_C_BINDINGS_LIB_TYPE_DESCRIPTOR_H_ | 25 #define MOJO_PUBLIC_C_INCLUDE_MOJO_BINDINGS_INTERNAL_TYPE_DESCRIPTOR_H_ |
| 26 | 26 |
| 27 #include <mojo/bindings/buffer.h> |
| 28 #include <mojo/bindings/internal/util.h> |
| 29 #include <mojo/bindings/validation.h> |
| 27 #include <mojo/macros.h> | 30 #include <mojo/macros.h> |
| 28 #include <mojo/system/handle.h> | 31 #include <mojo/system/handle.h> |
| 29 #include <stdbool.h> | 32 #include <stdbool.h> |
| 30 #include <stddef.h> | 33 #include <stddef.h> |
| 31 #include <stdint.h> | 34 #include <stdint.h> |
| 32 | 35 |
| 33 #include "mojo/public/c/bindings/buffer.h" | |
| 34 #include "mojo/public/c/bindings/lib/util.h" | |
| 35 #include "mojo/public/c/bindings/validation.h" | |
| 36 | |
| 37 MOJO_BEGIN_EXTERN_C | 36 MOJO_BEGIN_EXTERN_C |
| 38 | 37 |
| 39 // This enum is used in a type descriptor entry for the |elem_type| field, and | 38 // This enum is used in a type descriptor entry for the |elem_type| field, and |
| 40 // indicates which type the accompanying |elem_descriptor| is describing (if it | 39 // indicates which type the accompanying |elem_descriptor| is describing (if it |
| 41 // is describing a reference type), or to indicate that it's a handle type. | 40 // is describing a reference type), or to indicate that it's a handle type. |
| 42 // Values that correspond to an |elem_descriptor|'s pointer type: | 41 // Values that correspond to an |elem_descriptor|'s pointer type: |
| 43 // - If MOJOM_TYPE_DESCRIPTOR_TYPE_STRUCT_PTR, then |elem_descriptor| points to | 42 // - If MOJOM_TYPE_DESCRIPTOR_TYPE_STRUCT_PTR, then |elem_descriptor| points to |
| 44 // a |MojomTypeDescriptorStruct|. | 43 // a |MojomTypeDescriptorStruct|. |
| 45 // - If MOJOM_TYPE_DESCRIPTOR_TYPE_MAP_PTR, then |elem_descriptor| points to | 44 // - If MOJOM_TYPE_DESCRIPTOR_TYPE_MAP_PTR, then |elem_descriptor| points to |
| 46 // a |MojomTypeDescriptorStruct|. | 45 // a |MojomTypeDescriptorStruct|. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 // new union before dispatching a call to MojomUnion_DeepCopy. Returns false if | 208 // new union before dispatching a call to MojomUnion_DeepCopy. Returns false if |
| 210 // the copy failed due to insufficient space in the buffer. | 209 // the copy failed due to insufficient space in the buffer. |
| 211 bool MojomType_DispatchDeepCopy(struct MojomBuffer* buffer, | 210 bool MojomType_DispatchDeepCopy(struct MojomBuffer* buffer, |
| 212 enum MojomTypeDescriptorType in_elem_type, | 211 enum MojomTypeDescriptorType in_elem_type, |
| 213 const void* in_type_desc, | 212 const void* in_type_desc, |
| 214 const void* in_data, | 213 const void* in_data, |
| 215 void* out_data); | 214 void* out_data); |
| 216 | 215 |
| 217 MOJO_END_EXTERN_C | 216 MOJO_END_EXTERN_C |
| 218 | 217 |
| 219 #endif // MOJO_PUBLIC_C_BINDINGS_LIB_TYPE_DESCRIPTOR_H_ | 218 #endif // MOJO_PUBLIC_C_INCLUDE_MOJO_BINDINGS_INTERNAL_TYPE_DESCRIPTOR_H_ |
| OLD | NEW |