mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-02-18 08:07:17 +02:00
nix::Value: Use more descriptive names
This commit is contained in:
parent
5cc4af5231
commit
9d7dee4a8f
2 changed files with 12 additions and 7 deletions
|
@ -23,7 +23,7 @@ class BindingsBuilder;
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
tUnset,
|
tUninitialized = 0,
|
||||||
tInt = 1,
|
tInt = 1,
|
||||||
tBool,
|
tBool,
|
||||||
tString,
|
tString,
|
||||||
|
@ -167,7 +167,7 @@ public:
|
||||||
struct Value
|
struct Value
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
InternalType internalType = tUnset;
|
InternalType internalType = tUninitialized;
|
||||||
|
|
||||||
friend std::string showType(const Value & v);
|
friend std::string showType(const Value & v);
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ public:
|
||||||
inline ValueType type(bool invalidIsThunk = false) const
|
inline ValueType type(bool invalidIsThunk = false) const
|
||||||
{
|
{
|
||||||
switch (internalType) {
|
switch (internalType) {
|
||||||
case tUnset: break;
|
case tUninitialized: break;
|
||||||
case tInt: return nInt;
|
case tInt: return nInt;
|
||||||
case tBool: return nBool;
|
case tBool: return nBool;
|
||||||
case tString: return nString;
|
case tString: return nString;
|
||||||
|
@ -296,9 +296,14 @@ public:
|
||||||
internalType = newType;
|
internalType = newType;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool isInitialized()
|
/**
|
||||||
|
* A value becomes valid when it is initialized. We don't use this
|
||||||
|
* in the evaluator; only in the bindings, where the slight extra
|
||||||
|
* cost is warranted because of inexperienced callers.
|
||||||
|
*/
|
||||||
|
inline bool isValid() const
|
||||||
{
|
{
|
||||||
return internalType != tUnset;
|
return internalType != tUninitialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void mkInt(NixInt n)
|
inline void mkInt(NixInt n)
|
||||||
|
|
|
@ -10,7 +10,7 @@ class ValueTest : public LibStoreTest
|
||||||
TEST_F(ValueTest, unsetValue)
|
TEST_F(ValueTest, unsetValue)
|
||||||
{
|
{
|
||||||
Value unsetValue;
|
Value unsetValue;
|
||||||
ASSERT_EQ(false, unsetValue.isInitialized());
|
ASSERT_EQ(false, unsetValue.isValid());
|
||||||
ASSERT_EQ(nThunk, unsetValue.type(true));
|
ASSERT_EQ(nThunk, unsetValue.type(true));
|
||||||
ASSERT_DEATH(unsetValue.type(), "");
|
ASSERT_DEATH(unsetValue.type(), "");
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ TEST_F(ValueTest, vInt)
|
||||||
{
|
{
|
||||||
Value vInt;
|
Value vInt;
|
||||||
vInt.mkInt(42);
|
vInt.mkInt(42);
|
||||||
ASSERT_EQ(true, vInt.isInitialized());
|
ASSERT_EQ(true, vInt.isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
|
|
Loading…
Add table
Reference in a new issue