aboutsummaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-09-05 16:12:26 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-09-05 16:12:26 +0100
commit91a77a7156f6a730097393abae5a43b11f8a7e5a (patch)
tree1626f58a5b58981b1c425dd7a2f720f0b6962f04 /ruby
parentfcf224a626d967528bba7d4cbabec46a03814000 (diff)
parent95e7880705435bee4833c0bd1b8694f023038e48 (diff)
downloadpaludis-91a77a7156f6a730097393abae5a43b11f8a7e5a.tar.gz
paludis-91a77a7156f6a730097393abae5a43b11f8a7e5a.tar.xz
Merge branch 'blocker-annotations'
Diffstat (limited to 'ruby')
-rw-r--r--ruby/dep_spec.cc21
-rw-r--r--ruby/dep_spec_TEST.rb8
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