aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2007-01-19 16:56:37 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2007-01-19 16:56:37 +0000
commit07a0556fef033c88aa8026d88e51ae832b2d7564 (patch)
tree9a913f128a5200ca4cd91580b9b157ac461e6e73
parent3ab920214db2acb12e67c5d9cb1a6d874ebce60e (diff)
downloadpaludis-07a0556fef033c88aa8026d88e51ae832b2d7564.tar.gz
paludis-07a0556fef033c88aa8026d88e51ae832b2d7564.tar.xz
Ruby DepListOverrideMasks work.
-rw-r--r--ruby/dep_list.cc33
-rw-r--r--ruby/dep_list_TEST.rb15
2 files changed, 48 insertions, 0 deletions
diff --git a/ruby/dep_list.cc b/ruby/dep_list.cc
index ddd69c8..0463dd6 100644
--- a/ruby/dep_list.cc
+++ b/ruby/dep_list.cc
@@ -1097,6 +1097,38 @@ namespace
}
}
+ VALUE
+ dep_list_override_masks_reset(int argc, VALUE * argv, VALUE self)
+ {
+ DepListOverrideMasks * m_ptr;
+ Data_Get_Struct(self, DepListOverrideMasks, m_ptr);
+ if (argc == 0)
+ {
+ m_ptr->reset();
+ return Qnil;
+ }
+ else if (argc == 1)
+ {
+ try
+ {
+ int mr = NUM2INT(argv[0]);
+ if (mr < 0 || mr >= last_dl_override)
+ rb_raise(rb_eArgError, "DepListOverrideMask out of range");
+ m_ptr->reset(mr);
+ return Qnil;
+
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+ else
+ {
+ rb_raise(rb_eArgError, "clear expects one or zero arguments, but got %d",argc);
+ }
+ }
+
/*
* call-seq:
* == other_mask_reason -> True or False
@@ -1445,6 +1477,7 @@ namespace
rb_include_module(c_dep_list_override_masks, rb_mEnumerable);
rb_define_method(c_dep_list_override_masks, "empty?", RUBY_FUNC_CAST(&dep_list_override_masks_empty), 0);
rb_define_method(c_dep_list_override_masks, "set", RUBY_FUNC_CAST(&dep_list_override_masks_set), 1);
+ rb_define_method(c_dep_list_override_masks, "reset", RUBY_FUNC_CAST(&dep_list_override_masks_reset), -1);
rb_define_method(c_dep_list_override_masks, "==", RUBY_FUNC_CAST(&dep_list_override_masks_equal), 1);
}
}
diff --git a/ruby/dep_list_TEST.rb b/ruby/dep_list_TEST.rb
index 6ebbb86..eb186a4 100644
--- a/ruby/dep_list_TEST.rb
+++ b/ruby/dep_list_TEST.rb
@@ -258,6 +258,8 @@ module Paludis
def test_empty
m = DepListOverrideMasks.new
assert m.empty?
+ m.set DepListOverrideMask::Licenses
+ assert !m.empty?
end
def test_set
@@ -271,5 +273,18 @@ module Paludis
assert m.include?(DepListOverrideMask::Licenses)
assert m.include?(DepListOverrideMask::ProfileMasks)
end
+
+ def test_clear
+ m = DepListOverrideMasks.new
+ m.set DepListOverrideMask::Licenses
+ m.set DepListOverrideMask::ProfileMasks
+ m.set DepListOverrideMask::TildeKeywords
+
+ assert_equal 3, m.entries.length
+ m.reset DepListOverrideMask::TildeKeywords
+ assert_equal 2, m.entries.length
+ m.reset
+ assert m.empty?
+ end
end
end