aboutsummaryrefslogtreecommitdiff
path: root/paludis/repositories/fake
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-12-16 19:09:18 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-12-16 19:09:18 +0000
commitd91e364ec2194766b7477cf482eedaa88d6acebc (patch)
tree479d9ac5ead34c630f0d771bdb527f54ebd8bc53 /paludis/repositories/fake
parenta71cdd3cdc1873659745b742ed1b1756c4aa2722 (diff)
downloadpaludis-d91e364ec2194766b7477cf482eedaa88d6acebc.tar.gz
paludis-d91e364ec2194766b7477cf482eedaa88d6acebc.tar.xz
Add initial_labels to the newly specialised MetadataSpecTreeKey<DependencySpecTree>. Add EAPI paludis-1 support for labels. Let FakeRepository's EAPI be overridden.
Diffstat (limited to 'paludis/repositories/fake')
-rw-r--r--paludis/repositories/fake/Makefile.am18
-rw-r--r--paludis/repositories/fake/fake_installed_repository.cc3
-rw-r--r--paludis/repositories/fake/fake_package_id.cc102
-rw-r--r--paludis/repositories/fake/fake_package_id.hh32
-rw-r--r--paludis/repositories/fake/fake_repository.cc29
-rw-r--r--paludis/repositories/fake/fake_repository.hh6
-rw-r--r--paludis/repositories/fake/fake_repository_base.cc28
-rw-r--r--paludis/repositories/fake/fake_repository_base.hh2
8 files changed, 185 insertions, 35 deletions
diff --git a/paludis/repositories/fake/Makefile.am b/paludis/repositories/fake/Makefile.am
index 9edf162fb..115d855d3 100644
--- a/paludis/repositories/fake/Makefile.am
+++ b/paludis/repositories/fake/Makefile.am
@@ -27,7 +27,9 @@ check_PROGRAMS = $(TESTS)
EXTRA_DIST = \
fake_repository_TEST.cc \
- fake_installed_repository_TEST.cc
+ fake_installed_repository_TEST.cc \
+ fake_repository-sr.hh \
+ fake_repository-sr.cc
fake_repository_TEST_LDADD = \
libpaludisfakerepository.la \
@@ -73,7 +75,18 @@ paludis_repositories_fake_include_HEADERS = \
fake_repository.hh \
fake_repository_base.hh \
fake_installed_repository.hh \
- fake_package_id.hh
+ fake_package_id.hh \
+ fake_repository-sr.hh
+
+BUILT_SOURCES = \
+ fake_repository-sr.hh \
+ fake_repository-sr.cc
+
+fake_repository-sr.hh : fake_repository.sr $(top_srcdir)/misc/make_sr.bash
+ $(top_srcdir)/misc/make_sr.bash --header $(srcdir)/fake_repository.sr > $@
+
+fake_repository-sr.cc : fake_repository.sr $(top_srcdir)/misc/make_sr.bash
+ $(top_srcdir)/misc/make_sr.bash --source $(srcdir)/fake_repository.sr > $@
built-sources : $(BUILT_SOURCES)
for s in `echo $(SUBDIRS) | tr -d .` ; do $(MAKE) -C $$s built-sources || exit 1 ; done
@@ -85,3 +98,4 @@ distcheck-deps : distcheck-deps-subdirs
distcheck-deps-subdirs :
for s in $(SUBDIRS) . ; do if test x$$s = x. ; then $(MAKE) distcheck-deps-local || exit 1 ; \
else $(MAKE) -C $$s distcheck-deps || exit 1 ; fi ; done
+
diff --git a/paludis/repositories/fake/fake_installed_repository.cc b/paludis/repositories/fake/fake_installed_repository.cc
index ba31ae5ad..1d1f86c2b 100644
--- a/paludis/repositories/fake/fake_installed_repository.cc
+++ b/paludis/repositories/fake/fake_installed_repository.cc
@@ -67,7 +67,8 @@ FakeInstalledRepository::FakeInstalledRepository(const Environment * const e, co
.make_virtuals_interface(0)
.qa_interface(0)
.hook_interface(0)
- .manifest_interface(0)),
+ .manifest_interface(0),
+ "0"),
PrivateImplementationPattern<FakeInstalledRepository>(new Implementation<FakeInstalledRepository>),
_imp(PrivateImplementationPattern<FakeInstalledRepository>::_imp)
{
diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc
index ede593c0d..8cc5ad3ae 100644
--- a/paludis/repositories/fake/fake_package_id.cc
+++ b/paludis/repositories/fake/fake_package_id.cc
@@ -152,6 +152,22 @@ namespace paludis
{
}
};
+
+ template <>
+ struct Implementation<FakeMetadataSpecTreeKey<DependencySpecTree> >
+ {
+ tr1::shared_ptr<const DependencySpecTree::ConstItem> value;
+ std::string string_value;
+ const tr1::function<const tr1::shared_ptr<const DependencySpecTree::ConstItem> (const std::string &)> func;
+ tr1::shared_ptr<const DependencyLabelSequence> labels;
+
+ Implementation(const tr1::function<const tr1::shared_ptr<const DependencySpecTree::ConstItem> (const std::string &)> & f,
+ const tr1::shared_ptr<const DependencyLabelSequence> & s) :
+ func(f),
+ labels(s)
+ {
+ }
+ };
}
template <typename C_>
@@ -243,6 +259,52 @@ FakeMetadataSpecTreeKey<FetchableURISpecTree>::initial_label() const
return _imp->initial_label;
}
+FakeMetadataSpecTreeKey<DependencySpecTree>::FakeMetadataSpecTreeKey(const std::string & r, const std::string & h, const std::string & v,
+ const tr1::function<const tr1::shared_ptr<const DependencySpecTree::ConstItem> (const std::string &)> & f,
+ const tr1::shared_ptr<const DependencyLabelSequence> & s, const MetadataKeyType t) :
+ MetadataSpecTreeKey<DependencySpecTree>(r, h, t),
+ PrivateImplementationPattern<FakeMetadataSpecTreeKey<DependencySpecTree> >(
+ new Implementation<FakeMetadataSpecTreeKey<DependencySpecTree> >(f, s)),
+ _imp(PrivateImplementationPattern<FakeMetadataSpecTreeKey<DependencySpecTree> >::_imp)
+{
+ set_from_string(v);
+}
+
+FakeMetadataSpecTreeKey<DependencySpecTree>::~FakeMetadataSpecTreeKey()
+{
+}
+
+void
+FakeMetadataSpecTreeKey<DependencySpecTree>::set_from_string(const std::string & s)
+{
+ _imp->string_value = s;
+ _imp->value = _imp->func(s);
+}
+
+const tr1::shared_ptr<const DependencySpecTree::ConstItem>
+FakeMetadataSpecTreeKey<DependencySpecTree>::value() const
+{
+ return _imp->value;
+}
+
+std::string
+FakeMetadataSpecTreeKey<DependencySpecTree>::pretty_print(const DependencySpecTree::ItemFormatter &) const
+{
+ return _imp->string_value;
+}
+
+std::string
+FakeMetadataSpecTreeKey<DependencySpecTree>::pretty_print_flat(const DependencySpecTree::ItemFormatter &) const
+{
+ return _imp->string_value;
+}
+
+const tr1::shared_ptr<const DependencyLabelSequence>
+FakeMetadataSpecTreeKey<DependencySpecTree>::initial_labels() const
+{
+ return _imp->labels;
+}
+
namespace paludis
{
template <>
@@ -303,6 +365,11 @@ namespace paludis
const VersionSpec version;
SlotName slot;
+ tr1::shared_ptr<DependencyLabelSequence> build_dependencies_labels;
+ tr1::shared_ptr<DependencyLabelSequence> run_dependencies_labels;
+ tr1::shared_ptr<DependencyLabelSequence> post_dependencies_labels;
+ tr1::shared_ptr<DependencyLabelSequence> suggested_dependencies_labels;
+
tr1::shared_ptr<LiteralMetadataPackageIDKey> package_id;
tr1::shared_ptr<LiteralMetadataPackageIDKey> virtual_for;
tr1::shared_ptr<FakeMetadataKeywordSetKey> keywords;
@@ -320,44 +387,58 @@ namespace paludis
mutable bool has_masks;
Implementation(const Environment * const e, const tr1::shared_ptr<const FakeRepositoryBase> & r,
- const QualifiedPackageName & q, const VersionSpec & v, const PackageID * const id) :
+ const QualifiedPackageName & q, const VersionSpec & v, const PackageID * const id,
+ const std::string & eapi) :
env(e),
repository(r),
name(q),
version(v),
slot("0"),
+ build_dependencies_labels(new DependencyLabelSequence),
+ run_dependencies_labels(new DependencyLabelSequence),
+ post_dependencies_labels(new DependencyLabelSequence),
+ suggested_dependencies_labels(new DependencyLabelSequence),
keywords(new FakeMetadataKeywordSetKey("KEYWORDS", "Keywords", "test", mkt_normal, id, env)),
iuse(new FakeMetadataIUseSetKey("IUSE", "Used USE flags", "", iuse_pm_permissive, mkt_normal, id, env)),
license(new FakeMetadataSpecTreeKey<LicenseSpecTree>("LICENSE", "Licenses",
"", tr1::bind(&erepository::parse_license, _1,
- *erepository::EAPIData::get_instance()->eapi_from_string("0")), mkt_normal)),
+ *erepository::EAPIData::get_instance()->eapi_from_string(eapi)), mkt_normal)),
provide(new FakeMetadataSpecTreeKey<ProvideSpecTree>("PROVIDE", "Provided packages",
"", tr1::bind(&erepository::parse_provide, _1,
- *erepository::EAPIData::get_instance()->eapi_from_string("0")), mkt_normal)),
+ *erepository::EAPIData::get_instance()->eapi_from_string(eapi)), mkt_normal)),
build_dependencies(new FakeMetadataSpecTreeKey<DependencySpecTree>("DEPEND", "Build dependencies",
"", tr1::bind(&erepository::parse_depend, _1,
- *erepository::EAPIData::get_instance()->eapi_from_string("0")), mkt_dependencies)),
+ *erepository::EAPIData::get_instance()->eapi_from_string(eapi)),
+ build_dependencies_labels, mkt_dependencies)),
run_dependencies(new FakeMetadataSpecTreeKey<DependencySpecTree>("RDEPEND", "Run dependencies",
"", tr1::bind(&erepository::parse_depend, _1,
- *erepository::EAPIData::get_instance()->eapi_from_string("0")), mkt_dependencies)),
+ *erepository::EAPIData::get_instance()->eapi_from_string(eapi)),
+ run_dependencies_labels, mkt_dependencies)),
post_dependencies(new FakeMetadataSpecTreeKey<DependencySpecTree>("PDEPEND", "Post dependencies",
"", tr1::bind(&erepository::parse_depend, _1,
- *erepository::EAPIData::get_instance()->eapi_from_string("0")), mkt_dependencies)),
+ *erepository::EAPIData::get_instance()->eapi_from_string(eapi)),
+ post_dependencies_labels, mkt_dependencies)),
suggested_dependencies(new FakeMetadataSpecTreeKey<DependencySpecTree>("SDEPEND", "Suggested dependencies",
"", tr1::bind(&erepository::parse_depend, _1,
- *erepository::EAPIData::get_instance()->eapi_from_string("0")), mkt_dependencies)),
+ *erepository::EAPIData::get_instance()->eapi_from_string(eapi)),
+ suggested_dependencies_labels, mkt_dependencies)),
src_uri(new FakeMetadataSpecTreeKey<FetchableURISpecTree>("SRC_URI", "Source URIs",
"", tr1::bind(&erepository::parse_fetchable_uri, _1,
- *erepository::EAPIData::get_instance()->eapi_from_string("0")), mkt_dependencies)),
+ *erepository::EAPIData::get_instance()->eapi_from_string(eapi)), mkt_dependencies)),
has_masks(false)
{
+ build_dependencies_labels->push_back(make_shared_ptr(new DependencyBuildLabel("DEPEND")));
+ run_dependencies_labels->push_back(make_shared_ptr(new DependencyRunLabel("RDEPEND")));
+ post_dependencies_labels->push_back(make_shared_ptr(new DependencyPostLabel("PDEPEND")));
+ suggested_dependencies_labels->push_back(make_shared_ptr(new DependencySuggestedLabel("SDEPEND")));
+ suggested_dependencies_labels->push_back(make_shared_ptr(new DependencyPostLabel("SDEPEND")));
}
};
}
FakePackageID::FakePackageID(const Environment * const e, const tr1::shared_ptr<const FakeRepositoryBase> & r,
- const QualifiedPackageName & q, const VersionSpec & v) :
- PrivateImplementationPattern<FakePackageID>(new Implementation<FakePackageID>(e, r, q, v, this)),
+ const QualifiedPackageName & q, const VersionSpec & v, const std::string & eapi) :
+ PrivateImplementationPattern<FakePackageID>(new Implementation<FakePackageID>(e, r, q, v, this, eapi)),
_imp(PrivateImplementationPattern<FakePackageID>::_imp)
{
add_metadata_key(_imp->keywords);
@@ -908,6 +989,7 @@ template class FakeMetadataSpecTreeKey<DependencySpecTree>;
template class FakeMetadataSpecTreeKey<RestrictSpecTree>;
#ifndef PALUDIS_NO_EXPLICIT_FULLY_SPECIALISED
template class FakeMetadataSpecTreeKey<FetchableURISpecTree>;
+template class FakeMetadataSpecTreeKey<DependencySpecTree>;
#endif
template class FakeMetadataSpecTreeKey<SimpleURISpecTree>;
diff --git a/paludis/repositories/fake/fake_package_id.hh b/paludis/repositories/fake/fake_package_id.hh
index 71a63d886..ccee19a00 100644
--- a/paludis/repositories/fake/fake_package_id.hh
+++ b/paludis/repositories/fake/fake_package_id.hh
@@ -134,6 +134,36 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
};
+ template <>
+ class PALUDIS_VISIBLE FakeMetadataSpecTreeKey<DependencySpecTree> :
+ public MetadataSpecTreeKey<DependencySpecTree>,
+ private PrivateImplementationPattern<FakeMetadataSpecTreeKey<DependencySpecTree> >
+ {
+ private:
+ PrivateImplementationPattern<FakeMetadataSpecTreeKey<DependencySpecTree> >::ImpPtr & _imp;
+
+ public:
+ FakeMetadataSpecTreeKey(const std::string &, const std::string &, const std::string &,
+ const tr1::function<const tr1::shared_ptr<const DependencySpecTree::ConstItem> (const std::string &)> &,
+ const tr1::shared_ptr<const DependencyLabelSequence> &,
+ const MetadataKeyType);
+ ~FakeMetadataSpecTreeKey();
+
+ virtual const tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ void set_from_string(const std::string &);
+
+ virtual std::string pretty_print(const DependencySpecTree::ItemFormatter &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::string pretty_print_flat(const DependencySpecTree::ItemFormatter &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual const tr1::shared_ptr<const DependencyLabelSequence> initial_labels() const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
class PALUDIS_VISIBLE FakeUnacceptedMask :
public UnacceptedMask,
private PrivateImplementationPattern<FakeUnacceptedMask>
@@ -161,7 +191,7 @@ namespace paludis
public:
FakePackageID(const Environment * const e,
const tr1::shared_ptr<const FakeRepositoryBase> &,
- const QualifiedPackageName &, const VersionSpec &);
+ const QualifiedPackageName &, const VersionSpec &, const std::string & eapi);
~FakePackageID();
virtual const std::string canonical_form(const PackageIDCanonicalForm) const;
diff --git a/paludis/repositories/fake/fake_repository.cc b/paludis/repositories/fake/fake_repository.cc
index 49c733ffc..477f7ebe0 100644
--- a/paludis/repositories/fake/fake_repository.cc
+++ b/paludis/repositories/fake/fake_repository.cc
@@ -34,6 +34,8 @@
using namespace paludis;
+#include <paludis/repositories/fake/fake_repository-sr.cc>
+
namespace paludis
{
template<>
@@ -72,7 +74,32 @@ FakeRepository::FakeRepository(const Environment * const e, const RepositoryName
.make_virtuals_interface(0)
.qa_interface(0)
.hook_interface(0)
- .manifest_interface(0)),
+ .manifest_interface(0),
+ "0"),
+ _imp(PrivateImplementationPattern<FakeRepository>::_imp)
+{
+ add_metadata_key(_imp->format_key);
+}
+
+FakeRepository::FakeRepository(const FakeRepositoryParams & params) :
+ PrivateImplementationPattern<FakeRepository>(new Implementation<FakeRepository>),
+ FakeRepositoryBase(params.environment, params.name, RepositoryCapabilities::create()
+ .sets_interface(this)
+ .syncable_interface(0)
+ .use_interface(this)
+ .world_interface(0)
+ .mirrors_interface(this)
+ .environment_variable_interface(0)
+ .provides_interface(0)
+ .virtuals_interface(DistributionData::get_instance()->distribution_from_string(
+ params.environment->default_distribution())->support_old_style_virtuals ? this : 0)
+ .destination_interface(0)
+ .e_interface(0)
+ .make_virtuals_interface(0)
+ .qa_interface(0)
+ .hook_interface(0)
+ .manifest_interface(0),
+ params.eapi),
_imp(PrivateImplementationPattern<FakeRepository>::_imp)
{
add_metadata_key(_imp->format_key);
diff --git a/paludis/repositories/fake/fake_repository.hh b/paludis/repositories/fake/fake_repository.hh
index efdc61af6..65ff6daec 100644
--- a/paludis/repositories/fake/fake_repository.hh
+++ b/paludis/repositories/fake/fake_repository.hh
@@ -24,6 +24,8 @@
namespace paludis
{
+#include <paludis/repositories/fake/fake_repository-sr.hh>
+
/**
* Fake repository for use in test cases.
*
@@ -45,6 +47,10 @@ namespace paludis
FakeRepository(const Environment * const, const RepositoryName &);
~FakeRepository();
+ ///\since 0.26
+ FakeRepository(const FakeRepositoryParams &);
+
+
///\}
/**
diff --git a/paludis/repositories/fake/fake_repository_base.cc b/paludis/repositories/fake/fake_repository_base.cc
index e2d0ba1ac..082781c1d 100644
--- a/paludis/repositories/fake/fake_repository_base.cc
+++ b/paludis/repositories/fake/fake_repository_base.cc
@@ -39,45 +39,35 @@ using namespace paludis;
namespace paludis
{
- /**
- * Implementation data for FakeRepositoryBase.
- *
- * \ingroup grpfakerepository
- */
template<>
struct Implementation<FakeRepositoryBase> :
private InstantiationPolicy<Implementation<FakeRepositoryBase>, instantiation_method::NonCopyableTag>
{
- /// Our category names.
tr1::shared_ptr<CategoryNamePartSet> category_names;
-
- /// Our package names.
std::map<CategoryNamePart, tr1::shared_ptr<PackageNamePartSet> > package_names;
-
- /// Our IDs.
std::map<QualifiedPackageName, tr1::shared_ptr<PackageIDSequence> > ids;
-
- /// Our sets.
std::map<SetName, tr1::shared_ptr<SetSpecTree::ConstItem> > sets;
const Environment * const env;
+ const std::string eapi;
- /// Constructor.
- Implementation(const Environment * const);
+ Implementation(const Environment * const, const std::string & ea);
};
- Implementation<FakeRepositoryBase>::Implementation(const Environment * const e) :
+ Implementation<FakeRepositoryBase>::Implementation(const Environment * const e, const std::string & ea) :
category_names(new CategoryNamePartSet),
- env(e)
+ env(e),
+ eapi(ea)
{
}
}
FakeRepositoryBase::FakeRepositoryBase(const Environment * const e,
- const RepositoryName & our_name, const RepositoryCapabilities & caps) :
+ const RepositoryName & our_name, const RepositoryCapabilities & caps,
+ const std::string & eapi) :
Repository(our_name, caps),
RepositoryUseInterface(),
- PrivateImplementationPattern<FakeRepositoryBase>(new Implementation<FakeRepositoryBase>(e)),
+ PrivateImplementationPattern<FakeRepositoryBase>(new Implementation<FakeRepositoryBase>(e, eapi)),
_imp(PrivateImplementationPattern<FakeRepositoryBase>::_imp)
{
}
@@ -149,7 +139,7 @@ tr1::shared_ptr<FakePackageID>
FakeRepositoryBase::add_version(const QualifiedPackageName & q, const VersionSpec & v)
{
add_package(q);
- tr1::shared_ptr<FakePackageID> id(new FakePackageID(_imp->env, shared_from_this(), q, v));
+ tr1::shared_ptr<FakePackageID> id(new FakePackageID(_imp->env, shared_from_this(), q, v, _imp->eapi));
_imp->ids.find(q)->second->push_back(id);
return id;
}
diff --git a/paludis/repositories/fake/fake_repository_base.hh b/paludis/repositories/fake/fake_repository_base.hh
index eaf20f974..ff64703ab 100644
--- a/paludis/repositories/fake/fake_repository_base.hh
+++ b/paludis/repositories/fake/fake_repository_base.hh
@@ -57,7 +57,7 @@ namespace paludis
* Constructor.
*/
FakeRepositoryBase(const Environment * const env, const RepositoryName & name,
- const RepositoryCapabilities & caps);
+ const RepositoryCapabilities & caps, const std::string & eapi);
virtual void need_keys_added() const;