aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-13 19:55:41 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-13 19:55:41 +0000
commitae19491e3ec5991491205a4ea97a1619faf0205c (patch)
tree1e165c70b7156b4376e9bdf261a18c5abbb332c0
parent1819e7a1858fa061f9e69ecef64062d434cc2c01 (diff)
downloadpaludis-ae19491e3ec5991491205a4ea97a1619faf0205c.tar.gz
paludis-ae19491e3ec5991491205a4ea97a1619faf0205c.tar.xz
Replace bitset with less ABI-sensitive Options class
-rw-r--r--paludis/dep_list/dep_list.cc30
-rw-r--r--paludis/dep_list/dep_list.hh2
-rw-r--r--paludis/dep_list/options.hh4
-rw-r--r--paludis/environment.cc28
-rw-r--r--paludis/mask_reasons.hh4
-rw-r--r--paludis/util/files.m41
-rw-r--r--paludis/util/options.cc122
-rw-r--r--paludis/util/options.hh114
-rw-r--r--paludis/util/options_TEST.cc97
-rw-r--r--ruby/dep_list.cc29
-rw-r--r--ruby/dep_list_TEST.rb6
-rw-r--r--ruby/mask_reasons.cc27
-rw-r--r--src/clients/adjutrix/what_needs_keywording.cc12
-rw-r--r--src/clients/contrarius/install.cc4
-rw-r--r--src/clients/paludis/install.cc14
-rw-r--r--src/clients/paludis/query.cc2
-rw-r--r--src/clients/paludis/report.cc4
-rw-r--r--src/output/console_install_task.cc4
-rw-r--r--src/output/console_query_task.cc2
19 files changed, 399 insertions, 107 deletions
diff --git a/paludis/dep_list/dep_list.cc b/paludis/dep_list/dep_list.cc
index aa77820..b1973fa 100644
--- a/paludis/dep_list/dep_list.cc
+++ b/paludis/dep_list/dep_list.cc
@@ -581,11 +581,11 @@ DepList::AddVisitor::visit(const PackageDepSpec * const a)
{
while (next != last_dl_override)
{
- if (masks_to_override.test(next))
+ if (masks_to_override[next])
next = static_cast<DepListOverrideMask>(static_cast<int>(next) + 1);
- else if (d->_imp->opts->override_masks.test(next))
+ else if (d->_imp->opts->override_masks[next])
{
- masks_to_override.set(next);
+ masks_to_override += next;
break;
}
else
@@ -596,23 +596,21 @@ DepList::AddVisitor::visit(const PackageDepSpec * const a)
break;
MaskReasons mask_mask;
- if (masks_to_override.test(dl_override_repository_masks))
- mask_mask.set(mr_repository_mask);
- if (masks_to_override.test(dl_override_profile_masks))
- mask_mask.set(mr_profile_mask);
- if (masks_to_override.test(dl_override_licenses))
- mask_mask.set(mr_license);
- mask_mask.set(mr_by_association);
- mask_mask.flip();
-
- bool override_tilde_keywords(masks_to_override.test(dl_override_tilde_keywords));
- bool override_unkeyworded(masks_to_override.test(dl_override_unkeyworded));
+ if (masks_to_override[dl_override_repository_masks])
+ mask_mask += mr_repository_mask;
+ if (masks_to_override[dl_override_profile_masks])
+ mask_mask += mr_profile_mask;
+ if (masks_to_override[dl_override_licenses])
+ mask_mask += mr_license;
+ mask_mask += mr_by_association;
+
+ bool override_tilde_keywords(masks_to_override[dl_override_tilde_keywords]);
+ bool override_unkeyworded(masks_to_override[dl_override_unkeyworded]);
for (PackageDatabaseEntryCollection::ReverseIterator p(installable_candidates->rbegin()),
p_end(installable_candidates->rend()) ; p != p_end ; ++p)
{
- if (! (d->_imp->env->mask_reasons(*p, override_tilde_keywords, override_unkeyworded)
- & mask_mask).any())
+ if (! (d->_imp->env->mask_reasons(*p, override_tilde_keywords, override_unkeyworded).subtract(mask_mask).any()))
{
d->add_error_package(*p, dlk_masked);
best_visible_candidate = &*p;
diff --git a/paludis/dep_list/dep_list.hh b/paludis/dep_list/dep_list.hh
index bdf4f36..ed46387 100644
--- a/paludis/dep_list/dep_list.hh
+++ b/paludis/dep_list/dep_list.hh
@@ -27,10 +27,10 @@
#include <paludis/environment.hh>
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/options.hh>
#include <paludis/version_spec.hh>
#include <iosfwd>
-#include <bitset>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
diff --git a/paludis/dep_list/options.hh b/paludis/dep_list/options.hh
index 84b55f0..191401f 100644
--- a/paludis/dep_list/options.hh
+++ b/paludis/dep_list/options.hh
@@ -22,7 +22,7 @@
#include <iosfwd>
#include <paludis/util/attributes.hh>
-#include <bitset>
+#include <paludis/util/options.hh>
namespace paludis
{
@@ -35,7 +35,7 @@ namespace paludis
* \ingroup grpdepresolver
* \see DepListOverrideMask
*/
- typedef std::bitset<last_dl_override> DepListOverrideMasks;
+ typedef Options<DepListOverrideMask> DepListOverrideMasks;
}
#endif
diff --git a/paludis/environment.cc b/paludis/environment.cc
index 30a449a..2f1a583 100644
--- a/paludis/environment.cc
+++ b/paludis/environment.cc
@@ -133,20 +133,20 @@ Environment::mask_reasons(const PackageDatabaseEntry & e, const bool override_ti
e.repository)->version_metadata(e.name, e.version));
if (! accept_eapi(metadata->eapi))
- result.set(mr_eapi);
+ result += mr_eapi;
else
{
if (breaks_portage(e, *metadata) && ! accept_breaks_portage())
- result.set(mr_breaks_portage);
+ result += mr_breaks_portage;
if (metadata->interactive && ! accept_interactive())
- result.set(mr_interactive);
+ result += mr_interactive;
if (metadata->virtual_interface)
{
result |= mask_reasons(metadata->virtual_interface->virtual_for);
if (result.any())
- result.set(mr_by_association);
+ result += mr_by_association;
}
if (metadata->ebuild_interface)
@@ -158,26 +158,26 @@ Environment::mask_reasons(const PackageDatabaseEntry & e, const bool override_ti
if (keywords.empty())
keywords.insert(KeywordName("empty"));
- result.set(mr_keyword);
+ result += mr_keyword;
for (std::set<KeywordName>::const_iterator i(keywords.begin()),
i_end(keywords.end()) ; i != i_end ; ++i)
if (accept_keyword(*i, &e, override_tilde_keywords))
{
- result.reset(mr_keyword);
+ result -= mr_keyword;
break;
}
- if (override_unkeyworded && result.test(mr_keyword))
+ if (override_unkeyworded && result[mr_keyword])
{
- result.reset(mr_keyword);
+ result -= mr_keyword;
for (std::set<KeywordName>::const_iterator i(keywords.begin()),
i_end(keywords.end()) ; i != i_end ; ++i)
if ("-*" == stringify(*i))
- result.set(mr_keyword);
+ result += mr_keyword;
else if ('-' == stringify(*i).at(0))
if (accept_keyword(KeywordName(stringify(*i).substr(1)), &e, override_tilde_keywords))
{
- result.set(mr_keyword);
+ result += mr_keyword;
break;
}
}
@@ -188,13 +188,13 @@ Environment::mask_reasons(const PackageDatabaseEntry & e, const bool override_ti
LicenceChecker lc(this, &e);
metadata->license_interface->license()->accept(&lc);
if (! lc.ok)
- result.set(mr_license);
+ result += mr_license;
}
if (! query_user_unmasks(e))
{
if (query_user_masks(e))
- result.set(mr_user_mask);
+ result += mr_user_mask;
const Repository * const repo(package_database()->fetch_repository(e.repository).get());
@@ -202,11 +202,11 @@ Environment::mask_reasons(const PackageDatabaseEntry & e, const bool override_ti
{
if (repo->mask_interface->query_profile_masks(e.name,
e.version))
- result.set(mr_profile_mask);
+ result += mr_profile_mask;
if (repo->mask_interface->query_repository_masks(e.name,
e.version))
- result.set(mr_repository_mask);
+ result += mr_repository_mask;
}
}
}
diff --git a/paludis/mask_reasons.hh b/paludis/mask_reasons.hh
index d3338c0..d5aa2f3 100644
--- a/paludis/mask_reasons.hh
+++ b/paludis/mask_reasons.hh
@@ -20,7 +20,7 @@
#ifndef PALUDIS_GUARD_PALUDIS_MASK_REASONS_HH
#define PALUDIS_GUARD_PALUDIS_MASK_REASONS_HH 1
-#include <bitset>
+#include <paludis/util/options.hh>
#include <iosfwd>
/** \file
@@ -39,7 +39,7 @@ namespace paludis
*
* \ingroup grpmaskreasons
*/
- typedef std::bitset<last_mr> MaskReasons;
+ typedef Options<MaskReason> MaskReasons;
}
#endif
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 4ec2330..9cc9ac5 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -26,6 +26,7 @@ add(`instantiation_policy', `hh', `test')
add(`is_file_with_extension', `hh', `cc', `test', `testscript')
add(`join', `hh', `test')
add(`log', `hh', `cc', `test')
+add(`options', `hh', `cc', `test')
add(`pipe', `hh', `cc')
add(`private_implementation_pattern', `hh')
add(`pstream', `hh', `cc', `test')
diff --git a/paludis/util/options.cc b/paludis/util/options.cc
new file mode 100644
index 0000000..56fbd7b
--- /dev/null
+++ b/paludis/util/options.cc
@@ -0,0 +1,122 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "options.hh"
+#include <vector>
+#include <algorithm>
+#include <functional>
+#include <stdint.h>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template<>
+ struct Implementation<OptionsStore>
+ {
+ std::vector<uint8_t> pool;
+
+ Implementation()
+ {
+ }
+
+ Implementation(const Implementation & i) :
+ pool(i.pool)
+ {
+ }
+ };
+}
+
+OptionsStore::OptionsStore() :
+ PrivateImplementationPattern<OptionsStore>(new Implementation<OptionsStore>)
+{
+}
+
+OptionsStore::OptionsStore(const OptionsStore & s) :
+ PrivateImplementationPattern<OptionsStore>(new Implementation<OptionsStore>(*s._imp.operator-> ()))
+{
+}
+
+const OptionsStore &
+OptionsStore::operator= (const OptionsStore & s)
+{
+ if (this != &s)
+ _imp.reset(new Implementation<OptionsStore>(*s._imp.operator-> ()));
+
+ return *this;
+}
+
+OptionsStore::~OptionsStore()
+{
+}
+
+void
+OptionsStore::add(const unsigned e)
+{
+ if (_imp->pool.size() < e / 8 + 1)
+ _imp->pool.resize(e / 8 + 1, 0);
+
+ _imp->pool.at(e / 8) |= (1 << (e % 8));
+}
+
+void
+OptionsStore::remove(const unsigned e)
+{
+ if (_imp->pool.size() < e / 8 + 1)
+ _imp->pool.resize(e / 8 + 1, 0);
+
+ _imp->pool.at(e / 8) &= ~(1 << (e % 8));
+}
+
+void
+OptionsStore::combine(const OptionsStore & e)
+{
+ if (_imp->pool.size() < e._imp->pool.size())
+ _imp->pool.resize(e._imp->pool.size(), 0);
+
+ for (unsigned s(0), s_end(e._imp->pool.size()) ; s != s_end ; ++s)
+ _imp->pool.at(s) |= e._imp->pool.at(s);
+}
+
+void
+OptionsStore::subtract(const OptionsStore & e)
+{
+ if (_imp->pool.size() < e._imp->pool.size())
+ _imp->pool.resize(e._imp->pool.size(), 0);
+
+ for (unsigned s(0), s_end(e._imp->pool.size()) ; s != s_end ; ++s)
+ _imp->pool.at(s) &= ~e._imp->pool.at(s);
+}
+
+bool
+OptionsStore::test(const unsigned e) const
+{
+ if (_imp->pool.size() < e / 8 + 1)
+ return false;
+
+ return _imp->pool.at(e / 8) & (1 << (e % 8));
+}
+
+bool
+OptionsStore::any() const
+{
+ return _imp->pool.end() != std::find_if(_imp->pool.begin(), _imp->pool.end(),
+ std::bind2nd(std::not_equal_to<uint8_t>(), 0));
+}
+
diff --git a/paludis/util/options.hh b/paludis/util/options.hh
new file mode 100644
index 0000000..daa1504
--- /dev/null
+++ b/paludis/util/options.hh
@@ -0,0 +1,114 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_OPTIONS_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_OPTIONS_HH 1
+
+#include <paludis/util/private_implementation_pattern.hh>
+
+namespace paludis
+{
+ class OptionsStore :
+ private PrivateImplementationPattern<OptionsStore>
+ {
+ public:
+ OptionsStore();
+ OptionsStore(const OptionsStore &);
+ const OptionsStore & operator= (const OptionsStore &);
+ ~OptionsStore();
+
+ void add(const unsigned);
+ void remove(const unsigned);
+ void combine(const OptionsStore &);
+ void subtract(const OptionsStore &);
+
+ bool test(const unsigned) const;
+ bool any() const;
+ };
+
+ template <typename E_>
+ class Options
+ {
+ private:
+ OptionsStore _store;
+
+ public:
+ Options operator+ (const E_ & e) const
+ {
+ Options result(*this);
+ result._store.add(static_cast<unsigned>(e));
+ return result;
+ }
+
+ Options & operator+= (const E_ & e)
+ {
+ _store.add(static_cast<unsigned>(e));
+ return *this;
+ }
+
+ Options operator- (const E_ & e) const
+ {
+ Options result(*this);
+ result._store.remove(static_cast<unsigned>(e));
+ return result;
+ }
+
+ Options & operator-= (const E_ & e)
+ {
+ _store.remove(static_cast<unsigned>(e));
+ return *this;
+ }
+
+ Options operator| (const Options<E_> & e) const
+ {
+ Options result(*this);
+ result._store.combine(e._store);
+ return result;
+ }
+
+ Options & operator|= (const Options<E_> & e)
+ {
+ _store.combine(e._store);
+ return *this;
+ }
+
+ Options & subtract(const Options<E_> & e)
+ {
+ _store.subtract(e._store);
+ return *this;
+ }
+
+ bool operator[] (const E_ & e) const
+ {
+ return _store.test(static_cast<unsigned>(e));
+ }
+
+ bool any() const
+ {
+ return _store.any();
+ }
+
+ bool none() const
+ {
+ return ! _store.any();
+ }
+ };
+}
+
+#endif
diff --git a/paludis/util/options_TEST.cc b/paludis/util/options_TEST.cc
new file mode 100644
index 0000000..52be5cc
--- /dev/null
+++ b/paludis/util/options_TEST.cc
@@ -0,0 +1,97 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * 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
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "options.hh"
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+
+using namespace test;
+using namespace paludis;
+
+enum MyOption { mo_one, mo_two, mo_three, mo_four, mo_five, mo_six, mo_seven, mo_eight, mo_nine, mo_ten, last_mo };
+typedef Options<MyOption> MyOptions;
+
+namespace test_cases
+{
+ struct OptionsTest : TestCase
+ {
+ OptionsTest() : TestCase("options") { }
+
+ void run()
+ {
+ MyOptions options, second;
+
+ TEST_CHECK(! options.any());
+
+ for (MyOption o(static_cast<MyOption>(0)) ; o < last_mo ; o = static_cast<MyOption>(static_cast<long>(o) + 1))
+ {
+ TestMessageSuffix so("o:" + stringify(o));
+ TEST_CHECK(! options[o]);
+ }
+
+ for (MyOption o(static_cast<MyOption>(0)) ; o < last_mo ; o = static_cast<MyOption>(static_cast<long>(o) + 2))
+ options = options + o;
+
+ TEST_CHECK(options.any());
+
+ for (MyOption o(static_cast<MyOption>(0)) ; o < last_mo ; o = static_cast<MyOption>(static_cast<long>(o) + 2))
+ {
+ TestMessageSuffix so("o:" + stringify(o));
+ TEST_CHECK(options[o]);
+ }
+
+ for (MyOption o(static_cast<MyOption>(1)) ; o < last_mo ; o = static_cast<MyOption>(static_cast<long>(o) + 2))
+ {
+ TestMessageSuffix so("o:" + stringify(o));
+ TEST_CHECK(! options[o]);
+ }
+
+ for (MyOption o(static_cast<MyOption>(0)) ; o < last_mo ; o = static_cast<MyOption>(static_cast<long>(o) + 1))
+ second += o;
+
+ options |= second;
+
+ for (MyOption o(static_cast<MyOption>(0)) ; o < last_mo ; o = static_cast<MyOption>(static_cast<long>(o) + 1))
+ {
+ TestMessageSuffix so("o:" + stringify(o));
+ TEST_CHECK(options[o]);
+ }
+
+ for (MyOption o(static_cast<MyOption>(1)) ; o < last_mo ; o = static_cast<MyOption>(static_cast<long>(o) + 2))
+ options -= o;
+
+ TEST_CHECK(options.any());
+
+ for (MyOption o(static_cast<MyOption>(0)) ; o < last_mo ; o = static_cast<MyOption>(static_cast<long>(o) + 2))
+ options = options - o;
+
+ TEST_CHECK(! options.any());
+
+ second = MyOptions() + mo_three + mo_eight;
+ options |= second;
+ options += mo_seven;
+ TEST_CHECK(options.any());
+ options.subtract(second);
+ TEST_CHECK(options.any());
+ options -= mo_seven;
+ TEST_CHECK(! options.any());
+ }
+ } test_options;
+}
+
diff --git a/ruby/dep_list.cc b/ruby/dep_list.cc
index 0d083f7..4eeaba5 100644
--- a/ruby/dep_list.cc
+++ b/ruby/dep_list.cc
@@ -1125,7 +1125,7 @@ namespace
int mr = NUM2INT(mask_reason);
if (mr < 0 || mr >= last_dl_override)
rb_raise(rb_eArgError, "DepListOverrideMask out of range");
- m_ptr->set(mr);
+ *m_ptr += static_cast<DepListOverrideMask>(mr);
return Qnil;
}
@@ -1142,7 +1142,7 @@ namespace
Data_Get_Struct(self, DepListOverrideMasks, m_ptr);
if (argc == 0)
{
- m_ptr->reset();
+ *m_ptr = DepListOverrideMasks();
return Qnil;
}
else if (argc == 1)
@@ -1152,7 +1152,7 @@ namespace
int mr = NUM2INT(argv[0]);
if (mr < 0 || mr >= last_dl_override)
rb_raise(rb_eArgError, "DepListOverrideMask out of range");
- m_ptr->reset(mr);
+ *m_ptr -= static_cast<DepListOverrideMask>(mr);
return Qnil;
}
@@ -1167,28 +1167,6 @@ namespace
}
}
- /*
- * call-seq:
- * == other_mask_reason -> True or False
- *
- * Are two DepListOverrideMasks equal
- */
- VALUE
- dep_list_override_masks_equal(VALUE self, VALUE other)
- {
- DepListOverrideMasks * m_ptr;
- Data_Get_Struct(self, DepListOverrideMasks, m_ptr);
- try
- {
- DepListOverrideMasks mr = value_to_dep_list_override_masks(other);
- return (*m_ptr) == mr ? Qtrue : Qfalse;
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
void do_register_dep_list()
{
/*
@@ -1517,7 +1495,6 @@ namespace
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 865caf4..bd76988 100644
--- a/ruby/dep_list_TEST.rb
+++ b/ruby/dep_list_TEST.rb
@@ -148,6 +148,7 @@ module Paludis
#This will fail if the defaults change, please also update the rdoc.
default_options.each_pair do |method, value|
assert_respond_to options, method
+ next if method == :override_masks
assert_equal value, options.send(method)
#check setters work
assert_nothing_raised do
@@ -155,6 +156,10 @@ module Paludis
assert_equal options_hash[method], options.send(method)
end
end
+ assert_kind_of DepListOverrideMasks, options.override_masks
+ assert_nothing_raised do
+ options.override_masks = DepListOverrideMasks.new
+ end
end
def test_bad_create
@@ -305,3 +310,4 @@ module Paludis
end
end
end
+
diff --git a/ruby/mask_reasons.cc b/ruby/mask_reasons.cc
index 8fa8279..dda10c3 100644
--- a/ruby/mask_reasons.cc
+++ b/ruby/mask_reasons.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* 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
@@ -104,7 +104,7 @@ namespace
int mr = NUM2INT(mask_reason);
if (mr < 0 || mr >= last_mr)
rb_raise(rb_eArgError, "MaskReason out of range");
- m_ptr->set(mr);
+ *m_ptr += static_cast<MaskReason>(mr);
return Qnil;
}
@@ -114,28 +114,6 @@ namespace
}
}
- /*
- * call-seq:
- * == other_mask_reason -> True or False
- *
- * Are two MaskReasons equal
- */
- VALUE
- mask_reasons_equal(VALUE self, VALUE other)
- {
- MaskReasons * m_ptr;
- Data_Get_Struct(self, MaskReasons, m_ptr);
- try
- {
- MaskReasons mr = value_to_mask_reasons(other);
- return (*m_ptr) == mr ? Qtrue : Qfalse;
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
void do_register_mask_reasons()
{
/*
@@ -152,7 +130,6 @@ namespace
rb_include_module(c_mask_reasons, rb_mEnumerable);
rb_define_method(c_mask_reasons, "empty?", RUBY_FUNC_CAST(&mask_reasons_empty), 0);
rb_define_method(c_mask_reasons, "set", RUBY_FUNC_CAST(&mask_reasons_set), 1);
- rb_define_method(c_mask_reasons, "==", RUBY_FUNC_CAST(&mask_reasons_equal), 1);
/*
* Document-module: Paludis::MaskReason
diff --git a/src/clients/adjutrix/what_needs_keywording.cc b/src/clients/adjutrix/what_needs_keywording.cc
index 2d9b37f..d383441 100644
--- a/src/clients/adjutrix/what_needs_keywording.cc
+++ b/src/clients/adjutrix/what_needs_keywording.cc
@@ -62,10 +62,10 @@ int do_what_needs_keywording(NoConfigEnvironment & env)
d_options.circular = dl_circular_discard_silently;
d_options.use = dl_use_deps_take_all;
d_options.blocks = dl_blocks_discard_completely;
- d_options.override_masks.set(dl_override_tilde_keywords);
- d_options.override_masks.set(dl_override_unkeyworded);
- d_options.override_masks.set(dl_override_repository_masks);
- d_options.override_masks.set(dl_override_profile_masks);
+ d_options.override_masks += dl_override_tilde_keywords;
+ d_options.override_masks += dl_override_unkeyworded;
+ d_options.override_masks += dl_override_repository_masks;
+ d_options.override_masks += dl_override_profile_masks;
DepList d(&env, d_options);
@@ -122,9 +122,9 @@ int do_what_needs_keywording(NoConfigEnvironment & env)
std::string masks;
MaskReasons r(env.mask_reasons(p->package));
- if (r.test(mr_repository_mask))
+ if (r[mr_repository_mask])
masks.append("R");
- if (r.test(mr_profile_mask))
+ if (r[mr_profile_mask])
masks.append("P");
cout << std::setw(10) << std::left << masks;
diff --git a/src/clients/contrarius/install.cc b/src/clients/contrarius/install.cc
index 7af4e4e..2daf6ca 100644
--- a/src/clients/contrarius/install.cc
+++ b/src/clients/contrarius/install.cc
@@ -319,8 +319,8 @@ do_install(std::tr1::shared_ptr<Environment> env, std::string spec_str)
bool need_comma(false);
MaskReasons m(env->mask_reasons(*pp));
- for (unsigned mm = 0 ; mm < m.size() ; ++mm)
- if (m[mm])
+ for (unsigned mm = 0 ; mm < last_mr ; ++mm)
+ if (m[static_cast<MaskReason>(mm)])
{
if (need_comma)
cerr << ", ";
diff --git a/src/clients/paludis/install.cc b/src/clients/paludis/install.cc
index d1703a5..0a3ced0 100644
--- a/src/clients/paludis/install.cc
+++ b/src/clients/paludis/install.cc
@@ -420,15 +420,15 @@ do_install(std::tr1::shared_ptr<Environment> env)
a_end(CommandLine::get_instance()->dl_override_masks.end_args()) ; a != a_end ; ++a)
{
if (*a == "tilde-keyword")
- options.override_masks.set(dl_override_tilde_keywords);
+ options.override_masks += dl_override_tilde_keywords;
else if (*a == "unkeyworded")
- options.override_masks.set(dl_override_unkeyworded);
+ options.override_masks += dl_override_unkeyworded;
else if (*a == "repository")
- options.override_masks.set(dl_override_repository_masks);
+ options.override_masks += dl_override_repository_masks;
else if (*a == "profile")
- options.override_masks.set(dl_override_repository_masks);
+ options.override_masks += dl_override_repository_masks;
else if (*a == "license")
- options.override_masks.set(dl_override_licenses);
+ options.override_masks += dl_override_licenses;
else
throw args::DoHelp("bad value for --dl-override-masks");
}
@@ -611,8 +611,8 @@ do_install(std::tr1::shared_ptr<Environment> env)
bool need_comma(false);
MaskReasons m(env->mask_reasons(*pp));
- for (unsigned mm = 0 ; mm < m.size() ; ++mm)
- if (m[mm])
+ for (unsigned mm = 0 ; mm < last_mr ; ++mm)
+ if (m[static_cast<MaskReason>(mm)])
{
if (need_comma)
cerr << ", ";
diff --git a/src/clients/paludis/query.cc b/src/clients/paludis/query.cc
index c03a457..167e156 100644
--- a/src/clients/paludis/query.cc
+++ b/src/clients/paludis/query.cc
@@ -171,7 +171,7 @@ int do_query(std::tr1::shared_ptr<Environment> env)
for (MaskReason m(MaskReason(0)) ; m < last_mr ;
m = MaskReason(static_cast<int>(m) + 1))
{
- if (! mask_reasons_to_explain.test(m))
+ if (! mask_reasons_to_explain[m])
continue;
switch (m)
diff --git a/src/clients/paludis/report.cc b/src/clients/paludis/report.cc
index 2588e3d..66a7b1c 100644
--- a/src/clients/paludis/report.cc
+++ b/src/clients/paludis/report.cc
@@ -95,8 +95,8 @@ namespace
cout << endl << " Masked by: ";
bool comma(false);
- for (unsigned i(0), i_end(mr.size()); i != i_end; ++i)
- if (mr.test(i))
+ for (unsigned i(0), i_end(last_mr); i != i_end; ++i)
+ if (mr[static_cast<MaskReason>(i)])
{
if (comma)
cout << ", ";
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index c9872ae..3816c93 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -1075,8 +1075,8 @@ ConsoleInstallTask::display_merge_list_entry_mask_reasons(const DepListEntry & e
output_no_endl(" Masked by: ");
- for (unsigned mm = 0 ; mm < r.size() ; ++mm)
- if (r[mm])
+ for (unsigned mm = 0 ; mm < last_mr ; ++mm)
+ if (r[static_cast<MaskReason>(mm)])
{
if (need_comma)
output_no_endl(", ");
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index e9b2616..859eaef 100644
--- a/src/output/console_query_task.cc
+++ b/src/output/console_query_task.cc
@@ -136,7 +136,7 @@ ConsoleQueryTask::display_versions_by_repository(const PackageDepSpec &,
for (MaskReason m(MaskReason(0)) ; m < last_mr ;
m = MaskReason(static_cast<int>(m) + 1))
{
- if (! masks.test(m))
+ if (! masks[m])
continue;
switch (m)