aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-10-05 22:36:28 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-10-05 22:36:28 +0000
commit3d8bceb5a95a455eb6c1106686ac686a997cee6b (patch)
treed0c4562c45c604481fc381ab95c91d055906aae6
parentb2283078e13fdfd6f72ae5db941740e19b34b593 (diff)
downloadpaludis-3d8bceb5a95a455eb6c1106686ac686a997cee6b.tar.gz
paludis-3d8bceb5a95a455eb6c1106686ac686a997cee6b.tar.xz
Use visitor_cast<>. Fixes: ticket:387
-rw-r--r--paludis/install_task.cc4
-rw-r--r--paludis/override_functions.cc457
2 files changed, 38 insertions, 423 deletions
diff --git a/paludis/install_task.cc b/paludis/install_task.cc
index a27ef89..894eb46 100644
--- a/paludis/install_task.cc
+++ b/paludis/install_task.cc
@@ -934,10 +934,6 @@ namespace
task->on_update_world(a);
}
}
-
- void visit_leaf(const BlockDepSpec &)
- {
- }
};
}
diff --git a/paludis/override_functions.cc b/paludis/override_functions.cc
index 079f390..7898f2c 100644
--- a/paludis/override_functions.cc
+++ b/paludis/override_functions.cc
@@ -19,6 +19,7 @@
#include <paludis/override_functions.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/visitor_cast.hh>
#include <paludis/util/set.hh>
#include <paludis/util/stringify.hh>
#include <paludis/environment.hh>
@@ -29,448 +30,66 @@
using namespace paludis;
-namespace
+bool
+paludis::override_tilde_keywords(const Environment * const e, const PackageID & id, const Mask & m)
{
- struct OverrideTildeKeywordsKeyVisitor :
- ConstVisitor<MetadataKeyVisitorTypes>
- {
- const Environment * const env;
- const PackageID & id;
- bool result;
-
- OverrideTildeKeywordsKeyVisitor(const Environment * const e, const PackageID & i) :
- env(e),
- id(i),
- result(false)
- {
- }
-
- void visit(const MetadataPackageIDKey &)
- {
- }
-
- void visit(const MetadataTimeKey &)
- {
- }
-
- void visit(const MetadataContentsKey &)
- {
- }
-
- void visit(const MetadataStringKey &)
- {
- }
-
- void visit(const MetadataRepositoryMaskInfoKey &)
- {
- }
-
- void visit(const MetadataFSEntryKey &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<RestrictSpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<ProvideSpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<FetchableURISpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<SimpleURISpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<LicenseSpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<DependencySpecTree> &)
- {
- }
-
- void visit(const MetadataSetKey<Set<std::string> > &)
- {
- }
-
- void visit(const MetadataSetKey<PackageIDSequence> &)
- {
- }
-
- void visit(const MetadataSetKey<KeywordNameSet> & k)
- {
- tr1::shared_ptr<KeywordNameSet> kk(new KeywordNameSet);
- for (KeywordNameSet::ConstIterator i(k.value()->begin()), i_end(k.value()->end()) ;
- i != i_end ; ++i)
- {
- kk->insert(*i);
- if ('~' == stringify(*i).at(0))
- kk->insert(KeywordName(stringify(*i).substr(1)));
- }
-
- result |= env->accept_keywords(kk, id);
- }
-
- void visit(const MetadataSetKey<IUseFlagSet> &)
- {
- }
-
- void visit(const MetadataSetKey<UseFlagNameSet> &)
- {
- }
- };
-
- struct OverrideTildeKeywordsMaskVisitor :
- ConstVisitor<MaskVisitorTypes>
- {
- const Environment * const env;
- const PackageID & id;
- bool result;
-
- OverrideTildeKeywordsMaskVisitor(const Environment * const e, const PackageID & i) :
- env(e),
- id(i),
- result(false)
- {
- }
-
- void visit(const UserMask &)
- {
- }
-
- void visit(const UnacceptedMask & m)
- {
- OverrideTildeKeywordsKeyVisitor k(env, id);
- m.unaccepted_key()->accept(k);
- result |= k.result;
- }
-
- void visit(const RepositoryMask &)
- {
- }
-
- void visit(const AssociationMask &)
- {
- }
-
- void visit(const UnsupportedMask &)
- {
- }
- };
-
- struct OverrideUnkeywordedKeyVisitor :
- ConstVisitor<MetadataKeyVisitorTypes>
- {
- const Environment * const env;
- const PackageID & id;
- bool result;
-
- OverrideUnkeywordedKeyVisitor(const Environment * const e, const PackageID & i) :
- env(e),
- id(i),
- result(false)
- {
- }
-
- void visit(const MetadataPackageIDKey &)
- {
- }
-
- void visit(const MetadataTimeKey &)
- {
- }
-
- void visit(const MetadataContentsKey &)
- {
- }
-
- void visit(const MetadataStringKey &)
- {
- }
-
- void visit(const MetadataRepositoryMaskInfoKey &)
- {
- }
-
- void visit(const MetadataFSEntryKey &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<RestrictSpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<ProvideSpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<FetchableURISpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<SimpleURISpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<LicenseSpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<DependencySpecTree> &)
- {
- }
-
- void visit(const MetadataSetKey<Set<std::string> > &)
- {
- }
-
- void visit(const MetadataSetKey<KeywordNameSet> & k)
- {
- tr1::shared_ptr<KeywordNameSet> kk(new KeywordNameSet);
- for (KeywordNameSet::ConstIterator i(k.value()->begin()), i_end(k.value()->end()) ;
- i != i_end ; ++i)
- if ('-' == stringify(*i).at(0))
- kk->insert(KeywordName(stringify(*i).substr(1)));
-
- result |= ! env->accept_keywords(kk, id);
- }
-
- void visit(const MetadataSetKey<IUseFlagSet> &)
- {
- }
-
- void visit(const MetadataSetKey<UseFlagNameSet> &)
- {
- }
-
- void visit(const MetadataSetKey<PackageIDSequence> &)
- {
- }
- };
-
- struct OverrideUnkeywordedMaskVisitor :
- ConstVisitor<MaskVisitorTypes>
- {
- const Environment * const env;
- const PackageID & id;
- bool result;
-
- OverrideUnkeywordedMaskVisitor(const Environment * const e, const PackageID & i) :
- env(e),
- id(i),
- result(false)
- {
- }
-
- void visit(const UserMask &)
- {
- }
-
- void visit(const UnacceptedMask & m)
- {
- OverrideUnkeywordedKeyVisitor k(env, id);
- m.unaccepted_key()->accept(k);
- result |= k.result;
- }
-
- void visit(const RepositoryMask &)
- {
- }
-
- void visit(const AssociationMask &)
- {
- }
-
- void visit(const UnsupportedMask &)
- {
- }
- };
-
- struct OverrideRepositoryMasksVisitor :
- ConstVisitor<MaskVisitorTypes>
- {
- bool result;
-
- OverrideRepositoryMasksVisitor() :
- result(false)
- {
- }
-
- void visit(const UserMask &)
- {
- }
-
- void visit(const UnacceptedMask &)
- {
- }
-
- void visit(const RepositoryMask &)
- {
- result = true;
- }
-
- void visit(const AssociationMask &)
- {
- }
-
- void visit(const UnsupportedMask &)
- {
- }
- };
-
- struct OverrideLicenseKeyVisitor :
- ConstVisitor<MetadataKeyVisitorTypes>
- {
- bool result;
-
- OverrideLicenseKeyVisitor() :
- result(false)
- {
- }
-
- void visit(const MetadataPackageIDKey &)
- {
- }
-
- void visit(const MetadataTimeKey &)
- {
- }
-
- void visit(const MetadataContentsKey &)
- {
- }
-
- void visit(const MetadataStringKey &)
- {
- }
-
- void visit(const MetadataRepositoryMaskInfoKey &)
- {
- }
-
- void visit(const MetadataFSEntryKey &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<RestrictSpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<ProvideSpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<SimpleURISpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<FetchableURISpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<LicenseSpecTree> &)
- {
- result = true;
- }
-
- void visit(const MetadataSpecTreeKey<DependencySpecTree> &)
- {
- }
-
- void visit(const MetadataSetKey<Set<std::string> > &)
- {
- }
-
- void visit(const MetadataSetKey<KeywordNameSet> &)
- {
- }
-
- void visit(const MetadataSetKey<IUseFlagSet> &)
- {
- }
+ Context c("When working out whether mask is a tilde keyword mask for override:");
- void visit(const MetadataSetKey<PackageIDSequence> &)
- {
- }
+ const UnacceptedMask * const mm(visitor_cast<const UnacceptedMask>(m));
+ if (! mm)
+ return false;
- void visit(const MetadataSetKey<UseFlagNameSet> &)
- {
- }
- };
+ const MetadataSetKey<KeywordNameSet> * const k(visitor_cast<const MetadataSetKey<KeywordNameSet> >(*mm->unaccepted_key()));
+ if (! k)
+ return false;
- struct OverrideLicenseVisitor :
- ConstVisitor<MaskVisitorTypes>
+ tr1::shared_ptr<KeywordNameSet> kk(new KeywordNameSet);
+ for (KeywordNameSet::ConstIterator i(k->value()->begin()), i_end(k->value()->end()) ;
+ i != i_end ; ++i)
{
- bool result;
-
- OverrideLicenseVisitor() :
- result(false)
- {
- }
-
- void visit(const UserMask &)
- {
- }
+ kk->insert(*i);
+ if ('~' == stringify(*i).at(0))
+ kk->insert(KeywordName(stringify(*i).substr(1)));
+ }
- void visit(const UnacceptedMask & m)
- {
- OverrideLicenseKeyVisitor k;
- m.unaccepted_key()->accept(k);
- result |= k.result;
- }
-
- void visit(const RepositoryMask &)
- {
- }
-
- void visit(const AssociationMask &)
- {
- }
-
- void visit(const UnsupportedMask &)
- {
- }
- };
-}
-
-bool
-paludis::override_tilde_keywords(const Environment * const e, const PackageID & i, const Mask & m)
-{
- Context c("When working out whether mask is a tilde keyword mask for override:");
- OverrideTildeKeywordsMaskVisitor k(e, i);
- m.accept(k);
- return k.result;
+ return e->accept_keywords(kk, id);
}
bool
-paludis::override_unkeyworded(const Environment * const e, const PackageID & i, const Mask & m)
+paludis::override_unkeyworded(const Environment * const e, const PackageID & id, const Mask & m)
{
Context c("When working out whether mask is an unkeyworded mask for override:");
- OverrideUnkeywordedMaskVisitor k(e, i);
- m.accept(k);
- return k.result;
+
+ const UnacceptedMask * const mm(visitor_cast<const UnacceptedMask>(m));
+ if (! mm)
+ return false;
+
+ const MetadataSetKey<KeywordNameSet> * const k(visitor_cast<const MetadataSetKey<KeywordNameSet> >(*mm->unaccepted_key()));
+ if (! k)
+ return false;
+
+ tr1::shared_ptr<KeywordNameSet> kk(new KeywordNameSet);
+ for (KeywordNameSet::ConstIterator i(k->value()->begin()), i_end(k->value()->end()) ;
+ i != i_end ; ++i)
+ if ('-' == stringify(*i).at(0))
+ kk->insert(KeywordName(stringify(*i).substr(1)));
+
+ return ! e->accept_keywords(kk, id);
}
bool
paludis::override_repository_masks(const Mask & m)
{
Context c("When working out whether mask is a repository mask for override:");
- OverrideRepositoryMasksVisitor k;
- m.accept(k);
- return k.result;
+ return visitor_cast<const RepositoryMask>(m);
}
bool
paludis::override_license(const Mask & m)
{
Context c("When working out whether mask is a license mask for override:");
- OverrideLicenseVisitor k;
- m.accept(k);
- return k.result;
+ const UnacceptedMask * const mm(visitor_cast<const UnacceptedMask>(m));
+ return mm && visitor_cast<const MetadataSpecTreeKey<LicenseSpecTree> >(*mm->unaccepted_key());
}