aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-25 21:51:26 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-25 21:51:26 +0000
commit08ac2c69c0075f332c0ae3593c92704c9b5b4ace (patch)
tree1dc4f812d6e0c5e81c8f5087ee232cd7a5344585
parent3694ba8427a47f2b2ff5eefa2da315f11c224049 (diff)
downloadpaludis-08ac2c69c0075f332c0ae3593c92704c9b5b4ace.tar.gz
paludis-08ac2c69c0075f332c0ae3593c92704c9b5b4ace.tar.xz
Allow access to deps through VersionMetadata.
-rw-r--r--ruby/version_metadata.cc20
-rw-r--r--ruby/version_metadata_TEST.rb6
2 files changed, 26 insertions, 0 deletions
diff --git a/ruby/version_metadata.cc b/ruby/version_metadata.cc
index 0674aae..41d1fa3 100644
--- a/ruby/version_metadata.cc
+++ b/ruby/version_metadata.cc
@@ -94,6 +94,19 @@ namespace
}
};
+ template <DepAtom::ConstPointer (VersionMetadataDeps::* m_) () const>
+ struct DependValue
+ {
+ static VALUE
+ fetch(VALUE self)
+ {
+ VersionMetadata::ConstPointer * self_ptr;
+ Data_Get_Struct(self, VersionMetadata::ConstPointer, self_ptr);
+ // don't change the line below to something cleaner, it makes g++-4.1 puke
+ return dep_atom_to_value(((&(*self_ptr)->deps)->*m_)());
+ }
+ };
+
void do_register_version_metadata()
{
c_version_metadata = rb_define_class_under(master_class(), "VersionMetadata", rb_cObject);
@@ -127,6 +140,13 @@ namespace
&EbuildVersionMetadata::iuse>::fetch)), 0);
rb_define_method(c_version_metadata, "inherited", RUBY_FUNC_CAST((&EbuildValue<std::string,
&EbuildVersionMetadata::inherited>::fetch)), 0);
+
+ rb_define_method(c_version_metadata, "build_depend", RUBY_FUNC_CAST((&DependValue<
+ &VersionMetadataDeps::build_depend>::fetch)), 0);
+ rb_define_method(c_version_metadata, "run_depend", RUBY_FUNC_CAST((&DependValue<
+ &VersionMetadataDeps::run_depend>::fetch)), 0);
+ rb_define_method(c_version_metadata, "post_depend", RUBY_FUNC_CAST((&DependValue<
+ &VersionMetadataDeps::post_depend>::fetch)), 0);
}
}
diff --git a/ruby/version_metadata_TEST.rb b/ruby/version_metadata_TEST.rb
index a8ae7d4..df88900 100644
--- a/ruby/version_metadata_TEST.rb
+++ b/ruby/version_metadata_TEST.rb
@@ -68,6 +68,12 @@ class Paludis
assert_equal "test", vmd("1.0").keywords.gsub(%r/\s/, "")
assert_equal "", vmd("1.0").iuse.gsub(%r/\s/, "")
end
+
+ def test_deps
+ assert_kind_of AllDepAtom, vmd("1.0").build_depend
+ assert_kind_of AllDepAtom, vmd("1.0").run_depend
+ assert_kind_of AllDepAtom, vmd("1.0").post_depend
+ end
end
end