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