OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Functions to help with verifying various |Mojo...Options| structs from the | 5 // Functions to help with verifying various |Mojo...Options| structs from the |
6 // (public, C) API. These are "extensible" structs, which all have |struct_size| | 6 // (public, C) API. These are "extensible" structs, which all have |struct_size| |
7 // as their first member. All fields (other than |struct_size|) are optional, | 7 // as their first member. All fields (other than |struct_size|) are optional, |
8 // but any |flags| specified must be known to the system (otherwise, an error of | 8 // but any |flags| specified must be known to the system (otherwise, an error of |
9 // |MOJO_RESULT_UNIMPLEMENTED| should be returned). | 9 // |MOJO_RESULT_UNIMPLEMENTED| should be returned). |
10 | 10 |
11 #ifndef MOJO_SYSTEM_OPTIONS_VALIDATION_H_ | 11 #ifndef MOJO_EDK_SYSTEM_OPTIONS_VALIDATION_H_ |
12 #define MOJO_SYSTEM_OPTIONS_VALIDATION_H_ | 12 #define MOJO_EDK_SYSTEM_OPTIONS_VALIDATION_H_ |
13 | 13 |
14 #include <stddef.h> | 14 #include <stddef.h> |
15 #include <stdint.h> | 15 #include <stdint.h> |
16 | 16 |
17 #include <algorithm> | 17 #include <algorithm> |
18 | 18 |
19 #include "base/logging.h" | 19 #include "base/logging.h" |
20 #include "base/macros.h" | 20 #include "base/macros.h" |
| 21 #include "mojo/edk/system/constants.h" |
| 22 #include "mojo/edk/system/memory.h" |
| 23 #include "mojo/edk/system/system_impl_export.h" |
21 #include "mojo/public/c/system/types.h" | 24 #include "mojo/public/c/system/types.h" |
22 #include "mojo/system/constants.h" | |
23 #include "mojo/system/memory.h" | |
24 #include "mojo/system/system_impl_export.h" | |
25 | 25 |
26 namespace mojo { | 26 namespace mojo { |
27 namespace system { | 27 namespace system { |
28 | 28 |
29 template <class Options> | 29 template <class Options> |
30 class UserOptionsReader { | 30 class UserOptionsReader { |
31 public: | 31 public: |
32 // Constructor from a |UserPointer<const Options>| (which it checks -- this | 32 // Constructor from a |UserPointer<const Options>| (which it checks -- this |
33 // constructor has side effects!). | 33 // constructor has side effects!). |
34 // Note: We initialize |options_reader_| without checking, since we do a check | 34 // Note: We initialize |options_reader_| without checking, since we do a check |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // | 93 // |
94 // TODO(vtl): With C++11, use |sizeof(Options::member)| instead of (the | 94 // TODO(vtl): With C++11, use |sizeof(Options::member)| instead of (the |
95 // contortion below). We might also be able to pull out the type |Options| from | 95 // contortion below). We might also be able to pull out the type |Options| from |
96 // |reader| (using |decltype|) instead of requiring a parameter. | 96 // |reader| (using |decltype|) instead of requiring a parameter. |
97 #define OPTIONS_STRUCT_HAS_MEMBER(Options, member, reader) \ | 97 #define OPTIONS_STRUCT_HAS_MEMBER(Options, member, reader) \ |
98 reader.HasMember(offsetof(Options, member), sizeof(reader.options().member)) | 98 reader.HasMember(offsetof(Options, member), sizeof(reader.options().member)) |
99 | 99 |
100 } // namespace system | 100 } // namespace system |
101 } // namespace mojo | 101 } // namespace mojo |
102 | 102 |
103 #endif // MOJO_SYSTEM_OPTIONS_VALIDATION_H_ | 103 #endif // MOJO_EDK_SYSTEM_OPTIONS_VALIDATION_H_ |
OLD | NEW |