aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2007-01-26 16:03:25 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2007-01-26 16:03:25 +0000
commit371b8e8426b88be82f043bfa047a80814b901295 (patch)
treeb07aa7b9144b22627aad8726e127185d996f9ae2
parent76da50c645eeb1d3bca9014209919d1fe2c540f3 (diff)
downloadpaludis-371b8e8426b88be82f043bfa047a80814b901295.tar.gz
paludis-371b8e8426b88be82f043bfa047a80814b901295.tar.xz
Bring ruby PackageDepAtom up to date.
-rw-r--r--paludis/version_requirements.cc24
-rw-r--r--paludis/version_requirements.hh8
-rw-r--r--ruby/dep_atom.cc26
-rw-r--r--ruby/dep_atom_TEST.rb7
4 files changed, 63 insertions, 2 deletions
diff --git a/paludis/version_requirements.cc b/paludis/version_requirements.cc
index 4d2321f..004e9aa 100644
--- a/paludis/version_requirements.cc
+++ b/paludis/version_requirements.cc
@@ -23,3 +23,27 @@ using namespace paludis;
#include <paludis/version_requirements-sr.cc>
+std::ostream &
+paludis::operator<< (std::ostream & o, const VersionRequirementsMode & s)
+{
+ do
+ {
+ switch (s)
+ {
+ case vr_and:
+ o << "and";
+ continue;
+
+ case vr_or:
+ o << "or";
+ continue;
+
+ case last_vr:
+ ;
+ }
+
+ throw InternalError(PALUDIS_HERE, "Bad VersionRequirementsMode");
+ } while (false);
+
+ return o;
+}
diff --git a/paludis/version_requirements.hh b/paludis/version_requirements.hh
index eb25fcb..921f478 100644
--- a/paludis/version_requirements.hh
+++ b/paludis/version_requirements.hh
@@ -44,6 +44,14 @@ namespace paludis
vr_and, ///\< Must match all
last_vr
};
+
+ /**
+ * Write a VersionRequirementsMode to a stream.
+ *
+ * \ingroup grpversions
+ */
+ std::ostream &
+ operator<< (std::ostream &, const VersionRequirementsMode &) PALUDIS_VISIBLE;
}
#endif
diff --git a/ruby/dep_atom.cc b/ruby/dep_atom.cc
index 9ad29fd..cb04232 100644
--- a/ruby/dep_atom.cc
+++ b/ruby/dep_atom.cc
@@ -38,6 +38,7 @@ namespace
static VALUE c_use_dep_atom;
static VALUE c_block_dep_atom;
static VALUE c_string_dep_atom;
+ static VALUE c_version_requirements_mode;
VALUE
dep_atom_init_1(VALUE self, VALUE)
@@ -210,7 +211,8 @@ namespace
* Fetch the version requirements. E.g. [ {:operator => '=', :spec => VersionSpec.new('0.1') } ]
*/
VALUE
- package_dep_atom_version_requirements_ptr(VALUE self) {
+ package_dep_atom_version_requirements_ptr(VALUE self)
+ {
PackageDepAtom::ConstPointer * ptr;
Data_Get_Struct(self, PackageDepAtom::ConstPointer, ptr);
VALUE result(rb_ary_new());
@@ -229,6 +231,14 @@ namespace
return result;
}
+ VALUE
+ package_dep_atom_version_requirements_mode(VALUE self)
+ {
+ PackageDepAtom::ConstPointer * ptr;
+ Data_Get_Struct(self, PackageDepAtom::ConstPointer, ptr);
+ return INT2FIX((*ptr)->version_requirements_mode());
+ }
+
void do_register_dep_atom()
{
/*
@@ -300,6 +310,7 @@ namespace
rb_define_method(c_package_dep_atom, "slot", RUBY_FUNC_CAST(&package_dep_atom_slot_ptr), 0);
rb_define_method(c_package_dep_atom, "repository", RUBY_FUNC_CAST(&package_dep_atom_repository_ptr), 0);
rb_define_method(c_package_dep_atom, "version_requirements", RUBY_FUNC_CAST(&package_dep_atom_version_requirements_ptr), 0);
+ rb_define_method(c_package_dep_atom, "version_requirements_mode", RUBY_FUNC_CAST(&package_dep_atom_version_requirements_mode), 0);
/*
* Document-class: Paludis::PlainTextDepAtom
@@ -321,6 +332,19 @@ namespace
rb_define_singleton_method(c_block_dep_atom, "new", RUBY_FUNC_CAST(&block_dep_atom_new), 1);
rb_define_method(c_block_dep_atom, "initialize", RUBY_FUNC_CAST(&dep_atom_init_1), 1);
rb_define_method(c_block_dep_atom, "blocked_atom", RUBY_FUNC_CAST(&block_dep_atom_blocked_atom), 0);
+
+ /*
+ * Document-module: Paludis::VersionRequirementsMode
+ *
+ * What sort of VersionRequirements to we have.
+ *
+ */
+ c_version_requirements_mode = rb_define_module_under(paludis_module(), "VersionRequirementsMode");
+ for (VersionRequirementsMode l(static_cast<VersionRequirementsMode>(0)), l_end(last_vr) ; l != l_end ;
+ l = static_cast<VersionRequirementsMode>(static_cast<int>(l) + 1))
+ rb_define_const(c_version_requirements_mode, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
+
+ // cc_enum_special<paludis/version_requirements.hh, VersionRequirementsMode, c_version_requirements_mode>
}
}
diff --git a/ruby/dep_atom_TEST.rb b/ruby/dep_atom_TEST.rb
index e87a722..c328e34 100644
--- a/ruby/dep_atom_TEST.rb
+++ b/ruby/dep_atom_TEST.rb
@@ -1,8 +1,8 @@
#!/usr/bin/env ruby
# vim: set sw=4 sts=4 et tw=80 :
-
#
# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+# Copyright (c) 2007 Richard Brown <mynamewasgone@gmail.com>
#
# This file is part of the Paludis package manager. Paludis is free software;
# you can redistribute it and/or modify it under the terms of the GNU General
@@ -83,6 +83,11 @@ module Paludis
assert_equal VersionSpec.new('1'), pda.version_requirements.first[:spec]
assert_equal ">=", pda.version_requirements.first[:operator]
end
+
+ def test_version_requirements_mode
+ assert_kind_of Fixnum, pda.version_requirements_mode
+ assert_equal VersionRequirementsMode::And, pda.version_requirements_mode
+ end
end
class TestCase_PlainTextDepAtom < Test::Unit::TestCase