diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2023-08-16 12:29:23 -0400 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2023-08-18 11:44:00 -0400 |
commit | 9121fed4b4d02c286166373fe9805773afb13694 (patch) | |
tree | 195ec159fde2c2b2e81b8270101f2c37f38e097c /src/libexpr/value | |
parent | 284c18073233b3c7e7e027d696465a0e773dc881 (diff) |
Fixing #7479
Types converted:
- `NixStringContextElem`
- `OutputsSpec`
- `ExtendedOutputsSpec`
- `DerivationOutput`
- `DerivationType`
Existing ones mostly conforming the pattern cleaned up:
- `ContentAddressMethod`
- `ContentAddressWithReferences`
The `DerivationGoal::derivationType` field had a bogus initialization,
now caught, so I made it `std::optional`. I think #8829 can make it
non-optional again because it will ensure we always have the derivation
when we construct a `DerivationGoal`.
See that issue (#7479) for details on the general goal.
`git grep 'Raw::Raw'` indicates the two types I didn't yet convert
`DerivedPath` and `BuiltPath` (and their `Single` variants) . This is
because @roberth and I (can't find issue right now...) plan on reworking
them somewhat, so I didn't want to churn them more just yet.
Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
Diffstat (limited to 'src/libexpr/value')
-rw-r--r-- | src/libexpr/value/context.cc | 2 | ||||
-rw-r--r-- | src/libexpr/value/context.hh | 94 |
2 files changed, 42 insertions, 54 deletions
diff --git a/src/libexpr/value/context.cc b/src/libexpr/value/context.cc index d8116011e..22361d8fa 100644 --- a/src/libexpr/value/context.cc +++ b/src/libexpr/value/context.cc @@ -99,7 +99,7 @@ std::string NixStringContextElem::to_string() const res += '='; res += d.drvPath.to_string(); }, - }, raw()); + }, raw); return res; } diff --git a/src/libexpr/value/context.hh b/src/libexpr/value/context.hh index a1b71695b..9f1d59317 100644 --- a/src/libexpr/value/context.hh +++ b/src/libexpr/value/context.hh @@ -4,8 +4,7 @@ #include "util.hh" #include "comparator.hh" #include "derived-path.hh" - -#include <variant> +#include "variant-wrapper.hh" #include <nlohmann/json_fwd.hpp> @@ -26,58 +25,47 @@ public: } }; -/** - * Plain opaque path to some store object. - * - * Encoded as just the path: ‘<path>’. - */ -typedef SingleDerivedPath::Opaque NixStringContextElem_Opaque; - -/** - * Path to a derivation and its entire build closure. - * - * The path doesn't just refer to derivation itself and its closure, but - * also all outputs of all derivations in that closure (including the - * root derivation). - * - * Encoded in the form ‘=<drvPath>’. - */ -struct NixStringContextElem_DrvDeep { - StorePath drvPath; - - GENERATE_CMP(NixStringContextElem_DrvDeep, me->drvPath); -}; +struct NixStringContextElem { + /** + * Plain opaque path to some store object. + * + * Encoded as just the path: ‘<path>’. + */ + using Opaque = SingleDerivedPath::Opaque; -/** - * Derivation output. - * - * Encoded in the form ‘!<output>!<drvPath>’. - */ -typedef SingleDerivedPath::Built NixStringContextElem_Built; - -using _NixStringContextElem_Raw = std::variant< - NixStringContextElem_Opaque, - NixStringContextElem_DrvDeep, - NixStringContextElem_Built ->; - -struct NixStringContextElem : _NixStringContextElem_Raw { - using Raw = _NixStringContextElem_Raw; - using Raw::Raw; - - using Opaque = NixStringContextElem_Opaque; - using DrvDeep = NixStringContextElem_DrvDeep; - using Built = NixStringContextElem_Built; - - inline const Raw & raw() const & { - return static_cast<const Raw &>(*this); - } - inline Raw & raw() & { - return static_cast<Raw &>(*this); - } - inline Raw && raw() && { - return static_cast<Raw &&>(*this); - } + /** + * Path to a derivation and its entire build closure. + * + * The path doesn't just refer to derivation itself and its closure, but + * also all outputs of all derivations in that closure (including the + * root derivation). + * + * Encoded in the form ‘=<drvPath>’. + */ + struct DrvDeep { + StorePath drvPath; + + GENERATE_CMP(DrvDeep, me->drvPath); + }; + + /** + * Derivation output. + * + * Encoded in the form ‘!<output>!<drvPath>’. + */ + using Built = SingleDerivedPath::Built; + + using Raw = std::variant< + Opaque, + DrvDeep, + Built + >; + + Raw raw; + + GENERATE_CMP(NixStringContextElem, me->raw); + + MAKE_WRAPPER_CONSTRUCTOR(NixStringContextElem); /** * Decode a context string, one of: |