Chris@64
|
1 // Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
|
Chris@64
|
2 // Licensed under the MIT License:
|
Chris@64
|
3 //
|
Chris@64
|
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
Chris@64
|
5 // of this software and associated documentation files (the "Software"), to deal
|
Chris@64
|
6 // in the Software without restriction, including without limitation the rights
|
Chris@64
|
7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
Chris@64
|
8 // copies of the Software, and to permit persons to whom the Software is
|
Chris@64
|
9 // furnished to do so, subject to the following conditions:
|
Chris@64
|
10 //
|
Chris@64
|
11 // The above copyright notice and this permission notice shall be included in
|
Chris@64
|
12 // all copies or substantial portions of the Software.
|
Chris@64
|
13 //
|
Chris@64
|
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
Chris@64
|
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
Chris@64
|
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
Chris@64
|
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
Chris@64
|
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
Chris@64
|
19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
Chris@64
|
20 // THE SOFTWARE.
|
Chris@64
|
21
|
Chris@64
|
22 // This file is included from all generated headers.
|
Chris@64
|
23
|
Chris@64
|
24 #ifndef CAPNP_GENERATED_HEADER_SUPPORT_H_
|
Chris@64
|
25 #define CAPNP_GENERATED_HEADER_SUPPORT_H_
|
Chris@64
|
26
|
Chris@64
|
27 #if defined(__GNUC__) && !defined(CAPNP_HEADER_WARNINGS)
|
Chris@64
|
28 #pragma GCC system_header
|
Chris@64
|
29 #endif
|
Chris@64
|
30
|
Chris@64
|
31 #include "raw-schema.h"
|
Chris@64
|
32 #include "layout.h"
|
Chris@64
|
33 #include "list.h"
|
Chris@64
|
34 #include "orphan.h"
|
Chris@64
|
35 #include "pointer-helpers.h"
|
Chris@64
|
36 #include "any.h"
|
Chris@64
|
37 #include <kj/string.h>
|
Chris@64
|
38 #include <kj/string-tree.h>
|
Chris@64
|
39
|
Chris@64
|
40 namespace capnp {
|
Chris@64
|
41
|
Chris@64
|
42 class MessageBuilder; // So that it can be declared a friend.
|
Chris@64
|
43
|
Chris@64
|
44 template <typename T, Kind k = CAPNP_KIND(T)>
|
Chris@64
|
45 struct ToDynamic_; // Defined in dynamic.h, needs to be declared as everyone's friend.
|
Chris@64
|
46
|
Chris@64
|
47 struct DynamicStruct; // So that it can be declared a friend.
|
Chris@64
|
48
|
Chris@64
|
49 struct Capability; // To declare brandBindingFor<Capability>()
|
Chris@64
|
50
|
Chris@64
|
51 namespace _ { // private
|
Chris@64
|
52
|
Chris@64
|
53 #if !CAPNP_LITE
|
Chris@64
|
54
|
Chris@64
|
55 template <typename T, typename CapnpPrivate = typename T::_capnpPrivate, bool = false>
|
Chris@64
|
56 inline const RawSchema& rawSchema() {
|
Chris@64
|
57 return *CapnpPrivate::schema;
|
Chris@64
|
58 }
|
Chris@64
|
59 template <typename T, uint64_t id = schemas::EnumInfo<T>::typeId>
|
Chris@64
|
60 inline const RawSchema& rawSchema() {
|
Chris@64
|
61 return *schemas::EnumInfo<T>::schema;
|
Chris@64
|
62 }
|
Chris@64
|
63
|
Chris@64
|
64 template <typename T, typename CapnpPrivate = typename T::_capnpPrivate>
|
Chris@64
|
65 inline const RawBrandedSchema& rawBrandedSchema() {
|
Chris@64
|
66 return *CapnpPrivate::brand();
|
Chris@64
|
67 }
|
Chris@64
|
68 template <typename T, uint64_t id = schemas::EnumInfo<T>::typeId>
|
Chris@64
|
69 inline const RawBrandedSchema& rawBrandedSchema() {
|
Chris@64
|
70 return schemas::EnumInfo<T>::schema->defaultBrand;
|
Chris@64
|
71 }
|
Chris@64
|
72
|
Chris@64
|
73 template <typename TypeTag, typename... Params>
|
Chris@64
|
74 struct ChooseBrand;
|
Chris@64
|
75 // If all of `Params` are `AnyPointer`, return the type's default brand. Otherwise, return a
|
Chris@64
|
76 // specific brand instance. TypeTag is the _capnpPrivate struct for the type in question.
|
Chris@64
|
77
|
Chris@64
|
78 template <typename TypeTag>
|
Chris@64
|
79 struct ChooseBrand<TypeTag> {
|
Chris@64
|
80 // All params were AnyPointer. No specific brand needed.
|
Chris@64
|
81 static constexpr _::RawBrandedSchema const* brand() { return &TypeTag::schema->defaultBrand; }
|
Chris@64
|
82 };
|
Chris@64
|
83
|
Chris@64
|
84 template <typename TypeTag, typename... Rest>
|
Chris@64
|
85 struct ChooseBrand<TypeTag, AnyPointer, Rest...>: public ChooseBrand<TypeTag, Rest...> {};
|
Chris@64
|
86 // The first parameter is AnyPointer, so recurse to check the rest.
|
Chris@64
|
87
|
Chris@64
|
88 template <typename TypeTag, typename First, typename... Rest>
|
Chris@64
|
89 struct ChooseBrand<TypeTag, First, Rest...> {
|
Chris@64
|
90 // At least one parameter is not AnyPointer, so use the specificBrand constant.
|
Chris@64
|
91 static constexpr _::RawBrandedSchema const* brand() { return &TypeTag::specificBrand; }
|
Chris@64
|
92 };
|
Chris@64
|
93
|
Chris@64
|
94 template <typename T, Kind k = kind<T>()>
|
Chris@64
|
95 struct BrandBindingFor_;
|
Chris@64
|
96
|
Chris@64
|
97 #define HANDLE_TYPE(Type, which) \
|
Chris@64
|
98 template <> \
|
Chris@64
|
99 struct BrandBindingFor_<Type, Kind::PRIMITIVE> { \
|
Chris@64
|
100 static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) { \
|
Chris@64
|
101 return { which, listDepth, nullptr }; \
|
Chris@64
|
102 } \
|
Chris@64
|
103 }
|
Chris@64
|
104 HANDLE_TYPE(Void, 0);
|
Chris@64
|
105 HANDLE_TYPE(bool, 1);
|
Chris@64
|
106 HANDLE_TYPE(int8_t, 2);
|
Chris@64
|
107 HANDLE_TYPE(int16_t, 3);
|
Chris@64
|
108 HANDLE_TYPE(int32_t, 4);
|
Chris@64
|
109 HANDLE_TYPE(int64_t, 5);
|
Chris@64
|
110 HANDLE_TYPE(uint8_t, 6);
|
Chris@64
|
111 HANDLE_TYPE(uint16_t, 7);
|
Chris@64
|
112 HANDLE_TYPE(uint32_t, 8);
|
Chris@64
|
113 HANDLE_TYPE(uint64_t, 9);
|
Chris@64
|
114 HANDLE_TYPE(float, 10);
|
Chris@64
|
115 HANDLE_TYPE(double, 11);
|
Chris@64
|
116 #undef HANDLE_TYPE
|
Chris@64
|
117
|
Chris@64
|
118 template <>
|
Chris@64
|
119 struct BrandBindingFor_<Text, Kind::BLOB> {
|
Chris@64
|
120 static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) {
|
Chris@64
|
121 return { 12, listDepth, nullptr };
|
Chris@64
|
122 }
|
Chris@64
|
123 };
|
Chris@64
|
124
|
Chris@64
|
125 template <>
|
Chris@64
|
126 struct BrandBindingFor_<Data, Kind::BLOB> {
|
Chris@64
|
127 static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) {
|
Chris@64
|
128 return { 13, listDepth, nullptr };
|
Chris@64
|
129 }
|
Chris@64
|
130 };
|
Chris@64
|
131
|
Chris@64
|
132 template <typename T>
|
Chris@64
|
133 struct BrandBindingFor_<List<T>, Kind::LIST> {
|
Chris@64
|
134 static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) {
|
Chris@64
|
135 return BrandBindingFor_<T>::get(listDepth + 1);
|
Chris@64
|
136 }
|
Chris@64
|
137 };
|
Chris@64
|
138
|
Chris@64
|
139 template <typename T>
|
Chris@64
|
140 struct BrandBindingFor_<T, Kind::ENUM> {
|
Chris@64
|
141 static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) {
|
Chris@64
|
142 return { 15, listDepth, nullptr };
|
Chris@64
|
143 }
|
Chris@64
|
144 };
|
Chris@64
|
145
|
Chris@64
|
146 template <typename T>
|
Chris@64
|
147 struct BrandBindingFor_<T, Kind::STRUCT> {
|
Chris@64
|
148 static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) {
|
Chris@64
|
149 return { 16, listDepth, T::_capnpPrivate::brand() };
|
Chris@64
|
150 }
|
Chris@64
|
151 };
|
Chris@64
|
152
|
Chris@64
|
153 template <typename T>
|
Chris@64
|
154 struct BrandBindingFor_<T, Kind::INTERFACE> {
|
Chris@64
|
155 static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) {
|
Chris@64
|
156 return { 17, listDepth, T::_capnpPrivate::brand() };
|
Chris@64
|
157 }
|
Chris@64
|
158 };
|
Chris@64
|
159
|
Chris@64
|
160 template <>
|
Chris@64
|
161 struct BrandBindingFor_<AnyPointer, Kind::OTHER> {
|
Chris@64
|
162 static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) {
|
Chris@64
|
163 return { 18, listDepth, 0, 0 };
|
Chris@64
|
164 }
|
Chris@64
|
165 };
|
Chris@64
|
166
|
Chris@64
|
167 template <>
|
Chris@64
|
168 struct BrandBindingFor_<AnyStruct, Kind::OTHER> {
|
Chris@64
|
169 static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) {
|
Chris@64
|
170 return { 18, listDepth, 0, 1 };
|
Chris@64
|
171 }
|
Chris@64
|
172 };
|
Chris@64
|
173
|
Chris@64
|
174 template <>
|
Chris@64
|
175 struct BrandBindingFor_<AnyList, Kind::OTHER> {
|
Chris@64
|
176 static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) {
|
Chris@64
|
177 return { 18, listDepth, 0, 2 };
|
Chris@64
|
178 }
|
Chris@64
|
179 };
|
Chris@64
|
180
|
Chris@64
|
181 template <>
|
Chris@64
|
182 struct BrandBindingFor_<Capability, Kind::OTHER> {
|
Chris@64
|
183 static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) {
|
Chris@64
|
184 return { 18, listDepth, 0, 3 };
|
Chris@64
|
185 }
|
Chris@64
|
186 };
|
Chris@64
|
187
|
Chris@64
|
188 template <typename T>
|
Chris@64
|
189 constexpr RawBrandedSchema::Binding brandBindingFor() {
|
Chris@64
|
190 return BrandBindingFor_<T>::get(0);
|
Chris@64
|
191 }
|
Chris@64
|
192
|
Chris@64
|
193 kj::StringTree structString(StructReader reader, const RawBrandedSchema& schema);
|
Chris@64
|
194 kj::String enumString(uint16_t value, const RawBrandedSchema& schema);
|
Chris@64
|
195 // Declared here so that we can declare inline stringify methods on generated types.
|
Chris@64
|
196 // Defined in stringify.c++, which depends on dynamic.c++, which is allowed not to be linked in.
|
Chris@64
|
197
|
Chris@64
|
198 template <typename T>
|
Chris@64
|
199 inline kj::StringTree structString(StructReader reader) {
|
Chris@64
|
200 return structString(reader, rawBrandedSchema<T>());
|
Chris@64
|
201 }
|
Chris@64
|
202 template <typename T>
|
Chris@64
|
203 inline kj::String enumString(T value) {
|
Chris@64
|
204 return enumString(static_cast<uint16_t>(value), rawBrandedSchema<T>());
|
Chris@64
|
205 }
|
Chris@64
|
206
|
Chris@64
|
207 #endif // !CAPNP_LITE
|
Chris@64
|
208
|
Chris@64
|
209 // TODO(cleanup): Unify ConstStruct and ConstList.
|
Chris@64
|
210 template <typename T>
|
Chris@64
|
211 class ConstStruct {
|
Chris@64
|
212 public:
|
Chris@64
|
213 ConstStruct() = delete;
|
Chris@64
|
214 KJ_DISALLOW_COPY(ConstStruct);
|
Chris@64
|
215 inline explicit constexpr ConstStruct(const word* ptr): ptr(ptr) {}
|
Chris@64
|
216
|
Chris@64
|
217 inline typename T::Reader get() const {
|
Chris@64
|
218 return AnyPointer::Reader(PointerReader::getRootUnchecked(ptr)).getAs<T>();
|
Chris@64
|
219 }
|
Chris@64
|
220
|
Chris@64
|
221 inline operator typename T::Reader() const { return get(); }
|
Chris@64
|
222 inline typename T::Reader operator*() const { return get(); }
|
Chris@64
|
223 inline TemporaryPointer<typename T::Reader> operator->() const { return get(); }
|
Chris@64
|
224
|
Chris@64
|
225 private:
|
Chris@64
|
226 const word* ptr;
|
Chris@64
|
227 };
|
Chris@64
|
228
|
Chris@64
|
229 template <typename T>
|
Chris@64
|
230 class ConstList {
|
Chris@64
|
231 public:
|
Chris@64
|
232 ConstList() = delete;
|
Chris@64
|
233 KJ_DISALLOW_COPY(ConstList);
|
Chris@64
|
234 inline explicit constexpr ConstList(const word* ptr): ptr(ptr) {}
|
Chris@64
|
235
|
Chris@64
|
236 inline typename List<T>::Reader get() const {
|
Chris@64
|
237 return AnyPointer::Reader(PointerReader::getRootUnchecked(ptr)).getAs<List<T>>();
|
Chris@64
|
238 }
|
Chris@64
|
239
|
Chris@64
|
240 inline operator typename List<T>::Reader() const { return get(); }
|
Chris@64
|
241 inline typename List<T>::Reader operator*() const { return get(); }
|
Chris@64
|
242 inline TemporaryPointer<typename List<T>::Reader> operator->() const { return get(); }
|
Chris@64
|
243
|
Chris@64
|
244 private:
|
Chris@64
|
245 const word* ptr;
|
Chris@64
|
246 };
|
Chris@64
|
247
|
Chris@64
|
248 template <size_t size>
|
Chris@64
|
249 class ConstText {
|
Chris@64
|
250 public:
|
Chris@64
|
251 ConstText() = delete;
|
Chris@64
|
252 KJ_DISALLOW_COPY(ConstText);
|
Chris@64
|
253 inline explicit constexpr ConstText(const word* ptr): ptr(ptr) {}
|
Chris@64
|
254
|
Chris@64
|
255 inline Text::Reader get() const {
|
Chris@64
|
256 return Text::Reader(reinterpret_cast<const char*>(ptr), size);
|
Chris@64
|
257 }
|
Chris@64
|
258
|
Chris@64
|
259 inline operator Text::Reader() const { return get(); }
|
Chris@64
|
260 inline Text::Reader operator*() const { return get(); }
|
Chris@64
|
261 inline TemporaryPointer<Text::Reader> operator->() const { return get(); }
|
Chris@64
|
262
|
Chris@64
|
263 inline kj::StringPtr toString() const {
|
Chris@64
|
264 return get();
|
Chris@64
|
265 }
|
Chris@64
|
266
|
Chris@64
|
267 private:
|
Chris@64
|
268 const word* ptr;
|
Chris@64
|
269 };
|
Chris@64
|
270
|
Chris@64
|
271 template <size_t size>
|
Chris@64
|
272 inline kj::StringPtr KJ_STRINGIFY(const ConstText<size>& s) {
|
Chris@64
|
273 return s.get();
|
Chris@64
|
274 }
|
Chris@64
|
275
|
Chris@64
|
276 template <size_t size>
|
Chris@64
|
277 class ConstData {
|
Chris@64
|
278 public:
|
Chris@64
|
279 ConstData() = delete;
|
Chris@64
|
280 KJ_DISALLOW_COPY(ConstData);
|
Chris@64
|
281 inline explicit constexpr ConstData(const word* ptr): ptr(ptr) {}
|
Chris@64
|
282
|
Chris@64
|
283 inline Data::Reader get() const {
|
Chris@64
|
284 return Data::Reader(reinterpret_cast<const byte*>(ptr), size);
|
Chris@64
|
285 }
|
Chris@64
|
286
|
Chris@64
|
287 inline operator Data::Reader() const { return get(); }
|
Chris@64
|
288 inline Data::Reader operator*() const { return get(); }
|
Chris@64
|
289 inline TemporaryPointer<Data::Reader> operator->() const { return get(); }
|
Chris@64
|
290
|
Chris@64
|
291 private:
|
Chris@64
|
292 const word* ptr;
|
Chris@64
|
293 };
|
Chris@64
|
294
|
Chris@64
|
295 template <size_t size>
|
Chris@64
|
296 inline auto KJ_STRINGIFY(const ConstData<size>& s) -> decltype(kj::toCharSequence(s.get())) {
|
Chris@64
|
297 return kj::toCharSequence(s.get());
|
Chris@64
|
298 }
|
Chris@64
|
299
|
Chris@64
|
300 } // namespace _ (private)
|
Chris@64
|
301
|
Chris@64
|
302 template <typename T, typename CapnpPrivate = typename T::_capnpPrivate>
|
Chris@64
|
303 inline constexpr uint64_t typeId() { return CapnpPrivate::typeId; }
|
Chris@64
|
304 template <typename T, uint64_t id = schemas::EnumInfo<T>::typeId>
|
Chris@64
|
305 inline constexpr uint64_t typeId() { return id; }
|
Chris@64
|
306 // typeId<MyType>() returns the type ID as defined in the schema. Works with structs, enums, and
|
Chris@64
|
307 // interfaces.
|
Chris@64
|
308
|
Chris@64
|
309 template <typename T>
|
Chris@64
|
310 inline constexpr uint sizeInWords() {
|
Chris@64
|
311 // Return the size, in words, of a Struct type, if allocated free-standing (not in a list).
|
Chris@64
|
312 // May be useful for pre-computing space needed in order to precisely allocate messages.
|
Chris@64
|
313
|
Chris@64
|
314 return unbound((upgradeBound<uint>(_::structSize<T>().data) +
|
Chris@64
|
315 _::structSize<T>().pointers * WORDS_PER_POINTER) / WORDS);
|
Chris@64
|
316 }
|
Chris@64
|
317
|
Chris@64
|
318 } // namespace capnp
|
Chris@64
|
319
|
Chris@64
|
320 #if _MSC_VER
|
Chris@64
|
321 // MSVC doesn't understand floating-point constexpr yet.
|
Chris@64
|
322 //
|
Chris@64
|
323 // TODO(msvc): Remove this hack when MSVC is fixed.
|
Chris@64
|
324 #define CAPNP_NON_INT_CONSTEXPR_DECL_INIT(value)
|
Chris@64
|
325 #define CAPNP_NON_INT_CONSTEXPR_DEF_INIT(value) = value
|
Chris@64
|
326 #else
|
Chris@64
|
327 #define CAPNP_NON_INT_CONSTEXPR_DECL_INIT(value) = value
|
Chris@64
|
328 #define CAPNP_NON_INT_CONSTEXPR_DEF_INIT(value)
|
Chris@64
|
329 #endif
|
Chris@64
|
330
|
Chris@64
|
331 #if _MSC_VER
|
Chris@64
|
332 // TODO(msvc): A little hack to allow MSVC to use C++14 return type deduction in cases where the
|
Chris@64
|
333 // explicit type exposes bugs in the compiler.
|
Chris@64
|
334 #define CAPNP_AUTO_IF_MSVC(...) auto
|
Chris@64
|
335 #else
|
Chris@64
|
336 #define CAPNP_AUTO_IF_MSVC(...) __VA_ARGS__
|
Chris@64
|
337 #endif
|
Chris@64
|
338
|
Chris@64
|
339 #if CAPNP_LITE
|
Chris@64
|
340
|
Chris@64
|
341 #define CAPNP_DECLARE_SCHEMA(id) \
|
Chris@64
|
342 extern ::capnp::word const* const bp_##id
|
Chris@64
|
343
|
Chris@64
|
344 #define CAPNP_DECLARE_ENUM(type, id) \
|
Chris@64
|
345 inline ::kj::String KJ_STRINGIFY(type##_##id value) { \
|
Chris@64
|
346 return ::kj::str(static_cast<uint16_t>(value)); \
|
Chris@64
|
347 } \
|
Chris@64
|
348 template <> struct EnumInfo<type##_##id> { \
|
Chris@64
|
349 struct IsEnum; \
|
Chris@64
|
350 static constexpr uint64_t typeId = 0x##id; \
|
Chris@64
|
351 static inline ::capnp::word const* encodedSchema() { return bp_##id; } \
|
Chris@64
|
352 }
|
Chris@64
|
353
|
Chris@64
|
354 #if _MSC_VER
|
Chris@64
|
355 // TODO(msvc): MSVC dosen't expect constexprs to have definitions.
|
Chris@64
|
356 #define CAPNP_DEFINE_ENUM(type, id)
|
Chris@64
|
357 #else
|
Chris@64
|
358 #define CAPNP_DEFINE_ENUM(type, id) \
|
Chris@64
|
359 constexpr uint64_t EnumInfo<type>::typeId
|
Chris@64
|
360 #endif
|
Chris@64
|
361
|
Chris@64
|
362 #define CAPNP_DECLARE_STRUCT_HEADER(id, dataWordSize_, pointerCount_) \
|
Chris@64
|
363 struct IsStruct; \
|
Chris@64
|
364 static constexpr uint64_t typeId = 0x##id; \
|
Chris@64
|
365 static constexpr uint16_t dataWordSize = dataWordSize_; \
|
Chris@64
|
366 static constexpr uint16_t pointerCount = pointerCount_; \
|
Chris@64
|
367 static inline ::capnp::word const* encodedSchema() { return ::capnp::schemas::bp_##id; }
|
Chris@64
|
368
|
Chris@64
|
369 #else // CAPNP_LITE
|
Chris@64
|
370
|
Chris@64
|
371 #define CAPNP_DECLARE_SCHEMA(id) \
|
Chris@64
|
372 extern ::capnp::word const* const bp_##id; \
|
Chris@64
|
373 extern const ::capnp::_::RawSchema s_##id
|
Chris@64
|
374
|
Chris@64
|
375 #define CAPNP_DECLARE_ENUM(type, id) \
|
Chris@64
|
376 inline ::kj::String KJ_STRINGIFY(type##_##id value) { \
|
Chris@64
|
377 return ::capnp::_::enumString(value); \
|
Chris@64
|
378 } \
|
Chris@64
|
379 template <> struct EnumInfo<type##_##id> { \
|
Chris@64
|
380 struct IsEnum; \
|
Chris@64
|
381 static constexpr uint64_t typeId = 0x##id; \
|
Chris@64
|
382 static inline ::capnp::word const* encodedSchema() { return bp_##id; } \
|
Chris@64
|
383 static constexpr ::capnp::_::RawSchema const* schema = &s_##id; \
|
Chris@64
|
384 }
|
Chris@64
|
385 #define CAPNP_DEFINE_ENUM(type, id) \
|
Chris@64
|
386 constexpr uint64_t EnumInfo<type>::typeId; \
|
Chris@64
|
387 constexpr ::capnp::_::RawSchema const* EnumInfo<type>::schema
|
Chris@64
|
388
|
Chris@64
|
389 #define CAPNP_DECLARE_STRUCT_HEADER(id, dataWordSize_, pointerCount_) \
|
Chris@64
|
390 struct IsStruct; \
|
Chris@64
|
391 static constexpr uint64_t typeId = 0x##id; \
|
Chris@64
|
392 static constexpr ::capnp::Kind kind = ::capnp::Kind::STRUCT; \
|
Chris@64
|
393 static constexpr uint16_t dataWordSize = dataWordSize_; \
|
Chris@64
|
394 static constexpr uint16_t pointerCount = pointerCount_; \
|
Chris@64
|
395 static inline ::capnp::word const* encodedSchema() { return ::capnp::schemas::bp_##id; } \
|
Chris@64
|
396 static constexpr ::capnp::_::RawSchema const* schema = &::capnp::schemas::s_##id;
|
Chris@64
|
397
|
Chris@64
|
398 #define CAPNP_DECLARE_INTERFACE_HEADER(id) \
|
Chris@64
|
399 struct IsInterface; \
|
Chris@64
|
400 static constexpr uint64_t typeId = 0x##id; \
|
Chris@64
|
401 static constexpr ::capnp::Kind kind = ::capnp::Kind::INTERFACE; \
|
Chris@64
|
402 static inline ::capnp::word const* encodedSchema() { return ::capnp::schemas::bp_##id; } \
|
Chris@64
|
403 static constexpr ::capnp::_::RawSchema const* schema = &::capnp::schemas::s_##id;
|
Chris@64
|
404
|
Chris@64
|
405 #endif // CAPNP_LITE, else
|
Chris@64
|
406
|
Chris@64
|
407 #endif // CAPNP_GENERATED_HEADER_SUPPORT_H_
|