Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
fix all -Wall -Wextra -Wpedantic
Browse files Browse the repository at this point in the history
  • Loading branch information
aakropotkin committed Aug 16, 2023
1 parent 7b9171b commit b67ad5f
Show file tree
Hide file tree
Showing 32 changed files with 183 additions and 162 deletions.
5 changes: 3 additions & 2 deletions include/descriptor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,16 @@ class Descriptor {

Descriptor() = default;
Descriptor( const nlohmann::json & desc );
/**
// TODO
/* *
* "hello" -> { name: "hello" }
* "hello@18" -> { name: "hello", semver: "18" }
* "hello@=18" -> { name: "hello", version: "18" }
* "packages.*.hello" -> { path: ["packages", null, "hello"] }
* "nixpkgs#hello" -> { flake.id: "nixpkgs", name: "hello" }
* "catalog:floxpkgs#hello" -> { catalog.id: "floxpkgs", name: "hello" }
*/
Descriptor( const std::string_view desc );
//Descriptor( const std::string_view desc );

predicates::PkgPred pred( bool checkPath = false ) const;

Expand Down
14 changes: 7 additions & 7 deletions include/flox/attrs-iter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ class AttrSetIterClosure {
nix::ref<nix::EvalState> state
, std::shared_ptr<nix::flake::LockedFlake> flake
, Cursor cur
) : _state( (std::shared_ptr<nix::EvalState>) state )
, _flake( flake )
) : _flake( flake )
, _state( (std::shared_ptr<nix::EvalState>) state )
, _cur( (MaybeCursor) cur )
{
for ( const auto & str :
Expand All @@ -94,8 +94,8 @@ class AttrSetIterClosure {
nix::ref<nix::EvalState> state
, std::shared_ptr<nix::flake::LockedFlake> flake
, const std::list<std::string> & path
) : _state( (std::shared_ptr<nix::EvalState>) state )
, _flake( flake )
) : _flake( flake )
, _state( (std::shared_ptr<nix::EvalState>) state )
, _path( path )
{
nix::ref<nix::eval_cache::EvalCache> cache = this->openEvalCache();
Expand Down Expand Up @@ -131,7 +131,7 @@ class AttrSetIterClosure {
{
std::list<std::string_view> rsl;
for ( const auto & p : this->_path ) { rsl.emplace_back( p ); }
return std::move( rsl );
return rsl;
}


Expand Down Expand Up @@ -211,13 +211,13 @@ class AttrSetIterClosure {
}

bool
operator==( const sentinel & other ) const
operator==( const sentinel ) const
{
return this->_ptr == nullptr;
}

bool
operator!=( const sentinel & other ) const
operator!=( const sentinel ) const
{
return this->_ptr != nullptr;
}
Expand Down
7 changes: 3 additions & 4 deletions include/flox/cached-package-set.hh
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ class CachedPackageSet : public PackageSet {
, const subtree_type & subtree
, std::string_view system
, const std::optional<std::string_view> & stability = std::nullopt
) : _state( state )
, _subtree( subtree )
) : _subtree( subtree )
, _system( system )
, _stability( stability )
, _flake( flake )
, _state( state )
{
/* Determine the Db status.
* We may be creating from scratch, or filling a missing package set. */
Expand Down Expand Up @@ -124,7 +124,6 @@ class CachedPackageSet : public PackageSet {
, const subtree_type & subtree
, std::string_view system
, const std::optional<std::string_view> & stability = std::nullopt
, bool trace = false
) : CachedPackageSet(
state
, std::make_shared<nix::flake::LockedFlake>(
Expand Down Expand Up @@ -202,7 +201,7 @@ class CachedPackageSet : public PackageSet {
, std::shared_ptr<DbPackageSet> dbps
, std::shared_ptr<DrvDb> db
)
: _populateDb( populateDb ), _db( db )
: _db( db ), _populateDb( populateDb )
{
if ( _populateDb )
{
Expand Down
2 changes: 1 addition & 1 deletion include/flox/db-package-set.hh
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class DbPackageSet : public PackageSet {
std::shared_ptr<CachedPackage> _ptr;

public:
const_iterator() : _ptr( nullptr ), _query( nullptr ) {}
const_iterator() : _query( nullptr ), _ptr( nullptr ) {}

explicit const_iterator(
std::shared_ptr<nix::SQLiteStmt::Use> query
Expand Down
9 changes: 4 additions & 5 deletions include/flox/flake-package-set.hh
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ class FlakePackageSet : public PackageSet {
, const subtree_type & subtree
, std::string_view system
, const std::optional<std::string_view> & stability = std::nullopt
) : _state( state )
, _subtree( subtree )
) : _subtree( subtree )
, _system( system )
, _stability( stability )
, _flake( flake )
, _state( state )
{}

FlakePackageSet(
Expand All @@ -102,7 +102,6 @@ class FlakePackageSet : public PackageSet {
, const subtree_type & subtree
, std::string_view system
, const std::optional<std::string_view> & stability = std::nullopt
, bool trace = false
) : FlakePackageSet(
state
, std::make_shared<nix::flake::LockedFlake>(
Expand Down Expand Up @@ -204,7 +203,7 @@ class FlakePackageSet : public PackageSet {
, nix::SymbolTable * symtab
, todo_queue todo
)
: _subtree( subtree ), _todo( todo ), _symtab( symtab )
: _symtab( symtab ), _subtree( subtree ), _todo( todo )
{
if ( todo.empty() )
{
Expand All @@ -226,9 +225,9 @@ class FlakePackageSet : public PackageSet {
const_iterator()
: _symtab( nullptr )
, _subtree( ST_NONE )
, _ptr( nullptr )
, _todo( todo_queue() )
, _syms( symbol_queue() )
, _ptr( nullptr )
{}

std::string_view getType() const { return "flake"; }
Expand Down
1 change: 1 addition & 0 deletions include/flox/package.hh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace flox {
*/
class Package {
public:
virtual ~Package() {}
virtual std::vector<std::string> getPathStrs() const = 0;
virtual std::string getFullName() const = 0;
virtual std::string getPname() const = 0;
Expand Down
14 changes: 12 additions & 2 deletions include/flox/predicates.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,21 @@ struct PkgPred {

PkgPred() : pred( []( const Package & ) { return true; } ) {}
PkgPred( const pred_fn & f ) : pred( f ) {}
PkgPred( const PkgPred & p ) : pred( p.pred ) {}

PkgPred( PkgPred && p ) : pred( std::move( p.pred ) ) {}

PkgPred &
operator=( const PkgPred & other )
{
this->pred = other.pred;
return * this;
}

PkgPred &
operator=( PkgPred other )
operator=( PkgPred && other )
{
std::swap( this->pred, other.pred );
this->pred = std::move( other.pred );
return * this;
}

Expand Down
6 changes: 3 additions & 3 deletions include/flox/raw-package-set.hh
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,16 @@ class RawPackageSet : public PackageSet {
public:

iterator_impl( container_type * pkgs )
: _end( pkgs->end() )
: _pkgs( pkgs )
, _end( pkgs->end() )
, _it( pkgs->begin() )
, _pkgs( pkgs )
, _ptr( nullptr )
{
if ( this->_it != this->_end ) { this->_ptr = this->_it->second; }
}

iterator_impl( container_type * pkgs, wrapped_iter_type it )
: _end( pkgs->end() ), _it( it ), _pkgs( pkgs ), _ptr( nullptr )
: _pkgs( pkgs ), _end( pkgs->end() ), _it( it ), _ptr( nullptr )
{
if ( this->_it != this->_end ) { this->_ptr = this->_it->second; }
}
Expand Down
38 changes: 18 additions & 20 deletions include/flox/raw-package.hh
Original file line number Diff line number Diff line change
Expand Up @@ -54,35 +54,33 @@ class RawPackage : public Package {
RawPackage( const nlohmann::json & drvInfo );
RawPackage( nlohmann::json && drvInfo );
RawPackage(
const std::vector<std::string_view> & pathS = {}
, std::string_view fullname = {}
, std::string_view pname = {}
, std::optional<std::string_view> version = std::nullopt
, std::optional<std::string_view> semver = std::nullopt
, std::optional<std::string_view> license = std::nullopt
, const std::vector<std::string_view> & outputs = { "out" }
, const std::vector<std::string_view> & outputsToInstall = { "out" }
, std::optional<bool> broken = std::nullopt
, std::optional<bool> unfree = std::nullopt
, bool hasMetaAttr = false
, bool hasPnameAttr = false
, bool hasVersionAttr = false
) : _pname( pname )
const std::vector<std::string> & pathS = {}
, std::string_view fullname = {}
, std::string_view pname = {}
, std::optional<std::string> version = std::nullopt
, std::optional<std::string> semver = std::nullopt
, std::optional<std::string> license = std::nullopt
, const std::vector<std::string> & outputs = { "out" }
, const std::vector<std::string> & outputsToInstall = { "out" }
, std::optional<bool> broken = std::nullopt
, std::optional<bool> unfree = std::nullopt
, bool hasMetaAttr = false
, bool hasPnameAttr = false
, bool hasVersionAttr = false
) : _pathS( pathS )
, _fullname( fullname )
, _pname( pname )
, _version( version )
, _semver( semver )
, _license( license )
, _outputs( outputs )
, _outputsToInstall( outputsToInstall )
, _broken( broken )
, _unfree( unfree )
, _hasMetaAttr( hasMetaAttr )
, _hasPnameAttr( hasPnameAttr )
, _hasVersionAttr( hasVersionAttr )
{
for ( auto & s : pathS ) { this->_pathS.emplace_back( s ); }
for ( auto & s : outputs ) { this->_outputs.emplace_back( s ); }
for ( auto & s : outputsToInstall )
{
this->_outputsToInstall.emplace_back( s );
}
}


Expand Down
6 changes: 3 additions & 3 deletions include/flox/resolved.hh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class Resolved {
nlohmann::json info;

Resolved( const nlohmann::json & attrs )
: inputId( attrs.at( "input" ).at( "id" ) )
, _input( nix::FlakeRef::fromAttrs( nix::fetchers::jsonToAttrs(
: _input( nix::FlakeRef::fromAttrs( nix::fetchers::jsonToAttrs(
attrs.at( "input" ).at( "locked" )
) ) )
, inputId( attrs.at( "input" ).at( "id" ) )
, path( AttrPathGlob::fromJSON( attrs.at( "path" ) ) )
, info( attrs.at( "info" ) )
{}
Expand All @@ -41,7 +41,7 @@ class Resolved {
, const AttrPathGlob & path
, const nlohmann::json & info
)
: inputId( inputId ), _input( input ), path( path ), info( info )
: _input( input ), inputId( inputId ), path( path ), info( info )
{}

std::string
Expand Down
42 changes: 37 additions & 5 deletions include/flox/util.hh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ struct std::hash<std::list<std::string_view>>

/* -------------------------------------------------------------------------- */

#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wunused-function"
#endif /* ifdef __clang__ */

#ifdef __GNUG__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunused-function"
#endif /* ifdef __GNUG__ */

static bool
operator==( const std::list<std::string> & lhs
, const std::list<std::string_view> & rhs
Expand All @@ -72,6 +82,15 @@ operator==( const std::list<std::string_view> & lhs
}


#ifdef __clang__
# pragma clang diagnostic pop
#endif /* ifdef __clang__ */

#ifdef __GNUG__
# pragma GCC diagnostic pop
#endif /* ifdef __GNUG__ */


/* -------------------------------------------------------------------------- */

namespace flox {
Expand Down Expand Up @@ -113,11 +132,24 @@ isPkgsSubtree( std::string_view attrName )

/* -------------------------------------------------------------------------- */

/** `nix' configuration options used when locking flakes. */
static nix::flake::LockFlags floxFlakeLockFlags = {
.updateLockFile = false
, .writeLockFile = false
, .applyNixConfig = false
/**
* Default flags used when locking flakes.
* - Disable `updateLockFile` and read existing lockfiles directly.
* - Disable `writeLockFile` to avoid writing generated lockfiles to the
* filesystem; this will only occur if there is no existing lockfile.
*/
static const nix::flake::LockFlags floxFlakeLockFlags = {
.recreateLockFile = false /* default */
, .updateLockFile = false
, .writeLockFile = false
, .useRegistries = std::nullopt /* default */
, .applyNixConfig = false /* default */
, .allowUnlocked = true /* default */
, .commitLockFile = false /* default */
, .referenceLockFilePath = std::nullopt /* default */
, .outputLockFilePath = std::nullopt /* default */
, .inputOverrides = {} /* default */
, .inputUpdates = {} /* default */
};


Expand Down
18 changes: 3 additions & 15 deletions src/cached-package-set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,15 @@ CachedPackageSet::const_iterator::loadPkg()

this->_db->setDrvInfo( * p );

std::vector<std::string_view> pathS;
for ( const auto & s : p->getPathStrs() ) { pathS.push_back( s ); }

std::vector<std::string_view> outputs;
for ( const auto & s : p->getOutputs() ) { outputs.push_back( s ); }

std::vector<std::string_view> outputsToInstall;
for ( const auto & s : p->getOutputsToInstall() )
{
outputsToInstall.push_back( s );
}

this->_ptr = std::make_shared<value_type>(
pathS
p->getPathStrs()
, p->getFullName()
, p->getPname()
, p->getVersion()
, p->getSemver()
, p->getLicense()
, outputs
, outputsToInstall
, p->getOutputs()
, p->getOutputsToInstall()
, p->isBroken()
, p->isUnfree()
, p->hasMetaAttr()
Expand Down
8 changes: 0 additions & 8 deletions src/descriptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@
namespace flox {
namespace resolve {

/* -------------------------------------------------------------------------- */

Descriptor::Descriptor( std::string_view desc )
{
// TODO
}


/* -------------------------------------------------------------------------- */

Descriptor::Descriptor( const nlohmann::json & desc )
Expand Down
Loading

0 comments on commit b67ad5f

Please sign in to comment.