aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-05-17 00:57:54 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-05-17 00:57:54 +0100
commit3455286da10dbabcc27db157a8b1b7881f06ea2e (patch)
tree77a8ab3e1fd52f394513cde085e24ad619204fa0
parent20b5964db49950e5651354e88e4f651c2a30cf09 (diff)
downloadpaludis-3455286da10dbabcc27db157a8b1b7881f06ea2e.tar.gz
paludis-3455286da10dbabcc27db157a8b1b7881f06ea2e.tar.xz
Add remaining ActiveDependencyLabels bindings
-rw-r--r--ruby/dep_label.cc37
-rw-r--r--ruby/dep_spec_TEST.rb5
2 files changed, 41 insertions, 1 deletions
diff --git a/ruby/dep_label.cc b/ruby/dep_label.cc
index f98db88..af25f82 100644
--- a/ruby/dep_label.cc
+++ b/ruby/dep_label.cc
@@ -367,6 +367,31 @@ namespace
}
}
+ template <typename T_, const std::tr1::shared_ptr<const T_> (ActiveDependencyLabels::* f_) () const>
+ struct ActiveDependencyLabelsLabels
+ {
+ static VALUE
+ get(VALUE self)
+ {
+ try
+ {
+ std::tr1::shared_ptr<ActiveDependencyLabels> * ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<ActiveDependencyLabels>, ptr);
+ std::tr1::shared_ptr<const T_> v(((**ptr).*(f_))());
+
+ VALUE result(rb_ary_new());
+ for (typename T_::ConstIterator i(v->begin()), i_end(v->end()) ;
+ i != i_end ; ++i)
+ rb_ary_push(result, dependency_label_to_value(*i));
+ return result;
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+ };
+
void do_register_dep_label()
{
/*
@@ -448,6 +473,18 @@ namespace
c_active_dependency_labels = rb_define_class_under(paludis_module(), "ActiveDependencyLabels", rb_cObject);
rb_define_singleton_method(c_active_dependency_labels, "new", RUBY_FUNC_CAST(&active_dependency_labels_new), -1);
rb_define_method(c_active_dependency_labels, "initialize", RUBY_FUNC_CAST(&empty_init), -1);
+ rb_define_method(c_active_dependency_labels, "system_labels", RUBY_FUNC_CAST((
+ ActiveDependencyLabelsLabels<DependencySystemLabelSequence,
+ &ActiveDependencyLabels::system_labels>::get)), 0);
+ rb_define_method(c_active_dependency_labels, "type_labels", RUBY_FUNC_CAST((
+ ActiveDependencyLabelsLabels<DependencyTypeLabelSequence,
+ &ActiveDependencyLabels::type_labels>::get)), 0);
+ rb_define_method(c_active_dependency_labels, "abi_labels", RUBY_FUNC_CAST((
+ ActiveDependencyLabelsLabels<DependencyABIsLabelSequence,
+ &ActiveDependencyLabels::abi_labels>::get)), 0);
+ rb_define_method(c_active_dependency_labels, "suggest_labels", RUBY_FUNC_CAST((
+ ActiveDependencyLabelsLabels<DependencySuggestLabelSequence,
+ &ActiveDependencyLabels::suggest_labels>::get)), 0);
}
}
diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb
index 314f2a1..8615987 100644
--- a/ruby/dep_spec_TEST.rb
+++ b/ruby/dep_spec_TEST.rb
@@ -417,7 +417,10 @@ module Paludis
assert_kind_of DependencyBuildLabel, spec_key.initial_labels[0]
assert_equal "DEPEND", spec_key.initial_labels[0].text
assert_equal "DEPEND", spec_key.initial_labels[0].to_s
- ActiveDependencyLabels.new spec_key.initial_labels
+
+ a = ActiveDependencyLabels.new spec_key.initial_labels
+ assert_kind_of Array, a.type_labels
+ assert_kind_of DependencyBuildLabel, a.type_labels[0]
end
end
end