1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 10:41:16 +02:00

Style tweaks

This commit is contained in:
Eelco Dolstra 2022-05-25 12:32:22 +02:00
parent ba035f7dd0
commit 91b7d5373a
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
9 changed files with 165 additions and 370 deletions

View file

@ -554,20 +554,14 @@ std::string AttrCursor::getString()
debug("using cached string attribute '%s'", getAttrPathStr());
return s->first;
} else
{
auto e = TypeError("'%s' is not a string", getAttrPathStr());
root->state.debugThrowLastTrace(e);
}
root->state.debugThrowLastTrace(TypeError("'%s' is not a string", getAttrPathStr()));
}
}
auto & v = forceValue();
if (v.type() != nString && v.type() != nPath)
{
auto e = TypeError("'%s' is not a string but %s", getAttrPathStr(), showType(v.type()));
root->state.debugThrowLastTrace(e);
}
root->state.debugThrowLastTrace(TypeError("'%s' is not a string but %s", getAttrPathStr(), showType(v.type())));
return v.type() == nString ? v.string.s : v.path;
}
@ -591,10 +585,7 @@ string_t AttrCursor::getStringWithContext()
return *s;
}
} else
{
auto e = TypeError("'%s' is not a string", getAttrPathStr());
root->state.debugThrowLastTrace(e);
}
root->state.debugThrowLastTrace(TypeError("'%s' is not a string", getAttrPathStr()));
}
}
@ -605,10 +596,7 @@ string_t AttrCursor::getStringWithContext()
else if (v.type() == nPath)
return {v.path, {}};
else
{
auto e = TypeError("'%s' is not a string but %s", getAttrPathStr(), showType(v.type()));
root->state.debugThrowLastTrace(e);
}
root->state.debugThrowLastTrace(TypeError("'%s' is not a string but %s", getAttrPathStr(), showType(v.type())));
}
bool AttrCursor::getBool()
@ -621,20 +609,14 @@ bool AttrCursor::getBool()
debug("using cached Boolean attribute '%s'", getAttrPathStr());
return *b;
} else
{
auto e = TypeError("'%s' is not a Boolean", getAttrPathStr());
root->state.debugThrowLastTrace(e);
}
root->state.debugThrowLastTrace(TypeError("'%s' is not a Boolean", getAttrPathStr()));
}
}
auto & v = forceValue();
if (v.type() != nBool)
{
auto e = TypeError("'%s' is not a Boolean", getAttrPathStr());
root->state.debugThrowLastTrace(e);
}
root->state.debugThrowLastTrace(TypeError("'%s' is not a Boolean", getAttrPathStr()));
return v.boolean;
}
@ -682,20 +664,14 @@ std::vector<Symbol> AttrCursor::getAttrs()
debug("using cached attrset attribute '%s'", getAttrPathStr());
return *attrs;
} else
{
auto e = TypeError("'%s' is not an attribute set", getAttrPathStr());
root->state.debugThrowLastTrace(e);
}
root->state.debugThrowLastTrace(TypeError("'%s' is not an attribute set", getAttrPathStr()));
}
}
auto & v = forceValue();
if (v.type() != nAttrs)
{
auto e = TypeError("'%s' is not an attribute set", getAttrPathStr());
root->state.debugThrowLastTrace(e);
}
root->state.debugThrowLastTrace(TypeError("'%s' is not an attribute set", getAttrPathStr()));
std::vector<Symbol> attrs;
for (auto & attr : *getValue().attrs)