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