class Paludis::InfoActionOptions
Options for Paludis::InfoAction
Public Class Methods
new() → InfoActionOptions
click to toggle source
new(Hash) → InfoActionOptions
::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.
VALUE info_action_options_new(int argc, VALUE *argv, VALUE self) { InfoActionOptions *options = nullptr; try { if (argc == 1 && rb_obj_is_kind_of(argv[0], rb_cHash)) { // TODO(compnerd) raise an error if hashtable is not empty } else if (argc == 0) { } else { rb_raise(rb_eArgError, "InfoActionOptions expects zero or one arguments, but got %d", argc); } options = new InfoActionOptions(make_named_values<InfoActionOptions>( n::make_output_manager() = &make_standard_output_manager)); VALUE object = Data_Wrap_Struct(self, 0, &Common<InfoActionOptions>::free, options); rb_obj_call_init(object, argc, argv); return object; } catch (const std::exception & e) { delete options; exception_to_ruby_exception(e); } } /* * call-seq: * ConfigActionOptions.new() -> ConfigActionOptions * ConfigActionOptions.new(Hash) -> ConfigActionOptions * * ConfigActionOptions.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. */ VALUE config_action_options_new(int argc, VALUE *argv, VALUE self) { ConfigActionOptions *options = nullptr; try { if (argc == 1 && rb_obj_is_kind_of(argv[0], rb_cHash)) { // TODO(compnerd) raise an error if hashtable is not empty } else if (argc == 0) { } else { rb_raise(rb_eArgError, "ConfigActionOptions expects zero or one arguments, but got %d", argc); } options = new ConfigActionOptions(make_named_values<ConfigActionOptions>( n::make_output_manager() = &make_standard_output_manager)); VALUE object = Data_Wrap_Struct(self, 0, &Common<ConfigActionOptions>::free, options); rb_obj_call_init(object, argc, argv); return object; } catch (const std::exception & e) { delete options; exception_to_ruby_exception(e); } } /* * call-seq: * FetchAction.new(fetch_action_options) -> FetchAction */ VALUE fetch_action_new(VALUE self, VALUE opts) { auto options = BoxedOptions<FetchActionOptions>::unbox(opts); std::shared_ptr<Action> * a( new std::shared_ptr<Action>(std::make_shared<FetchAction>(options))); VALUE tdata(Data_Wrap_Struct(self, 0, &Common<std::shared_ptr<Action> >::free, a)); rb_obj_call_init(tdata, 1, &self); return tdata; } /* * call-seq: * FetchActionFailure.new(target_file, requires_manual_fetching, failed_automatic_fetching, failed_integrity_checks) -> FetchActionFailure * FetchActionFailure.new(Hash) -> FetchActionFailure * * FetchActionFailure.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. */ VALUE fetch_action_failure_new(int argc, VALUE *argv, VALUE self) { FetchActionFailure * ptr(0); try { std::string v_target_file; bool v_requires_manual_fetching; bool v_failed_automatic_fetching; std::string v_failed_integrity_checks; if (1 == argc && rb_obj_is_kind_of(argv[0], rb_cHash)) { if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("target_file")))) rb_raise(rb_eArgError, "Missing Parameter: target_file"); if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("requires_manual_fetching")))) rb_raise(rb_eArgError, "Missing Parameter: requires_manual_fetching"); if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("failed_automatic_fetching")))) rb_raise(rb_eArgError, "Missing Parameter: failed_automatic_fetching"); if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("failed_integrity_checks")))) rb_raise(rb_eArgError, "Missing Parameter: failed_integrity_checks"); VALUE v0 = (rb_hash_aref(argv[0], ID2SYM(rb_intern("target_file")))); v_target_file = StringValuePtr(v0); v_requires_manual_fetching = value_to_bool(rb_hash_aref(argv[0], ID2SYM(rb_intern("requires_manual_fetching")))); v_failed_automatic_fetching = value_to_bool(rb_hash_aref(argv[0], ID2SYM(rb_intern("failed_automatic_fetching")))); VALUE v1 = rb_hash_aref(argv[0], ID2SYM(rb_intern("failed_integrity_checks"))); v_failed_integrity_checks = StringValuePtr(v1); } else if (4 == argc) { v_target_file = StringValuePtr(argv[0]); v_requires_manual_fetching = value_to_bool(argv[1]); v_failed_automatic_fetching = value_to_bool(argv[2]); v_failed_integrity_checks = StringValuePtr(argv[3]); } else { rb_raise(rb_eArgError, "FetchActionFailure expects one or four arguments, but got %d",argc); } ptr = new FetchActionFailure(make_named_values<FetchActionFailure>( n::failed_automatic_fetching() = v_failed_automatic_fetching, n::failed_integrity_checks() = v_failed_integrity_checks, n::requires_manual_fetching() = v_requires_manual_fetching, n::target_file() = v_target_file )); VALUE tdata(Data_Wrap_Struct(self, 0, &Common<FetchActionFailure>::free, ptr)); rb_obj_call_init(tdata, argc, argv); return tdata; } catch (const std::exception & e) { delete ptr; exception_to_ruby_exception(e); } } /* * Document-method: target_file * * call-seq: target_file -> String * * Our target file. */ /* * Document-method: failed_integrity_checks * * call-seq: failed_integrity_checks -> String * * Our failed integrity checks. */ /* * Document-method: fetch_unneeded? * * call-seq: * fetch_unneeded -> true or false */ /* * Document-method: safe_resume? * * call-seq: * safe_resume -> true or false */ /* * Document-method: requires_manual_fetching? * * call-seq: * requires_manual_fetching? -> true or false * * Do we require manual fetching? */ /* * Document-method: failed_automatic_fetching? * * call-seq: * failed_automatic_fetching? -> true or false * * Did we fail automatic fetching? */ template <typename T_, typename K_, typename R_, NamedValue<K_, R_> (T_::*) > struct NVFetch; template <typename T_, typename K_, NamedValue<K_, bool> (T_::* f_) > struct NVFetch<T_, K_, bool, f_> { static VALUE fetch(VALUE self) { T_ * p; Data_Get_Struct(self, T_, p); return bool_to_value((p->*f_)()); } }; template <typename T_, typename K_, NamedValue<K_, std::string> (T_::* f_) > struct NVFetch<T_, K_, std::string, f_> { static VALUE fetch(VALUE self) { T_ * p; Data_Get_Struct(self, T_, p); return rb_str_new2((p->*f_)().c_str()); } }; void cannot_perform_uninstall(const std::shared_ptr<const PackageID> & id, const UninstallActionOptions &) { throw InternalError(PALUDIS_HERE, "Can't uninstall '" + stringify(*id) + "'"); } /* * call-seq: * InstallActionOptions.new(destination) -> InstallActionOptions * InstallActionOptions.new(Hash) -> InstallActionOptions * * InstallActionOptions.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. */ VALUE install_action_options_new(int argc, VALUE *argv, VALUE self) { InstallActionOptions * ptr(0); try { std::shared_ptr<Repository> v_destination; if (1 == argc && rb_obj_is_kind_of(argv[0], rb_cHash)) { if (Qnil == rb_hash_aref(argv[0], ID2SYM(rb_intern("destination")))) rb_raise(rb_eArgError, "Missing Parameter: destination"); v_destination = value_to_repository(rb_hash_aref(argv[0], ID2SYM(rb_intern("destination")))); } else if (1 == argc) { v_destination = value_to_repository(argv[0]); } else { rb_raise(rb_eArgError, "InstallActionOptions expects one argument, but got %d",argc); } ptr = new InstallActionOptions(make_named_values<InstallActionOptions>( n::destination() = v_destination, n::make_output_manager() = &make_standard_output_manager, n::perform_uninstall() = &cannot_perform_uninstall, n::replacing() = std::make_shared<PackageIDSequence>(), n::want_phase() = &want_all_phases )); VALUE tdata(Data_Wrap_Struct(self, 0, &Common<InstallActionOptions>::free, ptr)); rb_obj_call_init(tdata, argc, argv); return tdata; } catch (const std::exception & e) { delete ptr; exception_to_ruby_exception(e); } } /* * call-seq: * PretendActionOptions.new(destination) -> InstallActionOptions */ VALUE pretend_action_options_new(int argc, VALUE *argv, VALUE self) { PretendActionOptions * ptr(0); try { std::shared_ptr<Repository> v_destination; if (1 == argc) { v_destination = value_to_repository(argv[0]); } else { rb_raise(rb_eArgError, "PretendActionOptions expects one argument, but got %d",argc); } ptr = new PretendActionOptions(make_named_values<PretendActionOptions>( n::destination() = v_destination, n::make_output_manager() = &make_standard_output_manager, n::replacing() = std::make_shared<PackageIDSequence>() )); VALUE tdata(Data_Wrap_Struct(self, 0, &Common<PretendActionOptions>::free, ptr)); rb_obj_call_init(tdata, argc, argv); return tdata; } catch (const std::exception & e) { delete ptr; exception_to_ruby_exception(e); } } /* * call-seq: * InstallAction.new(install_action_options) -> InstallAction * * Create a new InstallAction. */ VALUE install_action_new(VALUE self, VALUE opts) { auto options = BoxedOptions<InstallActionOptions>::unbox(opts); std::shared_ptr<Action> * a( new std::shared_ptr<Action>(std::make_shared<InstallAction>(options))); VALUE tdata(Data_Wrap_Struct(self, 0, &Common<std::shared_ptr<Action> >::free, a)); rb_obj_call_init(tdata, 1, &self); return tdata; } /* * call-seq: * PretendAction.new(pretend_action_options) -> PretendAction * * Create a new PretendAction. */ VALUE pretend_action_new(VALUE self, VALUE opts) { auto options = BoxedOptions<PretendActionOptions>::unbox(opts); std::shared_ptr<Action> * a( new std::shared_ptr<Action>(std::make_shared<PretendAction>(options))); VALUE tdata(Data_Wrap_Struct(self, 0, &Common<std::shared_ptr<Action> >::free, a)); rb_obj_call_init(tdata, 1, &self); return tdata; } bool ignore_nothing(const FSPath &) { return false; } /* * call-seq: * UninstallActionOptions.new(config_protect) -> UninstallActionOptions */ VALUE uninstall_action_options_new(int argc, VALUE *argv, VALUE self) { UninstallActionOptions * ptr(0); try { std::string v_config_protect; if (1 == argc) { v_config_protect = std::string(StringValuePtr(argv[0])); } else { rb_raise(rb_eArgError, "UninstallActionOptions expects one argument, but got %d",argc); } ptr = new UninstallActionOptions(make_named_values<UninstallActionOptions>( n::config_protect() = v_config_protect, n::if_for_install_id() = nullptr, n::ignore_for_unmerge() = &ignore_nothing, n::is_overwrite() = false, n::make_output_manager() = &make_standard_output_manager, n::override_contents() = nullptr, n::want_phase() = &want_all_phases )); VALUE tdata(Data_Wrap_Struct(self, 0, &Common<UninstallActionOptions>::free, ptr)); rb_obj_call_init(tdata, argc, argv); return tdata; } catch (const std::exception & e) { delete ptr; exception_to_ruby_exception(e); } } /* * call-seq: * UninstallAction.new(uninstall_action_options) -> UninstallAction * * Create a new UninstallAction. */ VALUE uninstall_action_new(VALUE self, VALUE opts) { auto options = BoxedOptions<UninstallActionOptions>::unbox(opts); std::shared_ptr<Action> * a(new std::shared_ptr<Action>(std::make_shared<UninstallAction>(options))); VALUE tdata(Data_Wrap_Struct(self, 0, &Common<std::shared_ptr<Action> >::free, a)); rb_obj_call_init(tdata, 1, &self); return tdata; } /* * Document-method: config_protect * * call-seq: * config_protect -> String * * Our config_protect value */ VALUE uninstall_action_options_config_protect(VALUE self) { UninstallActionOptions * p; Data_Get_Struct(self, UninstallActionOptions, p); return rb_str_new2((*p).config_protect().c_str()); } /* * call-seq: * failed? -> true or false * * Did our pretend phase fail? */ VALUE pretend_action_failed(VALUE self) { std::shared_ptr<Action> * p; Data_Get_Struct(self, std::shared_ptr<Action>, p); return bool_to_value(std::static_pointer_cast<PretendAction>(*p)->failed()); } /* * call-seq: * set_failed -> Qnil * * Mark the action as failed. */ VALUE pretend_action_set_failed(VALUE self) { std::shared_ptr<Action> * p; Data_Get_Struct(self, std::shared_ptr<Action>, p); std::static_pointer_cast<PretendAction>(*p)->set_failed(); return Qnil; } void do_register_action() { /* * Document-class: Paludis::SupportsActionTest * * Tests whether a Paludis::PackageID supports a particular action. */ c_supports_action_test = rb_define_class_under(c_paludis_module, "SupportsActionTest", rb_cObject); rb_define_singleton_method(c_supports_action_test, "new", supports_action_test_new, 1); /* * Document-class: Paludis::Action * * Base class for actions, used by Paludis::PackageID#perform_action. */ c_action = rb_define_class_under(c_paludis_module, "Action", rb_cObject); rb_funcall(c_action, rb_intern("private_class_method"), 1, rb_str_new2("new")); /* * Document-class: Paludis::FetchAction * * An action for fetching. */ c_fetch_action = rb_define_class_under(c_paludis_module, "FetchAction", c_action); rb_define_singleton_method(c_fetch_action, "new", fetch_action_new, 1); rb_define_method(c_fetch_action, "initialize", empty_init, -1); rb_define_method(c_fetch_action, "options", template_methods, 0); /* * Document-class: Paludis::FetchActionOptions * * Options for Paludis::FetchAction. */ c_fetch_action_options = rb_define_class_under(c_paludis_module, "FetchActionOptions", rb_cObject); rb_define_singleton_method(c_fetch_action_options, "new", fetch_action_options_new, -1); rb_define_method(c_fetch_action_options, "initialize", empty_init, -1); rb_define_method(c_fetch_action_options, "safe_resume?", RUBY_FUNC_CAST((&NVFetch<FetchActionOptions, n::safe_resume, bool, &FetchActionOptions::safe_resume>::fetch)), 0); rb_define_method(c_fetch_action_options, "exclude_unmirrorable?", RUBY_FUNC_CAST((&NVFetch<FetchActionOptions, n::exclude_unmirrorable, bool, &FetchActionOptions::exclude_unmirrorable>::fetch)), 0); /* * Document-class: Paludis::FetchActionFailure * * A failed fetch action part. */ c_fetch_action_failure = rb_define_class_under(c_paludis_module, "FetchActionFailure", rb_cObject); rb_define_singleton_method(c_fetch_action_failure, "new", fetch_action_failure_new, -1); rb_define_method(c_fetch_action_failure, "initialize", empty_init, -1); rb_define_method(c_fetch_action_failure, "target_file", RUBY_FUNC_CAST((&NVFetch<FetchActionFailure, n::target_file, std::string, &FetchActionFailure::target_file>::fetch)), 0); rb_define_method(c_fetch_action_failure, "requires_manual_fetching?", RUBY_FUNC_CAST((&NVFetch<FetchActionFailure, n::requires_manual_fetching, bool, &FetchActionFailure::requires_manual_fetching>::fetch)), 0); rb_define_method(c_fetch_action_failure, "failed_automatic_fetching?", RUBY_FUNC_CAST((&NVFetch<FetchActionFailure, n::failed_automatic_fetching, bool, &FetchActionFailure::failed_automatic_fetching>::fetch)), 0); rb_define_method(c_fetch_action_failure, "failed_integrity_checks", RUBY_FUNC_CAST((&NVFetch<FetchActionFailure, n::failed_integrity_checks, std::string, &FetchActionFailure::failed_integrity_checks>::fetch)), 0); /* * Document-class: Paludis::InfoActionOptions * * Options for Paludis::InfoAction */ c_info_action_options = rb_define_class_under(c_paludis_module, "InfoActionOptions", rb_cObject); rb_define_singleton_method(c_info_action_options, "new", info_action_options_new, -1); rb_define_method(c_info_action_options, "initialize", empty_init, -1); /* * Document-class: Paludis::InfoAction * * An action for fetching. */ c_info_action = rb_define_class_under(c_paludis_module, "InfoAction", c_action); rb_define_singleton_method(c_info_action, "new", info_action_new, 1); rb_define_method(c_info_action, "initialize", empty_init, -1); rb_define_method(c_info_action, "options", template_methods, 0); /* * Document-class: Paludis::ConfigActionOptions * * Options for Paludis::ConfigAction */ c_config_action_options = rb_define_class_under(c_paludis_module, "ConfigActionOptions", rb_cObject); rb_define_singleton_method(c_config_action_options, "new", config_action_options_new, -1); rb_define_method(c_config_action_options, "initialize", empty_init, -1); /* * Document-class: Paludis::ConfigAction * * An action for fetching. */ c_config_action = rb_define_class_under(c_paludis_module, "ConfigAction", c_action); rb_define_singleton_method(c_config_action, "new", config_action_new, 1); rb_define_method(c_config_action, "initialize", empty_init, -1); rb_define_method(c_config_action, "options", template_methods, 0); /* * Document-class: Paludis::InstallActionOptions * * Options for Paludis::InstallAction. */ c_install_action_options = rb_define_class_under(c_paludis_module, "InstallActionOptions", rb_cObject); rb_define_singleton_method(c_install_action_options, "new", install_action_options_new, -1); rb_define_method(c_install_action_options, "initialize", empty_init, -1); rb_define_method(c_install_action_options, "destination", template_methods, 0); /* * Document-class: Paludis::InstallAction * * An InstallAction is used by InstallTask to install a PackageID. */ c_install_action = rb_define_class_under(c_paludis_module, "InstallAction", c_action); rb_define_singleton_method(c_install_action, "new", install_action_new, 1); rb_define_method(c_install_action, "initialize", empty_init, -1); rb_define_method(c_install_action, "options", template_methods, 0); /* * Document-class: Paludis::UninstallActionOptions * * Options for Paludis::UninstallAction. */ c_uninstall_action_options = rb_define_class_under(c_paludis_module, "UninstallActionOptions", rb_cObject); rb_define_singleton_method(c_uninstall_action_options, "new", uninstall_action_options_new, -1); rb_define_method(c_uninstall_action_options, "initialize", empty_init, -1); rb_define_method(c_uninstall_action_options, "config_protect", uninstall_action_options_config_protect, 0); /* * Document-class: Paludis::UninstallAction * * An UninstallAction is used by UninstallTask to uninstall a PackageID. */ c_uninstall_action = rb_define_class_under(c_paludis_module, "UninstallAction", c_action); rb_define_singleton_method(c_uninstall_action, "new", uninstall_action_new, 1); rb_define_method(c_uninstall_action, "initialize", empty_init, -1); rb_define_method(c_uninstall_action, "options", template_methods, 0); /* * Document-class: Paludis::PretendActionOptions * * Options for Paludis::PretendAction. */ c_pretend_action_options = rb_define_class_under(c_paludis_module, "PretendActionOptions", rb_cObject); rb_define_singleton_method(c_pretend_action_options, "new", pretend_action_options_new, -1); rb_define_method(c_pretend_action_options, "initialize", empty_init, -1); rb_define_method(c_pretend_action_options, "destination", template_methods, 0); /* * Document-class: Paludis::PretendAction * * A PretendAction is used by InstallTask to handle install-pretend-phase checks on a PackageID. */ c_pretend_action = rb_define_class_under(c_paludis_module, "PretendAction", c_action); rb_define_singleton_method(c_pretend_action, "new", pretend_action_new, 1); rb_define_method(c_pretend_action, "initialize", empty_init, -1); rb_define_method(c_pretend_action, "failed?", pretend_action_failed, 0); rb_define_method(c_pretend_action, "set_failed", pretend_action_set_failed, 0); rb_define_method(c_pretend_action, "options", template_methods, 0); c_pretend_fetch_action = rb_define_class_under(c_paludis_module, "PretendFetchAction", c_action); rb_funcall(c_pretend_fetch_action, rb_intern("private_class_method"), 1, rb_str_new2("new")); } }