mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 00:56:15 +02:00
Merge pull request #10838 from obsidiansystems/spaceship-no-comparator
Remove `comparator.hh` and switch to `<=>` in a bunch of places
This commit is contained in:
commit
db3e99d9d4
49 changed files with 300 additions and 271 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include "built-path.hh"
|
#include "built-path.hh"
|
||||||
#include "derivations.hh"
|
#include "derivations.hh"
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
|
#include "comparator.hh"
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
@ -8,30 +9,24 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
#define CMP_ONE(CHILD_TYPE, MY_TYPE, FIELD, COMPARATOR) \
|
// Custom implementation to avoid `ref` ptr equality
|
||||||
bool MY_TYPE ::operator COMPARATOR (const MY_TYPE & other) const \
|
GENERATE_CMP_EXT(
|
||||||
{ \
|
,
|
||||||
const MY_TYPE* me = this; \
|
std::strong_ordering,
|
||||||
auto fields1 = std::tie(*me->drvPath, me->FIELD); \
|
SingleBuiltPathBuilt,
|
||||||
me = &other; \
|
*me->drvPath,
|
||||||
auto fields2 = std::tie(*me->drvPath, me->FIELD); \
|
me->output);
|
||||||
return fields1 COMPARATOR fields2; \
|
|
||||||
}
|
|
||||||
#define CMP(CHILD_TYPE, MY_TYPE, FIELD) \
|
|
||||||
CMP_ONE(CHILD_TYPE, MY_TYPE, FIELD, ==) \
|
|
||||||
CMP_ONE(CHILD_TYPE, MY_TYPE, FIELD, !=) \
|
|
||||||
CMP_ONE(CHILD_TYPE, MY_TYPE, FIELD, <)
|
|
||||||
|
|
||||||
#define FIELD_TYPE std::pair<std::string, StorePath>
|
// Custom implementation to avoid `ref` ptr equality
|
||||||
CMP(SingleBuiltPath, SingleBuiltPathBuilt, output)
|
|
||||||
#undef FIELD_TYPE
|
|
||||||
|
|
||||||
#define FIELD_TYPE std::map<std::string, StorePath>
|
// TODO no `GENERATE_CMP_EXT` because no `std::set::operator<=>` on
|
||||||
CMP(SingleBuiltPath, BuiltPathBuilt, outputs)
|
// Darwin, per header.
|
||||||
#undef FIELD_TYPE
|
GENERATE_EQUAL(
|
||||||
|
,
|
||||||
#undef CMP
|
BuiltPathBuilt ::,
|
||||||
#undef CMP_ONE
|
BuiltPathBuilt,
|
||||||
|
*me->drvPath,
|
||||||
|
me->outputs);
|
||||||
|
|
||||||
StorePath SingleBuiltPath::outPath() const
|
StorePath SingleBuiltPath::outPath() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,7 +18,8 @@ struct SingleBuiltPathBuilt {
|
||||||
static SingleBuiltPathBuilt parse(const StoreDirConfig & store, std::string_view, std::string_view);
|
static SingleBuiltPathBuilt parse(const StoreDirConfig & store, std::string_view, std::string_view);
|
||||||
nlohmann::json toJSON(const StoreDirConfig & store) const;
|
nlohmann::json toJSON(const StoreDirConfig & store) const;
|
||||||
|
|
||||||
DECLARE_CMP(SingleBuiltPathBuilt);
|
bool operator ==(const SingleBuiltPathBuilt &) const noexcept;
|
||||||
|
std::strong_ordering operator <=>(const SingleBuiltPathBuilt &) const noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
using _SingleBuiltPathRaw = std::variant<
|
using _SingleBuiltPathRaw = std::variant<
|
||||||
|
@ -33,6 +34,9 @@ struct SingleBuiltPath : _SingleBuiltPathRaw {
|
||||||
using Opaque = DerivedPathOpaque;
|
using Opaque = DerivedPathOpaque;
|
||||||
using Built = SingleBuiltPathBuilt;
|
using Built = SingleBuiltPathBuilt;
|
||||||
|
|
||||||
|
bool operator == (const SingleBuiltPath &) const = default;
|
||||||
|
auto operator <=> (const SingleBuiltPath &) const = default;
|
||||||
|
|
||||||
inline const Raw & raw() const {
|
inline const Raw & raw() const {
|
||||||
return static_cast<const Raw &>(*this);
|
return static_cast<const Raw &>(*this);
|
||||||
}
|
}
|
||||||
|
@ -59,11 +63,13 @@ struct BuiltPathBuilt {
|
||||||
ref<SingleBuiltPath> drvPath;
|
ref<SingleBuiltPath> drvPath;
|
||||||
std::map<std::string, StorePath> outputs;
|
std::map<std::string, StorePath> outputs;
|
||||||
|
|
||||||
|
bool operator == (const BuiltPathBuilt &) const noexcept;
|
||||||
|
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
|
||||||
|
//std::strong_ordering operator <=> (const BuiltPathBuilt &) const noexcept;
|
||||||
|
|
||||||
std::string to_string(const StoreDirConfig & store) const;
|
std::string to_string(const StoreDirConfig & store) const;
|
||||||
static BuiltPathBuilt parse(const StoreDirConfig & store, std::string_view, std::string_view);
|
static BuiltPathBuilt parse(const StoreDirConfig & store, std::string_view, std::string_view);
|
||||||
nlohmann::json toJSON(const StoreDirConfig & store) const;
|
nlohmann::json toJSON(const StoreDirConfig & store) const;
|
||||||
|
|
||||||
DECLARE_CMP(BuiltPathBuilt);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
using _BuiltPathRaw = std::variant<
|
using _BuiltPathRaw = std::variant<
|
||||||
|
@ -82,6 +88,10 @@ struct BuiltPath : _BuiltPathRaw {
|
||||||
using Opaque = DerivedPathOpaque;
|
using Opaque = DerivedPathOpaque;
|
||||||
using Built = BuiltPathBuilt;
|
using Built = BuiltPathBuilt;
|
||||||
|
|
||||||
|
bool operator == (const BuiltPath &) const = default;
|
||||||
|
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
|
||||||
|
//auto operator <=> (const BuiltPath &) const = default;
|
||||||
|
|
||||||
inline const Raw & raw() const {
|
inline const Raw & raw() const {
|
||||||
return static_cast<const Raw &>(*this);
|
return static_cast<const Raw &>(*this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Compare to another value of the same type.
|
* Compare to another value of the same type.
|
||||||
*/
|
*/
|
||||||
virtual bool operator==(const ExternalValueBase & b) const override
|
virtual bool operator==(const ExternalValueBase & b) const noexcept override
|
||||||
{
|
{
|
||||||
if (!desc.equal) {
|
if (!desc.equal) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -27,9 +27,9 @@ struct Attr
|
||||||
Attr(Symbol name, Value * value, PosIdx pos = noPos)
|
Attr(Symbol name, Value * value, PosIdx pos = noPos)
|
||||||
: name(name), pos(pos), value(value) { };
|
: name(name), pos(pos), value(value) { };
|
||||||
Attr() { };
|
Attr() { };
|
||||||
bool operator < (const Attr & a) const
|
auto operator <=> (const Attr & a) const
|
||||||
{
|
{
|
||||||
return name < a.name;
|
return name <=> a.name;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2842,7 +2842,7 @@ std::string ExternalValueBase::coerceToString(EvalState & state, const PosIdx &
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ExternalValueBase::operator==(const ExternalValueBase & b) const
|
bool ExternalValueBase::operator==(const ExternalValueBase & b) const noexcept
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,20 +28,15 @@ public:
|
||||||
return id > 0;
|
return id > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator<(const PosIdx other) const
|
auto operator<=>(const PosIdx other) const
|
||||||
{
|
{
|
||||||
return id < other.id;
|
return id <=> other.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const PosIdx other) const
|
bool operator==(const PosIdx other) const
|
||||||
{
|
{
|
||||||
return id == other.id;
|
return id == other.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const PosIdx other) const
|
|
||||||
{
|
|
||||||
return id != other.id;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline PosIdx noPos = {};
|
inline PosIdx noPos = {};
|
||||||
|
|
|
@ -62,9 +62,8 @@ public:
|
||||||
|
|
||||||
explicit operator bool() const { return id > 0; }
|
explicit operator bool() const { return id > 0; }
|
||||||
|
|
||||||
bool operator<(const Symbol other) const { return id < other.id; }
|
auto operator<=>(const Symbol other) const { return id <=> other.id; }
|
||||||
bool operator==(const Symbol other) const { return id == other.id; }
|
bool operator==(const Symbol other) const { return id == other.id; }
|
||||||
bool operator!=(const Symbol other) const { return id != other.id; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -111,7 +111,7 @@ class ExternalValueBase
|
||||||
* Compare to another value of the same type. Defaults to uncomparable,
|
* Compare to another value of the same type. Defaults to uncomparable,
|
||||||
* i.e. always false.
|
* i.e. always false.
|
||||||
*/
|
*/
|
||||||
virtual bool operator ==(const ExternalValueBase & b) const;
|
virtual bool operator ==(const ExternalValueBase & b) const noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print the value as JSON. Defaults to unconvertable, i.e. throws an error
|
* Print the value as JSON. Defaults to unconvertable, i.e. throws an error
|
||||||
|
|
|
@ -150,7 +150,7 @@ Attrs Input::toAttrs() const
|
||||||
return attrs;
|
return attrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Input::operator ==(const Input & other) const
|
bool Input::operator ==(const Input & other) const noexcept
|
||||||
{
|
{
|
||||||
return attrs == other.attrs;
|
return attrs == other.attrs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ public:
|
||||||
*/
|
*/
|
||||||
bool isLocked() const;
|
bool isLocked() const;
|
||||||
|
|
||||||
bool operator ==(const Input & other) const;
|
bool operator ==(const Input & other) const noexcept;
|
||||||
|
|
||||||
bool contains(const Input & other) const;
|
bool contains(const Input & other) const;
|
||||||
|
|
||||||
|
|
|
@ -36,11 +36,6 @@ std::ostream & operator << (std::ostream & str, const FlakeRef & flakeRef)
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FlakeRef::operator ==(const FlakeRef & other) const
|
|
||||||
{
|
|
||||||
return input == other.input && subdir == other.subdir;
|
|
||||||
}
|
|
||||||
|
|
||||||
FlakeRef FlakeRef::resolve(ref<Store> store) const
|
FlakeRef FlakeRef::resolve(ref<Store> store) const
|
||||||
{
|
{
|
||||||
auto [input2, extraAttrs] = lookupInRegistries(store, input);
|
auto [input2, extraAttrs] = lookupInRegistries(store, input);
|
||||||
|
|
|
@ -46,7 +46,7 @@ struct FlakeRef
|
||||||
*/
|
*/
|
||||||
Path subdir;
|
Path subdir;
|
||||||
|
|
||||||
bool operator==(const FlakeRef & other) const;
|
bool operator ==(const FlakeRef & other) const = default;
|
||||||
|
|
||||||
FlakeRef(fetchers::Input && input, const Path & subdir)
|
FlakeRef(fetchers::Input && input, const Path & subdir)
|
||||||
: input(std::move(input)), subdir(subdir)
|
: input(std::move(input)), subdir(subdir)
|
||||||
|
|
|
@ -249,11 +249,6 @@ bool LockFile::operator ==(const LockFile & other) const
|
||||||
return toJSON().first == other.toJSON().first;
|
return toJSON().first == other.toJSON().first;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LockFile::operator !=(const LockFile & other) const
|
|
||||||
{
|
|
||||||
return !(*this == other);
|
|
||||||
}
|
|
||||||
|
|
||||||
InputPath parseInputPath(std::string_view s)
|
InputPath parseInputPath(std::string_view s)
|
||||||
{
|
{
|
||||||
InputPath path;
|
InputPath path;
|
||||||
|
|
|
@ -74,9 +74,6 @@ struct LockFile
|
||||||
std::optional<FlakeRef> isUnlocked() const;
|
std::optional<FlakeRef> isUnlocked() const;
|
||||||
|
|
||||||
bool operator ==(const LockFile & other) const;
|
bool operator ==(const LockFile & other) const;
|
||||||
// Needed for old gcc versions that don't synthesize it (like gcc 8.2.2
|
|
||||||
// that is still the default on aarch64-linux)
|
|
||||||
bool operator !=(const LockFile & other) const;
|
|
||||||
|
|
||||||
std::shared_ptr<Node> findInput(const InputPath & path);
|
std::shared_ptr<Node> findInput(const InputPath & path);
|
||||||
|
|
||||||
|
|
|
@ -2,17 +2,7 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
GENERATE_CMP_EXT(
|
bool BuildResult::operator==(const BuildResult &) const noexcept = default;
|
||||||
,
|
std::strong_ordering BuildResult::operator<=>(const BuildResult &) const noexcept = default;
|
||||||
BuildResult,
|
|
||||||
me->status,
|
|
||||||
me->errorMsg,
|
|
||||||
me->timesBuilt,
|
|
||||||
me->isNonDeterministic,
|
|
||||||
me->builtOutputs,
|
|
||||||
me->startTime,
|
|
||||||
me->stopTime,
|
|
||||||
me->cpuUser,
|
|
||||||
me->cpuSystem);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#include "realisation.hh"
|
#include "realisation.hh"
|
||||||
#include "derived-path.hh"
|
#include "derived-path.hh"
|
||||||
#include "comparator.hh"
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
@ -101,7 +100,8 @@ struct BuildResult
|
||||||
*/
|
*/
|
||||||
std::optional<std::chrono::microseconds> cpuUser, cpuSystem;
|
std::optional<std::chrono::microseconds> cpuUser, cpuSystem;
|
||||||
|
|
||||||
DECLARE_CMP(BuildResult);
|
bool operator ==(const BuildResult &) const noexcept;
|
||||||
|
std::strong_ordering operator <=>(const BuildResult &) const noexcept;
|
||||||
|
|
||||||
bool success()
|
bool success()
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,6 +73,7 @@ struct ContentAddressMethod
|
||||||
|
|
||||||
Raw raw;
|
Raw raw;
|
||||||
|
|
||||||
|
bool operator ==(const ContentAddressMethod &) const = default;
|
||||||
auto operator <=>(const ContentAddressMethod &) const = default;
|
auto operator <=>(const ContentAddressMethod &) const = default;
|
||||||
|
|
||||||
MAKE_WRAPPER_CONSTRUCTOR(ContentAddressMethod);
|
MAKE_WRAPPER_CONSTRUCTOR(ContentAddressMethod);
|
||||||
|
@ -159,6 +160,7 @@ struct ContentAddress
|
||||||
*/
|
*/
|
||||||
Hash hash;
|
Hash hash;
|
||||||
|
|
||||||
|
bool operator ==(const ContentAddress &) const = default;
|
||||||
auto operator <=>(const ContentAddress &) const = default;
|
auto operator <=>(const ContentAddress &) const = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -217,6 +219,10 @@ struct StoreReferences
|
||||||
* iff self is true.
|
* iff self is true.
|
||||||
*/
|
*/
|
||||||
size_t size() const;
|
size_t size() const;
|
||||||
|
|
||||||
|
bool operator ==(const StoreReferences &) const = default;
|
||||||
|
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
|
||||||
|
//auto operator <=>(const StoreReferences &) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This matches the additional info that we need for makeTextPath
|
// This matches the additional info that we need for makeTextPath
|
||||||
|
@ -232,6 +238,10 @@ struct TextInfo
|
||||||
* disallowed
|
* disallowed
|
||||||
*/
|
*/
|
||||||
StorePathSet references;
|
StorePathSet references;
|
||||||
|
|
||||||
|
bool operator ==(const TextInfo &) const = default;
|
||||||
|
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
|
||||||
|
//auto operator <=>(const TextInfo &) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FixedOutputInfo
|
struct FixedOutputInfo
|
||||||
|
@ -250,6 +260,10 @@ struct FixedOutputInfo
|
||||||
* References to other store objects or this one.
|
* References to other store objects or this one.
|
||||||
*/
|
*/
|
||||||
StoreReferences references;
|
StoreReferences references;
|
||||||
|
|
||||||
|
bool operator ==(const FixedOutputInfo &) const = default;
|
||||||
|
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
|
||||||
|
//auto operator <=>(const FixedOutputInfo &) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -266,6 +280,10 @@ struct ContentAddressWithReferences
|
||||||
|
|
||||||
Raw raw;
|
Raw raw;
|
||||||
|
|
||||||
|
bool operator ==(const ContentAddressWithReferences &) const = default;
|
||||||
|
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
|
||||||
|
//auto operator <=>(const ContentAddressWithReferences &) const = default;
|
||||||
|
|
||||||
MAKE_WRAPPER_CONSTRUCTOR(ContentAddressWithReferences);
|
MAKE_WRAPPER_CONSTRUCTOR(ContentAddressWithReferences);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include "repair-flag.hh"
|
#include "repair-flag.hh"
|
||||||
#include "derived-path-map.hh"
|
#include "derived-path-map.hh"
|
||||||
#include "sync.hh"
|
#include "sync.hh"
|
||||||
#include "comparator.hh"
|
|
||||||
#include "variant-wrapper.hh"
|
#include "variant-wrapper.hh"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -32,7 +31,8 @@ struct DerivationOutput
|
||||||
{
|
{
|
||||||
StorePath path;
|
StorePath path;
|
||||||
|
|
||||||
GENERATE_CMP(InputAddressed, me->path);
|
bool operator == (const InputAddressed &) const = default;
|
||||||
|
auto operator <=> (const InputAddressed &) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +56,8 @@ struct DerivationOutput
|
||||||
*/
|
*/
|
||||||
StorePath path(const StoreDirConfig & store, std::string_view drvName, OutputNameView outputName) const;
|
StorePath path(const StoreDirConfig & store, std::string_view drvName, OutputNameView outputName) const;
|
||||||
|
|
||||||
GENERATE_CMP(CAFixed, me->ca);
|
bool operator == (const CAFixed &) const = default;
|
||||||
|
auto operator <=> (const CAFixed &) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,7 +77,8 @@ struct DerivationOutput
|
||||||
*/
|
*/
|
||||||
HashAlgorithm hashAlgo;
|
HashAlgorithm hashAlgo;
|
||||||
|
|
||||||
GENERATE_CMP(CAFloating, me->method, me->hashAlgo);
|
bool operator == (const CAFloating &) const = default;
|
||||||
|
auto operator <=> (const CAFloating &) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,7 +86,8 @@ struct DerivationOutput
|
||||||
* isn't known yet.
|
* isn't known yet.
|
||||||
*/
|
*/
|
||||||
struct Deferred {
|
struct Deferred {
|
||||||
GENERATE_CMP(Deferred);
|
bool operator == (const Deferred &) const = default;
|
||||||
|
auto operator <=> (const Deferred &) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,7 +106,8 @@ struct DerivationOutput
|
||||||
*/
|
*/
|
||||||
HashAlgorithm hashAlgo;
|
HashAlgorithm hashAlgo;
|
||||||
|
|
||||||
GENERATE_CMP(Impure, me->method, me->hashAlgo);
|
bool operator == (const Impure &) const = default;
|
||||||
|
auto operator <=> (const Impure &) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::variant<
|
typedef std::variant<
|
||||||
|
@ -116,7 +120,8 @@ struct DerivationOutput
|
||||||
|
|
||||||
Raw raw;
|
Raw raw;
|
||||||
|
|
||||||
GENERATE_CMP(DerivationOutput, me->raw);
|
bool operator == (const DerivationOutput &) const = default;
|
||||||
|
auto operator <=> (const DerivationOutput &) const = default;
|
||||||
|
|
||||||
MAKE_WRAPPER_CONSTRUCTOR(DerivationOutput);
|
MAKE_WRAPPER_CONSTRUCTOR(DerivationOutput);
|
||||||
|
|
||||||
|
@ -177,7 +182,8 @@ struct DerivationType {
|
||||||
*/
|
*/
|
||||||
bool deferred;
|
bool deferred;
|
||||||
|
|
||||||
GENERATE_CMP(InputAddressed, me->deferred);
|
bool operator == (const InputAddressed &) const = default;
|
||||||
|
auto operator <=> (const InputAddressed &) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -201,7 +207,8 @@ struct DerivationType {
|
||||||
*/
|
*/
|
||||||
bool fixed;
|
bool fixed;
|
||||||
|
|
||||||
GENERATE_CMP(ContentAddressed, me->sandboxed, me->fixed);
|
bool operator == (const ContentAddressed &) const = default;
|
||||||
|
auto operator <=> (const ContentAddressed &) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -211,7 +218,8 @@ struct DerivationType {
|
||||||
* type, but has some restrictions on its usage.
|
* type, but has some restrictions on its usage.
|
||||||
*/
|
*/
|
||||||
struct Impure {
|
struct Impure {
|
||||||
GENERATE_CMP(Impure);
|
bool operator == (const Impure &) const = default;
|
||||||
|
auto operator <=> (const Impure &) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::variant<
|
typedef std::variant<
|
||||||
|
@ -222,7 +230,8 @@ struct DerivationType {
|
||||||
|
|
||||||
Raw raw;
|
Raw raw;
|
||||||
|
|
||||||
GENERATE_CMP(DerivationType, me->raw);
|
bool operator == (const DerivationType &) const = default;
|
||||||
|
auto operator <=> (const DerivationType &) const = default;
|
||||||
|
|
||||||
MAKE_WRAPPER_CONSTRUCTOR(DerivationType);
|
MAKE_WRAPPER_CONSTRUCTOR(DerivationType);
|
||||||
|
|
||||||
|
@ -312,14 +321,9 @@ struct BasicDerivation
|
||||||
|
|
||||||
static std::string_view nameFromPath(const StorePath & storePath);
|
static std::string_view nameFromPath(const StorePath & storePath);
|
||||||
|
|
||||||
GENERATE_CMP(BasicDerivation,
|
bool operator == (const BasicDerivation &) const = default;
|
||||||
me->outputs,
|
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
|
||||||
me->inputSrcs,
|
//auto operator <=> (const BasicDerivation &) const = default;
|
||||||
me->platform,
|
|
||||||
me->builder,
|
|
||||||
me->args,
|
|
||||||
me->env,
|
|
||||||
me->name);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Store;
|
class Store;
|
||||||
|
@ -377,9 +381,9 @@ struct Derivation : BasicDerivation
|
||||||
const nlohmann::json & json,
|
const nlohmann::json & json,
|
||||||
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
||||||
|
|
||||||
GENERATE_CMP(Derivation,
|
bool operator == (const Derivation &) const = default;
|
||||||
static_cast<const BasicDerivation &>(*me),
|
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
|
||||||
me->inputDrvs);
|
//auto operator <=> (const Derivation &) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,17 +54,18 @@ typename DerivedPathMap<V>::ChildNode * DerivedPathMap<V>::findSlot(const Single
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
GENERATE_CMP_EXT(
|
template<>
|
||||||
template<>,
|
bool DerivedPathMap<std::set<std::string>>::ChildNode::operator == (
|
||||||
DerivedPathMap<std::set<std::string>>::ChildNode,
|
const DerivedPathMap<std::set<std::string>>::ChildNode &) const noexcept = default;
|
||||||
me->value,
|
|
||||||
me->childMap);
|
|
||||||
|
|
||||||
GENERATE_CMP_EXT(
|
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
|
||||||
template<>,
|
#if 0
|
||||||
DerivedPathMap<std::set<std::string>>,
|
template<>
|
||||||
me->map);
|
std::strong_ordering DerivedPathMap<std::set<std::string>>::ChildNode::operator <=> (
|
||||||
|
const DerivedPathMap<std::set<std::string>>::ChildNode &) const noexcept = default;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template struct DerivedPathMap<std::set<std::string>>::ChildNode;
|
||||||
template struct DerivedPathMap<std::set<std::string>>;
|
template struct DerivedPathMap<std::set<std::string>>;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,7 +47,11 @@ struct DerivedPathMap {
|
||||||
*/
|
*/
|
||||||
Map childMap;
|
Map childMap;
|
||||||
|
|
||||||
DECLARE_CMP(ChildNode);
|
bool operator == (const ChildNode &) const noexcept;
|
||||||
|
|
||||||
|
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
|
||||||
|
// decltype(std::declval<V>() <=> std::declval<V>())
|
||||||
|
// operator <=> (const ChildNode &) const noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +64,10 @@ struct DerivedPathMap {
|
||||||
*/
|
*/
|
||||||
Map map;
|
Map map;
|
||||||
|
|
||||||
DECLARE_CMP(DerivedPathMap);
|
bool operator == (const DerivedPathMap &) const = default;
|
||||||
|
|
||||||
|
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
|
||||||
|
// auto operator <=> (const DerivedPathMap &) const noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the node for `k`, creating it if needed.
|
* Find the node for `k`, creating it if needed.
|
||||||
|
@ -83,14 +90,21 @@ struct DerivedPathMap {
|
||||||
ChildNode * findSlot(const SingleDerivedPath & k);
|
ChildNode * findSlot(const SingleDerivedPath & k);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
bool DerivedPathMap<std::set<std::string>>::ChildNode::operator == (
|
||||||
|
const DerivedPathMap<std::set<std::string>>::ChildNode &) const noexcept;
|
||||||
|
|
||||||
DECLARE_CMP_EXT(
|
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
|
||||||
template<>,
|
#if 0
|
||||||
DerivedPathMap<std::set<std::string>>::,
|
template<>
|
||||||
DerivedPathMap<std::set<std::string>>);
|
std::strong_ordering DerivedPathMap<std::set<std::string>>::ChildNode::operator <=> (
|
||||||
DECLARE_CMP_EXT(
|
const DerivedPathMap<std::set<std::string>>::ChildNode &) const noexcept;
|
||||||
template<>,
|
|
||||||
DerivedPathMap<std::set<std::string>>::ChildNode::,
|
template<>
|
||||||
DerivedPathMap<std::set<std::string>>::ChildNode);
|
inline auto DerivedPathMap<std::set<std::string>>::operator <=> (const DerivedPathMap<std::set<std::string>> &) const noexcept = default;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern template struct DerivedPathMap<std::set<std::string>>::ChildNode;
|
||||||
|
extern template struct DerivedPathMap<std::set<std::string>>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "derived-path.hh"
|
#include "derived-path.hh"
|
||||||
#include "derivations.hh"
|
#include "derivations.hh"
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
|
#include "comparator.hh"
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
|
@ -8,26 +9,32 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
#define CMP_ONE(CHILD_TYPE, MY_TYPE, FIELD, COMPARATOR) \
|
// Custom implementation to avoid `ref` ptr equality
|
||||||
bool MY_TYPE ::operator COMPARATOR (const MY_TYPE & other) const \
|
GENERATE_CMP_EXT(
|
||||||
{ \
|
,
|
||||||
const MY_TYPE* me = this; \
|
std::strong_ordering,
|
||||||
auto fields1 = std::tie(*me->drvPath, me->FIELD); \
|
SingleDerivedPathBuilt,
|
||||||
me = &other; \
|
*me->drvPath,
|
||||||
auto fields2 = std::tie(*me->drvPath, me->FIELD); \
|
me->output);
|
||||||
return fields1 COMPARATOR fields2; \
|
|
||||||
}
|
|
||||||
#define CMP(CHILD_TYPE, MY_TYPE, FIELD) \
|
|
||||||
CMP_ONE(CHILD_TYPE, MY_TYPE, FIELD, ==) \
|
|
||||||
CMP_ONE(CHILD_TYPE, MY_TYPE, FIELD, !=) \
|
|
||||||
CMP_ONE(CHILD_TYPE, MY_TYPE, FIELD, <)
|
|
||||||
|
|
||||||
CMP(SingleDerivedPath, SingleDerivedPathBuilt, output)
|
// Custom implementation to avoid `ref` ptr equality
|
||||||
|
|
||||||
CMP(SingleDerivedPath, DerivedPathBuilt, outputs)
|
// TODO no `GENERATE_CMP_EXT` because no `std::set::operator<=>` on
|
||||||
|
// Darwin, per header.
|
||||||
#undef CMP
|
GENERATE_EQUAL(
|
||||||
#undef CMP_ONE
|
,
|
||||||
|
DerivedPathBuilt ::,
|
||||||
|
DerivedPathBuilt,
|
||||||
|
*me->drvPath,
|
||||||
|
me->outputs);
|
||||||
|
GENERATE_ONE_CMP(
|
||||||
|
,
|
||||||
|
bool,
|
||||||
|
DerivedPathBuilt ::,
|
||||||
|
<,
|
||||||
|
DerivedPathBuilt,
|
||||||
|
*me->drvPath,
|
||||||
|
me->outputs);
|
||||||
|
|
||||||
nlohmann::json DerivedPath::Opaque::toJSON(const StoreDirConfig & store) const
|
nlohmann::json DerivedPath::Opaque::toJSON(const StoreDirConfig & store) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#include "path.hh"
|
#include "path.hh"
|
||||||
#include "outputs-spec.hh"
|
#include "outputs-spec.hh"
|
||||||
#include "comparator.hh"
|
|
||||||
#include "config.hh"
|
#include "config.hh"
|
||||||
#include "ref.hh"
|
#include "ref.hh"
|
||||||
|
|
||||||
|
@ -32,7 +31,8 @@ struct DerivedPathOpaque {
|
||||||
static DerivedPathOpaque parse(const StoreDirConfig & store, std::string_view);
|
static DerivedPathOpaque parse(const StoreDirConfig & store, std::string_view);
|
||||||
nlohmann::json toJSON(const StoreDirConfig & store) const;
|
nlohmann::json toJSON(const StoreDirConfig & store) const;
|
||||||
|
|
||||||
GENERATE_CMP(DerivedPathOpaque, me->path);
|
bool operator == (const DerivedPathOpaque &) const = default;
|
||||||
|
auto operator <=> (const DerivedPathOpaque &) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SingleDerivedPath;
|
struct SingleDerivedPath;
|
||||||
|
@ -79,7 +79,8 @@ struct SingleDerivedPathBuilt {
|
||||||
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
||||||
nlohmann::json toJSON(Store & store) const;
|
nlohmann::json toJSON(Store & store) const;
|
||||||
|
|
||||||
DECLARE_CMP(SingleDerivedPathBuilt);
|
bool operator == (const SingleDerivedPathBuilt &) const noexcept;
|
||||||
|
std::strong_ordering operator <=> (const SingleDerivedPathBuilt &) const noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
using _SingleDerivedPathRaw = std::variant<
|
using _SingleDerivedPathRaw = std::variant<
|
||||||
|
@ -109,6 +110,9 @@ struct SingleDerivedPath : _SingleDerivedPathRaw {
|
||||||
return static_cast<const Raw &>(*this);
|
return static_cast<const Raw &>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator == (const SingleDerivedPath &) const = default;
|
||||||
|
auto operator <=> (const SingleDerivedPath &) const = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the store path this is ultimately derived from (by realising
|
* Get the store path this is ultimately derived from (by realising
|
||||||
* and projecting outputs).
|
* and projecting outputs).
|
||||||
|
@ -202,7 +206,9 @@ struct DerivedPathBuilt {
|
||||||
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
|
||||||
nlohmann::json toJSON(Store & store) const;
|
nlohmann::json toJSON(Store & store) const;
|
||||||
|
|
||||||
DECLARE_CMP(DerivedPathBuilt);
|
bool operator == (const DerivedPathBuilt &) const noexcept;
|
||||||
|
// TODO libc++ 16 (used by darwin) missing `std::set::operator <=>`, can't do yet.
|
||||||
|
bool operator < (const DerivedPathBuilt &) const noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
using _DerivedPathRaw = std::variant<
|
using _DerivedPathRaw = std::variant<
|
||||||
|
@ -231,6 +237,10 @@ struct DerivedPath : _DerivedPathRaw {
|
||||||
return static_cast<const Raw &>(*this);
|
return static_cast<const Raw &>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator == (const DerivedPath &) const = default;
|
||||||
|
// TODO libc++ 16 (used by darwin) missing `std::set::operator <=>`, can't do yet.
|
||||||
|
//auto operator <=> (const DerivedPath &) const = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the store path this is ultimately derived from (by realising
|
* Get the store path this is ultimately derived from (by realising
|
||||||
* and projecting outputs).
|
* and projecting outputs).
|
||||||
|
|
|
@ -4,15 +4,6 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
GENERATE_CMP_EXT(
|
|
||||||
,
|
|
||||||
NarInfo,
|
|
||||||
me->url,
|
|
||||||
me->compression,
|
|
||||||
me->fileHash,
|
|
||||||
me->fileSize,
|
|
||||||
static_cast<const ValidPathInfo &>(*me));
|
|
||||||
|
|
||||||
NarInfo::NarInfo(const Store & store, const std::string & s, const std::string & whence)
|
NarInfo::NarInfo(const Store & store, const std::string & s, const std::string & whence)
|
||||||
: ValidPathInfo(StorePath(StorePath::dummy), Hash(Hash::dummy)) // FIXME: hack
|
: ValidPathInfo(StorePath(StorePath::dummy), Hash(Hash::dummy)) // FIXME: hack
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,7 +24,9 @@ struct NarInfo : ValidPathInfo
|
||||||
NarInfo(const ValidPathInfo & info) : ValidPathInfo(info) { }
|
NarInfo(const ValidPathInfo & info) : ValidPathInfo(info) { }
|
||||||
NarInfo(const Store & store, const std::string & s, const std::string & whence);
|
NarInfo(const Store & store, const std::string & s, const std::string & whence);
|
||||||
|
|
||||||
DECLARE_CMP(NarInfo);
|
bool operator ==(const NarInfo &) const = default;
|
||||||
|
// TODO libc++ 16 (used by darwin) missing `std::optional::operator <=>`, can't do yet
|
||||||
|
//auto operator <=>(const NarInfo &) const = default;
|
||||||
|
|
||||||
std::string to_string(const Store & store) const;
|
std::string to_string(const Store & store) const;
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,7 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
#include "comparator.hh"
|
|
||||||
#include "json-impls.hh"
|
#include "json-impls.hh"
|
||||||
#include "comparator.hh"
|
|
||||||
#include "variant-wrapper.hh"
|
#include "variant-wrapper.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
@ -60,7 +58,11 @@ struct OutputsSpec {
|
||||||
|
|
||||||
Raw raw;
|
Raw raw;
|
||||||
|
|
||||||
GENERATE_CMP(OutputsSpec, me->raw);
|
bool operator == (const OutputsSpec &) const = default;
|
||||||
|
// TODO libc++ 16 (used by darwin) missing `std::set::operator <=>`, can't do yet.
|
||||||
|
bool operator < (const OutputsSpec & other) const {
|
||||||
|
return raw < other.raw;
|
||||||
|
}
|
||||||
|
|
||||||
MAKE_WRAPPER_CONSTRUCTOR(OutputsSpec);
|
MAKE_WRAPPER_CONSTRUCTOR(OutputsSpec);
|
||||||
|
|
||||||
|
@ -99,7 +101,9 @@ struct ExtendedOutputsSpec {
|
||||||
|
|
||||||
Raw raw;
|
Raw raw;
|
||||||
|
|
||||||
GENERATE_CMP(ExtendedOutputsSpec, me->raw);
|
bool operator == (const ExtendedOutputsSpec &) const = default;
|
||||||
|
// TODO libc++ 16 (used by darwin) missing `std::set::operator <=>`, can't do yet.
|
||||||
|
bool operator < (const ExtendedOutputsSpec &) const;
|
||||||
|
|
||||||
MAKE_WRAPPER_CONSTRUCTOR(ExtendedOutputsSpec);
|
MAKE_WRAPPER_CONSTRUCTOR(ExtendedOutputsSpec);
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,13 @@
|
||||||
#include "path-info.hh"
|
#include "path-info.hh"
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
#include "json-utils.hh"
|
#include "json-utils.hh"
|
||||||
|
#include "comparator.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
GENERATE_CMP_EXT(
|
GENERATE_CMP_EXT(
|
||||||
,
|
,
|
||||||
|
std::weak_ordering,
|
||||||
UnkeyedValidPathInfo,
|
UnkeyedValidPathInfo,
|
||||||
me->deriver,
|
me->deriver,
|
||||||
me->narHash,
|
me->narHash,
|
||||||
|
@ -19,12 +21,6 @@ GENERATE_CMP_EXT(
|
||||||
me->sigs,
|
me->sigs,
|
||||||
me->ca);
|
me->ca);
|
||||||
|
|
||||||
GENERATE_CMP_EXT(
|
|
||||||
,
|
|
||||||
ValidPathInfo,
|
|
||||||
me->path,
|
|
||||||
static_cast<const UnkeyedValidPathInfo &>(*me));
|
|
||||||
|
|
||||||
std::string ValidPathInfo::fingerprint(const Store & store) const
|
std::string ValidPathInfo::fingerprint(const Store & store) const
|
||||||
{
|
{
|
||||||
if (narSize == 0)
|
if (narSize == 0)
|
||||||
|
|
|
@ -32,17 +32,47 @@ struct SubstitutablePathInfo
|
||||||
using SubstitutablePathInfos = std::map<StorePath, SubstitutablePathInfo>;
|
using SubstitutablePathInfos = std::map<StorePath, SubstitutablePathInfo>;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information about a store object.
|
||||||
|
*
|
||||||
|
* See `store/store-object` and `protocols/json/store-object-info` in
|
||||||
|
* the Nix manual
|
||||||
|
*/
|
||||||
struct UnkeyedValidPathInfo
|
struct UnkeyedValidPathInfo
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Path to derivation that produced this store object, if known.
|
||||||
|
*/
|
||||||
std::optional<StorePath> deriver;
|
std::optional<StorePath> deriver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \todo document this
|
* \todo document this
|
||||||
*/
|
*/
|
||||||
Hash narHash;
|
Hash narHash;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Other store objects this store object referes to.
|
||||||
|
*/
|
||||||
StorePathSet references;
|
StorePathSet references;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When this store object was registered in the store that contains
|
||||||
|
* it, if known.
|
||||||
|
*/
|
||||||
time_t registrationTime = 0;
|
time_t registrationTime = 0;
|
||||||
uint64_t narSize = 0; // 0 = unknown
|
|
||||||
uint64_t id = 0; // internal use only
|
/**
|
||||||
|
* 0 = unknown
|
||||||
|
*/
|
||||||
|
uint64_t narSize = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* internal use only: SQL primary key for on-disk store objects with
|
||||||
|
* `LocalStore`.
|
||||||
|
*
|
||||||
|
* @todo Remove, layer violation
|
||||||
|
*/
|
||||||
|
uint64_t id = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the path is ultimately trusted, that is, it's a
|
* Whether the path is ultimately trusted, that is, it's a
|
||||||
|
@ -75,7 +105,12 @@ struct UnkeyedValidPathInfo
|
||||||
|
|
||||||
UnkeyedValidPathInfo(Hash narHash) : narHash(narHash) { };
|
UnkeyedValidPathInfo(Hash narHash) : narHash(narHash) { };
|
||||||
|
|
||||||
DECLARE_CMP(UnkeyedValidPathInfo);
|
bool operator == (const UnkeyedValidPathInfo &) const noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo return `std::strong_ordering` once `id` is removed
|
||||||
|
*/
|
||||||
|
std::weak_ordering operator <=> (const UnkeyedValidPathInfo &) const noexcept;
|
||||||
|
|
||||||
virtual ~UnkeyedValidPathInfo() { }
|
virtual ~UnkeyedValidPathInfo() { }
|
||||||
|
|
||||||
|
@ -95,7 +130,8 @@ struct UnkeyedValidPathInfo
|
||||||
struct ValidPathInfo : UnkeyedValidPathInfo {
|
struct ValidPathInfo : UnkeyedValidPathInfo {
|
||||||
StorePath path;
|
StorePath path;
|
||||||
|
|
||||||
DECLARE_CMP(ValidPathInfo);
|
bool operator == (const ValidPathInfo &) const = default;
|
||||||
|
auto operator <=> (const ValidPathInfo &) const = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a fingerprint of the store path to be used in binary
|
* Return a fingerprint of the store path to be used in binary
|
||||||
|
|
|
@ -57,8 +57,7 @@ void Completions::add(std::string completion, std::string description)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Completion::operator<(const Completion & other) const
|
auto Completion::operator<=>(const Completion & other) const noexcept = default;
|
||||||
{ return completion < other.completion || (completion == other.completion && description < other.description); }
|
|
||||||
|
|
||||||
std::string completionMarker = "___COMPLETE___";
|
std::string completionMarker = "___COMPLETE___";
|
||||||
|
|
||||||
|
|
|
@ -380,7 +380,7 @@ struct Completion {
|
||||||
std::string completion;
|
std::string completion;
|
||||||
std::string description;
|
std::string description;
|
||||||
|
|
||||||
bool operator<(const Completion & other) const;
|
auto operator<=>(const Completion & other) const noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -169,7 +169,7 @@ public:
|
||||||
* a directory is always followed directly by its children. For
|
* a directory is always followed directly by its children. For
|
||||||
* instance, 'foo' < 'foo/bar' < 'foo!'.
|
* instance, 'foo' < 'foo/bar' < 'foo!'.
|
||||||
*/
|
*/
|
||||||
bool operator < (const CanonPath & x) const
|
auto operator <=> (const CanonPath & x) const
|
||||||
{
|
{
|
||||||
auto i = path.begin();
|
auto i = path.begin();
|
||||||
auto j = x.path.begin();
|
auto j = x.path.begin();
|
||||||
|
@ -178,10 +178,9 @@ public:
|
||||||
if (c_i == '/') c_i = 0;
|
if (c_i == '/') c_i = 0;
|
||||||
auto c_j = *j;
|
auto c_j = *j;
|
||||||
if (c_j == '/') c_j = 0;
|
if (c_j == '/') c_j = 0;
|
||||||
if (c_i < c_j) return true;
|
if (auto cmp = c_i <=> c_j; cmp != 0) return cmp;
|
||||||
if (c_i > c_j) return false;
|
|
||||||
}
|
}
|
||||||
return i == path.end() && j != x.path.end();
|
return (i != path.end()) <=> (j != x.path.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,17 +1,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
///@file
|
///@file
|
||||||
|
|
||||||
#define DECLARE_ONE_CMP(PRE, QUAL, COMPARATOR, MY_TYPE) \
|
#define GENERATE_ONE_CMP(PRE, RET, QUAL, COMPARATOR, MY_TYPE, ...) \
|
||||||
PRE bool QUAL operator COMPARATOR(const MY_TYPE & other) const;
|
PRE RET QUAL operator COMPARATOR(const MY_TYPE & other) const noexcept { \
|
||||||
#define DECLARE_EQUAL(prefix, qualification, my_type) \
|
|
||||||
DECLARE_ONE_CMP(prefix, qualification, ==, my_type)
|
|
||||||
#define DECLARE_LEQ(prefix, qualification, my_type) \
|
|
||||||
DECLARE_ONE_CMP(prefix, qualification, <, my_type)
|
|
||||||
#define DECLARE_NEQ(prefix, qualification, my_type) \
|
|
||||||
DECLARE_ONE_CMP(prefix, qualification, !=, my_type)
|
|
||||||
|
|
||||||
#define GENERATE_ONE_CMP(PRE, QUAL, COMPARATOR, MY_TYPE, ...) \
|
|
||||||
PRE bool QUAL operator COMPARATOR(const MY_TYPE & other) const { \
|
|
||||||
__VA_OPT__(const MY_TYPE * me = this;) \
|
__VA_OPT__(const MY_TYPE * me = this;) \
|
||||||
auto fields1 = std::tie( __VA_ARGS__ ); \
|
auto fields1 = std::tie( __VA_ARGS__ ); \
|
||||||
__VA_OPT__(me = &other;) \
|
__VA_OPT__(me = &other;) \
|
||||||
|
@ -19,30 +10,9 @@
|
||||||
return fields1 COMPARATOR fields2; \
|
return fields1 COMPARATOR fields2; \
|
||||||
}
|
}
|
||||||
#define GENERATE_EQUAL(prefix, qualification, my_type, args...) \
|
#define GENERATE_EQUAL(prefix, qualification, my_type, args...) \
|
||||||
GENERATE_ONE_CMP(prefix, qualification, ==, my_type, args)
|
GENERATE_ONE_CMP(prefix, bool, qualification, ==, my_type, args)
|
||||||
#define GENERATE_LEQ(prefix, qualification, my_type, args...) \
|
#define GENERATE_SPACESHIP(prefix, ret, qualification, my_type, args...) \
|
||||||
GENERATE_ONE_CMP(prefix, qualification, <, my_type, args)
|
GENERATE_ONE_CMP(prefix, ret, qualification, <=>, my_type, args)
|
||||||
#define GENERATE_NEQ(prefix, qualification, my_type, args...) \
|
|
||||||
GENERATE_ONE_CMP(prefix, qualification, !=, my_type, args)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Declare comparison methods without defining them.
|
|
||||||
*/
|
|
||||||
#define DECLARE_CMP(my_type) \
|
|
||||||
DECLARE_EQUAL(,,my_type) \
|
|
||||||
DECLARE_LEQ(,,my_type) \
|
|
||||||
DECLARE_NEQ(,,my_type)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param prefix This is for something before each declaration like
|
|
||||||
* `template<classname Foo>`.
|
|
||||||
*
|
|
||||||
* @param my_type the type are defining operators for.
|
|
||||||
*/
|
|
||||||
#define DECLARE_CMP_EXT(prefix, qualification, my_type) \
|
|
||||||
DECLARE_EQUAL(prefix, qualification, my_type) \
|
|
||||||
DECLARE_LEQ(prefix, qualification, my_type) \
|
|
||||||
DECLARE_NEQ(prefix, qualification, my_type)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Awful hacky generation of the comparison operators by doing a lexicographic
|
* Awful hacky generation of the comparison operators by doing a lexicographic
|
||||||
|
@ -55,15 +25,19 @@
|
||||||
* will generate comparison operators semantically equivalent to:
|
* will generate comparison operators semantically equivalent to:
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* bool operator<(const ClassName& other) {
|
* auto operator<=>(const ClassName& other) const noexcept {
|
||||||
* return field1 < other.field1 && field2 < other.field2 && ...;
|
* if (auto cmp = field1 <=> other.field1; cmp != 0)
|
||||||
|
* return cmp;
|
||||||
|
* if (auto cmp = field2 <=> other.field2; cmp != 0)
|
||||||
|
* return cmp;
|
||||||
|
* ...
|
||||||
|
* return 0;
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
#define GENERATE_CMP(args...) \
|
#define GENERATE_CMP(args...) \
|
||||||
GENERATE_EQUAL(,,args) \
|
GENERATE_EQUAL(,,args) \
|
||||||
GENERATE_LEQ(,,args) \
|
GENERATE_SPACESHIP(,auto,,args)
|
||||||
GENERATE_NEQ(,,args)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param prefix This is for something before each declaration like
|
* @param prefix This is for something before each declaration like
|
||||||
|
@ -71,7 +45,6 @@
|
||||||
*
|
*
|
||||||
* @param my_type the type are defining operators for.
|
* @param my_type the type are defining operators for.
|
||||||
*/
|
*/
|
||||||
#define GENERATE_CMP_EXT(prefix, my_type, args...) \
|
#define GENERATE_CMP_EXT(prefix, ret, my_type, args...) \
|
||||||
GENERATE_EQUAL(prefix, my_type ::, my_type, args) \
|
GENERATE_EQUAL(prefix, my_type ::, my_type, args) \
|
||||||
GENERATE_LEQ(prefix, my_type ::, my_type, args) \
|
GENERATE_SPACESHIP(prefix, ret, my_type ::, my_type, args)
|
||||||
GENERATE_NEQ(prefix, my_type ::, my_type, args)
|
|
||||||
|
|
|
@ -46,27 +46,22 @@ std::ostream & operator <<(std::ostream & os, const HintFmt & hf)
|
||||||
/**
|
/**
|
||||||
* An arbitrarily defined value comparison for the purpose of using traces in the key of a sorted container.
|
* An arbitrarily defined value comparison for the purpose of using traces in the key of a sorted container.
|
||||||
*/
|
*/
|
||||||
inline bool operator<(const Trace& lhs, const Trace& rhs)
|
inline std::strong_ordering operator<=>(const Trace& lhs, const Trace& rhs)
|
||||||
{
|
{
|
||||||
// `std::shared_ptr` does not have value semantics for its comparison
|
// `std::shared_ptr` does not have value semantics for its comparison
|
||||||
// functions, so we need to check for nulls and compare the dereferenced
|
// functions, so we need to check for nulls and compare the dereferenced
|
||||||
// values here.
|
// values here.
|
||||||
if (lhs.pos != rhs.pos) {
|
if (lhs.pos != rhs.pos) {
|
||||||
if (!lhs.pos)
|
if (auto cmp = bool{lhs.pos} <=> bool{rhs.pos}; cmp != 0)
|
||||||
return true;
|
return cmp;
|
||||||
if (!rhs.pos)
|
if (auto cmp = *lhs.pos <=> *rhs.pos; cmp != 0)
|
||||||
return false;
|
return cmp;
|
||||||
if (*lhs.pos != *rhs.pos)
|
|
||||||
return *lhs.pos < *rhs.pos;
|
|
||||||
}
|
}
|
||||||
// This formats a freshly formatted hint string and then throws it away, which
|
// This formats a freshly formatted hint string and then throws it away, which
|
||||||
// shouldn't be much of a problem because it only runs when pos is equal, and this function is
|
// shouldn't be much of a problem because it only runs when pos is equal, and this function is
|
||||||
// used for trace printing, which is infrequent.
|
// used for trace printing, which is infrequent.
|
||||||
return lhs.hint.str() < rhs.hint.str();
|
return lhs.hint.str() <=> rhs.hint.str();
|
||||||
}
|
}
|
||||||
inline bool operator> (const Trace& lhs, const Trace& rhs) { return rhs < lhs; }
|
|
||||||
inline bool operator<=(const Trace& lhs, const Trace& rhs) { return !(lhs > rhs); }
|
|
||||||
inline bool operator>=(const Trace& lhs, const Trace& rhs) { return !(lhs < rhs); }
|
|
||||||
|
|
||||||
// print lines of code to the ostream, indicating the error column.
|
// print lines of code to the ostream, indicating the error column.
|
||||||
void printCodeLines(std::ostream & out,
|
void printCodeLines(std::ostream & out,
|
||||||
|
|
|
@ -75,10 +75,7 @@ struct Trace {
|
||||||
TracePrint print = TracePrint::Default;
|
TracePrint print = TracePrint::Default;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool operator<(const Trace& lhs, const Trace& rhs);
|
inline std::strong_ordering operator<=>(const Trace& lhs, const Trace& rhs);
|
||||||
inline bool operator> (const Trace& lhs, const Trace& rhs);
|
|
||||||
inline bool operator<=(const Trace& lhs, const Trace& rhs);
|
|
||||||
inline bool operator>=(const Trace& lhs, const Trace& rhs);
|
|
||||||
|
|
||||||
struct ErrorInfo {
|
struct ErrorInfo {
|
||||||
Verbosity level;
|
Verbosity level;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
///@file
|
///@file
|
||||||
|
|
||||||
#include "comparator.hh"
|
|
||||||
#include "error.hh"
|
#include "error.hh"
|
||||||
#include "json-utils.hh"
|
#include "json-utils.hh"
|
||||||
#include "types.hh"
|
#include "types.hh"
|
||||||
|
|
|
@ -39,7 +39,8 @@ struct TreeEntry
|
||||||
Mode mode;
|
Mode mode;
|
||||||
Hash hash;
|
Hash hash;
|
||||||
|
|
||||||
GENERATE_CMP(TreeEntry, me->mode, me->hash);
|
bool operator ==(const TreeEntry &) const = default;
|
||||||
|
auto operator <=>(const TreeEntry &) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,7 +41,7 @@ Hash::Hash(HashAlgorithm algo) : algo(algo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Hash::operator == (const Hash & h2) const
|
bool Hash::operator == (const Hash & h2) const noexcept
|
||||||
{
|
{
|
||||||
if (hashSize != h2.hashSize) return false;
|
if (hashSize != h2.hashSize) return false;
|
||||||
for (unsigned int i = 0; i < hashSize; i++)
|
for (unsigned int i = 0; i < hashSize; i++)
|
||||||
|
@ -50,7 +50,7 @@ bool Hash::operator == (const Hash & h2) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::strong_ordering Hash::operator <=> (const Hash & h) const
|
std::strong_ordering Hash::operator <=> (const Hash & h) const noexcept
|
||||||
{
|
{
|
||||||
if (auto cmp = hashSize <=> h.hashSize; cmp != 0) return cmp;
|
if (auto cmp = hashSize <=> h.hashSize; cmp != 0) return cmp;
|
||||||
for (unsigned int i = 0; i < hashSize; i++) {
|
for (unsigned int i = 0; i < hashSize; i++) {
|
||||||
|
|
|
@ -88,12 +88,12 @@ public:
|
||||||
/**
|
/**
|
||||||
* Check whether two hashes are equal.
|
* Check whether two hashes are equal.
|
||||||
*/
|
*/
|
||||||
bool operator == (const Hash & h2) const;
|
bool operator == (const Hash & h2) const noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare how two hashes are ordered.
|
* Compare how two hashes are ordered.
|
||||||
*/
|
*/
|
||||||
std::strong_ordering operator <=> (const Hash & h2) const;
|
std::strong_ordering operator <=> (const Hash & h2) const noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the length of a base-16 representation of this hash.
|
* Returns the length of a base-16 representation of this hash.
|
||||||
|
|
|
@ -15,11 +15,15 @@ struct MemorySourceAccessor : virtual SourceAccessor
|
||||||
* defining what a "file system object" is in Nix.
|
* defining what a "file system object" is in Nix.
|
||||||
*/
|
*/
|
||||||
struct File {
|
struct File {
|
||||||
|
bool operator == (const File &) const noexcept;
|
||||||
|
std::strong_ordering operator <=> (const File &) const noexcept;
|
||||||
|
|
||||||
struct Regular {
|
struct Regular {
|
||||||
bool executable = false;
|
bool executable = false;
|
||||||
std::string contents;
|
std::string contents;
|
||||||
|
|
||||||
GENERATE_CMP(Regular, me->executable, me->contents);
|
bool operator == (const Regular &) const = default;
|
||||||
|
auto operator <=> (const Regular &) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Directory {
|
struct Directory {
|
||||||
|
@ -27,13 +31,16 @@ struct MemorySourceAccessor : virtual SourceAccessor
|
||||||
|
|
||||||
std::map<Name, File, std::less<>> contents;
|
std::map<Name, File, std::less<>> contents;
|
||||||
|
|
||||||
GENERATE_CMP(Directory, me->contents);
|
bool operator == (const Directory &) const noexcept;
|
||||||
|
// TODO libc++ 16 (used by darwin) missing `std::map::operator <=>`, can't do yet.
|
||||||
|
bool operator < (const Directory &) const noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Symlink {
|
struct Symlink {
|
||||||
std::string target;
|
std::string target;
|
||||||
|
|
||||||
GENERATE_CMP(Symlink, me->target);
|
bool operator == (const Symlink &) const = default;
|
||||||
|
auto operator <=> (const Symlink &) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
using Raw = std::variant<Regular, Directory, Symlink>;
|
using Raw = std::variant<Regular, Directory, Symlink>;
|
||||||
|
@ -41,14 +48,15 @@ struct MemorySourceAccessor : virtual SourceAccessor
|
||||||
|
|
||||||
MAKE_WRAPPER_CONSTRUCTOR(File);
|
MAKE_WRAPPER_CONSTRUCTOR(File);
|
||||||
|
|
||||||
GENERATE_CMP(File, me->raw);
|
|
||||||
|
|
||||||
Stat lstat() const;
|
Stat lstat() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
File root { File::Directory {} };
|
File root { File::Directory {} };
|
||||||
|
|
||||||
GENERATE_CMP(MemorySourceAccessor, me->root);
|
bool operator == (const MemorySourceAccessor &) const noexcept = default;
|
||||||
|
bool operator < (const MemorySourceAccessor & other) const noexcept {
|
||||||
|
return root < other.root;
|
||||||
|
}
|
||||||
|
|
||||||
std::string readFile(const CanonPath & path) override;
|
std::string readFile(const CanonPath & path) override;
|
||||||
bool pathExists(const CanonPath & path) override;
|
bool pathExists(const CanonPath & path) override;
|
||||||
|
@ -72,6 +80,20 @@ struct MemorySourceAccessor : virtual SourceAccessor
|
||||||
SourcePath addFile(CanonPath path, std::string && contents);
|
SourcePath addFile(CanonPath path, std::string && contents);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline bool MemorySourceAccessor::File::Directory::operator == (
|
||||||
|
const MemorySourceAccessor::File::Directory &) const noexcept = default;
|
||||||
|
inline bool MemorySourceAccessor::File::Directory::operator < (
|
||||||
|
const MemorySourceAccessor::File::Directory & other) const noexcept
|
||||||
|
{
|
||||||
|
return contents < other.contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool MemorySourceAccessor::File::operator == (
|
||||||
|
const MemorySourceAccessor::File &) const noexcept = default;
|
||||||
|
inline std::strong_ordering MemorySourceAccessor::File::operator <=> (
|
||||||
|
const MemorySourceAccessor::File &) const noexcept = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write to a `MemorySourceAccessor` at the given path
|
* Write to a `MemorySourceAccessor` at the given path
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -17,12 +17,6 @@ Pos::operator std::shared_ptr<Pos>() const
|
||||||
return std::make_shared<Pos>(&*this);
|
return std::make_shared<Pos>(&*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Pos::operator<(const Pos &rhs) const
|
|
||||||
{
|
|
||||||
return std::forward_as_tuple(line, column, origin)
|
|
||||||
< std::forward_as_tuple(rhs.line, rhs.column, rhs.origin);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::optional<LinesOfCode> Pos::getCodeLines() const
|
std::optional<LinesOfCode> Pos::getCodeLines() const
|
||||||
{
|
{
|
||||||
if (line == 0)
|
if (line == 0)
|
||||||
|
|
|
@ -22,21 +22,17 @@ struct Pos
|
||||||
|
|
||||||
struct Stdin {
|
struct Stdin {
|
||||||
ref<std::string> source;
|
ref<std::string> source;
|
||||||
bool operator==(const Stdin & rhs) const
|
bool operator==(const Stdin & rhs) const noexcept
|
||||||
{ return *source == *rhs.source; }
|
{ return *source == *rhs.source; }
|
||||||
bool operator!=(const Stdin & rhs) const
|
std::strong_ordering operator<=>(const Stdin & rhs) const noexcept
|
||||||
{ return *source != *rhs.source; }
|
{ return *source <=> *rhs.source; }
|
||||||
bool operator<(const Stdin & rhs) const
|
|
||||||
{ return *source < *rhs.source; }
|
|
||||||
};
|
};
|
||||||
struct String {
|
struct String {
|
||||||
ref<std::string> source;
|
ref<std::string> source;
|
||||||
bool operator==(const String & rhs) const
|
bool operator==(const String & rhs) const noexcept
|
||||||
{ return *source == *rhs.source; }
|
{ return *source == *rhs.source; }
|
||||||
bool operator!=(const String & rhs) const
|
std::strong_ordering operator<=>(const String & rhs) const noexcept
|
||||||
{ return *source != *rhs.source; }
|
{ return *source <=> *rhs.source; }
|
||||||
bool operator<(const String & rhs) const
|
|
||||||
{ return *source < *rhs.source; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::variant<std::monostate, Stdin, String, SourcePath> Origin;
|
typedef std::variant<std::monostate, Stdin, String, SourcePath> Origin;
|
||||||
|
@ -65,8 +61,7 @@ struct Pos
|
||||||
std::optional<LinesOfCode> getCodeLines() const;
|
std::optional<LinesOfCode> getCodeLines() const;
|
||||||
|
|
||||||
bool operator==(const Pos & rhs) const = default;
|
bool operator==(const Pos & rhs) const = default;
|
||||||
bool operator!=(const Pos & rhs) const = default;
|
auto operator<=>(const Pos & rhs) const = default;
|
||||||
bool operator<(const Pos & rhs) const;
|
|
||||||
|
|
||||||
struct LinesIterator {
|
struct LinesIterator {
|
||||||
using difference_type = size_t;
|
using difference_type = size_t;
|
||||||
|
|
|
@ -87,9 +87,9 @@ public:
|
||||||
return p != other.p;
|
return p != other.p;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator < (const ref<T> & other) const
|
auto operator <=> (const ref<T> & other) const
|
||||||
{
|
{
|
||||||
return p < other.p;
|
return p <=> other.p;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -152,9 +152,9 @@ struct SourceAccessor : std::enable_shared_from_this<SourceAccessor>
|
||||||
return number == x.number;
|
return number == x.number;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator < (const SourceAccessor & x) const
|
auto operator <=> (const SourceAccessor & x) const
|
||||||
{
|
{
|
||||||
return number < x.number;
|
return number <=> x.number;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPathDisplay(std::string displayPrefix, std::string displaySuffix = "");
|
void setPathDisplay(std::string displayPrefix, std::string displaySuffix = "");
|
||||||
|
|
|
@ -47,19 +47,14 @@ SourcePath SourcePath::operator / (const CanonPath & x) const
|
||||||
SourcePath SourcePath::operator / (std::string_view c) const
|
SourcePath SourcePath::operator / (std::string_view c) const
|
||||||
{ return {accessor, path / c}; }
|
{ return {accessor, path / c}; }
|
||||||
|
|
||||||
bool SourcePath::operator==(const SourcePath & x) const
|
bool SourcePath::operator==(const SourcePath & x) const noexcept
|
||||||
{
|
{
|
||||||
return std::tie(*accessor, path) == std::tie(*x.accessor, x.path);
|
return std::tie(*accessor, path) == std::tie(*x.accessor, x.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SourcePath::operator!=(const SourcePath & x) const
|
std::strong_ordering SourcePath::operator<=>(const SourcePath & x) const noexcept
|
||||||
{
|
{
|
||||||
return std::tie(*accessor, path) != std::tie(*x.accessor, x.path);
|
return std::tie(*accessor, path) <=> std::tie(*x.accessor, x.path);
|
||||||
}
|
|
||||||
|
|
||||||
bool SourcePath::operator<(const SourcePath & x) const
|
|
||||||
{
|
|
||||||
return std::tie(*accessor, path) < std::tie(*x.accessor, x.path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream & operator<<(std::ostream & str, const SourcePath & path)
|
std::ostream & operator<<(std::ostream & str, const SourcePath & path)
|
||||||
|
|
|
@ -103,9 +103,8 @@ struct SourcePath
|
||||||
*/
|
*/
|
||||||
SourcePath operator / (std::string_view c) const;
|
SourcePath operator / (std::string_view c) const;
|
||||||
|
|
||||||
bool operator==(const SourcePath & x) const;
|
bool operator==(const SourcePath & x) const noexcept;
|
||||||
bool operator!=(const SourcePath & x) const;
|
std::strong_ordering operator<=>(const SourcePath & x) const noexcept;
|
||||||
bool operator<(const SourcePath & x) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience wrapper around `SourceAccessor::resolveSymlinks()`.
|
* Convenience wrapper around `SourceAccessor::resolveSymlinks()`.
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
///@file
|
///@file
|
||||||
|
|
||||||
#include "comparator.hh"
|
|
||||||
#include "types.hh"
|
#include "types.hh"
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
@ -20,7 +19,8 @@ public:
|
||||||
|
|
||||||
std::string to_string() const;
|
std::string to_string() const;
|
||||||
|
|
||||||
GENERATE_CMP(Suggestion, me->distance, me->suggestion)
|
bool operator ==(const Suggestion &) const = default;
|
||||||
|
auto operator <=>(const Suggestion &) const = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Suggestions {
|
class Suggestions {
|
||||||
|
|
|
@ -132,7 +132,7 @@ std::string ParsedURL::to_string() const
|
||||||
+ (fragment.empty() ? "" : "#" + percentEncode(fragment));
|
+ (fragment.empty() ? "" : "#" + percentEncode(fragment));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ParsedURL::operator ==(const ParsedURL & other) const
|
bool ParsedURL::operator ==(const ParsedURL & other) const noexcept
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
scheme == other.scheme
|
scheme == other.scheme
|
||||||
|
|
|
@ -18,7 +18,7 @@ struct ParsedURL
|
||||||
|
|
||||||
std::string to_string() const;
|
std::string to_string() const;
|
||||||
|
|
||||||
bool operator ==(const ParsedURL & other) const;
|
bool operator ==(const ParsedURL & other) const noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove `.` and `..` path elements.
|
* Remove `.` and `..` path elements.
|
||||||
|
|
|
@ -27,7 +27,9 @@ struct ProfileElementSource
|
||||||
std::string attrPath;
|
std::string attrPath;
|
||||||
ExtendedOutputsSpec outputs;
|
ExtendedOutputsSpec outputs;
|
||||||
|
|
||||||
bool operator < (const ProfileElementSource & other) const
|
// TODO libc++ 16 (used by darwin) missing `std::set::operator <=>`, can't do yet.
|
||||||
|
//auto operator <=> (const ProfileElementSource & other) const
|
||||||
|
auto operator < (const ProfileElementSource & other) const
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
std::tuple(originalRef.to_string(), attrPath, outputs) <
|
std::tuple(originalRef.to_string(), attrPath, outputs) <
|
||||||
|
|
|
@ -229,7 +229,7 @@ TEST_F(GitTest, both_roundrip) {
|
||||||
|
|
||||||
mkSinkHook(CanonPath::root, root.hash, BlobMode::Regular);
|
mkSinkHook(CanonPath::root, root.hash, BlobMode::Regular);
|
||||||
|
|
||||||
ASSERT_EQ(*files, *files2);
|
ASSERT_EQ(files->root, files2->root);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(GitLsRemote, parseSymrefLineWithReference) {
|
TEST(GitLsRemote, parseSymrefLineWithReference) {
|
||||||
|
|
Loading…
Reference in a new issue