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