Commit 08a6b91f authored by Harris Hancock's avatar Harris Hancock

Convert brand-pointer to constexpr-function (3/3)

parent 1633318a
...@@ -32,9 +32,6 @@ ...@@ -32,9 +32,6 @@
namespace capnp { namespace capnp {
const _::RawBrandedSchema* const Capability::_capnpPrivate::brand =
&_::NULL_INTERFACE_SCHEMA.defaultBrand;
namespace _ { namespace _ {
void setGlobalBrokenCapFactoryForLayoutCpp(BrokenCapFactory& factory); void setGlobalBrokenCapFactoryForLayoutCpp(BrokenCapFactory& factory);
......
...@@ -82,11 +82,9 @@ struct Capability { ...@@ -82,11 +82,9 @@ struct Capability {
static constexpr Kind kind = Kind::INTERFACE; static constexpr Kind kind = Kind::INTERFACE;
static constexpr _::RawSchema const* schema = &_::NULL_INTERFACE_SCHEMA; static constexpr _::RawSchema const* schema = &_::NULL_INTERFACE_SCHEMA;
static const _::RawBrandedSchema* const brand; static const _::RawBrandedSchema* brand() {
// Can't quite declare this one inline without including generated-header-support.h. Avoiding return &_::NULL_INTERFACE_SCHEMA.defaultBrand;
// for now by declaring out-of-line. }
// TODO(cleanup): Split RawSchema stuff into its own header that can be included here, or
// something.
}; };
}; };
......
...@@ -63,7 +63,7 @@ inline const RawSchema& rawSchema() { ...@@ -63,7 +63,7 @@ inline const RawSchema& rawSchema() {
template <typename T, typename CapnpPrivate = typename T::_capnpPrivate> template <typename T, typename CapnpPrivate = typename T::_capnpPrivate>
inline const RawBrandedSchema& rawBrandedSchema() { inline const RawBrandedSchema& rawBrandedSchema() {
return *CapnpPrivate::brand; return *CapnpPrivate::brand();
} }
template <typename T, uint64_t id = schemas::EnumInfo<T>::typeId> template <typename T, uint64_t id = schemas::EnumInfo<T>::typeId>
inline const RawBrandedSchema& rawBrandedSchema() { inline const RawBrandedSchema& rawBrandedSchema() {
...@@ -78,7 +78,7 @@ struct ChooseBrand; ...@@ -78,7 +78,7 @@ struct ChooseBrand;
template <typename TypeTag> template <typename TypeTag>
struct ChooseBrand<TypeTag> { struct ChooseBrand<TypeTag> {
// All params were AnyPointer. No specific brand needed. // All params were AnyPointer. No specific brand needed.
static constexpr _::RawBrandedSchema const* brand = &TypeTag::schema->defaultBrand; static constexpr _::RawBrandedSchema const* brand() { return &TypeTag::schema->defaultBrand; }
}; };
template <typename TypeTag, typename... Rest> template <typename TypeTag, typename... Rest>
...@@ -88,7 +88,7 @@ struct ChooseBrand<TypeTag, AnyPointer, Rest...>: public ChooseBrand<TypeTag, Re ...@@ -88,7 +88,7 @@ struct ChooseBrand<TypeTag, AnyPointer, Rest...>: public ChooseBrand<TypeTag, Re
template <typename TypeTag, typename First, typename... Rest> template <typename TypeTag, typename First, typename... Rest>
struct ChooseBrand<TypeTag, First, Rest...> { struct ChooseBrand<TypeTag, First, Rest...> {
// At least one parameter is not AnyPointer, so use the specificBrand constant. // At least one parameter is not AnyPointer, so use the specificBrand constant.
static constexpr _::RawBrandedSchema const* brand = &TypeTag::specificBrand; static constexpr _::RawBrandedSchema const* brand() { return &TypeTag::specificBrand; }
}; };
template <typename T, Kind k = kind<T>()> template <typename T, Kind k = kind<T>()>
...@@ -146,14 +146,14 @@ struct BrandBindingFor_<T, Kind::ENUM> { ...@@ -146,14 +146,14 @@ struct BrandBindingFor_<T, Kind::ENUM> {
template <typename T> template <typename T>
struct BrandBindingFor_<T, Kind::STRUCT> { struct BrandBindingFor_<T, Kind::STRUCT> {
static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) { static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) {
return { 16, listDepth, T::_capnpPrivate::brand }; return { 16, listDepth, T::_capnpPrivate::brand() };
} }
}; };
template <typename T> template <typename T>
struct BrandBindingFor_<T, Kind::INTERFACE> { struct BrandBindingFor_<T, Kind::INTERFACE> {
static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) { static constexpr RawBrandedSchema::Binding get(uint16_t listDepth) {
return { 17, listDepth, T::_capnpPrivate::brand }; return { 17, listDepth, T::_capnpPrivate::brand() };
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment