diff options
author | 2010-09-03 10:21:57 +0100 | |
---|---|---|
committer | 2010-09-05 10:32:34 +0100 | |
commit | 0ad796a9ebe1a3706b3d97c100633fff3bc8b10c (patch) | |
tree | 9bf056b927e536fa2899b938e868d3fdf23676d2 /ruby | |
parent | 4d0a770757e430cb2e972ea8aefd09d3294c2ce3 (diff) | |
download | paludis-0ad796a9ebe1a3706b3d97c100633fff3bc8b10c.tar.gz paludis-0ad796a9ebe1a3706b3d97c100633fff3bc8b10c.tar.xz |
Blocker strength is an enum, not a bool
Diffstat (limited to 'ruby')
-rw-r--r-- | ruby/dep_spec.cc | 21 | ||||
-rw-r--r-- | ruby/dep_spec_TEST.rb | 8 |
2 files changed, 23 insertions, 6 deletions
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc index 6f6636175..aacaf7069 100644 --- a/ruby/dep_spec.cc +++ b/ruby/dep_spec.cc @@ -45,6 +45,7 @@ namespace static VALUE c_dep_spec; static VALUE c_string_dep_spec; + static VALUE c_block_kind; static VALUE c_block_dep_spec; static VALUE c_dependencies_labels_dep_spec; static VALUE c_fetchable_uri_dep_spec; @@ -465,14 +466,18 @@ namespace } VALUE - block_dep_spec_new(VALUE self, VALUE str, VALUE spec, VALUE strong) + block_dep_spec_new(VALUE self, VALUE str, VALUE spec, VALUE kind) { std::shared_ptr<const WrappedSpecBase> * ptr(0); try { + int l = NUM2INT(kind); + if (l < 0 || l >= last_bk) + rb_raise(rb_eTypeError, "BlockDepSpec expects a valid BlockKind as the third parameter"); + std::shared_ptr<const PackageDepSpec> pkg(value_to_package_dep_spec(spec)); ptr = new std::shared_ptr<const WrappedSpecBase>(std::make_shared<WrappedSpec<BlockDepSpec>>( - std::make_shared<BlockDepSpec>(StringValuePtr(str), *pkg, value_to_bool(strong)))); + std::make_shared<BlockDepSpec>(StringValuePtr(str), *pkg, static_cast<BlockKind>(l)))); VALUE tdata(Data_Wrap_Struct(self, 0, &Common<std::shared_ptr<const WrappedSpecBase> >::free, ptr)); rb_obj_call_init(tdata, 3, &str); return tdata; @@ -1274,6 +1279,18 @@ namespace rb_define_method(c_plain_text_label_dep_spec, "to_s", RUBY_FUNC_CAST(plain_text_dep_label_spec_to_s), 0); /* + * Document-module: Paludis::BlockKind + * + * The kind of a BlockDepSpec + */ + c_block_kind = rb_define_module_under(paludis_module(), "BlockKind"); + for (BlockKind l(static_cast<BlockKind>(0)), l_end(last_bk) ; l != l_end ; + l = static_cast<BlockKind>(static_cast<int>(l) + 1)) + rb_define_const(c_block_kind, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l)); + + // cc_enum_special<paludis/dep_spec.hh, BlockKind, c_block_kind> + + /* * Document-class: Paludis::BlockDepSpec * * A BlockDepSpec represents a block on a package name (for example, 'app-editors/vim'), possibly with diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb index 1ded8658e..8e8112a8d 100644 --- a/ruby/dep_spec_TEST.rb +++ b/ruby/dep_spec_TEST.rb @@ -273,22 +273,22 @@ module Paludis end def test_create - v = BlockDepSpec.new("!>=foo/bar-1", Paludis::parse_user_package_dep_spec(">=foo/bar-1", env, []), false) + v = BlockDepSpec.new("!>=foo/bar-1", Paludis::parse_user_package_dep_spec(">=foo/bar-1", env, []), BlockKind::Weak) end def test_create_error assert_raise TypeError do - v = BlockDepSpec.new("!>=foo/bar-1", 0, false) + v = BlockDepSpec.new("!>=foo/bar-1", 0, BlockKind::Weak) end assert_raise TypeError do - v = BlockDepSpec.new("!>=foo/bar-1", PlainTextDepSpec.new('foo-bar/baz'), false) + v = BlockDepSpec.new("!>=foo/bar-1", PlainTextDepSpec.new('foo-bar/baz'), BlockKind::Weak) end end def test_blocked_spec assert_equal "foo/baz", BlockDepSpec.new("!foo/baz", Paludis::parse_user_package_dep_spec( - "foo/baz", env, []), false).blocking.to_s + "foo/baz", env, []), BlockKind::Weak).blocking.to_s end end |