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