aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2007-02-10 21:17:00 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2007-02-10 21:17:00 +0000
commit4dbf13e6959ff4320c1b3dcbb8b6149feadfe7a1 (patch)
tree1418d27b4219e9389347578491485b6f128f9594
parent3a54ff3f3241ae868b235a94c4be6314954c8409 (diff)
downloadpaludis-4dbf13e6959ff4320c1b3dcbb8b6149feadfe7a1.tar.gz
paludis-4dbf13e6959ff4320c1b3dcbb8b6149feadfe7a1.tar.xz
Update ruby for latest destinations.
-rw-r--r--ruby/Makefile.am6
-rw-r--r--ruby/dep_list.cc64
-rw-r--r--ruby/dep_list_TEST.rb26
-rwxr-xr-xruby/dep_list_TEST_setup.sh24
-rw-r--r--ruby/environment.cc37
-rw-r--r--ruby/environment_TEST.rb32
-rw-r--r--ruby/paludis_ruby.cc4
-rw-r--r--ruby/paludis_ruby.hh3
-rw-r--r--ruby/query.cc37
-rw-r--r--ruby/repository.cc95
10 files changed, 251 insertions, 77 deletions
diff --git a/ruby/Makefile.am b/ruby/Makefile.am
index af84bb0..306ccdc 100644
--- a/ruby/Makefile.am
+++ b/ruby/Makefile.am
@@ -23,7 +23,6 @@ IF_RUBY_TESTS = \
version_spec_TEST.rb \
mask_reasons_TEST.rb \
dep_atom_TEST.rb \
- package_database_TEST.rb \
repository_TEST.rb \
version_metadata_TEST.rb \
portage_dep_parser_TEST.rb \
@@ -31,7 +30,8 @@ IF_RUBY_TESTS = \
contents_TEST.rb \
dep_list_TEST.rb \
dep_tag_TEST.rb \
- query_TEST.rb
+ query_TEST.rb \
+ package_database_TEST.rb
IF_RUBY_QA_TESTS = \
message_TEST.rb \
@@ -120,7 +120,7 @@ libpaludisruby_la_LIBADD = \
$(top_builddir)/paludis/environment/default/libpaludisdefaultenvironment.la \
$(top_builddir)/paludis/qa/libpaludisqa.la
-TESTS = $(IF_RUBY_TESTS) $(IF_RUBY_QA_TESTS)
+TESTS = $(IF_RUBY_QA_TESTS) $(IF_RUBY_TESTS)
else
diff --git a/ruby/dep_list.cc b/ruby/dep_list.cc
index 8a0df92..5b1e125 100644
--- a/ruby/dep_list.cc
+++ b/ruby/dep_list.cc
@@ -17,10 +17,9 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifdef CIARANM_DISABLED_THIS
-
#include <paludis_ruby.hh>
#include <paludis/dep_list/dep_list.hh>
+#include <paludis/util/collection_concrete.hh>
#include <ruby.h>
using namespace paludis;
@@ -825,18 +824,25 @@ namespace
/*
* call-seq:
- * add(dep_atom)
+ * add(dep_atom, destinations)
*
* Add the packages required to resolve an additional dependency atom.
*/
VALUE
- dep_list_add(VALUE self, VALUE da)
+ dep_list_add(VALUE self, VALUE da, VALUE d)
{
try
{
DepList * p;
Data_Get_Struct(self, DepList, p);
- p->add(value_to_dep_atom(da));
+ if (!rb_obj_is_kind_of(d, rb_cArray))
+ rb_raise(rb_eTypeError, "Can't convert %s into Array", rb_obj_classname(d));
+ std::tr1::shared_ptr<DestinationsCollection> destinations(new DestinationsCollection::Concrete);
+
+ for (long i = 0 ; i < RARRAY(d)->len ; ++i)
+ destinations->insert(value_to_repository(rb_ary_entry(d, i)));
+
+ p->add(value_to_dep_atom(da), destinations);
return self;
}
catch (const std::exception & e)
@@ -876,16 +882,30 @@ namespace
/*
* call-seq:
- * already_installed?(dep_atom)
+ * already_installed?(dep_atom, destinations)
*
* Is an atom structure already installed?
*/
VALUE
- dep_list_already_installed(VALUE self, VALUE da)
+ dep_list_already_installed(VALUE self, VALUE da, VALUE d)
{
- DepList * p;
- Data_Get_Struct(self, DepList, p);
- return p->already_installed(*value_to_dep_atom(da)) ? Qtrue : Qfalse;
+ try
+ {
+ DepList * p;
+ Data_Get_Struct(self, DepList, p);
+ if (!rb_obj_is_kind_of(d, rb_cArray))
+ rb_raise(rb_eTypeError, "Can't convert %s into Array", rb_obj_classname(d));
+ std::tr1::shared_ptr<DestinationsCollection> destinations(new DestinationsCollection::Concrete);
+
+ for (long i = 0 ; i < RARRAY(d)->len ; ++i)
+ destinations->insert(value_to_repository(rb_ary_entry(d, i)));
+
+ return p->already_installed(*value_to_dep_atom(da), destinations) ? Qtrue : Qfalse;
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
}
/*
@@ -1016,6 +1036,14 @@ namespace
}
VALUE
+ dep_list_entry_destination(VALUE self)
+ {
+ DepListEntry * p;
+ Data_Get_Struct(self, DepListEntry, p);
+ return(repository_to_value(p->destination));
+ }
+
+ VALUE
dep_list_override_masks_init(VALUE self)
{
return self;
@@ -1445,9 +1473,9 @@ namespace
c_dep_list= rb_define_class_under(paludis_module(), "DepList", rb_cObject);
rb_define_singleton_method(c_dep_list, "new", RUBY_FUNC_CAST(&dep_list_new), -1);
rb_define_method(c_dep_list, "initialize", RUBY_FUNC_CAST(&dep_list_init), -1);
- rb_define_method(c_dep_list, "add", RUBY_FUNC_CAST(&dep_list_add), 1);
+ rb_define_method(c_dep_list, "add", RUBY_FUNC_CAST(&dep_list_add), 2);
rb_define_method(c_dep_list, "clear", RUBY_FUNC_CAST(&dep_list_clear), 0);
- rb_define_method(c_dep_list, "already_installed?", RUBY_FUNC_CAST(&dep_list_already_installed), 1);
+ rb_define_method(c_dep_list, "already_installed?", RUBY_FUNC_CAST(&dep_list_already_installed), 2);
rb_define_method(c_dep_list, "each", RUBY_FUNC_CAST(&dep_list_each), 0);
rb_include_module(c_dep_list, rb_mEnumerable);
rb_define_method(c_dep_list, "options", RUBY_FUNC_CAST(&dep_list_options), 0);
@@ -1459,11 +1487,12 @@ namespace
*/
c_dep_list_entry = rb_define_class_under(paludis_module(), "DepListEntry", rb_cObject);
rb_funcall(c_dep_list_entry, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_dep_list_entry, "kind", RUBY_FUNC_CAST(&dep_list_entry_kind),0);
- rb_define_method(c_dep_list_entry, "package", RUBY_FUNC_CAST(&dep_list_entry_package),0);
- rb_define_method(c_dep_list_entry, "metadata", RUBY_FUNC_CAST(&dep_list_entry_metadata),0);
- rb_define_method(c_dep_list_entry, "state", RUBY_FUNC_CAST(&dep_list_entry_state),0);
- rb_define_method(c_dep_list_entry, "tags", RUBY_FUNC_CAST(&dep_list_entry_tags),0);
+ rb_define_method(c_dep_list_entry, "kind", RUBY_FUNC_CAST(&dep_list_entry_kind), 0);
+ rb_define_method(c_dep_list_entry, "package", RUBY_FUNC_CAST(&dep_list_entry_package), 0);
+ rb_define_method(c_dep_list_entry, "metadata", RUBY_FUNC_CAST(&dep_list_entry_metadata), 0);
+ rb_define_method(c_dep_list_entry, "state", RUBY_FUNC_CAST(&dep_list_entry_state), 0);
+ rb_define_method(c_dep_list_entry, "tags", RUBY_FUNC_CAST(&dep_list_entry_tags), 0);
+ rb_define_method(c_dep_list_entry, "destination", RUBY_FUNC_CAST(&dep_list_entry_destination), 0);
/*
* Document-class: DepListOverrideMasks
@@ -1486,5 +1515,4 @@ namespace
RegisterRubyClass::Register paludis_ruby_register_dep_list PALUDIS_ATTRIBUTE((used))
(&do_register_dep_list);
-#endif
diff --git a/ruby/dep_list_TEST.rb b/ruby/dep_list_TEST.rb
index 313e06b..ad90240 100644
--- a/ruby/dep_list_TEST.rb
+++ b/ruby/dep_list_TEST.rb
@@ -17,9 +17,6 @@
# Place, Suite 330, Boston, MA 02111-1307 USA
#
-# CIARANM_DISABLED_THIS
-exit 0
-
ENV['PALUDIS_HOME'] = Dir.getwd() + '/dep_list_TEST_dir/home'
require 'test/unit'
@@ -123,6 +120,10 @@ module Paludis
def pda
PackageDepAtom.new('foo/bar')
end
+
+ def dd
+ env.default_destinations
+ end
end
class TestCase_DepListOptions < Test::Unit::TestCase
@@ -181,7 +182,7 @@ module Paludis
def test_add
assert_nothing_raised do
- dl.add(pda)
+ dl.add(pda, dd)
end
end
@@ -194,21 +195,22 @@ module Paludis
def test_already_installed?
dep_atom = pda
dep_list = dl
- assert !dep_list.already_installed?(dep_atom)
- dep_list.add(dep_atom)
- assert dep_list.already_installed?(dep_atom)
+ assert !dep_list.already_installed?(dep_atom, dd)
+ dep_list.add(dep_atom, dd)
+ assert dep_list.already_installed?(dep_atom, dd)
end
def test_each
- assert_kind_of DepListEntry, dl.add(pda).entries.first
+ assert_kind_of DepListEntry, dl.add(pda, dd).entries.first
end
def test_errors
assert_raise AllMaskedError do
- dl.add(PackageDepAtom.new('foo/ba'))
+ dl.add(PackageDepAtom.new('foo/ba'), dd)
end
+
begin
- dl.add(PackageDepAtom.new('foo/ba'))
+ dl.add(PackageDepAtom.new('foo/ba'), dd)
rescue AllMaskedError => error
assert_equal 'foo/ba', error.query
end
@@ -233,7 +235,7 @@ module Paludis
include Shared
def dle
- dl.add(pda).entries.first
+ dl.add(pda, dd).entries.first
end
def test_create
@@ -246,7 +248,7 @@ module Paludis
dep_list_entry = dle
{
:package => PackageDatabaseEntry, :metadata => VersionMetadata,
- :state=> Integer, :tags => Array
+ :state=> Integer, :tags => Array, :destination => Repository
}.each_pair do |method, returns|
assert_respond_to dep_list_entry, method
assert_kind_of returns, dep_list_entry.send(method)
diff --git a/ruby/dep_list_TEST_setup.sh b/ruby/dep_list_TEST_setup.sh
index fae8002..e8eb919 100755
--- a/ruby/dep_list_TEST_setup.sh
+++ b/ruby/dep_list_TEST_setup.sh
@@ -14,6 +14,13 @@ cache = /var/empty
profiles = \${location}/profiles/testprofile
END
+cat <<END > home/.paludis/repositories/installed.conf
+location = `pwd`/installed
+format = vdb
+names_cache = /var/empty
+provides_cache = /var/empty
+END
+
cat <<END > home/.paludis/keywords.conf
* test
~foo/bar-1.0 ~test
@@ -68,4 +75,21 @@ KEYWORDS="~test"
END
cd ..
+mkdir -p installed/cat-one/pkg-one-1 || exit 1
+
+for i in SLOT EAPI; do
+ echo "0" >installed/cat-one/pkg-one-1/${i}
+done
+
+for i in DEPEND RDEPEND LICENSE INHERITED IUSE PDEPEND PROVIDE; do
+ touch installed/cat-one/pkg-one-1/${i}
+done
+
+echo "flag1 flag2" >>installed/cat-one/pkg-one-1/USE
+
+cat <<END >installed/cat-one/pkg-one-1/CONTENTS
+dir //test
+obj /test/test_file de54c26b0678df67aca147575523b3c2 1165250496
+sym /test/test_link -> /test/test_file 1165250496
+END
diff --git a/ruby/environment.cc b/ruby/environment.cc
index 4ddcd29..5dfe221 100644
--- a/ruby/environment.cc
+++ b/ruby/environment.cc
@@ -231,6 +231,41 @@ namespace
}
/*
+ * call-seq:
+ * root -> String
+ *
+ * Default root location, default is /.
+ */
+ VALUE
+ environment_root(VALUE self)
+ {
+ EnvironmentData * env_data;
+ Data_Get_Struct(self, EnvironmentData, env_data);
+ return rb_str_new2(stringify(env_data->env_ptr->root()).c_str());
+ }
+
+ /*
+ * call-seq:
+ * default_destinations -> Array
+ *
+ * Default: All repositories that provide RepositoryDestinationInterface and mark themselves
+ * as a default destination.
+ */
+ VALUE
+ environment_default_destinations(VALUE self)
+ {
+ EnvironmentData * env_data;
+ Data_Get_Struct(self, EnvironmentData, env_data);
+ std::tr1::shared_ptr<const DestinationsCollection> dc = env_data->env_ptr->default_destinations();
+ VALUE result(rb_ary_new());
+ for (DestinationsCollection::Iterator i(dc->begin()), i_end(dc->end()) ; i != i_end ; ++i)
+ rb_ary_push(result, repository_to_value(*i));
+
+ return result;
+
+ }
+
+ /*
* Gets the config suffix.
*/
VALUE
@@ -410,6 +445,8 @@ namespace
RUBY_FUNC_CAST((&EnvBoolStruct<&Environment::query_user_unmasks>::fetch)), 1);
rb_define_method(c_environment, "package_database", RUBY_FUNC_CAST(&environment_package_database), 0);
rb_define_method(c_environment, "package_set", RUBY_FUNC_CAST(&environment_package_set), 1);
+ rb_define_method(c_environment, "root", RUBY_FUNC_CAST(&environment_root), 0);
+ rb_define_method(c_environment, "default_destinations", RUBY_FUNC_CAST(&environment_default_destinations), 0);
/*
* Document-class: Paludis::DefaultEnvironment
diff --git a/ruby/environment_TEST.rb b/ruby/environment_TEST.rb
index ac99f50..19f9d5f 100644
--- a/ruby/environment_TEST.rb
+++ b/ruby/environment_TEST.rb
@@ -385,5 +385,37 @@ module Paludis
cd.gsub(Dir.getwd,'')
end
end
+
+ class TestCase_DefaultEnvironmentRoot < Test::Unit::TestCase
+ def test_root
+ assert_kind_of String, DefaultEnvironment.instance.root
+ end
+ end
+
+ class TestCase_DefaultEnvironmentDefaultDestinations < Test::Unit::TestCase
+ def test_default_destinations
+ assert_kind_of Array, DefaultEnvironment.instance.default_destinations
+ end
+ end
+
+ class TestCase_DefaultEnvironmentRoot < Test::Unit::TestCase
+ def env
+ NoConfigEnvironment.new(Dir.getwd().to_s + "/environment_TEST_dir/testrepo")
+ end
+
+ def test_root
+ assert_kind_of String, env.root
+ end
+ end
+
+ class TestCase_DefaultEnvironmentDefaultDestinations < Test::Unit::TestCase
+ def env
+ NoConfigEnvironment.new(Dir.getwd().to_s + "/environment_TEST_dir/testrepo")
+ end
+
+ def test_default_destinations
+ assert_kind_of Array, env.default_destinations
+ end
+ end
end
diff --git a/ruby/paludis_ruby.cc b/ruby/paludis_ruby.cc
index 04d2957..0729e81 100644
--- a/ruby/paludis_ruby.cc
+++ b/ruby/paludis_ruby.cc
@@ -69,6 +69,7 @@ namespace
static VALUE c_circular_dependency_error;
static VALUE c_use_requirements_not_met_error;
static VALUE c_downgrade_not_allowed_error;
+ static VALUE c_no_destination_error;
static VALUE c_environment;
static VALUE c_no_config_environment;
@@ -176,6 +177,8 @@ void paludis::ruby::exception_to_ruby_exception(const std::exception & ee)
rb_raise(c_use_requirements_not_met_error, dynamic_cast<const paludis::UseRequirementsNotMetError *>(&ee)->message().c_str());
else if (0 != dynamic_cast<const paludis::DowngradeNotAllowedError *>(&ee))
rb_raise(c_downgrade_not_allowed_error, dynamic_cast<const paludis::DowngradeNotAllowedError *>(&ee)->message().c_str());
+ else if (0 != dynamic_cast<const paludis::NoDestinationError *>(&ee))
+ rb_raise(c_no_destination_error, dynamic_cast<const paludis::NoDestinationError *>(&ee)->message().c_str());
else if (0 != dynamic_cast<const paludis::DepListError *>(&ee))
rb_raise(c_dep_list_error, dynamic_cast<const paludis::DepListError *>(&ee)->message().c_str());
#ifdef ENABLE_RUBY_QA
@@ -333,6 +336,7 @@ void paludis::ruby::init()
rb_define_method(c_use_requirements_not_met_error, "initialize", RUBY_FUNC_CAST(&has_query_property_error_init), -1);
rb_define_method(c_use_requirements_not_met_error, "query", RUBY_FUNC_CAST(&has_query_property_error_query), 0);
c_downgrade_not_allowed_error = rb_define_class_under(c_paludis_module, "DowngradeNotAllowedError", c_dep_list_error);
+ c_no_destination_error = rb_define_class_under(c_paludis_module, "NoDestinationError", c_dep_list_error);
rb_define_module_function(c_paludis_module, "match_package", RUBY_FUNC_CAST(&paludis_match_package), 3);
diff --git a/ruby/paludis_ruby.hh b/ruby/paludis_ruby.hh
index 7c1c301..8bfa0a2 100644
--- a/ruby/paludis_ruby.hh
+++ b/ruby/paludis_ruby.hh
@@ -84,7 +84,7 @@ namespace paludis
VALUE mask_reasons_to_value(const MaskReasons &);
VALUE package_database_to_value(std::tr1::shared_ptr<PackageDatabase>);
VALUE package_database_entry_to_value(const PackageDatabaseEntry &);
- VALUE repository_to_value(std::tr1::shared_ptr<const Repository>);
+ VALUE repository_to_value(std::tr1::shared_ptr<Repository>);
VALUE version_spec_to_value(const VersionSpec &);
VALUE version_metadata_to_value(std::tr1::shared_ptr<const VersionMetadata>);
VALUE dep_atom_to_value(std::tr1::shared_ptr<const DepAtom>);
@@ -105,6 +105,7 @@ namespace paludis
PortageRepositoryProfilesDescLine value_to_portage_repository_profiles_desc_line(VALUE v);
MaskReasons value_to_mask_reasons(VALUE v);
Query value_to_query(VALUE v);
+ std::tr1::shared_ptr<Repository> value_to_repository(VALUE);
#ifdef ENABLE_RUBY_QA
VALUE paludis_qa_module();
diff --git a/ruby/query.cc b/ruby/query.cc
index 2675005..d245a74 100644
--- a/ruby/query.cc
+++ b/ruby/query.cc
@@ -37,6 +37,7 @@ namespace
static VALUE c_repository_has_installed_interface;
static VALUE c_repository_has_installable_interface;
static VALUE c_repository_has_uninstallable_interface;
+ static VALUE c_installed_at_root;
VALUE
query_to_value(const Query & v)
@@ -137,6 +138,32 @@ namespace
}
};
+ /*
+ * call-seq:
+ * InstalledAtRoot.new(root)
+ *
+ *
+ */
+ VALUE
+ installed_at_root_new(VALUE self, VALUE root)
+ {
+ query::InstalledAtRoot * ptr(0);
+ try
+ {
+ ptr = new query::InstalledAtRoot(FSEntry(StringValuePtr(root)));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<query::InstalledAtRoot>::free, ptr));
+ rb_obj_call_init(tdata, 1, &root);
+ return tdata;
+
+ }
+ catch (const std::exception & e)
+ {
+ delete ptr;
+ exception_to_ruby_exception(e);
+ }
+ }
+
+
void do_register_query()
{
/*
@@ -178,18 +205,22 @@ namespace
c_repository_has_installed_interface = rb_define_class_under(c_query_module,
"RepositoryHasInstalledInterface", c_query);
- rb_define_singleton_method(c_repository_has_installed_interface, "new",
+ rb_define_singleton_method(c_repository_has_installed_interface, "new",
RUBY_FUNC_CAST(&QueryNew<query::RepositoryHasInstalledInterface>::query_new), 0);
c_repository_has_installable_interface = rb_define_class_under(c_query_module,
"RepositoryHasInstallableInterface", c_query);
- rb_define_singleton_method(c_repository_has_installable_interface, "new",
+ rb_define_singleton_method(c_repository_has_installable_interface, "new",
RUBY_FUNC_CAST(&QueryNew<query::RepositoryHasInstallableInterface>::query_new), 0);
c_repository_has_uninstallable_interface = rb_define_class_under(c_query_module,
"RepositoryHasUninstallableInterface", c_query);
- rb_define_singleton_method(c_repository_has_uninstallable_interface, "new",
+ rb_define_singleton_method(c_repository_has_uninstallable_interface, "new",
RUBY_FUNC_CAST(&QueryNew<query::RepositoryHasUninstallableInterface>::query_new), 0);
+
+ c_installed_at_root = rb_define_class_under(c_query_module,
+ "InstalledAtRoot", c_query);
+ rb_define_singleton_method(c_installed_at_root, "new", RUBY_FUNC_CAST(&installed_at_root_new), 1);
}
}
diff --git a/ruby/repository.cc b/ruby/repository.cc
index 53a592a..677dd44 100644
--- a/ruby/repository.cc
+++ b/ruby/repository.cc
@@ -48,8 +48,8 @@ namespace
{
try
{
- std::tr1::shared_ptr<const Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const Repository>, self_ptr);
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
return rb_str_new2(stringify((*self_ptr)->name()).c_str());
}
catch (const std::exception & e)
@@ -69,8 +69,8 @@ namespace
{
try
{
- std::tr1::shared_ptr<const Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const Repository>, self_ptr);
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
return rb_str_new2(stringify((*self_ptr)->format()).c_str());
}
catch (const std::exception & e)
@@ -90,8 +90,8 @@ namespace
{
try
{
- std::tr1::shared_ptr<const Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const Repository>, self_ptr);
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
return (*self_ptr)->has_category_named(CategoryNamePart(StringValuePtr(cat))) ? Qtrue : Qfalse;
}
catch (const std::exception & e)
@@ -115,8 +115,8 @@ namespace
{
try
{
- std::tr1::shared_ptr<const Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const Repository>, self_ptr);
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
return (*self_ptr)->has_package_named(value_to_qualified_package_name(name)) ? Qtrue : Qfalse;
}
catch (const std::exception & e)
@@ -136,8 +136,8 @@ namespace
{
try
{
- std::tr1::shared_ptr<const Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const Repository>, self_ptr);
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
return (*self_ptr)->has_version(value_to_qualified_package_name(name),
value_to_version_spec(version)) ? Qtrue : Qfalse;
}
@@ -159,8 +159,8 @@ namespace
{
try
{
- std::tr1::shared_ptr<const Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const Repository>, self_ptr);
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
if (rb_block_given_p())
{
std::tr1::shared_ptr<const CategoryNamePartCollection> c((*self_ptr)->category_names());
@@ -193,8 +193,8 @@ namespace
{
try
{
- std::tr1::shared_ptr<const Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const Repository>, self_ptr);
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
PackageNamePart package(StringValuePtr(pkg));
if (rb_block_given_p())
@@ -229,8 +229,8 @@ namespace
{
try
{
- std::tr1::shared_ptr<const Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const Repository>, self_ptr);
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
CategoryNamePart category(StringValuePtr(cat));
if (rb_block_given_p())
@@ -265,8 +265,8 @@ namespace
{
try
{
- std::tr1::shared_ptr<const Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const Repository>, self_ptr);
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
QualifiedPackageName q = value_to_qualified_package_name(qpn);
if (rb_block_given_p())
@@ -299,8 +299,8 @@ namespace
{
try
{
- std::tr1::shared_ptr<const Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const Repository>, self_ptr);
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
return version_metadata_to_value((*self_ptr)->version_metadata(value_to_qualified_package_name(name),
value_to_version_spec(version)));
}
@@ -411,8 +411,8 @@ namespace
{
static VALUE fetch(VALUE self)
{
- std::tr1::shared_ptr<const Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const Repository>, self_ptr);
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
return ((**self_ptr).*m_) ? self : Qnil;
}
};
@@ -426,8 +426,8 @@ namespace
VALUE
repository_info(VALUE self, VALUE verbose)
{
- std::tr1::shared_ptr<const Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const Repository>, self_ptr);
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
std::tr1::shared_ptr<const RepositoryInfo> * p = new std::tr1::shared_ptr<const RepositoryInfo>((*self_ptr)->info(Qfalse == verbose));
return Data_Wrap_Struct(c_repository_info, 0, &Common<std::tr1::shared_ptr<const RepositoryInfo> >::free, p);
@@ -513,9 +513,9 @@ namespace
{
try
{
- std::tr1::shared_ptr<const Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const Repository>, self_ptr);
- const RepositoryContentsInterface * const contents_interface ((**self_ptr).contents_interface);
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
+ RepositoryContentsInterface * const contents_interface ((**self_ptr).contents_interface);
if (contents_interface)
{
return contents_to_value(
@@ -547,9 +547,9 @@ namespace
{
try
{
- std::tr1::shared_ptr<const Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const Repository>, self_ptr);
- const RepositoryInstalledInterface * const installed_interface ((**self_ptr).installed_interface);
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
+ RepositoryInstalledInterface * const installed_interface ((**self_ptr).installed_interface);
if (installed_interface)
{
return rb_time_new(installed_interface->installed_time(
@@ -722,9 +722,9 @@ namespace
{
try
{
- std::tr1::shared_ptr<const Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const Repository>, self_ptr);
- const RepositoryUseInterface * const use_interface ((**self_ptr).use_interface);
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
+ RepositoryUseInterface * const use_interface ((**self_ptr).use_interface);
if (use_interface)
{
@@ -802,9 +802,9 @@ namespace
{
try
{
- std::tr1::shared_ptr<const Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const Repository>, self_ptr);
- const RepositoryMaskInterface * const mask_interface ((**self_ptr).mask_interface);
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
+ RepositoryMaskInterface * const mask_interface ((**self_ptr).mask_interface);
if (mask_interface)
{
@@ -838,8 +838,8 @@ namespace
{
try
{
- std::tr1::shared_ptr<const Repository> * self_ptr;
- Data_Get_Struct(self, std::tr1::shared_ptr<const Repository>, self_ptr);
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
if ((*self_ptr)->use_interface) {
if (1 == argc || 2 ==argc)
{
@@ -999,13 +999,28 @@ VALUE repo_to_value(T_ m, VALUE * klass)
}
VALUE
-paludis::ruby::repository_to_value(std::tr1::shared_ptr<const Repository> m)
+paludis::ruby::repository_to_value(std::tr1::shared_ptr<Repository> m)
{
if (0 != dynamic_cast<const PortageRepository *>(m.get()))
return repo_to_value<std::tr1::shared_ptr<const PortageRepository> >(
std::tr1::static_pointer_cast<const PortageRepository>(m), &c_portage_repository);
else
- return repo_to_value<std::tr1::shared_ptr<const Repository> >(m, &c_repository);
+ return repo_to_value<std::tr1::shared_ptr<Repository> >(m, &c_repository);
+}
+
+std::tr1::shared_ptr<Repository>
+paludis::ruby::value_to_repository(VALUE v)
+{
+ if (rb_obj_is_kind_of(v, c_repository))
+ {
+ std::tr1::shared_ptr<Repository> * v_ptr;
+ Data_Get_Struct(v, std::tr1::shared_ptr<Repository>, v_ptr);
+ return *v_ptr;
+ }
+ else
+ {
+ rb_raise(rb_eTypeError, "Can't convert %s into Repository", rb_obj_classname(v));
+ }
}
VALUE