Chris@47: // Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors Chris@47: // Licensed under the MIT License: Chris@47: // Chris@47: // Permission is hereby granted, free of charge, to any person obtaining a copy Chris@47: // of this software and associated documentation files (the "Software"), to deal Chris@47: // in the Software without restriction, including without limitation the rights Chris@47: // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell Chris@47: // copies of the Software, and to permit persons to whom the Software is Chris@47: // furnished to do so, subject to the following conditions: Chris@47: // Chris@47: // The above copyright notice and this permission notice shall be included in Chris@47: // all copies or substantial portions of the Software. Chris@47: // Chris@47: // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR Chris@47: // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, Chris@47: // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE Chris@47: // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER Chris@47: // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, Chris@47: // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN Chris@47: // THE SOFTWARE. Chris@47: Chris@47: // This file is included form all generated headers. Chris@47: Chris@47: #ifndef CAPNP_GENERATED_HEADER_SUPPORT_H_ Chris@47: #define CAPNP_GENERATED_HEADER_SUPPORT_H_ Chris@47: Chris@47: #if defined(__GNUC__) && !defined(CAPNP_HEADER_WARNINGS) Chris@47: #pragma GCC system_header Chris@47: #endif Chris@47: Chris@47: #include "layout.h" Chris@47: #include "list.h" Chris@47: #include "orphan.h" Chris@47: #include "pointer-helpers.h" Chris@47: #include "any.h" Chris@47: #include Chris@47: #include Chris@47: Chris@47: namespace capnp { Chris@47: Chris@47: class MessageBuilder; // So that it can be declared a friend. Chris@47: Chris@47: template Chris@47: struct ToDynamic_; // Defined in dynamic.h, needs to be declared as everyone's friend. Chris@47: Chris@47: struct DynamicStruct; // So that it can be declared a friend. Chris@47: Chris@47: struct Capability; // To declare brandBindingFor() Chris@47: Chris@47: namespace _ { // private Chris@47: Chris@47: #if !CAPNP_LITE Chris@47: Chris@47: struct RawSchema; Chris@47: Chris@47: struct RawBrandedSchema { Chris@47: // Represents a combination of a schema and bindings for its generic parameters. Chris@47: // Chris@47: // Note that while we generate one `RawSchema` per type, we generate a `RawBrandedSchema` for Chris@47: // every _instance_ of a generic type -- or, at least, every instance that is actually used. For Chris@47: // generated-code types, we use template magic to initialize these. Chris@47: Chris@47: const RawSchema* generic; Chris@47: // Generic type which we're branding. Chris@47: Chris@47: struct Binding { Chris@47: uint8_t which; // Numeric value of one of schema::Type::Which. Chris@47: Chris@47: bool isImplicitParameter; Chris@47: // For AnyPointer, true if it's an implicit method parameter. Chris@47: Chris@47: uint16_t listDepth; // Number of times to wrap the base type in List(). Chris@47: Chris@47: uint16_t paramIndex; Chris@47: // For AnyPointer. If it's a type parameter (scopeId is non-zero) or it's an implicit parameter Chris@47: // (isImplicitParameter is true), then this is the parameter index. Otherwise this is a numeric Chris@47: // value of one of schema::Type::AnyPointer::Unconstrained::Which. Chris@47: Chris@47: union { Chris@47: const RawBrandedSchema* schema; // for struct, enum, interface Chris@47: uint64_t scopeId; // for AnyPointer, if it's a type parameter Chris@47: }; Chris@47: Chris@47: Binding() = default; Chris@47: inline constexpr Binding(uint8_t which, uint16_t listDepth, const RawBrandedSchema* schema) Chris@47: : which(which), isImplicitParameter(false), listDepth(listDepth), paramIndex(0), Chris@47: schema(schema) {} Chris@47: inline constexpr Binding(uint8_t which, uint16_t listDepth, Chris@47: uint64_t scopeId, uint16_t paramIndex) Chris@47: : which(which), isImplicitParameter(false), listDepth(listDepth), paramIndex(paramIndex), Chris@47: scopeId(scopeId) {} Chris@47: inline constexpr Binding(uint8_t which, uint16_t listDepth, uint16_t implicitParamIndex) Chris@47: : which(which), isImplicitParameter(true), listDepth(listDepth), Chris@47: paramIndex(implicitParamIndex), scopeId(0) {} Chris@47: }; Chris@47: Chris@47: struct Scope { Chris@47: uint64_t typeId; Chris@47: // Type ID whose parameters are being bound. Chris@47: Chris@47: const Binding* bindings; Chris@47: uint bindingCount; Chris@47: // Bindings for those parameters. Chris@47: Chris@47: bool isUnbound; Chris@47: // This scope is unbound, in the sense of SchemaLoader::getUnbound(). Chris@47: }; Chris@47: Chris@47: const Scope* scopes; Chris@47: // Array of enclosing scopes for which generic variables have been bound, sorted by type ID. Chris@47: Chris@47: struct Dependency { Chris@47: uint location; Chris@47: const RawBrandedSchema* schema; Chris@47: }; Chris@47: Chris@47: const Dependency* dependencies; Chris@47: // Map of branded schemas for dependencies of this type, given our brand. Only dependencies that Chris@47: // are branded are included in this map; if a dependency is missing, use its `defaultBrand`. Chris@47: Chris@47: uint32_t scopeCount; Chris@47: uint32_t dependencyCount; Chris@47: Chris@47: enum class DepKind { Chris@47: // Component of a Dependency::location. Specifies what sort of dependency this is. Chris@47: Chris@47: INVALID, Chris@47: // Mostly defined to ensure that zero is not a valid location. Chris@47: Chris@47: FIELD, Chris@47: // Binding needed for a field's type. The index is the field index (NOT ordinal!). Chris@47: Chris@47: METHOD_PARAMS, Chris@47: // Bindings needed for a method's params type. The index is the method number. Chris@47: Chris@47: METHOD_RESULTS, Chris@47: // Bindings needed for a method's results type. The index is the method ordinal. Chris@47: Chris@47: SUPERCLASS, Chris@47: // Bindings needed for a superclass type. The index is the superclass's index in the Chris@47: // "extends" list. Chris@47: Chris@47: CONST_TYPE Chris@47: // Bindings needed for the type of a constant. The index is zero. Chris@47: }; Chris@47: Chris@47: static inline uint makeDepLocation(DepKind kind, uint index) { Chris@47: // Make a number representing the location of a particular dependency within its parent Chris@47: // schema. Chris@47: Chris@47: return (static_cast(kind) << 24) | index; Chris@47: } Chris@47: Chris@47: class Initializer { Chris@47: public: Chris@47: virtual void init(const RawBrandedSchema* generic) const = 0; Chris@47: }; Chris@47: Chris@47: const Initializer* lazyInitializer; Chris@47: // Lazy initializer, invoked by ensureInitialized(). Chris@47: Chris@47: inline void ensureInitialized() const { Chris@47: // Lazy initialization support. Invoke to ensure that initialization has taken place. This Chris@47: // is required in particular when traversing the dependency list. RawSchemas for compiled-in Chris@47: // types are always initialized; only dynamically-loaded schemas may be lazy. Chris@47: Chris@47: const Initializer* i = __atomic_load_n(&lazyInitializer, __ATOMIC_ACQUIRE); Chris@47: if (i != nullptr) i->init(this); Chris@47: } Chris@47: Chris@47: inline bool isUnbound() const; Chris@47: // Checks if this schema is the result of calling SchemaLoader::getUnbound(), in which case Chris@47: // binding lookups need to be handled specially. Chris@47: }; Chris@47: Chris@47: struct RawSchema { Chris@47: // The generated code defines a constant RawSchema for every compiled declaration. Chris@47: // Chris@47: // This is an internal structure which could change in the future. Chris@47: Chris@47: uint64_t id; Chris@47: Chris@47: const word* encodedNode; Chris@47: // Encoded SchemaNode, readable via readMessageUnchecked(encodedNode). Chris@47: Chris@47: uint32_t encodedSize; Chris@47: // Size of encodedNode, in words. Chris@47: Chris@47: const RawSchema* const* dependencies; Chris@47: // Pointers to other types on which this one depends, sorted by ID. The schemas in this table Chris@47: // may be uninitialized -- you must call ensureInitialized() on the one you wish to use before Chris@47: // using it. Chris@47: // Chris@47: // TODO(someday): Make this a hashtable. Chris@47: Chris@47: const uint16_t* membersByName; Chris@47: // Indexes of members sorted by name. Used to implement name lookup. Chris@47: // TODO(someday): Make this a hashtable. Chris@47: Chris@47: uint32_t dependencyCount; Chris@47: uint32_t memberCount; Chris@47: // Sizes of above tables. Chris@47: Chris@47: const uint16_t* membersByDiscriminant; Chris@47: // List of all member indexes ordered by discriminant value. Those which don't have a Chris@47: // discriminant value are listed at the end, in order by ordinal. Chris@47: Chris@47: const RawSchema* canCastTo; Chris@47: // Points to the RawSchema of a compiled-in type to which it is safe to cast any DynamicValue Chris@47: // with this schema. This is null for all compiled-in types; it is only set by SchemaLoader on Chris@47: // dynamically-loaded types. Chris@47: Chris@47: class Initializer { Chris@47: public: Chris@47: virtual void init(const RawSchema* schema) const = 0; Chris@47: }; Chris@47: Chris@47: const Initializer* lazyInitializer; Chris@47: // Lazy initializer, invoked by ensureInitialized(). Chris@47: Chris@47: inline void ensureInitialized() const { Chris@47: // Lazy initialization support. Invoke to ensure that initialization has taken place. This Chris@47: // is required in particular when traversing the dependency list. RawSchemas for compiled-in Chris@47: // types are always initialized; only dynamically-loaded schemas may be lazy. Chris@47: Chris@47: const Initializer* i = __atomic_load_n(&lazyInitializer, __ATOMIC_ACQUIRE); Chris@47: if (i != nullptr) i->init(this); Chris@47: } Chris@47: Chris@47: RawBrandedSchema defaultBrand; Chris@47: // Specifies the brand to use for this schema if no generic parameters have been bound to Chris@47: // anything. Generally, in the default brand, all generic parameters are treated as if they were Chris@47: // bound to `AnyPointer`. Chris@47: }; Chris@47: Chris@47: inline bool RawBrandedSchema::isUnbound() const { Chris@47: // The unbound schema is the only one that has no scopes but is not the default schema. Chris@47: return scopeCount == 0 && this != &generic->defaultBrand; Chris@47: } Chris@47: Chris@47: template Chris@47: inline const RawSchema& rawSchema() { Chris@47: return *CapnpPrivate::schema; Chris@47: } Chris@47: template ::typeId> Chris@47: inline const RawSchema& rawSchema() { Chris@47: return *schemas::EnumInfo::schema; Chris@47: } Chris@47: Chris@47: template Chris@47: inline const RawBrandedSchema& rawBrandedSchema() { Chris@47: return *CapnpPrivate::brand; Chris@47: } Chris@47: template ::typeId> Chris@47: inline const RawBrandedSchema& rawBrandedSchema() { Chris@47: return schemas::EnumInfo::schema->defaultBrand; Chris@47: } Chris@47: Chris@47: template Chris@47: struct ChooseBrand; Chris@47: // If all of `Params` are `AnyPointer`, return the type's default brand. Otherwise, return a Chris@47: // specific brand instance. TypeTag is the _capnpPrivate struct for the type in question. Chris@47: Chris@47: template Chris@47: struct ChooseBrand { Chris@47: // All params were AnyPointer. No specific brand needed. Chris@47: static constexpr _::RawBrandedSchema const* brand = &TypeTag::schema->defaultBrand; Chris@47: }; Chris@47: Chris@47: template Chris@47: struct ChooseBrand: public ChooseBrand {}; Chris@47: // The first parameter is AnyPointer, so recurse to check the rest. Chris@47: Chris@47: template Chris@47: struct ChooseBrand { Chris@47: // At least one parameter is not AnyPointer, so use the specificBrand constant. Chris@47: static constexpr _::RawBrandedSchema const* brand = &TypeTag::specificBrand; Chris@47: }; Chris@47: Chris@47: template ()> Chris@47: struct BrandBindingFor_; Chris@47: Chris@47: #define HANDLE_TYPE(Type, which) \ Chris@47: template <> \ Chris@47: struct BrandBindingFor_ { \ Chris@47: static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) { \ Chris@47: return { which, listDepth, nullptr }; \ Chris@47: } \ Chris@47: } Chris@47: HANDLE_TYPE(Void, 0); Chris@47: HANDLE_TYPE(bool, 1); Chris@47: HANDLE_TYPE(int8_t, 2); Chris@47: HANDLE_TYPE(int16_t, 3); Chris@47: HANDLE_TYPE(int32_t, 4); Chris@47: HANDLE_TYPE(int64_t, 5); Chris@47: HANDLE_TYPE(uint8_t, 6); Chris@47: HANDLE_TYPE(uint16_t, 7); Chris@47: HANDLE_TYPE(uint32_t, 8); Chris@47: HANDLE_TYPE(uint64_t, 9); Chris@47: HANDLE_TYPE(float, 10); Chris@47: HANDLE_TYPE(double, 11); Chris@47: #undef HANDLE_TYPE Chris@47: Chris@47: template <> Chris@47: struct BrandBindingFor_ { Chris@47: static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) { Chris@47: return { 12, listDepth, nullptr }; Chris@47: } Chris@47: }; Chris@47: Chris@47: template <> Chris@47: struct BrandBindingFor_ { Chris@47: static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) { Chris@47: return { 13, listDepth, nullptr }; Chris@47: } Chris@47: }; Chris@47: Chris@47: template Chris@47: struct BrandBindingFor_, Kind::LIST> { Chris@47: static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) { Chris@47: return BrandBindingFor_::get(listDepth + 1); Chris@47: } Chris@47: }; Chris@47: Chris@47: template Chris@47: struct BrandBindingFor_ { Chris@47: static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) { Chris@47: return { 15, listDepth, nullptr }; Chris@47: } Chris@47: }; Chris@47: Chris@47: template Chris@47: struct BrandBindingFor_ { Chris@47: static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) { Chris@47: return { 16, listDepth, T::_capnpPrivate::brand }; Chris@47: } Chris@47: }; Chris@47: Chris@47: template Chris@47: struct BrandBindingFor_ { Chris@47: static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) { Chris@47: return { 17, listDepth, T::_capnpPrivate::brand }; Chris@47: } Chris@47: }; Chris@47: Chris@47: template <> Chris@47: struct BrandBindingFor_ { Chris@47: static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) { Chris@47: return { 18, listDepth, 0, 0 }; Chris@47: } Chris@47: }; Chris@47: Chris@47: template <> Chris@47: struct BrandBindingFor_ { Chris@47: static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) { Chris@47: return { 18, listDepth, 0, 1 }; Chris@47: } Chris@47: }; Chris@47: Chris@47: template <> Chris@47: struct BrandBindingFor_ { Chris@47: static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) { Chris@47: return { 18, listDepth, 0, 2 }; Chris@47: } Chris@47: }; Chris@47: Chris@47: template <> Chris@47: struct BrandBindingFor_ { Chris@47: static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) { Chris@47: return { 18, listDepth, 0, 3 }; Chris@47: } Chris@47: }; Chris@47: Chris@47: template Chris@47: constexpr RawBrandedSchema::Binding brandBindingFor() { Chris@47: return BrandBindingFor_::get(0); Chris@47: } Chris@47: Chris@47: kj::StringTree structString(StructReader reader, const RawBrandedSchema& schema); Chris@47: kj::String enumString(uint16_t value, const RawBrandedSchema& schema); Chris@47: // Declared here so that we can declare inline stringify methods on generated types. Chris@47: // Defined in stringify.c++, which depends on dynamic.c++, which is allowed not to be linked in. Chris@47: Chris@47: template Chris@47: inline kj::StringTree structString(StructReader reader) { Chris@47: return structString(reader, rawBrandedSchema()); Chris@47: } Chris@47: template Chris@47: inline kj::String enumString(T value) { Chris@47: return enumString(static_cast(value), rawBrandedSchema()); Chris@47: } Chris@47: Chris@47: #endif // !CAPNP_LITE Chris@47: Chris@47: // TODO(cleanup): Unify ConstStruct and ConstList. Chris@47: template Chris@47: class ConstStruct { Chris@47: public: Chris@47: ConstStruct() = delete; Chris@47: KJ_DISALLOW_COPY(ConstStruct); Chris@47: inline explicit constexpr ConstStruct(const word* ptr): ptr(ptr) {} Chris@47: Chris@47: inline typename T::Reader get() const { Chris@47: return AnyPointer::Reader(PointerReader::getRootUnchecked(ptr)).getAs(); Chris@47: } Chris@47: Chris@47: inline operator typename T::Reader() const { return get(); } Chris@47: inline typename T::Reader operator*() const { return get(); } Chris@47: inline TemporaryPointer operator->() const { return get(); } Chris@47: Chris@47: private: Chris@47: const word* ptr; Chris@47: }; Chris@47: Chris@47: template Chris@47: class ConstList { Chris@47: public: Chris@47: ConstList() = delete; Chris@47: KJ_DISALLOW_COPY(ConstList); Chris@47: inline explicit constexpr ConstList(const word* ptr): ptr(ptr) {} Chris@47: Chris@47: inline typename List::Reader get() const { Chris@47: return AnyPointer::Reader(PointerReader::getRootUnchecked(ptr)).getAs>(); Chris@47: } Chris@47: Chris@47: inline operator typename List::Reader() const { return get(); } Chris@47: inline typename List::Reader operator*() const { return get(); } Chris@47: inline TemporaryPointer::Reader> operator->() const { return get(); } Chris@47: Chris@47: private: Chris@47: const word* ptr; Chris@47: }; Chris@47: Chris@47: template Chris@47: class ConstText { Chris@47: public: Chris@47: ConstText() = delete; Chris@47: KJ_DISALLOW_COPY(ConstText); Chris@47: inline explicit constexpr ConstText(const word* ptr): ptr(ptr) {} Chris@47: Chris@47: inline Text::Reader get() const { Chris@47: return Text::Reader(reinterpret_cast(ptr), size); Chris@47: } Chris@47: Chris@47: inline operator Text::Reader() const { return get(); } Chris@47: inline Text::Reader operator*() const { return get(); } Chris@47: inline TemporaryPointer operator->() const { return get(); } Chris@47: Chris@47: inline kj::StringPtr toString() const { Chris@47: return get(); Chris@47: } Chris@47: Chris@47: private: Chris@47: const word* ptr; Chris@47: }; Chris@47: Chris@47: template Chris@47: inline kj::StringPtr KJ_STRINGIFY(const ConstText& s) { Chris@47: return s.get(); Chris@47: } Chris@47: Chris@47: template Chris@47: class ConstData { Chris@47: public: Chris@47: ConstData() = delete; Chris@47: KJ_DISALLOW_COPY(ConstData); Chris@47: inline explicit constexpr ConstData(const word* ptr): ptr(ptr) {} Chris@47: Chris@47: inline Data::Reader get() const { Chris@47: return Data::Reader(reinterpret_cast(ptr), size); Chris@47: } Chris@47: Chris@47: inline operator Data::Reader() const { return get(); } Chris@47: inline Data::Reader operator*() const { return get(); } Chris@47: inline TemporaryPointer operator->() const { return get(); } Chris@47: Chris@47: private: Chris@47: const word* ptr; Chris@47: }; Chris@47: Chris@47: template Chris@47: inline auto KJ_STRINGIFY(const ConstData& s) -> decltype(kj::toCharSequence(s.get())) { Chris@47: return kj::toCharSequence(s.get()); Chris@47: } Chris@47: Chris@47: } // namespace _ (private) Chris@47: Chris@47: template Chris@47: inline constexpr uint64_t typeId() { return CapnpPrivate::typeId; } Chris@47: template ::typeId> Chris@47: inline constexpr uint64_t typeId() { return id; } Chris@47: // typeId() returns the type ID as defined in the schema. Works with structs, enums, and Chris@47: // interfaces. Chris@47: Chris@47: template Chris@47: inline constexpr uint sizeInWords() { Chris@47: // Return the size, in words, of a Struct type, if allocated free-standing (not in a list). Chris@47: // May be useful for pre-computing space needed in order to precisely allocate messages. Chris@47: Chris@47: return (WordCount32(_::structSize().data) + Chris@47: _::structSize().pointers * WORDS_PER_POINTER) / WORDS; Chris@47: } Chris@47: Chris@47: } // namespace capnp Chris@47: Chris@47: #if _MSC_VER Chris@47: // MSVC doesn't understand floating-point constexpr yet. Chris@47: // Chris@47: // TODO(msvc): Remove this hack when MSVC is fixed. Chris@47: #define CAPNP_NON_INT_CONSTEXPR_DECL_INIT(value) Chris@47: #define CAPNP_NON_INT_CONSTEXPR_DEF_INIT(value) = value Chris@47: #else Chris@47: #define CAPNP_NON_INT_CONSTEXPR_DECL_INIT(value) = value Chris@47: #define CAPNP_NON_INT_CONSTEXPR_DEF_INIT(value) Chris@47: #endif Chris@47: Chris@47: #if CAPNP_LITE Chris@47: Chris@47: #define CAPNP_DECLARE_SCHEMA(id) \ Chris@47: extern ::capnp::word const* const bp_##id Chris@47: Chris@47: #define CAPNP_DECLARE_ENUM(type, id) \ Chris@47: inline ::kj::String KJ_STRINGIFY(type##_##id value) { \ Chris@47: return ::kj::str(static_cast(value)); \ Chris@47: } \ Chris@47: template <> struct EnumInfo { \ Chris@47: struct IsEnum; \ Chris@47: static constexpr uint64_t typeId = 0x##id; \ Chris@47: static inline ::capnp::word const* encodedSchema() { return bp_##id; } \ Chris@47: } Chris@47: Chris@47: #if _MSC_VER Chris@47: // TODO(msvc): MSVC dosen't expect constexprs to have definitions. Chris@47: #define CAPNP_DEFINE_ENUM(type, id) Chris@47: #else Chris@47: #define CAPNP_DEFINE_ENUM(type, id) \ Chris@47: constexpr uint64_t EnumInfo::typeId Chris@47: #endif Chris@47: Chris@47: #define CAPNP_DECLARE_STRUCT_HEADER(id, dataWordSize_, pointerCount_) \ Chris@47: struct IsStruct; \ Chris@47: static constexpr uint64_t typeId = 0x##id; \ Chris@47: static constexpr uint16_t dataWordSize = dataWordSize_; \ Chris@47: static constexpr uint16_t pointerCount = pointerCount_; \ Chris@47: static inline ::capnp::word const* encodedSchema() { return ::capnp::schemas::bp_##id; } Chris@47: Chris@47: #else // CAPNP_LITE Chris@47: Chris@47: #define CAPNP_DECLARE_SCHEMA(id) \ Chris@47: extern ::capnp::word const* const bp_##id; \ Chris@47: extern const ::capnp::_::RawSchema s_##id Chris@47: Chris@47: #define CAPNP_DECLARE_ENUM(type, id) \ Chris@47: inline ::kj::String KJ_STRINGIFY(type##_##id value) { \ Chris@47: return ::capnp::_::enumString(value); \ Chris@47: } \ Chris@47: template <> struct EnumInfo { \ Chris@47: struct IsEnum; \ Chris@47: static constexpr uint64_t typeId = 0x##id; \ Chris@47: static inline ::capnp::word const* encodedSchema() { return bp_##id; } \ Chris@47: static constexpr ::capnp::_::RawSchema const* schema = &s_##id; \ Chris@47: } Chris@47: #define CAPNP_DEFINE_ENUM(type, id) \ Chris@47: constexpr uint64_t EnumInfo::typeId; \ Chris@47: constexpr ::capnp::_::RawSchema const* EnumInfo::schema Chris@47: Chris@47: #define CAPNP_DECLARE_STRUCT_HEADER(id, dataWordSize_, pointerCount_) \ Chris@47: struct IsStruct; \ Chris@47: static constexpr uint64_t typeId = 0x##id; \ Chris@47: static constexpr ::capnp::Kind kind = ::capnp::Kind::STRUCT; \ Chris@47: static constexpr uint16_t dataWordSize = dataWordSize_; \ Chris@47: static constexpr uint16_t pointerCount = pointerCount_; \ Chris@47: static inline ::capnp::word const* encodedSchema() { return ::capnp::schemas::bp_##id; } \ Chris@47: static constexpr ::capnp::_::RawSchema const* schema = &::capnp::schemas::s_##id; Chris@47: Chris@47: #define CAPNP_DECLARE_INTERFACE_HEADER(id) \ Chris@47: struct IsInterface; \ Chris@47: static constexpr uint64_t typeId = 0x##id; \ Chris@47: static constexpr ::capnp::Kind kind = ::capnp::Kind::INTERFACE; \ Chris@47: static inline ::capnp::word const* encodedSchema() { return ::capnp::schemas::bp_##id; } \ Chris@47: static constexpr ::capnp::_::RawSchema const* schema = &::capnp::schemas::s_##id; Chris@47: Chris@47: #endif // CAPNP_LITE, else Chris@47: Chris@47: #endif // CAPNP_GENERATED_HEADER_SUPPORT_H_