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 #include "mojo/public/c/bindings/lib/type_descriptor.h" | 5 #include "mojo/public/c/bindings/lib/type_descriptor.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 #include <stddef.h> | |
8 | 9 |
9 #include "mojo/public/c/bindings/array.h" | 10 #include "mojo/public/c/bindings/array.h" |
10 #include "mojo/public/c/bindings/interface.h" | 11 #include "mojo/public/c/bindings/interface.h" |
11 #include "mojo/public/c/bindings/lib/util.h" | 12 #include "mojo/public/c/bindings/lib/util.h" |
12 #include "mojo/public/c/bindings/map.h" | 13 #include "mojo/public/c/bindings/map.h" |
13 #include "mojo/public/c/bindings/struct.h" | 14 #include "mojo/public/c/bindings/struct.h" |
14 #include "mojo/public/c/bindings/union.h" | 15 #include "mojo/public/c/bindings/union.h" |
15 | 16 |
16 const struct MojomTypeDescriptorArray g_mojom_string_type_description = { | 17 const struct MojomTypeDescriptorArray g_mojom_string_type_description = { |
17 MOJOM_TYPE_DESCRIPTOR_TYPE_POD, // elem_type | 18 MOJOM_TYPE_DESCRIPTOR_TYPE_POD, // elem_type |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 break; | 79 break; |
79 } | 80 } |
80 return size; | 81 return size; |
81 } | 82 } |
82 | 83 |
83 static void encode_pointer(union MojomPointer* pointer, uint32_t max_offset) { | 84 static void encode_pointer(union MojomPointer* pointer, uint32_t max_offset) { |
84 if (pointer->ptr == NULL) { | 85 if (pointer->ptr == NULL) { |
85 pointer->offset = 0; | 86 pointer->offset = 0; |
86 } else { | 87 } else { |
87 assert((char*)pointer->ptr > (char*)pointer); | 88 assert((char*)pointer->ptr > (char*)pointer); |
88 assert((char*)pointer->ptr - (char*)pointer < max_offset); | 89 assert((char*)pointer->ptr - (char*)pointer < (ptrdiff_t)max_offset); |
viettrungluu
2016/08/02 20:10:29
Hmmm. So if ptrdiff_t is 32-bit, and max_offset is
vardhan
2016/08/02 20:28:30
Done.
| |
89 pointer->offset = (char*)(pointer->ptr) - (char*)pointer; | 90 pointer->offset = (char*)(pointer->ptr) - (char*)pointer; |
90 } | 91 } |
91 } | 92 } |
92 | 93 |
93 static void decode_pointer(union MojomPointer* pointer) { | 94 static void decode_pointer(union MojomPointer* pointer) { |
94 if (pointer->offset == 0) { | 95 if (pointer->offset == 0) { |
95 pointer->ptr = NULL; | 96 pointer->ptr = NULL; |
96 } else { | 97 } else { |
97 pointer->ptr = (char*)pointer + pointer->offset; | 98 pointer->ptr = (char*)pointer + pointer->offset; |
98 } | 99 } |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
392 return validate_handle(*(const MojoHandle*)in_buf, in_num_handles, | 393 return validate_handle(*(const MojoHandle*)in_buf, in_num_handles, |
393 in_nullable, inout_context); | 394 in_nullable, inout_context); |
394 case MOJOM_TYPE_DESCRIPTOR_TYPE_INTERFACE: | 395 case MOJOM_TYPE_DESCRIPTOR_TYPE_INTERFACE: |
395 return validate_handle(((const struct MojomInterfaceData*)in_buf)->handle, | 396 return validate_handle(((const struct MojomInterfaceData*)in_buf)->handle, |
396 in_num_handles, in_nullable, inout_context); | 397 in_num_handles, in_nullable, inout_context); |
397 case MOJOM_TYPE_DESCRIPTOR_TYPE_POD: | 398 case MOJOM_TYPE_DESCRIPTOR_TYPE_POD: |
398 break; | 399 break; |
399 } | 400 } |
400 return MOJOM_VALIDATION_ERROR_NONE; | 401 return MOJOM_VALIDATION_ERROR_NONE; |
401 } | 402 } |
OLD | NEW |