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

Side by Side Diff: mojo/public/c/lib/bindings/union.c

Issue 2232833003: Change the canonical way to include the C bindings headers to <mojo/bindings/*.h>. (Closed) Base URL: https://github.com/domokit/mojo.git@work791_mojo_tests
Patch Set: rebased Created 4 years, 4 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
« no previous file with comments | « mojo/public/c/lib/bindings/type_descriptor.c ('k') | mojo/public/tools/bindings/mojom.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "mojo/public/c/bindings/union.h" 5 #include <mojo/bindings/union.h>
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <mojo/bindings/internal/type_descriptor.h>
8 #include <string.h> 9 #include <string.h>
9 10
10 #include "mojo/public/c/bindings/lib/type_descriptor.h"
11
12 #define UNION_TAG_UNKNOWN ((uint32_t)0xFFFFFFFF) 11 #define UNION_TAG_UNKNOWN ((uint32_t)0xFFFFFFFF)
13 12
14 size_t MojomUnion_ComputeSerializedSize( 13 size_t MojomUnion_ComputeSerializedSize(
15 const struct MojomTypeDescriptorUnion* in_type_desc, 14 const struct MojomTypeDescriptorUnion* in_type_desc,
16 const struct MojomUnionLayout* in_union_data) { 15 const struct MojomUnionLayout* in_union_data) {
17 assert(in_type_desc); 16 assert(in_type_desc);
18 assert(in_union_data); 17 assert(in_union_data);
19 18
20 for (size_t i = 0; i < in_type_desc->num_entries; i++) { 19 for (size_t i = 0; i < in_type_desc->num_entries; i++) {
21 const struct MojomTypeDescriptorUnionEntry* entry = 20 const struct MojomTypeDescriptorUnionEntry* entry =
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 buffer, entry->elem_type, entry->elem_descriptor, 150 buffer, entry->elem_type, entry->elem_descriptor,
152 &(in_union_data->data), &(out_union_data->data)); 151 &(in_union_data->data), &(out_union_data->data));
153 } 152 }
154 // We reach here if we don't recognize the tag. If it's the UNKNOWN tag, it's 153 // We reach here if we don't recognize the tag. If it's the UNKNOWN tag, it's
155 // not a failure. If it's an unrecognized tag (erroneous or because this union 154 // not a failure. If it's an unrecognized tag (erroneous or because this union
156 // is from a future-version), we don't know how to copy it, so the copy is a 155 // is from a future-version), we don't know how to copy it, so the copy is a
157 // failure. 156 // failure.
158 return in_union_data->tag < in_type_desc->num_fields || 157 return in_union_data->tag < in_type_desc->num_fields ||
159 in_union_data->tag == UNION_TAG_UNKNOWN; 158 in_union_data->tag == UNION_TAG_UNKNOWN;
160 } 159 }
OLDNEW
« no previous file with comments | « mojo/public/c/lib/bindings/type_descriptor.c ('k') | mojo/public/tools/bindings/mojom.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698