aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2007-01-18 20:02:12 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2007-01-18 20:02:12 +0000
commitd3c7ed4e78574b12713b14cc9fb710fdb9dc5258 (patch)
treefc4450c1235eab13f96c2bdb6bfc6cd09cc72b1d
parentfc51572c82f44bb0c4eab04a7eec813265657529 (diff)
downloadpaludis-d3c7ed4e78574b12713b14cc9fb710fdb9dc5258.tar.gz
paludis-d3c7ed4e78574b12713b14cc9fb710fdb9dc5258.tar.xz
Bring ruby DepList up to date, shorten enum names.
-rw-r--r--doc/create_ruby_doc.rb8
-rw-r--r--paludis/dep_list/options.cc172
-rw-r--r--paludis/dep_list/options.hh34
-rw-r--r--ruby/dep_list.cc1017
-rw-r--r--ruby/dep_list_TEST.rb162
5 files changed, 1122 insertions, 271 deletions
diff --git a/doc/create_ruby_doc.rb b/doc/create_ruby_doc.rb
index 980c22c..3c59ee5 100644
--- a/doc/create_ruby_doc.rb
+++ b/doc/create_ruby_doc.rb
@@ -56,10 +56,12 @@ module RDoc
def generate_consts(header, type, in_class)
consts = []
file = File.read("../#{header}")
- match = Regexp.new(/enum\s+#{type}\s+\{([^}]+)\}/, Regexp::MULTILINE)
+ match = Regexp.new(/enum\s+#{type}\s+\{([^}]+)\}/)#, Regexp::MULTILINE)
if file =~ match
+ enum = $1
+ last = enum[Regexp.new(/\slast_(\w+)\s/),1]
i = 0
- $1.each_line do |line|
+ enum.each_line do |line|
next if line =~/last/
next if line.strip == ''
next unless line =~ /,/
@@ -67,7 +69,7 @@ module RDoc
const.strip!
comment.strip!
comment.gsub!(%r{^[^a-zA-Z0-9]*},'')
- const.sub!(%r{^[^_]+_},'').capitalize! #strip start
+ const.sub!("#{last}_",'').capitalize! #strip start
const.gsub!(%r{[_\s](\w)}) { |x| $1.capitalize}
consts << "/*\n*#{comment}\n*/\nrb_define_const(#{in_class}, \"#{const}\", #{i});"
i+=1
diff --git a/paludis/dep_list/options.cc b/paludis/dep_list/options.cc
index 5b235b1..9cfc46a 100644
--- a/paludis/dep_list/options.cc
+++ b/paludis/dep_list/options.cc
@@ -31,11 +31,11 @@ paludis::operator<< (std::ostream & o, const DepListTargetType & s)
switch (s)
{
case dl_target_package:
- o << "target_package";
+ o << "package";
continue;
case dl_target_set:
- o << "target_set";
+ o << "set";
continue;
case last_dl_target:
@@ -56,15 +56,15 @@ paludis::operator<< (std::ostream & o, const DepListReinstallOption & s)
switch (s)
{
case dl_reinstall_never:
- o << "reinstall_never";
+ o << "never";
continue;
case dl_reinstall_always:
- o << "reinstall_always";
+ o << "always";
continue;
case dl_reinstall_if_use_changed:
- o << "reinstall_if_use_changed";
+ o << "if_use_changed";
continue;
case last_dl_reinstall:
@@ -85,15 +85,15 @@ paludis::operator<< (std::ostream & o, const DepListFallBackOption & s)
switch (s)
{
case dl_fall_back_as_needed_except_targets:
- o << "fall_back_as_needed_except_targets";
+ o << "as_needed_except_targets";
continue;
case dl_fall_back_as_needed:
- o << "fall_back_as_needed";
+ o << "as_needed";
continue;
case dl_fall_back_never:
- o << "fall_back_never";
+ o << "never";
continue;
case last_dl_fall_back:
@@ -114,19 +114,19 @@ paludis::operator<< (std::ostream & o, const DepListReinstallScmOption & s)
switch (s)
{
case dl_reinstall_scm_never:
- o << "reinstall_scm_never";
+ o << "never";
continue;
case dl_reinstall_scm_always:
- o << "reinstall_scm_always";
+ o << "always";
continue;
case dl_reinstall_scm_daily:
- o << "reinstall_scm_daily";
+ o << "daily";
continue;
case dl_reinstall_scm_weekly:
- o << "reinstall_scm_weekly";
+ o << "weekly";
continue;
case last_dl_reinstall_scm:
@@ -147,11 +147,11 @@ paludis::operator<< (std::ostream & o, const DepListUpgradeOption & s)
switch (s)
{
case dl_upgrade_always:
- o << "upgrade_always";
+ o << "always";
continue;
case dl_upgrade_as_needed:
- o << "upgrade_as_needed";
+ o << "as_needed";
continue;
case last_dl_upgrade:
@@ -165,6 +165,35 @@ paludis::operator<< (std::ostream & o, const DepListUpgradeOption & s)
}
std::ostream &
+paludis::operator<< (std::ostream & o, const DepListDowngradeOption & s)
+{
+ do
+ {
+ switch (s)
+ {
+ case dl_downgrade_as_needed:
+ o << "as_needed";
+ continue;
+
+ case dl_downgrade_warning:
+ o << "warning";
+ continue;
+
+ case dl_downgrade_error:
+ o << "error";
+ continue;
+
+ case last_dl_downgrade:
+ ;
+ }
+
+ throw InternalError(PALUDIS_HERE, "Bad DepListDowngradeOption");
+ } while (false);
+
+ return o;
+}
+
+std::ostream &
paludis::operator<< (std::ostream & o, const DepListNewSlotsOption & s)
{
do
@@ -172,11 +201,11 @@ paludis::operator<< (std::ostream & o, const DepListNewSlotsOption & s)
switch (s)
{
case dl_new_slots_always:
- o << "new_slots_always";
+ o << "always";
continue;
case dl_new_slots_as_needed:
- o << "new_slots_as_needed";
+ o << "as_needed";
continue;
case last_dl_new_slots:
@@ -197,23 +226,23 @@ paludis::operator<< (std::ostream & o, const DepListDepsOption & s)
switch (s)
{
case dl_deps_discard:
- o << "deps_discard";
+ o << "discard";
continue;
case dl_deps_pre:
- o << "deps_pre";
+ o << "pre";
continue;
case dl_deps_pre_or_post:
- o << "deps_pre_or_post";
+ o << "pre_or_post";
continue;
case dl_deps_post:
- o << "deps_post";
+ o << "post";
continue;
case dl_deps_try_post:
- o << "deps_try_post";
+ o << "try_post";
continue;
case last_dl_deps:
@@ -227,6 +256,35 @@ paludis::operator<< (std::ostream & o, const DepListDepsOption & s)
}
std::ostream &
+paludis::operator<< (std::ostream & o, const DepListSuggestedOption & s)
+{
+ do
+ {
+ switch (s)
+ {
+ case dl_suggested_show:
+ o << "show";
+ continue;
+
+ case dl_suggested_discard:
+ o << "discard";
+ continue;
+
+ case dl_suggested_install:
+ o << "install";
+ continue;
+
+ case last_dl_suggested:
+ ;
+ }
+
+ throw InternalError(PALUDIS_HERE, "Bad DepListSuggestedOption");
+ } while (false);
+
+ return o;
+}
+
+std::ostream &
paludis::operator<< (std::ostream & o, const DepListCircularOption & s)
{
do
@@ -234,11 +292,11 @@ paludis::operator<< (std::ostream & o, const DepListCircularOption & s)
switch (s)
{
case dl_circular_error:
- o << "circular_error";
+ o << "error";
continue;
case dl_circular_discard:
- o << "circular_discard";
+ o << "discard";
continue;
case dl_circular_discard_silently:
@@ -263,15 +321,15 @@ paludis::operator<< (std::ostream & o, const DepListBlocksOption & s)
switch (s)
{
case dl_blocks_accumulate:
- o << "blocks_accumulate";
+ o << "accumulate";
continue;
case dl_blocks_error:
- o << "blocks_error";
+ o << "error";
continue;
case dl_blocks_discard:
- o << "blocks_discard";
+ o << "discard";
continue;
case last_dl_blocks:
@@ -285,6 +343,31 @@ paludis::operator<< (std::ostream & o, const DepListBlocksOption & s)
}
std::ostream &
+paludis::operator<< (std::ostream & o, const DepListUseOption & s)
+{
+ do
+ {
+ switch (s)
+ {
+ case dl_use_deps_standard:
+ o << "standard";
+ continue;
+
+ case dl_use_deps_take_all:
+ o << "take_all";
+ continue;
+
+ case last_dl_use_deps:
+ ;
+ }
+
+ throw InternalError(PALUDIS_HERE, "Bad DepListUseOption");
+ } while (false);
+
+ return o;
+}
+
+std::ostream &
paludis::operator<< (std::ostream & o, const DepListEntryState & s)
{
do
@@ -362,3 +445,40 @@ paludis::operator<< (std::ostream & o, const DepListEntryKind & s)
return o;
}
+std::ostream &
+paludis::operator<< (std::ostream & o, const DepListOverrideMask & s)
+{
+ do
+ {
+ switch (s)
+ {
+ case dl_override_licenses:
+ o << "licenses";
+ continue;
+
+ case dl_override_tilde_keywords:
+ o << "tilde_keywords";
+ continue;
+
+ case dl_override_unkeyworded:
+ o << "unkeyworded";
+ continue;
+
+ case dl_override_repository_masks:
+ o << "repository_masks";
+ continue;
+
+ case dl_override_profile_masks:
+ o << "profile_masks";
+ continue;
+
+ case last_dl_override:
+ ;
+ }
+
+ throw InternalError(PALUDIS_HERE, "Bad DepListEntryKind");
+ } while (false);
+
+ return o;
+}
+
diff --git a/paludis/dep_list/options.hh b/paludis/dep_list/options.hh
index 7abdbbd..2d2f1a7 100644
--- a/paludis/dep_list/options.hh
+++ b/paludis/dep_list/options.hh
@@ -279,6 +279,14 @@ namespace paludis
operator<< (std::ostream &, const DepListUpgradeOption &) PALUDIS_VISIBLE;
/**
+ * Write a DepListDowngradeOption to a stream.
+ *
+ * \ingroup grpdepresolver
+ */
+ std::ostream &
+ operator<< (std::ostream &, const DepListDowngradeOption &) PALUDIS_VISIBLE;
+
+ /**
* Write a DepListNewSlotsOption to a stream.
*
* \ingroup grpdepresolver
@@ -295,6 +303,14 @@ namespace paludis
operator<< (std::ostream &, const DepListDepsOption &) PALUDIS_VISIBLE;
/**
+ * Write a DepListSuggestedOption to a stream.
+ *
+ * \ingroup grpdepresolver
+ */
+ std::ostream &
+ operator<< (std::ostream &, const DepListSuggestedOption &) PALUDIS_VISIBLE;
+
+ /**
* Write a DepListCircularOption to a stream.
*
* \ingroup grpdepresolver
@@ -303,7 +319,7 @@ namespace paludis
operator<< (std::ostream &, const DepListCircularOption &) PALUDIS_VISIBLE;
/**
- * Write a DepListCircularOption to a stream.
+ * Write a DepListBlocksOption to a stream.
*
* \ingroup grpdepresolver
*/
@@ -311,6 +327,14 @@ namespace paludis
operator<< (std::ostream &, const DepListBlocksOption &) PALUDIS_VISIBLE;
/**
+ * Write a DepListUseOption to a stream.
+ *
+ * \ingroup grpdepresolver
+ */
+ std::ostream &
+ operator<< (std::ostream &, const DepListUseOption &) PALUDIS_VISIBLE;
+
+ /**
* Write a DepListEntryState to a stream.
*
* \ingroup grpdepresolver
@@ -325,6 +349,14 @@ namespace paludis
*/
std::ostream &
operator<< (std::ostream &, const DepListEntryKind &) PALUDIS_VISIBLE;
+
+ /**
+ * Write a DepListOverrideMask to a stream.
+ *
+ * \ingroup grpdepresolver
+ */
+ std::ostream &
+ operator<< (std::ostream &, const DepListOverrideMask &) PALUDIS_VISIBLE;
}
#endif
diff --git a/ruby/dep_list.cc b/ruby/dep_list.cc
index 403578a..ddd69c8 100644
--- a/ruby/dep_list.cc
+++ b/ruby/dep_list.cc
@@ -26,6 +26,8 @@ using namespace paludis::ruby;
#define RUBY_FUNC_CAST(x) reinterpret_cast<VALUE (*)(...)>(x)
+typedef CountedPtr<DepListOptions, count_policy::ExternalCountTag> DepListOptionsPointer;
+
namespace
{
static VALUE c_dep_list_target_type;
@@ -33,23 +35,28 @@ namespace
static VALUE c_dep_list_fall_back_option;
static VALUE c_dep_list_reinstall_scm_option;
static VALUE c_dep_list_upgrade_option;
+ static VALUE c_dep_list_downgrade_option;
static VALUE c_dep_list_new_slots_option;
static VALUE c_dep_list_deps_option;
+ static VALUE c_dep_list_suggested_option;
static VALUE c_dep_list_circular_option;
static VALUE c_dep_list_blocks_option;
+ static VALUE c_dep_list_use_option;
static VALUE c_dep_list_entry_state;
static VALUE c_dep_list_entry_kind;
+ static VALUE c_dep_list_override_mask;
static VALUE c_dep_list_options;
static VALUE c_dep_list;
static VALUE c_dep_list_entry;
+ static VALUE c_dep_list_override_masks;
- DepListOptions
+ DepListOptionsPointer
value_to_dep_list_options(VALUE v)
{
if (rb_obj_is_kind_of(v, c_dep_list_options))
{
- DepListOptions * v_ptr;
- Data_Get_Struct(v, DepListOptions, v_ptr);
+ DepListOptionsPointer * v_ptr;
+ Data_Get_Struct(v, DepListOptionsPointer, v_ptr);
return *v_ptr;
}
else
@@ -59,199 +66,317 @@ namespace
}
VALUE
- dep_list_entry_to_value(const DepListEntry & v)
+ dep_list_options_to_value(DepListOptionsPointer m)
{
- DepListEntry * vv(new DepListEntry(v));
- return Data_Wrap_Struct(c_dep_list_entry, 0, &Common<DepListEntry>::free, vv);
- }
+ DepListOptionsPointer * m_ptr(0);
+ try
+ {
+ m_ptr = new DepListOptionsPointer(m);
+ return Data_Wrap_Struct(c_dep_list_options, 0, &Common<DepListOptionsPointer>::free, m_ptr);
+ }
+ catch (const std::exception & e)
+ {
+ delete m_ptr;
+ exception_to_ruby_exception(e);
+ }
+ }
- VALUE
- dep_list_options_init(int, VALUE *, VALUE self)
- {
- return self;
- }
+ VALUE
+ dep_list_entry_to_value(const DepListEntry & v)
+ {
+ DepListEntry * vv(new DepListEntry(v));
+ return Data_Wrap_Struct(c_dep_list_entry, 0, &Common<DepListEntry>::free, vv);
+ }
-#ifdef CIARANM_REMOVED_THIS
- /*
- * call-seq:
- * DepListOptions.new(reinstall, reinstall_scm, target_type, upgrade, new_slots, fall_back, installed_deps_prem installed_deps_runtime, installed_deps_post, uninstalled_deps_pre, uninstalled_deps_runtime, uninstalled_deps_post, circular, blocks, dependency_tags) -> DepListOptions
+ VALUE
+ dep_list_override_masks_to_value(const DepListOverrideMasks & m)
+ {
+ return Data_Wrap_Struct(c_dep_list_override_masks, 0, &Common<DepListOverrideMasks>::free, new DepListOverrideMasks(m));
+ }
+
+ DepListOverrideMasks
+ value_to_dep_list_override_masks(VALUE v)
+ {
+ if (rb_obj_is_kind_of(v, c_dep_list_override_masks))
+ {
+ DepListOverrideMasks * v_ptr;
+ Data_Get_Struct(v, DepListOverrideMasks, v_ptr);
+ return *v_ptr;
+ }
+ else
+ {
+ rb_raise(rb_eTypeError, "Can't convert %s into DepListOverrideMasks", rb_obj_classname(v));
+ }
+ }
+
+ VALUE
+ dep_list_options_init(int, VALUE *, VALUE self)
+ {
+ return self;
+ }
+
+ /*
+ * call-seq:
+ * DepListOptions.new(reinstall, reinstall_scm, target_type, upgrade, new_slots, fall_back, installed_deps_prem installed_deps_runtime, installed_deps_post, uninstalled_deps_pre, uninstalled_deps_runtime, uninstalled_deps_post, uninstalled_deps_suggested, suggested, circular, blocks, dependency_tags) -> DepListOptions
* DepListOptions.new(Hash) -> DepListOptions
+ * DepListOptions.new -> DepListOptions
*
- * DepListOptions.new can either be called with all parameters in order, or with one hash parameter, where the hash keys are symbols with the names above.
+ * DepListOptions.new can either be called with all parameters in order, or with one hash
+ * parameter, where the hash keys are symbols with the names above, or with no parameters
+ * in which case it will be created with the default options, i.e. the following hash:
+ *
+ * {
+ * :reinstall => DepListReinstallOption::Never,
+ * :reinstall_scm => DepListReinstallScmOption::Never,
+ * :target_type => DepListTargetType::Package,
+ * :upgrade => DepListUpgradeOption::Always,
+ * :downgrade => DepListDowngradeOption::AsNeeded,
+ * :new_slots => DepListNewSlotsOption::Always,
+ * :fall_back => DepListFallBackOption::AsNeededExceptTargets,
+ * :installed_deps_pre => DepListDepsOption::Discard,
+ * :installed_deps_runtime => DepListDepsOption::TryPost,
+ * :installed_deps_post => DepListDepsOption::TryPost,
+ * :uninstalled_deps_pre => DepListDepsOption::Pre,
+ * :uninstalled_deps_runtime => DepListDepsOption::PreOrPost,
+ * :uninstalled_deps_post => DepListDepsOption::Post,
+ * :uninstalled_deps_suggested => DepListDepsOption::TryPost,
+ * :suggested => DepListSuggestedOption::Show,
+ * :circular => DepListCircularOption::Error,
+ * :use => DepListUseOption::Standard,
+ * :blocks => DepListBlocksOption::Accumulate,
+ * :override_masks => DepListOverrideMasks.new,
+ * :dependency_tags => false
+ * }
*/
VALUE
dep_list_options_new(int argc, VALUE *argv, VALUE self)
{
- DepListOptions * ptr(0);
- try
+ DepListOptionsPointer * ptr(0);
+ if (0 == argc)
{
- int value_for_reinstall;
- int value_for_reinstall_scm;
- int value_for_target_type;
- int value_for_upgrade;
- int value_for_new_slots;
- int value_for_fall_back;
- int value_for_installed_deps_pre;
- int value_for_installed_deps_runtime;
- int value_for_installed_deps_post;
- int value_for_uninstalled_deps_pre;
- int value_for_uninstalled_deps_runtime;
- int value_for_uninstalled_deps_post;
- int value_for_circular;
- int value_for_blocks;
- MaskReasons value_for_override_mask_reasons;
- bool value_for_dependency_tags;
-
- if (1 == argc && rb_obj_is_kind_of(argv[0], rb_cHash))
- {
- if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("reinstall"))))
- rb_raise(rb_eArgError, "Missing Parameter: reinstall");
- if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("reinstall_scm"))))
- rb_raise(rb_eArgError, "Missing Parameter: reinstall_scm");
- if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("target_type"))))
- rb_raise(rb_eArgError, "Missing Parameter: target_type");
- if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("upgrade"))))
- rb_raise(rb_eArgError, "Missing Parameter: upgrade");
- if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("new_slots"))))
- rb_raise(rb_eArgError, "Missing Parameter: new_slots");
- if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("fall_back"))))
- rb_raise(rb_eArgError, "Missing Parameter: fall_back");
- if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("installed_deps_pre"))))
- rb_raise(rb_eArgError, "Missing Parameter: installed_deps_pre");
- if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("installed_deps_runtime"))))
- rb_raise(rb_eArgError, "Missing Parameter: installed_deps_runtime");
- if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("installed_deps_post"))))
- rb_raise(rb_eArgError, "Missing Parameter: installed_deps_post");
- if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("uninstalled_deps_pre"))))
- rb_raise(rb_eArgError, "Missing Parameter: uninstalled_deps_pre");
- if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("installed_deps_runtime"))))
- rb_raise(rb_eArgError, "Missing Parameter: uninstalled_deps_runtime");
- if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("uninstalled_deps_post"))))
- rb_raise(rb_eArgError, "Missing Parameter: uninstalled_deps_post");
- if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("circular"))))
- rb_raise(rb_eArgError, "Missing Parameter: circular");
- if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("blocks"))))
- rb_raise(rb_eArgError, "Missing Parameter: blocks");
- if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("override_mask_reasons"))))
- rb_raise(rb_eArgError, "Missing Parameter: override_mask_reasons");
- if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("dependency_tags"))))
- rb_raise(rb_eArgError, "Missing Parameter: dependency_tags");
- value_for_reinstall =
- NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("reinstall"))));
- value_for_reinstall_scm =
- NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("reinstall_scm"))));
- value_for_target_type =
- NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("target_type"))));
- value_for_upgrade =
- NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("upgrade"))));
- value_for_new_slots =
- NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("new_slots"))));
- value_for_fall_back =
- NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("fall_back"))));
- value_for_installed_deps_pre =
- NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("installed_deps_pre"))));
- value_for_installed_deps_runtime =
- NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("installed_deps_runtime"))));
- value_for_installed_deps_post =
- NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("installed_deps_post"))));
- value_for_uninstalled_deps_pre =
- NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("uninstalled_deps_pre"))));
- value_for_uninstalled_deps_runtime =
- NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("uninstalled_deps_runtime"))));
- value_for_uninstalled_deps_post =
- NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("uninstalled_deps_post"))));
- value_for_circular =
- NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("circular"))));
- value_for_blocks =
- NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("blocks"))));
- value_for_override_mask_reasons = value_to_mask_reasons(
- rb_hash_aref(argv[0], ID2SYM(rb_intern("override_mask_reasons")))
- );
- value_for_dependency_tags =
- Qtrue == (rb_hash_aref(argv[0], ID2SYM(rb_intern("dependency_tags")))) ? true : false;
- }
- else if (16 == argc)
+ try
{
- value_for_reinstall = NUM2INT(argv[0]);
- value_for_reinstall_scm = NUM2INT(argv[1]);
- value_for_target_type = NUM2INT(argv[2]);
- value_for_upgrade = NUM2INT(argv[3]);
- value_for_new_slots = NUM2INT(argv[4]);
- value_for_fall_back = NUM2INT(argv[5]);
- value_for_installed_deps_pre = NUM2INT(argv[6]);
- value_for_installed_deps_runtime = NUM2INT(argv[7]);
- value_for_installed_deps_post = NUM2INT(argv[8]);
- value_for_uninstalled_deps_pre = NUM2INT(argv[9]);
- value_for_uninstalled_deps_runtime = NUM2INT(argv[10]);
- value_for_uninstalled_deps_post = NUM2INT(argv[11]);
- value_for_circular = NUM2INT(argv[12]);
- value_for_blocks = NUM2INT(argv[13]);
- value_for_override_mask_reasons = value_to_mask_reasons(argv[14]);
- value_for_dependency_tags = Qtrue == argv[15] ? true : false;
+ ptr = new DepListOptionsPointer(new DepListOptions);
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<DepListOptionsPointer>::free, ptr));
+ rb_obj_call_init(tdata, argc, argv);
+ return tdata;
}
- else
+ catch (const std::exception & e)
{
- rb_raise(rb_eArgError, "DepListOptions expects fourteen arguments, but got %d",argc);
+ delete ptr;
+ exception_to_ruby_exception(e);
}
-
- if (value_for_reinstall < 0 || value_for_reinstall >= last_dl_reinstall)
- rb_raise(rb_eArgError, "reinstall out of range");
- if (value_for_reinstall_scm < 0 || value_for_reinstall_scm >= last_dl_reinstall_scm)
- rb_raise(rb_eArgError, "reinstall_scm out of range");
- if (value_for_target_type < 0 || value_for_target_type >= last_dl_target)
- rb_raise(rb_eArgError, "target_type out of range");
- if (value_for_upgrade < 0 || value_for_upgrade >= last_dl_upgrade)
- rb_raise(rb_eArgError, "upgrade out of range");
- if (value_for_new_slots < 0 || value_for_new_slots >= last_dl_new_slots)
- rb_raise(rb_eArgError, "new_slots out of range");
- if (value_for_fall_back < 0 || value_for_fall_back >= last_dl_fall_back)
- rb_raise(rb_eArgError, "fall_back out of range");
- if (value_for_installed_deps_pre < 0 || value_for_installed_deps_pre >= last_dl_deps)
- rb_raise(rb_eArgError, "installed_deps_pre out of range");
- if (value_for_installed_deps_runtime < 0 || value_for_installed_deps_runtime >= last_dl_deps)
- rb_raise(rb_eArgError, "installed_deps_runtime out of range");
- if (value_for_installed_deps_post < 0 || value_for_installed_deps_post >= last_dl_deps)
- rb_raise(rb_eArgError, "installed_deps_post out of range");
- if (value_for_uninstalled_deps_pre < 0 || value_for_uninstalled_deps_pre >= last_dl_deps)
- rb_raise(rb_eArgError, "uninstalled_deps_pre out of range");
- if (value_for_uninstalled_deps_runtime < 0 || value_for_uninstalled_deps_runtime >= last_dl_deps)
- rb_raise(rb_eArgError, "uninstalled_deps_runtime out of range");
- if (value_for_uninstalled_deps_post < 0 || value_for_uninstalled_deps_post >= last_dl_deps)
- rb_raise(rb_eArgError, "uninstalled_deps_post out of range");
- if (value_for_circular < 0 || value_for_circular >= last_dl_circular)
- rb_raise(rb_eArgError, "circular out of range");
- if (value_for_circular < 0 || value_for_blocks >= last_dl_blocks)
- rb_raise(rb_eArgError, "blocks out of range");
-
- ptr = new DepListOptions(static_cast<DepListReinstallOption>(value_for_reinstall),
- static_cast<DepListReinstallScmOption>(value_for_reinstall_scm),
- static_cast<DepListTargetType>(value_for_target_type),
- static_cast<DepListUpgradeOption>(value_for_upgrade),
- static_cast<DepListNewSlotsOption>(value_for_new_slots),
- static_cast<DepListFallBackOption>(value_for_fall_back),
- static_cast<DepListDepsOption>(value_for_installed_deps_pre),
- static_cast<DepListDepsOption>(value_for_installed_deps_runtime),
- static_cast<DepListDepsOption>(value_for_installed_deps_post),
- static_cast<DepListDepsOption>(value_for_uninstalled_deps_pre),
- static_cast<DepListDepsOption>(value_for_uninstalled_deps_runtime),
- static_cast<DepListDepsOption>(value_for_uninstalled_deps_post),
- static_cast<DepListCircularOption>(value_for_circular),
- static_cast<DepListBlocksOption>(value_for_blocks),
- value_for_override_mask_reasons,
- value_for_dependency_tags
- );
-
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<DepListOptions>::free, ptr));
- rb_obj_call_init(tdata, argc, argv);
- return tdata;
}
- catch (const std::exception & e)
+ else
{
- delete ptr;
- exception_to_ruby_exception(e);
+ try
+ {
+ int value_for_reinstall;
+ int value_for_reinstall_scm;
+ int value_for_target_type;
+ int value_for_upgrade;
+ int value_for_downgrade;
+ int value_for_new_slots;
+ int value_for_fall_back;
+ int value_for_installed_deps_pre;
+ int value_for_installed_deps_runtime;
+ int value_for_installed_deps_post;
+ int value_for_uninstalled_deps_pre;
+ int value_for_uninstalled_deps_runtime;
+ int value_for_uninstalled_deps_post;
+ int value_for_uninstalled_deps_suggested;
+ int value_for_suggested;
+ int value_for_circular;
+ int value_for_use;
+ int value_for_blocks;
+ DepListOverrideMasks value_for_override_masks;
+ bool value_for_dependency_tags;
+
+ if (1 == argc && rb_obj_is_kind_of(argv[0], rb_cHash))
+ {
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("reinstall"))))
+ rb_raise(rb_eArgError, "Missing Parameter: reinstall");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("reinstall_scm"))))
+ rb_raise(rb_eArgError, "Missing Parameter: reinstall_scm");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("target_type"))))
+ rb_raise(rb_eArgError, "Missing Parameter: target_type");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("upgrade"))))
+ rb_raise(rb_eArgError, "Missing Parameter: upgrade");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("downgrade"))))
+ rb_raise(rb_eArgError, "Missing Parameter: downgrade");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("new_slots"))))
+ rb_raise(rb_eArgError, "Missing Parameter: new_slots");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("fall_back"))))
+ rb_raise(rb_eArgError, "Missing Parameter: fall_back");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("installed_deps_pre"))))
+ rb_raise(rb_eArgError, "Missing Parameter: installed_deps_pre");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("installed_deps_runtime"))))
+ rb_raise(rb_eArgError, "Missing Parameter: installed_deps_runtime");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("installed_deps_post"))))
+ rb_raise(rb_eArgError, "Missing Parameter: installed_deps_post");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("uninstalled_deps_pre"))))
+ rb_raise(rb_eArgError, "Missing Parameter: uninstalled_deps_pre");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("installed_deps_runtime"))))
+ rb_raise(rb_eArgError, "Missing Parameter: uninstalled_deps_runtime");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("uninstalled_deps_post"))))
+ rb_raise(rb_eArgError, "Missing Parameter: uninstalled_deps_post");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("uninstalled_deps_suggested"))))
+ rb_raise(rb_eArgError, "Missing Parameter: uninstalled_deps_suggested");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("suggested"))))
+ rb_raise(rb_eArgError, "Missing Parameter: suggested");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("circular"))))
+ rb_raise(rb_eArgError, "Missing Parameter: circular");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("use"))))
+ rb_raise(rb_eArgError, "Missing Parameter: use");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("blocks"))))
+ rb_raise(rb_eArgError, "Missing Parameter: blocks");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("override_masks"))))
+ rb_raise(rb_eArgError, "Missing Parameter: override_masks");
+ if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("dependency_tags"))))
+ rb_raise(rb_eArgError, "Missing Parameter: dependency_tags");
+ value_for_reinstall =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("reinstall"))));
+ value_for_reinstall_scm =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("reinstall_scm"))));
+ value_for_target_type =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("target_type"))));
+ value_for_upgrade =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("downgrade"))));
+ value_for_downgrade =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("downgrade"))));
+ value_for_new_slots =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("new_slots"))));
+ value_for_fall_back =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("fall_back"))));
+ value_for_installed_deps_pre =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("installed_deps_pre"))));
+ value_for_installed_deps_runtime =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("installed_deps_runtime"))));
+ value_for_installed_deps_post =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("installed_deps_post"))));
+ value_for_uninstalled_deps_pre =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("uninstalled_deps_pre"))));
+ value_for_uninstalled_deps_runtime =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("uninstalled_deps_runtime"))));
+ value_for_uninstalled_deps_post =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("uninstalled_deps_post"))));
+ value_for_uninstalled_deps_suggested =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("uninstalled_deps_suggested"))));
+ value_for_suggested =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("suggested"))));
+ value_for_circular =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("circular"))));
+ value_for_use =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("use"))));
+ value_for_blocks =
+ NUM2INT(rb_hash_aref(argv[0], ID2SYM(rb_intern("blocks"))));
+ value_for_override_masks = value_to_dep_list_override_masks(
+ rb_hash_aref(argv[0], ID2SYM(rb_intern("override_masks")))
+ );
+ value_for_dependency_tags =
+ Qtrue == (rb_hash_aref(argv[0], ID2SYM(rb_intern("dependency_tags")))) ? true : false;
+ }
+ else if (20 == argc)
+ {
+ value_for_reinstall = NUM2INT(argv[0]);
+ value_for_reinstall_scm = NUM2INT(argv[1]);
+ value_for_target_type = NUM2INT(argv[2]);
+ value_for_upgrade = NUM2INT(argv[3]);
+ value_for_downgrade = NUM2INT(argv[4]);
+ value_for_new_slots = NUM2INT(argv[5]);
+ value_for_fall_back = NUM2INT(argv[6]);
+ value_for_installed_deps_pre = NUM2INT(argv[7]);
+ value_for_installed_deps_runtime = NUM2INT(argv[8]);
+ value_for_installed_deps_post = NUM2INT(argv[9]);
+ value_for_uninstalled_deps_pre = NUM2INT(argv[10]);
+ value_for_uninstalled_deps_runtime = NUM2INT(argv[11]);
+ value_for_uninstalled_deps_post = NUM2INT(argv[12]);
+ value_for_uninstalled_deps_suggested = NUM2INT(argv[13]);
+ value_for_suggested = NUM2INT(argv[14]);
+ value_for_circular = NUM2INT(argv[15]);
+ value_for_use = NUM2INT(argv[16]);
+ value_for_blocks = NUM2INT(argv[17]);
+ value_for_override_masks = value_to_dep_list_override_masks(argv[18]);
+ value_for_dependency_tags = Qtrue == argv[19] ? true : false;
+ }
+ else
+ {
+ rb_raise(rb_eArgError, "DepListOptions expects twenty or zero arguments, but got %d",argc);
+ }
+
+ if (value_for_reinstall < 0 || value_for_reinstall >= last_dl_reinstall)
+ rb_raise(rb_eArgError, "reinstall out of range");
+ if (value_for_reinstall_scm < 0 || value_for_reinstall_scm >= last_dl_reinstall_scm)
+ rb_raise(rb_eArgError, "reinstall_scm out of range");
+ if (value_for_target_type < 0 || value_for_target_type >= last_dl_target)
+ rb_raise(rb_eArgError, "target_type out of range");
+ if (value_for_upgrade < 0 || value_for_upgrade >= last_dl_upgrade)
+ rb_raise(rb_eArgError, "upgrade out of range");
+ if (value_for_downgrade < 0 || value_for_downgrade >= last_dl_downgrade)
+ rb_raise(rb_eArgError, "downgrade out of range");
+ if (value_for_new_slots < 0 || value_for_new_slots >= last_dl_new_slots)
+ rb_raise(rb_eArgError, "new_slots out of range");
+ if (value_for_fall_back < 0 || value_for_fall_back >= last_dl_fall_back)
+ rb_raise(rb_eArgError, "fall_back out of range");
+ if (value_for_installed_deps_pre < 0 || value_for_installed_deps_pre >= last_dl_deps)
+ rb_raise(rb_eArgError, "installed_deps_pre out of range");
+ if (value_for_installed_deps_runtime < 0 || value_for_installed_deps_runtime >= last_dl_deps)
+ rb_raise(rb_eArgError, "installed_deps_runtime out of range");
+ if (value_for_installed_deps_post < 0 || value_for_installed_deps_post >= last_dl_deps)
+ rb_raise(rb_eArgError, "installed_deps_post out of range");
+ if (value_for_uninstalled_deps_pre < 0 || value_for_uninstalled_deps_pre >= last_dl_deps)
+ rb_raise(rb_eArgError, "uninstalled_deps_pre out of range");
+ if (value_for_uninstalled_deps_runtime < 0 || value_for_uninstalled_deps_runtime >= last_dl_deps)
+ rb_raise(rb_eArgError, "uninstalled_deps_runtime out of range");
+ if (value_for_uninstalled_deps_post < 0 || value_for_uninstalled_deps_post >= last_dl_deps)
+ rb_raise(rb_eArgError, "uninstalled_deps_post out of range");
+ if (value_for_uninstalled_deps_suggested < 0 || value_for_uninstalled_deps_suggested >= last_dl_deps)
+ rb_raise(rb_eArgError, "uninstalled_deps_suggested out of range");
+ if (value_for_suggested < 0 || value_for_suggested >= last_dl_suggested)
+ rb_raise(rb_eArgError, "suggested out of range");
+ if (value_for_circular < 0 || value_for_circular >= last_dl_circular)
+ rb_raise(rb_eArgError, "circular out of range");
+ if (value_for_circular < 0 || value_for_use >= last_dl_use_deps)
+ rb_raise(rb_eArgError, "use out of range");
+ if (value_for_circular < 0 || value_for_blocks >= last_dl_blocks)
+ rb_raise(rb_eArgError, "blocks out of range");
+
+ ptr = new DepListOptionsPointer(
+ new DepListOptions(
+ static_cast<DepListReinstallOption>(value_for_reinstall),
+ static_cast<DepListReinstallScmOption>(value_for_reinstall_scm),
+ static_cast<DepListTargetType>(value_for_target_type),
+ static_cast<DepListUpgradeOption>(value_for_upgrade),
+ static_cast<DepListDowngradeOption>(value_for_downgrade),
+ static_cast<DepListNewSlotsOption>(value_for_new_slots),
+ static_cast<DepListFallBackOption>(value_for_fall_back),
+ static_cast<DepListDepsOption>(value_for_installed_deps_pre),
+ static_cast<DepListDepsOption>(value_for_installed_deps_runtime),
+ static_cast<DepListDepsOption>(value_for_installed_deps_post),
+ static_cast<DepListDepsOption>(value_for_uninstalled_deps_pre),
+ static_cast<DepListDepsOption>(value_for_uninstalled_deps_runtime),
+ static_cast<DepListDepsOption>(value_for_uninstalled_deps_post),
+ static_cast<DepListDepsOption>(value_for_uninstalled_deps_suggested),
+ static_cast<DepListSuggestedOption>(value_for_suggested),
+ static_cast<DepListCircularOption>(value_for_circular),
+ static_cast<DepListUseOption>(value_for_use),
+ static_cast<DepListBlocksOption>(value_for_blocks),
+ value_for_override_masks,
+ value_for_dependency_tags
+ )
+ );
+
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<DepListOptionsPointer>::free, ptr));
+ rb_obj_call_init(tdata, argc, argv);
+ return tdata;
+ }
+ catch (const std::exception & e)
+ {
+ delete ptr;
+ exception_to_ruby_exception(e);
+ }
}
}
-#endif
/*
* Document-method: reinstall
@@ -286,6 +411,14 @@ namespace
* Our DepListUpgradeOption
*/
/*
+ * Document-method: downgrade
+ *
+ * call-seq:
+ * downgrade -> DepListDowngradeOption
+ *
+ * Our DepListDowngradeOption
+ */
+ /*
* Document-method: new_slots
*
* call-seq:
@@ -350,6 +483,22 @@ namespace
* Our uninstalled_deps_post
*/
/*
+ * Document-method: uninstalled_deps_suggested
+ *
+ * call-seq:
+ * uninstalled_deps_suggested -> DepListDepsOption
+ *
+ * Our uninstalled_deps_suggested
+ */
+ /*
+ * Document-method: suggested
+ *
+ * call-seq:
+ * suggested -> DepListSuggestedOption
+ *
+ * Our DepListSuggestedOption
+ */
+ /*
* Document-method: circular
*
* call-seq:
@@ -357,46 +506,283 @@ namespace
*
* Our DepListCircularOption
*/
+ /*
+ * Document-method: use
+ *
+ * call-seq:
+ * use -> DepListUseOption
+ *
+ * Our DepListSuggestedOption
+ */
+ /*
+ * Document-method: blocks
+ *
+ * call-seq:
+ * blocks -> DepListBlockOption
+ *
+ * Our DepListBlockOption
+ */
+ /*
+ * Document-method: suggested
+ *
+ * call-seq:
+ * suggested -> DepListSuggestedOption
+ *
+ * Our DepListSuggestedOption
+ */
+ /*
+ * Document-method: reinstall=
+ *
+ * call-seq:
+ * reinstall=(dep_list_reinstall_option) -> Qnil
+ *
+ * Set our DepListReinstallOption
+ */
+ /*
+ * Document-method: reinstall_scm=
+ *
+ * call-seq:
+ * reinstall_scm=(dep_list_reinstall_scm_option) -> Qnil
+ *
+ * Set our DepListReinstallScmOption
+ */
+ /*
+ * Document-method: target=
+ *
+ * call-seq:
+ * target=dep_list_target_type) -> Qnil
+ *
+ * Set our DepListTargetType
+ */
+ /*
+ * Document-method: upgrade=
+ *
+ * call-seq:
+ * upgrade=(dep_list_upgrade_option) -> Qnil
+ *
+ * Set our DepListUpgradeOption
+ */
+ /*
+ * Document-method: downgrade=
+ *
+ * call-seq:
+ * downgrade=(dep_list_downgrade_options) -> Qnil
+ *
+ * Set our DepListDowngradeOption
+ */
+ /*
+ * Document-method: new_slots=
+ *
+ * call-seq:
+ * new_slots=(dep_list_new_slots_options) -> Qnil
+ *
+ * Set our DepListNewSlotsOption
+ */
+ /*
+ * Document-method: fall_back=
+ *
+ * call-seq:
+ * fall_back=(dep_list_fall_back_option) -> Qnil
+ *
+ * Set our DepListFallBackOption
+ */
+ /*
+ * Document-method: installed_deps_pre=
+ *
+ * call-seq:
+ * installed_deps_pre=(dep_list_deps_option) -> Qnil
+ *
+ * Set our installed_deps_runtime
+ */
+ /*
+ * Document-method: installed_deps_runtime=
+ *
+ * call-seq:
+ * installed_deps_runtime=(dep_list_deps_option) -> Qnil
+ *
+ * Set our installed_deps_runtime
+ */
+ /*
+ * Document-method: installed_deps_post=
+ *
+ * call-seq:
+ * installed_deps_post=(dep_list_deps_option) -> Qnil
+ *
+ * Set our installed_deps_post
+ */
+ /*
+ * Document-method: uninstalled_deps_pre=
+ *
+ * call-seq:
+ * uninstalled_deps_pre=(dep_list_deps_option) -> Qnil
+ *
+ * Set our uninstalled_deps_runtime
+ */
+ /*
+ * Document-method: uninstalled_deps_runtime=
+ *
+ * call-seq:
+ * uninstalled_deps_runtime(dep_list_deps_option) -> Qnil
+ *
+ * Set our uninstalled_deps_runtime
+ */
+ /*
+ * Document-method: uninstalled_deps_post=
+ *
+ * call-seq:
+ * uninstalled_deps_post=(dep_list_deps_option) -> Qnil
+ *
+ * Set our uninstalled_deps_post
+ */
+ /*
+ * Document-method: uninstalled_deps_suggested=
+ *
+ * call-seq:
+ * uninstalled_deps_suggested=(dep_list_deps_option) -> Qnil
+ *
+ * Set our uninstalled_deps_suggested
+ */
+ /*
+ * Document-method: suggested=
+ *
+ * call-seq:
+ * suggested=(dep_list_suggested_option) -> Qnil
+ *
+ * Set our DepListSuggestedOption
+ */
+ /*
+ * Document-method: circular=
+ *
+ * call-seq:
+ * circular=(dep_list_circular_options) -> Qnil
+ *
+ * Set our DepListCircularOption
+ */
+ /*
+ * Document-method: use=
+ *
+ * call-seq:
+ * use=(dep_list_use_option) -> Qnil
+ *
+ * Set our DepListSuggestedOption
+ */
+ /*
+ * Document-method: blocks=
+ *
+ * call-seq:
+ * blocks=(dep_list_block_option) -> Qnil
+ *
+ * Set our DepListBlockOption
+ */
template <typename T_, T_ DepListOptions::* m_>
struct OptionsMember
{
static VALUE
fetch(VALUE self)
{
- DepListOptions * p;
- Data_Get_Struct(self, DepListOptions, p);
- return INT2FIX(p->*m_);
+ DepListOptionsPointer * p;
+ Data_Get_Struct(self, DepListOptionsPointer, p);
+ return INT2FIX((**p).*m_);
+ }
+
+ static VALUE
+ set (VALUE self, VALUE val)
+ {
+ DepListOptionsPointer * p;
+ Data_Get_Struct(self, DepListOptionsPointer, p);
+ try
+ {
+ ((**p).*m_) = static_cast<T_>(NUM2INT(val));
+ return Qnil;
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
}
};
-#ifdef CIARANM_REMOVED_THIS
/*
* call-seq:
- * override_mask_reasons -> MaskReasons
+ * override_masks -> DepListOverrideMasks
*
- * Our override MaskReasons.
+ * A copy of our override DepListOverrideMasks.
*/
VALUE
- dep_list_options_mask_reasons(VALUE self)
+ dep_list_options_override_masks(VALUE self)
{
- DepListOptions * p;
- Data_Get_Struct(self, DepListOptions, p);
- return mask_reasons_to_value(p->override_mask_reasons);
+ DepListOptionsPointer * p;
+ Data_Get_Struct(self, DepListOptionsPointer, p);
+ return dep_list_override_masks_to_value((*p)->override_masks);
+ }
+
+ /*
+ * call-seq:
+ * override_masks=(dep_list_override_masks) -> Qnil
+ *
+ * Set our override DepListOverrideMasks.
+ */
+ VALUE
+ dep_list_options_override_masks_set(VALUE self, VALUE mr)
+ {
+ DepListOptionsPointer * p;
+ Data_Get_Struct(self, DepListOptionsPointer, p);
+ try
+ {
+ (*p)->override_masks = value_to_dep_list_override_masks(mr);
+ return Qnil;
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
}
-#endif
/*
* call-seq:
* dependancy_tags -> true or false
*
- * Out dependency_tags
+ * Our dependency_tags
*/
VALUE
dep_list_options_dependency_tags(VALUE self)
{
- DepListOptions * p;
- Data_Get_Struct(self, DepListOptions, p);
- return p->dependency_tags ? Qtrue : Qfalse;
+ DepListOptionsPointer * p;
+ Data_Get_Struct(self, DepListOptionsPointer, p);
+ return (*p)->dependency_tags ? Qtrue : Qfalse;
+ }
+
+ /*
+ * call-seq:
+ * dependancy_tags=(true or false) -> Qnil
+ *
+ * Set our dependency_tags
+ */
+ VALUE
+ dep_list_options_dependency_tags_set(VALUE self, VALUE tags)
+ {
+ DepListOptionsPointer * p;
+ Data_Get_Struct(self, DepListOptionsPointer, p);
+ try
+ {
+ if (Qtrue == tags)
+ {
+ (*p)->dependency_tags = true;
+ }
+ else if (Qfalse == tags)
+ {
+ (*p)->dependency_tags = false;
+ }
+ else
+ {
+ rb_raise(rb_eTypeError, "dependency_tags= expects a bool");
+ }
+ return Qnil;
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
}
VALUE
@@ -420,7 +806,7 @@ namespace
if (2 == argc)
{
ptr = new DepList(value_to_environment_data(argv[0])->env_ptr,
- value_to_dep_list_options(argv[1]));
+ *value_to_dep_list_options(argv[1]));
}
else
{
@@ -476,6 +862,20 @@ namespace
/*
* call-seq:
+ * options -> DepListOptions
+ *
+ * Our DepListOptions.
+ */
+ VALUE
+ dep_list_options(VALUE self)
+ {
+ DepList * p;
+ Data_Get_Struct(self, DepList, p);
+ return dep_list_options_to_value(p->options());
+ }
+
+ /*
+ * call-seq:
* already_installed?(dep_atom)
*
* Is an atom structure already installed?
@@ -615,6 +1015,110 @@ namespace
}
}
+ VALUE
+ dep_list_override_masks_init(VALUE self)
+ {
+ return self;
+ }
+
+ VALUE
+ dep_list_override_masks_new(VALUE self)
+ {
+ DepListOverrideMasks * ptr(0);
+ try
+ {
+ ptr = new DepListOverrideMasks;
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<DepListOverrideMasks>::free, ptr));
+ rb_obj_call_init(tdata, 0, &self);
+ return tdata;
+ }
+ catch (const std::exception & e)
+ {
+ delete ptr;
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
+ * each {|override_mask| block } -> Nil
+ *
+ * Iterate through the mask reasons.
+ */
+ VALUE
+ dep_list_override_masks_each(VALUE self)
+ {
+ DepListOverrideMasks * m_ptr;
+ Data_Get_Struct(self, DepListOverrideMasks, m_ptr);
+ for (DepListOverrideMask i(static_cast<DepListOverrideMask>(0)), i_end(last_dl_override) ; i != i_end ;
+ i = static_cast<DepListOverrideMask>(static_cast<int>(i) + 1))
+ if ((*m_ptr)[i])
+ rb_yield(INT2FIX(i));
+ return Qnil;
+ }
+
+ /*
+ * call-seq:
+ * empty? -> true or false
+ *
+ * Is the collection empty.
+ */
+ VALUE
+ dep_list_override_masks_empty(VALUE self)
+ {
+ DepListOverrideMasks * m_ptr;
+ Data_Get_Struct(self, DepListOverrideMasks, m_ptr);
+ return m_ptr->any() ? Qfalse : Qtrue;
+ }
+
+ /*
+ * call-seq:
+ * set(mask_reason) -> Nil
+ *
+ * Add DepListOverrideMask to collection.
+ */
+ VALUE
+ dep_list_override_masks_set(VALUE self, VALUE mask_reason)
+ {
+ DepListOverrideMasks * m_ptr;
+ Data_Get_Struct(self, DepListOverrideMasks, m_ptr);
+ try
+ {
+ int mr = NUM2INT(mask_reason);
+ if (mr < 0 || mr >= last_dl_override)
+ rb_raise(rb_eArgError, "DepListOverrideMask out of range");
+ m_ptr->set(mr);
+ return Qnil;
+
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * 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()
{
/*
@@ -670,6 +1174,19 @@ namespace
// cc_enum_special<paludis/dep_list/options.hh, DepListReinstallScmOption, c_dep_list_reinstall_scm_option>
/*
+ * Document-module: Paludis::DepListDowngradeOption
+ *
+ * What do we do when we downgrade.
+ *
+ */
+ c_dep_list_downgrade_option = rb_define_module_under(paludis_module(), "DepListDowngradeOption");
+ for (DepListDowngradeOption l(static_cast<DepListDowngradeOption>(0)), l_end(last_dl_downgrade) ; l != l_end ;
+ l = static_cast<DepListDowngradeOption>(static_cast<int>(l) + 1))
+ rb_define_const(c_dep_list_downgrade_option, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
+
+ // cc_enum_special<paludis/dep_list/options.hh, DepListDowngradeOption, c_dep_list_downgrade_option>
+
+ /*
* Document-module: Paludis::DepListUpgradeOption
*
* When should we upgrade.
@@ -714,6 +1231,19 @@ namespace
* How we handle circular deps.
*
*/
+ c_dep_list_suggested_option = rb_define_module_under(paludis_module(), "DepListSuggestedOption");
+ for (DepListSuggestedOption l(static_cast<DepListSuggestedOption>(0)), l_end(last_dl_suggested) ; l != l_end ;
+ l = static_cast<DepListSuggestedOption>(static_cast<int>(l) + 1))
+ rb_define_const(c_dep_list_suggested_option, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
+
+ // cc_enum_special<paludis/dep_list/options.hh, DepListSuggestedOption, c_dep_list_suggested_option>
+
+ /*
+ * Document-module: Paludis::DepListCircularOption
+ *
+ * How we handle circular deps.
+ *
+ */
c_dep_list_circular_option = rb_define_module_under(paludis_module(), "DepListCircularOption");
for (DepListCircularOption l(static_cast<DepListCircularOption>(0)), l_end(last_dl_circular) ; l != l_end ;
l = static_cast<DepListCircularOption>(static_cast<int>(l) + 1))
@@ -722,6 +1252,19 @@ namespace
// cc_enum_special<paludis/dep_list/options.hh, DepListCircularOption, c_dep_list_circular_option>
/*
+ * Document-module: Paludis::DepListUseOption
+ *
+ * Not for end user use. Used by adjutrix and qa.
+ *
+ */
+ c_dep_list_use_option = rb_define_module_under(paludis_module(), "DepListUseOption");
+ for (DepListUseOption l(static_cast<DepListUseOption>(0)), l_end(last_dl_use_deps) ; l != l_end ;
+ l = static_cast<DepListUseOption>(static_cast<int>(l) + 1))
+ rb_define_const(c_dep_list_use_option, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
+
+ // cc_enum_special<paludis/dep_list/options.hh, DepListBlocksOption, c_dep_list_blocks_option>
+
+ /*
* Document-module: Paludis::DepListBlocksOption
*
* How we handle blocks.
@@ -761,14 +1304,25 @@ namespace
// cc_enum_special<paludis/dep_list/options.hh, DepListEntryKind, c_dep_list_entry_kind>
/*
+ * Document-module: Paludis::DepListOverrideMask
+ *
+ * Masks that can be overriden.
+ *
+ */
+ c_dep_list_override_mask = rb_define_module_under(paludis_module(), "DepListOverrideMask");
+ for (DepListOverrideMask l(static_cast<DepListOverrideMask>(0)), l_end(last_dl_override) ; l != l_end ;
+ l = static_cast<DepListOverrideMask>(static_cast<int>(l) + 1))
+ rb_define_const(c_dep_list_override_mask, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
+
+ // cc_enum_special<paludis/dep_list/options.hh, DepListOverrideMask, c_dep_list_override_mask>
+
+ /*
* Document-class: Paludis::DepListOptions
*
* Parameters for a DepList.
*/
c_dep_list_options = rb_define_class_under(paludis_module(), "DepListOptions", rb_cObject);
-#ifdef CIARANM_REMOVED_THIS
rb_define_singleton_method(c_dep_list_options, "new", RUBY_FUNC_CAST(&dep_list_options_new), -1);
-#endif
rb_define_method(c_dep_list_options, "initialize", RUBY_FUNC_CAST(&dep_list_options_init), -1);
rb_define_method(c_dep_list_options, "reinstall",
RUBY_FUNC_CAST((&OptionsMember<DepListReinstallOption, &DepListOptions::reinstall>::fetch)),0);
@@ -776,6 +1330,8 @@ namespace
RUBY_FUNC_CAST((&OptionsMember<DepListReinstallScmOption, &DepListOptions::reinstall_scm>::fetch)),0);
rb_define_method(c_dep_list_options, "target_type",
RUBY_FUNC_CAST((&OptionsMember<DepListTargetType, &DepListOptions::target_type>::fetch)),0);
+ rb_define_method(c_dep_list_options, "downgrade",
+ RUBY_FUNC_CAST((&OptionsMember<DepListDowngradeOption, &DepListOptions::downgrade>::fetch)),0);
rb_define_method(c_dep_list_options, "upgrade",
RUBY_FUNC_CAST((&OptionsMember<DepListUpgradeOption, &DepListOptions::upgrade>::fetch)),0);
rb_define_method(c_dep_list_options, "new_slots",
@@ -793,18 +1349,60 @@ namespace
rb_define_method(c_dep_list_options, "uninstalled_deps_runtime",
RUBY_FUNC_CAST((&OptionsMember<DepListDepsOption, &DepListOptions::uninstalled_deps_runtime>::fetch)),0);
rb_define_method(c_dep_list_options, "uninstalled_deps_post",
- RUBY_FUNC_CAST((&OptionsMember<DepListDepsOption, &DepListOptions::installed_deps_post>::fetch)),0);
+ RUBY_FUNC_CAST((&OptionsMember<DepListDepsOption, &DepListOptions::uninstalled_deps_post>::fetch)),0);
+ rb_define_method(c_dep_list_options, "uninstalled_deps_suggested",
+ RUBY_FUNC_CAST((&OptionsMember<DepListDepsOption, &DepListOptions::uninstalled_deps_suggested>::fetch)),0);
+ rb_define_method(c_dep_list_options, "suggested",
+ RUBY_FUNC_CAST((&OptionsMember<DepListSuggestedOption, &DepListOptions::suggested>::fetch)),0);
rb_define_method(c_dep_list_options, "circular",
RUBY_FUNC_CAST((&OptionsMember<DepListCircularOption, &DepListOptions::circular>::fetch)),0);
+ rb_define_method(c_dep_list_options, "use",
+ RUBY_FUNC_CAST((&OptionsMember<DepListUseOption, &DepListOptions::use>::fetch)),0);
rb_define_method(c_dep_list_options, "blocks",
RUBY_FUNC_CAST((&OptionsMember<DepListBlocksOption, &DepListOptions::blocks>::fetch)),0);
-#ifdef CIARANM_REMOVED_THIS
- rb_define_method(c_dep_list_options, "ovveride_mask_reasons",
- RUBY_FUNC_CAST((&OptionsMember<DepListBlocksOption, &DepListOptions::blocks>::fetch)),0);
- rb_define_method(c_dep_list_options, "override_mask_reasons", RUBY_FUNC_CAST(&dep_list_options_mask_reasons),0);
-#endif
+ rb_define_method(c_dep_list_options, "reinstall=",
+ RUBY_FUNC_CAST((&OptionsMember<DepListReinstallOption, &DepListOptions::reinstall>::set)),1);
+ rb_define_method(c_dep_list_options, "reinstall_scm=",
+ RUBY_FUNC_CAST((&OptionsMember<DepListReinstallScmOption, &DepListOptions::reinstall_scm>::set)),1);
+ rb_define_method(c_dep_list_options, "target_type=",
+ RUBY_FUNC_CAST((&OptionsMember<DepListTargetType, &DepListOptions::target_type>::set)),1);
+ rb_define_method(c_dep_list_options, "upgrade=",
+ RUBY_FUNC_CAST((&OptionsMember<DepListUpgradeOption, &DepListOptions::upgrade>::set)),1);
+ rb_define_method(c_dep_list_options, "downgrade=",
+ RUBY_FUNC_CAST((&OptionsMember<DepListDowngradeOption, &DepListOptions::downgrade>::set)),1);
+ rb_define_method(c_dep_list_options, "new_slots=",
+ RUBY_FUNC_CAST((&OptionsMember<DepListNewSlotsOption, &DepListOptions::new_slots>::set)),1);
+ rb_define_method(c_dep_list_options, "fall_back=",
+ RUBY_FUNC_CAST((&OptionsMember<DepListFallBackOption, &DepListOptions::fall_back>::set)),1);
+ rb_define_method(c_dep_list_options, "installed_deps_pre=",
+ RUBY_FUNC_CAST((&OptionsMember<DepListDepsOption, &DepListOptions::installed_deps_pre>::set)),1);
+ rb_define_method(c_dep_list_options, "installed_deps_runtime=",
+ RUBY_FUNC_CAST((&OptionsMember<DepListDepsOption, &DepListOptions::installed_deps_runtime>::set)),1);
+ rb_define_method(c_dep_list_options, "installed_deps_post=",
+ RUBY_FUNC_CAST((&OptionsMember<DepListDepsOption, &DepListOptions::installed_deps_post>::set)),1);
+ rb_define_method(c_dep_list_options, "uninstalled_deps_pre=",
+ RUBY_FUNC_CAST((&OptionsMember<DepListDepsOption, &DepListOptions::uninstalled_deps_pre>::set)),1);
+ rb_define_method(c_dep_list_options, "uninstalled_deps_runtime=",
+ RUBY_FUNC_CAST((&OptionsMember<DepListDepsOption, &DepListOptions::uninstalled_deps_runtime>::set)),1);
+ rb_define_method(c_dep_list_options, "uninstalled_deps_post=",
+ RUBY_FUNC_CAST((&OptionsMember<DepListDepsOption, &DepListOptions::uninstalled_deps_post>::set)),1);
+ rb_define_method(c_dep_list_options, "uninstalled_deps_suggested=",
+ RUBY_FUNC_CAST((&OptionsMember<DepListDepsOption, &DepListOptions::uninstalled_deps_suggested>::set)),1);
+ rb_define_method(c_dep_list_options, "suggested=",
+ RUBY_FUNC_CAST((&OptionsMember<DepListSuggestedOption, &DepListOptions::suggested>::set)),1);
+ rb_define_method(c_dep_list_options, "circular=",
+ RUBY_FUNC_CAST((&OptionsMember<DepListCircularOption, &DepListOptions::circular>::set)),1);
+ rb_define_method(c_dep_list_options, "use=",
+ RUBY_FUNC_CAST((&OptionsMember<DepListUseOption, &DepListOptions::use>::set)),1);
+ rb_define_method(c_dep_list_options, "blocks=",
+ RUBY_FUNC_CAST((&OptionsMember<DepListBlocksOption, &DepListOptions::blocks>::set)),1);
+
+
+ rb_define_method(c_dep_list_options, "override_masks", RUBY_FUNC_CAST(&dep_list_options_override_masks),0);
rb_define_method(c_dep_list_options, "dependency_tags", RUBY_FUNC_CAST(&dep_list_options_dependency_tags),0);
+ rb_define_method(c_dep_list_options, "override_masks=", RUBY_FUNC_CAST(&dep_list_options_override_masks_set),1);
+ rb_define_method(c_dep_list_options, "dependency_tags=", RUBY_FUNC_CAST(&dep_list_options_dependency_tags_set),1);
/*
* Document-class: Paludis::DepList
@@ -820,6 +1418,7 @@ namespace
rb_define_method(c_dep_list, "already_installed?", RUBY_FUNC_CAST(&dep_list_already_installed), 1);
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);
/*
* Document-class Paludis::DepListEntry
@@ -833,6 +1432,20 @@ namespace
rb_define_method(c_dep_list_entry, "metadata", RUBY_FUNC_CAST(&dep_list_entry_metadata),0);
rb_define_method(c_dep_list_entry, "destinations", RUBY_FUNC_CAST(&dep_list_entry_destinations),0);
rb_define_method(c_dep_list_entry, "state", RUBY_FUNC_CAST(&dep_list_entry_state),0);
+
+ /*
+ * Document-class: DepListOverrideMasks
+ *
+ * Set of masks that can be overriden.
+ */
+ c_dep_list_override_masks = rb_define_class_under(paludis_module(), "DepListOverrideMasks", rb_cObject);
+ rb_define_singleton_method(c_dep_list_override_masks, "new", RUBY_FUNC_CAST(&dep_list_override_masks_new), 0);
+ rb_define_method(c_dep_list_override_masks, "initialize", RUBY_FUNC_CAST(&dep_list_override_masks_init), 0);
+ rb_define_method(c_dep_list_override_masks, "each", RUBY_FUNC_CAST(&dep_list_override_masks_each), 0);
+ 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, "==", RUBY_FUNC_CAST(&dep_list_override_masks_equal), 1);
}
}
diff --git a/ruby/dep_list_TEST.rb b/ruby/dep_list_TEST.rb
index 5a5fa78..6ebbb86 100644
--- a/ruby/dep_list_TEST.rb
+++ b/ruby/dep_list_TEST.rb
@@ -1,6 +1,5 @@
#!/usr/bin/env ruby
# vim: set sw=4 sts=4 et tw=80 :
-
#
# Copyright (c) 2007 Richard Brown <mynamewasgone@gmail.com>
#
@@ -18,9 +17,6 @@
# Place, Suite 330, Boston, MA 02111-1307 USA
#
-# CIARANM_REMOVED_THIS
-exit 0
-
ENV['PALUDIS_HOME'] = Dir.getwd() + '/dep_list_TEST_dir/home'
require 'test/unit'
@@ -32,42 +28,50 @@ module Paludis
module Shared
def dlo
DepListOptions.new(
- DepListReinstallOption::ReinstallAlways,
- DepListReinstallScmOption::ReinstallScmAlways,
- DepListTargetType::TargetPackage,
- DepListUpgradeOption::UpgradeAlways,
- DepListNewSlotsOption::NewSlotsAlways,
- DepListFallBackOption::FallBackAsNeededExceptTargets,
- DepListDepsOption::DepsDiscard,
- DepListDepsOption::DepsDiscard,
- DepListDepsOption::DepsDiscard,
- DepListDepsOption::DepsDiscard,
- DepListDepsOption::DepsDiscard,
- DepListDepsOption::DepsDiscard,
- DepListCircularOption::CircularDiscard,
- DepListBlocksOption::BlocksError,
- MaskReasons.new,
+ DepListReinstallOption::Never,
+ DepListReinstallScmOption::Never,
+ DepListTargetType::Package,
+ DepListUpgradeOption::Always,
+ DepListDowngradeOption::AsNeeded,
+ DepListNewSlotsOption::Always,
+ DepListFallBackOption::AsNeededExceptTargets,
+ DepListDepsOption::Discard,
+ DepListDepsOption::TryPost,
+ DepListDepsOption::TryPost,
+ DepListDepsOption::Pre,
+ DepListDepsOption::PreOrPost,
+ DepListDepsOption::Post,
+ DepListDepsOption::TryPost,
+ DepListSuggestedOption::Show,
+ DepListCircularOption::Error,
+ DepListUseOption::Standard,
+ DepListBlocksOption::Accumulate,
+ DepListOverrideMasks.new,
false
)
end
- def options_hash
+ def default_options
{
- :reinstall => DepListReinstallOption::ReinstallAlways,
- :reinstall_scm => DepListReinstallScmOption::ReinstallScmAlways,
- :target_type => DepListTargetType::TargetPackage,
- :upgrade => DepListUpgradeOption::UpgradeAlways,
- :new_slots => DepListNewSlotsOption::NewSlotsAlways,
- :fall_back => DepListFallBackOption::FallBackAsNeededExceptTargets,
- :installed_deps_pre => DepListDepsOption::DepsDiscard,
- :installed_deps_runtime => DepListDepsOption::DepsDiscard,
- :installed_deps_post => DepListDepsOption::DepsDiscard,
- :uninstalled_deps_pre => DepListDepsOption::DepsDiscard,
- :uninstalled_deps_runtime => DepListDepsOption::DepsDiscard,
- :uninstalled_deps_post => DepListDepsOption::DepsDiscard,
- :circular => DepListCircularOption::CircularDiscard,
- :blocks => DepListBlocksOption::BlocksError,
- :override_mask_reasons => MaskReasons.new,
+ :reinstall => DepListReinstallOption::Never,
+ :reinstall_scm => DepListReinstallScmOption::Never,
+ :target_type => DepListTargetType::Package,
+ :upgrade => DepListUpgradeOption::Always,
+ :downgrade => DepListDowngradeOption::AsNeeded,
+ :new_slots => DepListNewSlotsOption::Always,
+ :fall_back => DepListFallBackOption::AsNeededExceptTargets,
+ :installed_deps_pre => DepListDepsOption::Discard,
+ :installed_deps_runtime => DepListDepsOption::TryPost,
+ :installed_deps_post => DepListDepsOption::TryPost,
+ :uninstalled_deps_pre => DepListDepsOption::Pre,
+ :uninstalled_deps_runtime => DepListDepsOption::PreOrPost,
+ :uninstalled_deps_post => DepListDepsOption::Post,
+ :uninstalled_deps_suggested => DepListDepsOption::TryPost,
+ :suggested => DepListSuggestedOption::Show,
+ :circular => DepListCircularOption::Error,
+ :use => DepListUseOption::Standard,
+ :blocks => DepListBlocksOption::Accumulate,
+ :override_masks => DepListOverrideMasks.new,
:dependency_tags => false
}
end
@@ -76,6 +80,35 @@ module Paludis
DepListOptions.new(options_hash)
end
+ def options_hash
+ {
+ :reinstall => DepListReinstallOption::Always,
+ :reinstall_scm => DepListReinstallScmOption::Always,
+ :target_type => DepListTargetType::Set,
+ :upgrade => DepListUpgradeOption::AsNeeded,
+ :downgrade => DepListDowngradeOption::Warning,
+ :new_slots => DepListNewSlotsOption::AsNeeded,
+ :fall_back => DepListFallBackOption::AsNeeded,
+ :installed_deps_pre => DepListDepsOption::Pre,
+ :installed_deps_runtime => DepListDepsOption::Discard,
+ :installed_deps_post => DepListDepsOption::Discard,
+ :uninstalled_deps_pre => DepListDepsOption::Discard,
+ :uninstalled_deps_runtime => DepListDepsOption::Discard,
+ :uninstalled_deps_post => DepListDepsOption::Discard,
+ :uninstalled_deps_suggested => DepListDepsOption::Discard,
+ :suggested => DepListSuggestedOption::Discard,
+ :circular => DepListCircularOption::Discard,
+ :use => DepListUseOption::TakeAll,
+ :blocks => DepListBlocksOption::Error,
+ :override_masks => DepListOverrideMasks.new,
+ :dependency_tags => true
+ }
+ end
+
+ def dlo_default
+ DepListOptions.new()
+ end
+
def env
DefaultEnvironment.instance
end
@@ -100,14 +133,23 @@ module Paludis
assert_nothing_raised do
dlo_hash
end
+
+ assert_nothing_raised do
+ dlo_default
+ end
end
def test_members
- options = dlo
- options_hash.each_pair do |method, value|
+ options = dlo_default
+ #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_mask_reasons
assert_equal value, options.send(method)
+ #check setters work
+ assert_nothing_raised do
+ options.send("#{method}=", options_hash[method])
+ assert_equal options_hash[method], options.send(method)
+ end
end
end
@@ -131,7 +173,7 @@ module Paludis
def test_respond
dep_list = dl
- [:add, :clear, :already_installed?, :each].each {|sym| assert_respond_to dep_list, sym}
+ [:add, :clear, :already_installed?, :each, :options].each {|sym| assert_respond_to dep_list, sym}
end
def test_add
@@ -163,6 +205,19 @@ module Paludis
dl.add(PackageDepAtom.new('foo/ba'))
end
end
+
+ def test_options
+ dep_list = dl
+ assert_kind_of DepListOptions, dep_list.options
+ assert_equal DepListReinstallOption::Never, dep_list.options.reinstall
+
+ assert_nothing_raised do
+ dep_list.options.reinstall = DepListReinstallOption::Always
+ end
+
+ assert_equal DepListReinstallOption::Always, dep_list.options.reinstall
+
+ end
end
class TestCase_DepListEntry < Test::Unit::TestCase
@@ -188,4 +243,33 @@ module Paludis
end
end
end
+
+
+ class TestCase_DepListOverrideMasks < Test::Unit::TestCase
+ def test_create
+ m = DepListOverrideMasks.new
+ end
+
+ def test_each
+ m = DepListOverrideMasks.new
+ assert_equal [], m.to_a
+ end
+
+ def test_empty
+ m = DepListOverrideMasks.new
+ assert m.empty?
+ end
+
+ def test_set
+ m = DepListOverrideMasks.new
+ m.set DepListOverrideMask::Licenses
+ m.set DepListOverrideMask::ProfileMasks
+
+ assert ! m.empty?
+ assert_equal 2, m.entries.length
+
+ assert m.include?(DepListOverrideMask::Licenses)
+ assert m.include?(DepListOverrideMask::ProfileMasks)
+ end
+ end
end