aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-05-16 00:23:19 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-05-16 00:40:07 +0100
commit7f486c0c5feb7e99e221c5036bfc9b60124f4a1d (patch)
tree8c5fcf78e0b8d8bec79d9b791c2caa7f2068adfc
parent8f61bcf0951208e2c8328fea387841e205d1c7bf (diff)
downloadpaludis-7f486c0c5feb7e99e221c5036bfc9b60124f4a1d.tar.gz
paludis-7f486c0c5feb7e99e221c5036bfc9b60124f4a1d.tar.xz
Add missing ruby generator bindings
-rw-r--r--ruby/generator.cc54
1 files changed, 53 insertions, 1 deletions
diff --git a/ruby/generator.cc b/ruby/generator.cc
index 6009944..52daed9 100644
--- a/ruby/generator.cc
+++ b/ruby/generator.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 Ciaran McCreesh
*
* 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
@@ -33,6 +33,7 @@ namespace
static VALUE c_generator_from_repository;
static VALUE c_generator_category;
static VALUE c_generator_intersection;
+ static VALUE c_generator_some_ids_might_support_action;
VALUE
generator_init(int, VALUE *, VALUE self)
@@ -224,6 +225,49 @@ namespace
}
}
+ /*
+ * call-seq:
+ * new(class) -> Filter
+ *
+ * Create a Generator that accepts packages that might support the
+ * specified Action subclass.
+ */
+ VALUE
+ generator_some_ids_might_support_action_new(VALUE self, VALUE action_class)
+ {
+ Generator * ptr(0);
+ try
+ {
+ if (Qtrue == rb_funcall2(action_class, rb_intern("<="), 1, install_action_value_ptr()))
+ ptr = new generator::SomeIDsMightSupportAction<InstallAction>();
+ else if (Qtrue == rb_funcall2(action_class, rb_intern("<="), 1, installed_action_value_ptr()))
+ ptr = new generator::SomeIDsMightSupportAction<InstalledAction>();
+ else if (Qtrue == rb_funcall2(action_class, rb_intern("<="), 1, uninstall_action_value_ptr()))
+ ptr = new generator::SomeIDsMightSupportAction<UninstallAction>();
+ else if (Qtrue == rb_funcall2(action_class, rb_intern("<="), 1, pretend_action_value_ptr()))
+ ptr = new generator::SomeIDsMightSupportAction<PretendAction>();
+ else if (Qtrue == rb_funcall2(action_class, rb_intern("<="), 1, config_action_value_ptr()))
+ ptr = new generator::SomeIDsMightSupportAction<ConfigAction>();
+ else if (Qtrue == rb_funcall2(action_class, rb_intern("<="), 1, fetch_action_value_ptr()))
+ ptr = new generator::SomeIDsMightSupportAction<FetchAction>();
+ else if (Qtrue == rb_funcall2(action_class, rb_intern("<="), 1, info_action_value_ptr()))
+ ptr = new generator::SomeIDsMightSupportAction<InfoAction>();
+ else if (Qtrue == rb_funcall2(action_class, rb_intern("<="), 1, pretend_fetch_action_value_ptr()))
+ ptr = new generator::SomeIDsMightSupportAction<PretendFetchAction>();
+ else
+ rb_raise(rb_eTypeError, "Can't convert %s into an Action subclass", rb_obj_classname(action_class));
+
+ VALUE data(Data_Wrap_Struct(self, 0, &Common<Generator>::free, ptr));
+ rb_obj_call_init(data, 1, &action_class);
+ return data;
+ }
+ catch (const std::exception & e)
+ {
+ delete ptr;
+ exception_to_ruby_exception(e);
+ }
+ }
+
void do_register_generator()
{
/*
@@ -301,6 +345,14 @@ namespace
*/
c_generator_from_repository = rb_define_class_under(c_generator_module, "FromRepository", c_generator);
rb_define_singleton_method(c_generator_from_repository, "new", RUBY_FUNC_CAST(&generator_from_repository_new), 1);
+
+ /*
+ * Document-class: Paludis::Generator::SomeIDsMightSupportAction
+ *
+ * Generate all packages that might support a particular action.
+ */
+ c_generator_some_ids_might_support_action = rb_define_class_under(c_generator_module, "SomeIDsMightSupportAction", c_generator);
+ rb_define_singleton_method(c_generator_some_ids_might_support_action, "new", RUBY_FUNC_CAST(&generator_some_ids_might_support_action_new), 1);
}
}