aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-11-18 09:47:19 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-11-18 09:47:19 +0000
commit1487104037a2708342f7a8c0359628f6c1e52d26 (patch)
tree52f5f79be41c04a0a60baeac09906e01155b97f2
parent1ac2d4a08a6d1f2686dfebd853f6b8f69f0e3999 (diff)
downloadpaludis-1487104037a2708342f7a8c0359628f6c1e52d26.tar.gz
paludis-1487104037a2708342f7a8c0359628f6c1e52d26.tar.xz
(ruby) Fix how we use Data_Get_Struct to avoid magic C casting between tr1::shared_ptr<>s of different types.
-rw-r--r--ruby/contents.cc99
-rw-r--r--ruby/dep_spec.cc133
-rw-r--r--ruby/dep_tag.cc59
-rw-r--r--ruby/environment.cc40
-rw-r--r--ruby/metadata_key.cc155
-rw-r--r--ruby/query.cc28
-rw-r--r--ruby/repository.cc10
7 files changed, 247 insertions, 277 deletions
diff --git a/ruby/contents.cc b/ruby/contents.cc
index 3ba97bc..a389c67 100644
--- a/ruby/contents.cc
+++ b/ruby/contents.cc
@@ -40,53 +40,52 @@ namespace
static VALUE c_contents_fifo_entry;
struct V :
- ConstVisitor<ContentsVisitorTypes>
- {
- VALUE value;
- tr1::shared_ptr<const ContentsEntry> mm;
-
- V(tr1::shared_ptr<const ContentsEntry> _m) :
- mm(_m)
- {
- }
+ ConstVisitor<ContentsVisitorTypes>
+ {
+ VALUE value;
+ tr1::shared_ptr<const ContentsEntry> mm;
- void visit(const ContentsFileEntry &)
- {
- value = Data_Wrap_Struct(c_contents_file_entry, 0, &Common<tr1::shared_ptr<const ContentsFileEntry> >::free,
- new tr1::shared_ptr<const ContentsFileEntry>(tr1::static_pointer_cast<const ContentsFileEntry>(mm)));
- }
+ V(tr1::shared_ptr<const ContentsEntry> _m) :
+ mm(_m)
+ {
+ }
- void visit(const ContentsDirEntry &)
- {
- value = Data_Wrap_Struct(c_contents_dir_entry, 0, &Common<tr1::shared_ptr<const ContentsDirEntry> >::free,
- new tr1::shared_ptr<const ContentsDirEntry>(tr1::static_pointer_cast<const ContentsDirEntry>(mm)));
- }
+ void visit(const ContentsFileEntry &)
+ {
+ value = Data_Wrap_Struct(c_contents_file_entry, 0, &Common<tr1::shared_ptr<const ContentsEntry> >::free,
+ new tr1::shared_ptr<const ContentsEntry>(mm));
+ }
- void visit(const ContentsMiscEntry &)
- {
- value = Data_Wrap_Struct(c_contents_misc_entry, 0, &Common<tr1::shared_ptr<const ContentsMiscEntry> >::free,
- new tr1::shared_ptr<const ContentsMiscEntry>(tr1::static_pointer_cast<const ContentsMiscEntry>(mm)));
- }
+ void visit(const ContentsDirEntry &)
+ {
+ value = Data_Wrap_Struct(c_contents_dir_entry, 0, &Common<tr1::shared_ptr<const ContentsEntry> >::free,
+ new tr1::shared_ptr<const ContentsEntry>(mm));
+ }
- void visit(const ContentsSymEntry &)
- {
- value = Data_Wrap_Struct(c_contents_sym_entry, 0, &Common<tr1::shared_ptr<const ContentsSymEntry> >::free,
- new tr1::shared_ptr<const ContentsSymEntry>(tr1::static_pointer_cast<const ContentsSymEntry>(mm)));
- }
+ void visit(const ContentsMiscEntry &)
+ {
+ value = Data_Wrap_Struct(c_contents_misc_entry, 0, &Common<tr1::shared_ptr<const ContentsEntry> >::free,
+ new tr1::shared_ptr<const ContentsEntry>(mm));
+ }
- void visit(const ContentsFifoEntry &)
- {
- value = Data_Wrap_Struct(c_contents_fifo_entry, 0, &Common<tr1::shared_ptr<const ContentsFifoEntry> >::free,
- new tr1::shared_ptr<const ContentsFifoEntry>(tr1::static_pointer_cast<const ContentsFifoEntry>(mm)));
- }
+ void visit(const ContentsSymEntry &)
+ {
+ value = Data_Wrap_Struct(c_contents_sym_entry, 0, &Common<tr1::shared_ptr<const ContentsEntry> >::free,
+ new tr1::shared_ptr<const ContentsEntry>(mm));
+ }
- void visit(const ContentsDevEntry &)
- {
- value = Data_Wrap_Struct(c_contents_dev_entry, 0, &Common<tr1::shared_ptr<const ContentsDevEntry> >::free,
- new tr1::shared_ptr<const ContentsDevEntry>(tr1::static_pointer_cast<const ContentsDevEntry>(mm)));
- }
- };
+ void visit(const ContentsFifoEntry &)
+ {
+ value = Data_Wrap_Struct(c_contents_fifo_entry, 0, &Common<tr1::shared_ptr<const ContentsEntry> >::free,
+ new tr1::shared_ptr<const ContentsEntry>(mm));
+ }
+ void visit(const ContentsDevEntry &)
+ {
+ value = Data_Wrap_Struct(c_contents_dev_entry, 0, &Common<tr1::shared_ptr<const ContentsEntry> >::free,
+ new tr1::shared_ptr<const ContentsEntry>(mm));
+ }
+ };
VALUE
contents_entry_to_value(tr1::shared_ptr<const ContentsEntry> m)
@@ -145,7 +144,6 @@ namespace
Data_Get_Struct(v, tr1::shared_ptr<const ContentsEntry>, v_ptr);
(*self_ptr)->add(*v_ptr);
return self;
-
}
catch (const std::exception & e)
{
@@ -187,18 +185,18 @@ namespace
static VALUE
contents_entry_new(int argc, VALUE * argv, VALUE self)
{
- typename tr1::shared_ptr<const A_> * ptr(0);
+ typename tr1::shared_ptr<const ContentsEntry> * ptr(0);
try
{
if (1 == argc)
{
- ptr = new tr1::shared_ptr<const A_>(new A_(StringValuePtr(argv[0])));
+ ptr = new tr1::shared_ptr<const ContentsEntry>(new A_(StringValuePtr(argv[0])));
}
else
{
rb_raise(rb_eArgError, "ContentsEntry expects one argument, but got %d",argc);
}
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const A_> >::free, ptr));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const ContentsEntry> >::free, ptr));
rb_obj_call_init(tdata, argc, argv);
return tdata;
}
@@ -212,18 +210,18 @@ namespace
VALUE contents_sym_entry_new(int argc, VALUE * argv, VALUE self)
{
- tr1::shared_ptr<const ContentsSymEntry> * ptr(0);
+ tr1::shared_ptr<const ContentsEntry> * ptr(0);
try
{
if (2 == argc)
{
- ptr = new tr1::shared_ptr<const ContentsSymEntry>(new ContentsSymEntry(StringValuePtr(argv[0]), StringValuePtr(argv[1])));
+ ptr = new tr1::shared_ptr<const ContentsEntry>(new ContentsSymEntry(StringValuePtr(argv[0]), StringValuePtr(argv[1])));
}
else
{
rb_raise(rb_eArgError, "ContentsSymEntry expects two arguments, but got %d",argc);
}
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const ContentsSymEntry> >::free, ptr));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const ContentsEntry> >::free, ptr));
rb_obj_call_init(tdata, argc, argv);
return tdata;
}
@@ -250,9 +248,9 @@ namespace
static VALUE
fetch(VALUE self)
{
- tr1::shared_ptr<const T_> * ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const T_>, ptr);
- return rb_str_new2((((**ptr).*m_)()).c_str());
+ tr1::shared_ptr<const ContentsEntry> * ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const ContentsEntry>, ptr);
+ return rb_str_new2((((*tr1::static_pointer_cast<const T_>(*ptr)).*m_)()).c_str());
}
};
@@ -332,7 +330,6 @@ namespace
c_contents_sym_entry = rb_define_class_under(paludis_module(), "ContentsSymEntry", c_contents_entry);
rb_define_singleton_method(c_contents_sym_entry, "new", RUBY_FUNC_CAST(&contents_sym_entry_new), -1);
rb_define_method(c_contents_sym_entry, "target", RUBY_FUNC_CAST((&ContentsThings<ContentsSymEntry,&ContentsSymEntry::target>::fetch)), 0);
- rb_define_method(c_contents_sym_entry, "to_s", RUBY_FUNC_CAST(&Common<tr1::shared_ptr<const ContentsSymEntry> >::to_s_via_ptr), 0);
}
}
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc
index 9a788a1..1ffe4ae 100644
--- a/ruby/dep_spec.cc
+++ b/ruby/dep_spec.cc
@@ -60,12 +60,12 @@ namespace
VALUE
block_dep_spec_new(VALUE self, VALUE spec)
{
- tr1::shared_ptr<const BlockDepSpec> * ptr(0);
+ tr1::shared_ptr<const DepSpec> * ptr(0);
try
{
tr1::shared_ptr<const PackageDepSpec> pkg(value_to_package_dep_spec(spec));
- ptr = new tr1::shared_ptr<const BlockDepSpec>(new BlockDepSpec(pkg));
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const BlockDepSpec> >::free, ptr));
+ ptr = new tr1::shared_ptr<const DepSpec>(new BlockDepSpec(pkg));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const DepSpec> >::free, ptr));
rb_obj_call_init(tdata, 1, &spec);
return tdata;
}
@@ -86,9 +86,9 @@ namespace
VALUE
block_dep_spec_blocked_spec(VALUE self)
{
- tr1::shared_ptr<const BlockDepSpec> * p;
- Data_Get_Struct(self, tr1::shared_ptr<const BlockDepSpec>, p);
- return dep_spec_to_value((*p)->blocked_spec());
+ tr1::shared_ptr<const DepSpec> * p;
+ Data_Get_Struct(self, tr1::shared_ptr<const DepSpec>, p);
+ return dep_spec_to_value(tr1::static_pointer_cast<const BlockDepSpec>(*p)->blocked_spec());
}
#endif
@@ -98,11 +98,11 @@ namespace
static VALUE
dep_spec_new_1(VALUE self, VALUE s)
{
- tr1::shared_ptr<const A_> * ptr(0);
+ tr1::shared_ptr<const DepSpec> * ptr(0);
try
{
- ptr = new tr1::shared_ptr<const A_>(new A_(StringValuePtr(s)));
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const A_> >::free, ptr));
+ ptr = new tr1::shared_ptr<const DepSpec>(new A_(StringValuePtr(s)));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const DepSpec> >::free, ptr));
rb_obj_call_init(tdata, 1, &s);
return tdata;
}
@@ -117,7 +117,7 @@ namespace
VALUE
package_dep_spec_new(int argc, VALUE *argv, VALUE self)
{
- tr1::shared_ptr<const PackageDepSpec> * ptr(0);
+ tr1::shared_ptr<const DepSpec> * ptr(0);
try
{
PackageDepSpecParseMode p;
@@ -129,12 +129,10 @@ namespace
else
p = static_cast<PackageDepSpecParseMode>(NUM2INT(argv[1]));
- ptr = new tr1::shared_ptr<const PackageDepSpec>(new PackageDepSpec(StringValuePtr(argv[0]), p));
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const PackageDepSpec> >::free, ptr));
+ ptr = new tr1::shared_ptr<const DepSpec>(new PackageDepSpec(StringValuePtr(argv[0]), p));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const DepSpec> >::free, ptr));
rb_obj_call_init(tdata, argc, argv);
return tdata;
-
-
}
catch (const std::exception & e)
{
@@ -152,9 +150,9 @@ namespace
VALUE
use_dep_spec_flag(VALUE self)
{
- tr1::shared_ptr<const UseDepSpec> * p;
- Data_Get_Struct(self, tr1::shared_ptr<const UseDepSpec>, p);
- return rb_str_new2(stringify((*p)->flag()).c_str());
+ tr1::shared_ptr<const DepSpec> * p;
+ Data_Get_Struct(self, tr1::shared_ptr<const DepSpec>, p);
+ return rb_str_new2(stringify(tr1::static_pointer_cast<const UseDepSpec>(*p)->flag()).c_str());
}
/*
@@ -166,28 +164,11 @@ namespace
VALUE
use_dep_spec_inverse(VALUE self)
{
- tr1::shared_ptr<const UseDepSpec> * p;
- Data_Get_Struct(self, tr1::shared_ptr<const UseDepSpec>, p);
- return (*p)->inverse() ? Qtrue : Qfalse;
+ tr1::shared_ptr<const DepSpec> * p;
+ Data_Get_Struct(self, tr1::shared_ptr<const DepSpec>, p);
+ return tr1::static_pointer_cast<const UseDepSpec>(*p)->inverse() ? Qtrue : Qfalse;
}
-#if CIARANM_REMOVED_THIS
- /*
- * call-seq: each {|spec| block }
- *
- * Iterate over each child DepSpec.
- */
- VALUE
- composite_dep_spec_each(VALUE self)
- {
- tr1::shared_ptr<CompositeDepSpec> * m_ptr;
- Data_Get_Struct(self, tr1::shared_ptr<CompositeDepSpec>, m_ptr);
- for (CompositeDepSpec::ConstIterator i((*m_ptr)->begin()), i_end((*m_ptr)->end()) ; i != i_end ; ++i)
- rb_yield(dep_spec_to_value(*i));
- return self;
- }
-#endif
-
/*
* call-seq:
* package -> String or Nil
@@ -197,11 +178,11 @@ namespace
VALUE
package_dep_spec_package(VALUE self)
{
- tr1::shared_ptr<const PackageDepSpec> * ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const PackageDepSpec>, ptr);
- if (0 == (*ptr)->package_ptr())
+ tr1::shared_ptr<const DepSpec> * ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const DepSpec>, ptr);
+ if (0 == tr1::static_pointer_cast<const PackageDepSpec>(*ptr)->package_ptr())
return Qnil;
- return rb_str_new2(stringify(*(*ptr)->package_ptr()).c_str());
+ return rb_str_new2(stringify(*tr1::static_pointer_cast<const PackageDepSpec>(*ptr)->package_ptr()).c_str());
}
/*
@@ -213,11 +194,11 @@ namespace
VALUE
package_dep_spec_package_name_part(VALUE self)
{
- tr1::shared_ptr<const PackageDepSpec> * ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const PackageDepSpec>, ptr);
- if (0 == (*ptr)->package_name_part_ptr())
+ tr1::shared_ptr<const DepSpec> * ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const DepSpec>, ptr);
+ if (0 == tr1::static_pointer_cast<const PackageDepSpec>(*ptr)->package_name_part_ptr())
return Qnil;
- return rb_str_new2(stringify(*(*ptr)->package_name_part_ptr()).c_str());
+ return rb_str_new2(stringify(*tr1::static_pointer_cast<const PackageDepSpec>(*ptr)->package_name_part_ptr()).c_str());
}
/*
@@ -229,11 +210,11 @@ namespace
VALUE
package_dep_spec_category_name_part(VALUE self)
{
- tr1::shared_ptr<const PackageDepSpec> * ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const PackageDepSpec>, ptr);
- if (0 == (*ptr)->category_name_part_ptr())
+ tr1::shared_ptr<const DepSpec> * ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const DepSpec>, ptr);
+ if (0 == tr1::static_pointer_cast<const PackageDepSpec>(*ptr)->category_name_part_ptr())
return Qnil;
- return rb_str_new2(stringify(*(*ptr)->category_name_part_ptr()).c_str());
+ return rb_str_new2(stringify(*tr1::static_pointer_cast<const PackageDepSpec>(*ptr)->category_name_part_ptr()).c_str());
}
/*
@@ -245,9 +226,9 @@ namespace
VALUE
package_dep_spec_text(VALUE self)
{
- tr1::shared_ptr<const PackageDepSpec> * ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const PackageDepSpec>, ptr);
- return rb_str_new2(stringify((*ptr)->text()).c_str());
+ tr1::shared_ptr<const DepSpec> * ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const DepSpec>, ptr);
+ return rb_str_new2(stringify(tr1::static_pointer_cast<const PackageDepSpec>(*ptr)->text()).c_str());
}
/*
@@ -259,11 +240,11 @@ namespace
VALUE
package_dep_spec_slot_ptr(VALUE self)
{
- tr1::shared_ptr<const PackageDepSpec> * ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const PackageDepSpec>, ptr);
- if (0 == (*ptr)->slot_ptr())
+ tr1::shared_ptr<const DepSpec> * ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const DepSpec>, ptr);
+ if (0 == tr1::static_pointer_cast<const PackageDepSpec>(*ptr)->slot_ptr())
return Qnil;
- return rb_str_new2(stringify((*(*ptr)->slot_ptr())).c_str());
+ return rb_str_new2(stringify((*tr1::static_pointer_cast<const PackageDepSpec>(*ptr)->slot_ptr())).c_str());
}
/*
@@ -275,11 +256,11 @@ namespace
VALUE
package_dep_spec_repository_ptr(VALUE self)
{
- tr1::shared_ptr<const PackageDepSpec> * ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const PackageDepSpec>, ptr);
- if (0 == (*ptr)->repository_ptr())
+ tr1::shared_ptr<const DepSpec> * ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const DepSpec>, ptr);
+ if (0 == tr1::static_pointer_cast<const PackageDepSpec>(*ptr)->repository_ptr())
return Qnil;
- return rb_str_new2(stringify((*(*ptr)->repository_ptr())).c_str());
+ return rb_str_new2(stringify((*tr1::static_pointer_cast<const PackageDepSpec>(*ptr)->repository_ptr())).c_str());
}
/*
@@ -291,13 +272,13 @@ namespace
VALUE
package_dep_spec_version_requirements_ptr(VALUE self)
{
- tr1::shared_ptr<const PackageDepSpec> * ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const PackageDepSpec>, ptr);
+ tr1::shared_ptr<const DepSpec> * ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const DepSpec>, ptr);
VALUE result(rb_ary_new());
VALUE result_hash;
- if ((*ptr)->version_requirements_ptr())
- for (VersionRequirements::ConstIterator i((*ptr)->version_requirements_ptr()->begin()),
- i_end((*ptr)->version_requirements_ptr()->end()) ; i != i_end; ++i)
+ if (tr1::static_pointer_cast<const PackageDepSpec>(*ptr)->version_requirements_ptr())
+ for (VersionRequirements::ConstIterator i(tr1::static_pointer_cast<const PackageDepSpec>(*ptr)->version_requirements_ptr()->begin()),
+ i_end(tr1::static_pointer_cast<const PackageDepSpec>(*ptr)->version_requirements_ptr()->end()) ; i != i_end; ++i)
{
result_hash = rb_hash_new();
rb_hash_aset(result_hash, ID2SYM(rb_intern("operator")),
@@ -318,13 +299,13 @@ namespace
VALUE
package_dep_spec_use_requirements(VALUE self)
{
- tr1::shared_ptr<const PackageDepSpec> * ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const PackageDepSpec>, ptr);
+ tr1::shared_ptr<const DepSpec> * ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const DepSpec>, ptr);
VALUE result(rb_ary_new());
VALUE result_hash;
- if ((*ptr)->use_requirements_ptr())
- for (UseRequirements::ConstIterator i((*ptr)->use_requirements_ptr()->begin()),
- i_end((*ptr)->use_requirements_ptr()->end()) ; i != i_end; ++i)
+ if (tr1::static_pointer_cast<const PackageDepSpec>(*ptr)->use_requirements_ptr())
+ for (UseRequirements::ConstIterator i(tr1::static_pointer_cast<const PackageDepSpec>(*ptr)->use_requirements_ptr()->begin()),
+ i_end(tr1::static_pointer_cast<const PackageDepSpec>(*ptr)->use_requirements_ptr()->end()) ; i != i_end; ++i)
{
result_hash = rb_hash_new();
rb_hash_aset(result_hash, ID2SYM(rb_intern("flag")),
@@ -340,9 +321,9 @@ namespace
VALUE
package_dep_spec_version_requirements_mode(VALUE self)
{
- tr1::shared_ptr<const PackageDepSpec> * ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const PackageDepSpec>, ptr);
- return INT2FIX((*ptr)->version_requirements_mode());
+ tr1::shared_ptr<const DepSpec> * ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const DepSpec>, ptr);
+ return INT2FIX(tr1::static_pointer_cast<const PackageDepSpec>(*ptr)->version_requirements_mode());
}
void do_register_dep_spec()
@@ -465,9 +446,9 @@ paludis::ruby::value_to_package_dep_spec(VALUE v)
{
if (rb_obj_is_kind_of(v, c_package_dep_spec))
{
- tr1::shared_ptr<const PackageDepSpec> * v_ptr;
- Data_Get_Struct(v, tr1::shared_ptr<const PackageDepSpec>, v_ptr);
- return *v_ptr;
+ tr1::shared_ptr<const DepSpec> * v_ptr;
+ Data_Get_Struct(v, tr1::shared_ptr<const DepSpec>, v_ptr);
+ return tr1::static_pointer_cast<const PackageDepSpec>(*v_ptr);
}
if (T_STRING == TYPE(v))
{
diff --git a/ruby/dep_tag.cc b/ruby/dep_tag.cc
index 20cf355..a0bf2d2 100644
--- a/ruby/dep_tag.cc
+++ b/ruby/dep_tag.cc
@@ -50,29 +50,28 @@ namespace
void visit(const DependencyDepTag &)
{
value = Data_Wrap_Struct(c_dependency_dep_tag, 0, &Common<tr1::shared_ptr<const DependencyDepTag> >::free,
- new tr1::shared_ptr<const DependencyDepTag>(tr1::static_pointer_cast<const DependencyDepTag>(mm)));
+ new tr1::shared_ptr<const DepTag>(mm));
}
void visit(const GLSADepTag &)
{
- value = Data_Wrap_Struct(c_glsa_dep_tag, 0, &Common<tr1::shared_ptr<const GLSADepTag> >::free,
- new tr1::shared_ptr<const GLSADepTag>(tr1::static_pointer_cast<const GLSADepTag>(mm)));
+ value = Data_Wrap_Struct(c_glsa_dep_tag, 0, &Common<tr1::shared_ptr<const DependencyDepTag> >::free,
+ new tr1::shared_ptr<const DepTag>(mm));
}
void visit(const GeneralSetDepTag &)
{
- value = Data_Wrap_Struct(c_general_set_dep_tag, 0, &Common<tr1::shared_ptr<const GeneralSetDepTag> >::free,
- new tr1::shared_ptr<const GeneralSetDepTag>(tr1::static_pointer_cast<const GeneralSetDepTag>(mm)));
+ value = Data_Wrap_Struct(c_general_set_dep_tag, 0, &Common<tr1::shared_ptr<const DependencyDepTag> >::free,
+ new tr1::shared_ptr<const DepTag>(mm));
}
void visit(const TargetDepTag &)
{
- value = Data_Wrap_Struct(c_target_dep_tag, 0, &Common<tr1::shared_ptr<const TargetDepTag> >::free,
- new tr1::shared_ptr<const TargetDepTag>(tr1::static_pointer_cast<const TargetDepTag>(mm)));
+ value = Data_Wrap_Struct(c_target_dep_tag, 0, &Common<tr1::shared_ptr<const DependencyDepTag> >::free,
+ new tr1::shared_ptr<const DepTag>(mm));
}
};
-
VALUE
dep_tag_init_1(int, VALUE*, VALUE self)
{
@@ -85,18 +84,18 @@ namespace
if (2 != argc)
rb_raise(rb_eArgError, "DependencyDepTag expects two arguments, but got %d", argc);
- tr1::shared_ptr<const DependencyDepTag> * ptr(0);
+ tr1::shared_ptr<const DepTag> * ptr(0);
try
{
- ptr = new tr1::shared_ptr<const DependencyDepTag>(
- new DependencyDepTag(value_to_package_id(argv[0]),
- *value_to_package_dep_spec(argv[1]),
- // XXX make this an argument, once the new
- // visitors are Rubified
- tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> >(
- new ConstTreeSequence<DependencySpecTree, AllDepSpec>(
- tr1::shared_ptr<AllDepSpec>(new AllDepSpec)))));
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const DependencyDepTag> >::free, ptr));
+ ptr = new tr1::shared_ptr<const DepTag>(
+ new DependencyDepTag(value_to_package_id(argv[0]),
+ *value_to_package_dep_spec(argv[1]),
+ // XXX make this an argument, once the new
+ // visitors are Rubified
+ tr1::shared_ptr<ConstTreeSequence<DependencySpecTree, AllDepSpec> >(
+ new ConstTreeSequence<DependencySpecTree, AllDepSpec>(
+ tr1::shared_ptr<AllDepSpec>(new AllDepSpec)))));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const DepTag> >::free, ptr));
rb_obj_call_init(tdata, argc, argv);
return tdata;
}
@@ -114,11 +113,11 @@ namespace
if (2 != argc)
rb_raise(rb_eArgError, "GLSADepTag expects two arguments, but got %d",argc);
- tr1::shared_ptr<const GLSADepTag> * ptr(0);
+ tr1::shared_ptr<const DepTag> * ptr(0);
try
{
- ptr = new tr1::shared_ptr<const GLSADepTag>(new GLSADepTag(StringValuePtr(argv[0]), StringValuePtr(argv[1])));
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const GLSADepTag> >::free, ptr));
+ ptr = new tr1::shared_ptr<const DepTag>(new GLSADepTag(StringValuePtr(argv[0]), StringValuePtr(argv[1])));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const DepTag> >::free, ptr));
rb_obj_call_init(tdata, argc, argv);
return tdata;
}
@@ -135,11 +134,11 @@ namespace
if (2 != argc)
rb_raise(rb_eArgError, "GeneralSetDepTag expects two arguments, but got %d",argc);
- tr1::shared_ptr<const GeneralSetDepTag> * ptr(0);
+ tr1::shared_ptr<const DepTag> * ptr(0);
try
{
- ptr = new tr1::shared_ptr<const GeneralSetDepTag>(new GeneralSetDepTag(SetName(StringValuePtr(argv[0])), StringValuePtr(argv[1])));
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const GeneralSetDepTag> >::free, ptr));
+ ptr = new tr1::shared_ptr<const DepTag>(new GeneralSetDepTag(SetName(StringValuePtr(argv[0])), StringValuePtr(argv[1])));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const DepTag> >::free, ptr));
rb_obj_call_init(tdata, argc, argv);
return tdata;
}
@@ -153,11 +152,11 @@ namespace
VALUE
target_dep_tag_new(VALUE self)
{
- tr1::shared_ptr<const TargetDepTag> * ptr(0);
+ tr1::shared_ptr<const DepTag> * ptr(0);
try
{
- ptr = new tr1::shared_ptr<const TargetDepTag>(new TargetDepTag);
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const TargetDepTag> >::free, ptr));
+ ptr = new tr1::shared_ptr<const DepTag>(new TargetDepTag);
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<const DepTag> >::free, ptr));
rb_obj_call_init(tdata, 0, 0);
return tdata;
}
@@ -207,9 +206,9 @@ namespace
static VALUE
fetch(VALUE self)
{
- tr1::shared_ptr<const T_> * ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const T_>, ptr);
- return rb_str_new2((((**ptr).*m_)()).c_str());
+ tr1::shared_ptr<const DepTag> * ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const DepTag>, ptr);
+ return rb_str_new2((((*tr1::static_pointer_cast<const T_>(*ptr)).*m_)()).c_str());
}
};
diff --git a/ruby/environment.cc b/ruby/environment.cc
index f602a3c..87e9fa6 100644
--- a/ruby/environment.cc
+++ b/ruby/environment.cc
@@ -45,9 +45,9 @@ namespace
{
if (rb_obj_is_kind_of(v, c_adapted_environment))
{
- tr1::shared_ptr<AdaptedEnvironment> * v_ptr;
- Data_Get_Struct(v, tr1::shared_ptr<AdaptedEnvironment>, v_ptr);
- return *v_ptr;
+ tr1::shared_ptr<Environment> * v_ptr;
+ Data_Get_Struct(v, tr1::shared_ptr<Environment>, v_ptr);
+ return tr1::static_pointer_cast<AdaptedEnvironment>(*v_ptr);
}
else
{
@@ -67,7 +67,8 @@ namespace
{
try
{
- return value_to_environment(self)->query_use(UseFlagName(StringValuePtr(flag)), *(value_to_package_id(pid))) ? Qtrue : Qfalse;
+ return value_to_environment(self)->query_use(
+ UseFlagName(StringValuePtr(flag)), *(value_to_package_id(pid))) ? Qtrue : Qfalse;
}
catch (const std::exception & e)
{
@@ -127,7 +128,8 @@ namespace
{
try
{
- return value_to_environment(self)->accept_license(std::string(StringValuePtr(license)), *(value_to_package_id(p))) ? Qtrue : Qfalse;
+ return value_to_environment(self)->accept_license(
+ std::string(StringValuePtr(license)), *(value_to_package_id(p))) ? Qtrue : Qfalse;
}
catch (const std::exception & e)
{
@@ -199,9 +201,9 @@ namespace
{
if (rb_obj_is_kind_of(v, c_paludis_environment))
{
- tr1::shared_ptr<PaludisEnvironment> * v_ptr;
- Data_Get_Struct(v, tr1::shared_ptr<PaludisEnvironment>, v_ptr);
- return *v_ptr;
+ tr1::shared_ptr<Environment> * v_ptr;
+ Data_Get_Struct(v, tr1::shared_ptr<Environment>, v_ptr);
+ return tr1::static_pointer_cast<PaludisEnvironment>(*v_ptr);
}
else
{
@@ -233,8 +235,8 @@ namespace
else if (0 != argc)
rb_raise(rb_eArgError, "PaludisEnvironment.new expects one or zero arguments, but got %d", argc);
- tr1::shared_ptr<PaludisEnvironment> * e = new tr1::shared_ptr<PaludisEnvironment>(new PaludisEnvironment(config_suffix));
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<PaludisEnvironment> >::free, e));
+ tr1::shared_ptr<Environment> * e = new tr1::shared_ptr<Environment>(new PaludisEnvironment(config_suffix));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<Environment> >::free, e));
rb_obj_call_init(tdata, argc, argv);
return tdata;
}
@@ -304,7 +306,7 @@ namespace
else
path = StringValuePtr(argv[0]);
- tr1::shared_ptr<NoConfigEnvironment> * e = new tr1::shared_ptr<NoConfigEnvironment>(new
+ tr1::shared_ptr<Environment> * e = new tr1::shared_ptr<Environment>(new
NoConfigEnvironment(no_config_environment::Params::create()
.repository_dir(FSEntry(path))
.write_cache(write_cache)
@@ -313,7 +315,7 @@ namespace
.repository_type(no_config_environment::ncer_auto)
.extra_params(tr1::shared_ptr<Map<std::string, std::string> >())
.master_repository_dir(FSEntry(master_repository_dir))));
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<NoConfigEnvironment> >::free, e));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<Environment> >::free, e));
rb_obj_call_init(tdata, argc, argv);
return tdata;
}
@@ -393,8 +395,8 @@ namespace
rb_raise(rb_eArgError, "AdaptedEnvironment.new expects one argument, but got %d", argc);
try
{
- tr1::shared_ptr<AdaptedEnvironment> * e = new tr1::shared_ptr<AdaptedEnvironment>(new AdaptedEnvironment(value_to_environment(argv[0])));
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<AdaptedEnvironment> >::free, e));
+ tr1::shared_ptr<Environment> * e = new tr1::shared_ptr<Environment>(new AdaptedEnvironment(value_to_environment(argv[0])));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<Environment> >::free, e));
rb_obj_call_init(tdata, argc, argv);
return tdata;
}
@@ -424,8 +426,8 @@ namespace
rb_raise(rb_eTypeError, "Can't convert %s into UseFlagState", rb_obj_classname(use_flag_state));
value_to_adapted_environment(self)->adapt_use(value_to_package_dep_spec(package_dep_spec),
- UseFlagName(StringValuePtr(use_flag_name)),
- ufs);
+ UseFlagName(StringValuePtr(use_flag_name)),
+ ufs);
return Qnil;
}
catch (const std::exception & e)
@@ -564,9 +566,9 @@ paludis::ruby::value_to_no_config_environment(VALUE v)
{
if (rb_obj_is_kind_of(v, c_no_config_environment))
{
- tr1::shared_ptr<NoConfigEnvironment> * v_ptr;
- Data_Get_Struct(v, tr1::shared_ptr<NoConfigEnvironment>, v_ptr);
- return *v_ptr;
+ tr1::shared_ptr<Environment> * v_ptr;
+ Data_Get_Struct(v, tr1::shared_ptr<Environment>, v_ptr);
+ return tr1::static_pointer_cast<NoConfigEnvironment>(*v_ptr);
}
else
{
diff --git a/ruby/metadata_key.cc b/ruby/metadata_key.cc
index f171276..cfe930b 100644
--- a/ruby/metadata_key.cc
+++ b/ruby/metadata_key.cc
@@ -77,9 +77,9 @@ namespace
static VALUE
fetch(VALUE self)
{
- tr1::shared_ptr<const S_> * self_ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const S_>, self_ptr);
- return rb_str_new2(stringify(((**self_ptr).*m_)()).c_str());
+ tr1::shared_ptr<const MetadataKey> * self_ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const MetadataKey>, self_ptr);
+ return rb_str_new2(stringify(((*tr1::static_pointer_cast<const S_>(*self_ptr)).*m_)()).c_str());
}
};
@@ -96,26 +96,26 @@ namespace
void visit(const MetadataPackageIDKey &)
{
- value = Data_Wrap_Struct(c_metadata_package_id_key, 0, &Common<tr1::shared_ptr<const MetadataPackageIDKey> >::free,
- new tr1::shared_ptr<const MetadataPackageIDKey>(tr1::static_pointer_cast<const MetadataPackageIDKey>(mm)));
+ value = Data_Wrap_Struct(c_metadata_package_id_key, 0, &Common<tr1::shared_ptr<const MetadataKey> >::free,
+ new tr1::shared_ptr<const MetadataKey>(mm));
}
void visit(const MetadataStringKey &)
{
- value = Data_Wrap_Struct(c_metadata_string_key, 0, &Common<tr1::shared_ptr<const MetadataStringKey> >::free,
- new tr1::shared_ptr<const MetadataStringKey>(tr1::static_pointer_cast<const MetadataStringKey>(mm)));
+ value = Data_Wrap_Struct(c_metadata_string_key, 0, &Common<tr1::shared_ptr<const MetadataKey> >::free,
+ new tr1::shared_ptr<const MetadataKey>(mm));
}
void visit(const MetadataTimeKey &)
{
- value = Data_Wrap_Struct(c_metadata_time_key, 0, &Common<tr1::shared_ptr<const MetadataTimeKey> >::free,
- new tr1::shared_ptr<const MetadataTimeKey>(tr1::static_pointer_cast<const MetadataTimeKey>(mm)));
+ value = Data_Wrap_Struct(c_metadata_time_key, 0, &Common<tr1::shared_ptr<const MetadataKey> >::free,
+ new tr1::shared_ptr<const MetadataKey>(mm));
}
void visit(const MetadataContentsKey &)
{
- value = Data_Wrap_Struct(c_metadata_contents_key, 0, &Common<tr1::shared_ptr<const MetadataContentsKey> >::free,
- new tr1::shared_ptr<const MetadataContentsKey>(tr1::static_pointer_cast<const MetadataContentsKey>(mm)));
+ value = Data_Wrap_Struct(c_metadata_contents_key, 0, &Common<tr1::shared_ptr<const MetadataKey> >::free,
+ new tr1::shared_ptr<const MetadataKey>(mm));
}
void visit(const MetadataFSEntryKey &)
@@ -130,95 +130,80 @@ namespace
void visit(const MetadataRepositoryMaskInfoKey &)
{
- value = Data_Wrap_Struct(c_metadata_repository_mask_info_key, 0, &Common<tr1::shared_ptr<const MetadataContentsKey> >::free,
- new tr1::shared_ptr<const MetadataRepositoryMaskInfoKey>(tr1::static_pointer_cast<const MetadataRepositoryMaskInfoKey>(mm)));
+ value = Data_Wrap_Struct(c_metadata_repository_mask_info_key, 0, &Common<tr1::shared_ptr<const MetadataKey> >::free,
+ new tr1::shared_ptr<const MetadataKey>(mm));
}
void visit(const MetadataCollectionKey<KeywordNameSet> &)
{
- value = Data_Wrap_Struct(c_metadata_keyword_name_set_key, 0, &Common<tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > >::free,
- new tr1::shared_ptr<const MetadataCollectionKey<KeywordNameSet> >(tr1::static_pointer_cast<const MetadataCollectionKey<KeywordNameSet> >(mm)));
+ value = Data_Wrap_Struct(c_metadata_keyword_name_set_key, 0, &Common<tr1::shared_ptr<const MetadataKey> >::free,
+ new tr1::shared_ptr<const MetadataKey>(mm));
}
void visit(const MetadataCollectionKey<UseFlagNameSet> &)
{
- value = Data_Wrap_Struct(c_metadata_use_flag_name_set_key, 0, &Common<tr1::shared_ptr<const MetadataCollectionKey<UseFlagNameSet> > >::free,
- new tr1::shared_ptr<const MetadataCollectionKey<UseFlagNameSet> >(tr1::static_pointer_cast<const MetadataCollectionKey<UseFlagNameSet> >(mm)));
+ value = Data_Wrap_Struct(c_metadata_use_flag_name_set_key, 0, &Common<tr1::shared_ptr<const MetadataKey> >::free,
+ new tr1::shared_ptr<const MetadataKey>(mm));
}
void visit(const MetadataCollectionKey<IUseFlagSet> &)
{
- value = Data_Wrap_Struct(c_metadata_iuse_flag_set_key, 0, &Common<tr1::shared_ptr<const MetadataCollectionKey<IUseFlagSet> > >::free,
- new tr1::shared_ptr<const MetadataCollectionKey<IUseFlagSet> >(tr1::static_pointer_cast<const MetadataCollectionKey<IUseFlagSet> >(mm)));
+ value = Data_Wrap_Struct(c_metadata_iuse_flag_set_key, 0, &Common<tr1::shared_ptr<const MetadataKey> >::free,
+ new tr1::shared_ptr<const MetadataKey>(mm));
}
void visit(const MetadataCollectionKey<Set<std::string> > &)
{
- value = Data_Wrap_Struct(c_metadata_string_set_key, 0, &Common<tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > > >::free,
- new tr1::shared_ptr<const MetadataCollectionKey<Set<std::string> > >(
- tr1::static_pointer_cast<const MetadataCollectionKey<Set<std::string> > >(mm)));
+ value = Data_Wrap_Struct(c_metadata_string_set_key, 0, &Common<tr1::shared_ptr<const MetadataKey> >::free,
+ new tr1::shared_ptr<const MetadataKey>(mm));
}
void visit(const MetadataCollectionKey<FSEntrySequence> &)
{
- value = Data_Wrap_Struct(c_metadata_fsentry_sequence_key, 0, &Common<tr1::shared_ptr<const FSEntrySequence> >::free,
- new tr1::shared_ptr<const MetadataCollectionKey<FSEntrySequence> >(
- tr1::static_pointer_cast<const MetadataCollectionKey<FSEntrySequence> >(mm)));
+ value = Data_Wrap_Struct(c_metadata_fsentry_sequence_key, 0, &Common<tr1::shared_ptr<const MetadataKey> >::free,
+ new tr1::shared_ptr<const MetadataKey>(mm));
}
void visit(const MetadataCollectionKey<PackageIDSequence> &)
{
- value = Data_Wrap_Struct(c_metadata_package_id_sequence_key, 0, &Common<tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> > >::free,
- new tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> >
- (tr1::static_pointer_cast<const MetadataCollectionKey<PackageIDSequence> >(mm)));
+ value = Data_Wrap_Struct(c_metadata_package_id_sequence_key, 0, &Common<tr1::shared_ptr<const MetadataKey> >::free,
+ new tr1::shared_ptr<const MetadataKey>(mm));
}
void visit(const MetadataSpecTreeKey<LicenseSpecTree> &)
{
- value = Data_Wrap_Struct(c_metadata_license_spec_tree_key, 0,
- &Common<tr1::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> > >::free,
- new tr1::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> >(
- tr1::static_pointer_cast<const MetadataSpecTreeKey<LicenseSpecTree> >(mm)));
+ value = Data_Wrap_Struct(c_metadata_license_spec_tree_key, 0, &Common<tr1::shared_ptr<const MetadataKey> >::free,
+ new tr1::shared_ptr<const MetadataKey>(mm));
}
void visit(const MetadataSpecTreeKey<ProvideSpecTree> &)
{
- value = Data_Wrap_Struct(c_metadata_provide_spec_tree_key, 0,
- &Common<tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> > >::free,
- new tr1::shared_ptr<const MetadataSpecTreeKey<ProvideSpecTree> >(
- tr1::static_pointer_cast<const MetadataSpecTreeKey<ProvideSpecTree> >(mm)));
+ value = Data_Wrap_Struct(c_metadata_provide_spec_tree_key, 0, &Common<tr1::shared_ptr<const MetadataKey> >::free,
+ new tr1::shared_ptr<const MetadataKey>(mm));
}
void visit(const MetadataSpecTreeKey<DependencySpecTree> &)
{
- value = Data_Wrap_Struct(c_metadata_dependency_spec_tree_key, 0,
- &Common<tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > >::free,
- new tr1::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> >(
- tr1::static_pointer_cast<const MetadataSpecTreeKey<DependencySpecTree> >(mm)));
+ value = Data_Wrap_Struct(c_metadata_dependency_spec_tree_key, 0, &Common<tr1::shared_ptr<const MetadataKey> >::free,
+ new tr1::shared_ptr<const MetadataKey>(mm));
}
void visit(const MetadataSpecTreeKey<RestrictSpecTree> &)
{
- value = Data_Wrap_Struct(c_metadata_restrict_spec_tree_key, 0,
- &Common<tr1::shared_ptr<const MetadataSpecTreeKey<RestrictSpecTree> > >::free,
- new tr1::shared_ptr<const MetadataSpecTreeKey<RestrictSpecTree> >(
- tr1::static_pointer_cast<const MetadataSpecTreeKey<RestrictSpecTree> >(mm)));
+ value = Data_Wrap_Struct(c_metadata_restrict_spec_tree_key, 0, &Common<tr1::shared_ptr<const MetadataKey> >::free,
+ new tr1::shared_ptr<const MetadataKey>(mm));
}
void visit(const MetadataSpecTreeKey<FetchableURISpecTree> &)
{
- value = Data_Wrap_Struct(c_metadata_fetchable_uri_spec_tree_key, 0,
- &Common<tr1::shared_ptr<const MetadataSpecTreeKey<FetchableURISpecTree> > >::free,
- new tr1::shared_ptr<const MetadataSpecTreeKey<FetchableURISpecTree> >(
- tr1::static_pointer_cast<const MetadataSpecTreeKey<FetchableURISpecTree> >(mm)));
+ value = Data_Wrap_Struct(c_metadata_fetchable_uri_spec_tree_key, 0, &Common<tr1::shared_ptr<const MetadataKey> >::free,
+ new tr1::shared_ptr<const MetadataKey>(mm));
}
void visit(const MetadataSpecTreeKey<SimpleURISpecTree> &)
{
- value = Data_Wrap_Struct(c_metadata_simple_uri_spec_tree_key, 0,
- &Common<tr1::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> > >::free,
- new tr1::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> >(
- tr1::static_pointer_cast<const MetadataSpecTreeKey<SimpleURISpecTree> >(mm)));
+ value = Data_Wrap_Struct(c_metadata_simple_uri_spec_tree_key, 0, &Common<tr1::shared_ptr<const MetadataKey> >::free,
+ new tr1::shared_ptr<const MetadataKey>(mm));
}
};
@@ -229,7 +214,8 @@ namespace
* Our significance to a user.
*/
VALUE
- metadata_key_type(VALUE self) {
+ metadata_key_type(VALUE self)
+ {
tr1::shared_ptr<const MetadataKey> * self_ptr;
Data_Get_Struct(self, tr1::shared_ptr<const MetadataKey>, self_ptr);
return INT2FIX((*self_ptr)->type());
@@ -242,41 +228,46 @@ namespace
* Our Value.
* */
VALUE
- metadata_package_id_key_value(VALUE self) {
- tr1::shared_ptr<const MetadataPackageIDKey> * self_ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const MetadataPackageIDKey>, self_ptr);
- return package_id_to_value((*self_ptr)->value());
+ metadata_package_id_key_value(VALUE self)
+ {
+ tr1::shared_ptr<const MetadataKey> * self_ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const MetadataKey>, self_ptr);
+ return package_id_to_value((tr1::static_pointer_cast<const MetadataPackageIDKey>(*self_ptr))->value());
}
VALUE
- metadata_string_key_value(VALUE self) {
- tr1::shared_ptr<const MetadataStringKey> * self_ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const MetadataStringKey>, self_ptr);
- return rb_str_new2((*self_ptr)->value().c_str());
+ metadata_string_key_value(VALUE self)
+ {
+ tr1::shared_ptr<const MetadataKey> * self_ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const MetadataKey>, self_ptr);
+ return rb_str_new2((tr1::static_pointer_cast<const MetadataStringKey>(*self_ptr))->value().c_str());
}
VALUE
- metadata_time_key_value(VALUE self) {
- tr1::shared_ptr<const MetadataTimeKey> * self_ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const MetadataTimeKey>, self_ptr);
- return rb_time_new((*self_ptr)->value(),0);
+ metadata_time_key_value(VALUE self)
+ {
+ tr1::shared_ptr<const MetadataKey> * self_ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const MetadataKey>, self_ptr);
+ return rb_time_new((tr1::static_pointer_cast<const MetadataTimeKey>(*self_ptr))->value(), 0);
}
VALUE
- metadata_contents_key_value(VALUE self) {
- tr1::shared_ptr<const MetadataContentsKey> * self_ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const MetadataContentsKey>, self_ptr);
- if ((*self_ptr)->value())
- return contents_to_value((*self_ptr)->value());
+ metadata_contents_key_value(VALUE self)
+ {
+ tr1::shared_ptr<const MetadataKey> * self_ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const MetadataKey>, self_ptr);
+ if (tr1::static_pointer_cast<const MetadataContentsKey>(*self_ptr)->value())
+ return contents_to_value(tr1::static_pointer_cast<const MetadataContentsKey>(*self_ptr)->value());
return Qnil;
}
VALUE
- metadata_repository_mask_info_key_value(VALUE self) {
- tr1::shared_ptr<const MetadataRepositoryMaskInfoKey> * self_ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const MetadataRepositoryMaskInfoKey>, self_ptr);
- if ((*self_ptr)->value())
- return repository_mask_info_to_value((*self_ptr)->value());
+ metadata_repository_mask_info_key_value(VALUE self)
+ {
+ tr1::shared_ptr<const MetadataKey> * self_ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const MetadataKey>, self_ptr);
+ if ((tr1::static_pointer_cast<const MetadataRepositoryMaskInfoKey>(*self_ptr))->value())
+ return repository_mask_info_to_value(tr1::static_pointer_cast<const MetadataRepositoryMaskInfoKey>(*self_ptr)->value());
return Qnil;
}
@@ -286,9 +277,9 @@ namespace
static VALUE
fetch(VALUE self)
{
- tr1::shared_ptr<const MetadataCollectionKey<T_> > * self_ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const MetadataCollectionKey<T_> >, self_ptr);
- tr1::shared_ptr<const T_> c = (*self_ptr)->value();
+ tr1::shared_ptr<const MetadataKey> * self_ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const MetadataKey>, self_ptr);
+ tr1::shared_ptr<const T_> c = tr1::static_pointer_cast<const MetadataCollectionKey<T_> >(*self_ptr)->value();
VALUE result (rb_ary_new());
for (typename T_::ConstIterator i(c->begin()), i_end(c->end()) ; i != i_end ; ++i)
rb_ary_push(result, rb_str_new2(stringify(*i).c_str()));
@@ -302,9 +293,10 @@ namespace
static VALUE
fetch(VALUE self)
{
- tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> > * self_ptr;
- Data_Get_Struct(self, tr1::shared_ptr<const MetadataCollectionKey<PackageIDSequence> >, self_ptr);
- tr1::shared_ptr<const PackageIDSequence> c = (*self_ptr)->value();
+ tr1::shared_ptr<const MetadataKey> * self_ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const MetadataKey>, self_ptr);
+ tr1::shared_ptr<const PackageIDSequence> c = tr1::static_pointer_cast<const MetadataCollectionKey<PackageIDSequence> >(
+ *self_ptr)->value();
VALUE result (rb_ary_new());
for (PackageIDSequence::ConstIterator i(c->begin()), i_end(c->end()) ; i != i_end ; ++i)
rb_ary_push(result, package_id_to_value(*i));
@@ -533,4 +525,3 @@ paludis::ruby::metadata_key_to_value(tr1::shared_ptr<const MetadataKey> m)
RegisterRubyClass::Register paludis_ruby_metadata_key PALUDIS_ATTRIBUTE((used))
(&do_register_metadata_key);
-
diff --git a/ruby/query.cc b/ruby/query.cc
index 57ff82f..0326c94 100644
--- a/ruby/query.cc
+++ b/ruby/query.cc
@@ -91,11 +91,11 @@ namespace
VALUE
matches_new(VALUE self, VALUE pda)
{
- query::Matches * ptr(0);
+ Query * ptr(0);
try
{
ptr = new query::Matches(*value_to_package_dep_spec(pda));
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<query::Matches>::free, ptr));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<Query>::free, ptr));
rb_obj_call_init(tdata, 1, &pda);
return tdata;
@@ -116,11 +116,11 @@ namespace
VALUE
package_new(VALUE self, VALUE qpn)
{
- query::Package * ptr(0);
+ Query * ptr(0);
try
{
ptr = new query::Package(value_to_qualified_package_name(qpn));
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<query::Package>::free, ptr));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<Query>::free, ptr));
rb_obj_call_init(tdata, 1, &qpn);
return tdata;
@@ -138,8 +138,8 @@ namespace
static VALUE
query_new(VALUE self)
{
- A_ * ptr = new A_();
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<A_>::free, ptr));
+ Query * ptr = new A_();
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<Query>::free, ptr));
rb_obj_call_init(tdata, 0, 0);
return tdata;
}
@@ -154,11 +154,11 @@ namespace
VALUE
installed_at_root_new(VALUE self, VALUE root)
{
- query::InstalledAtRoot * ptr(0);
+ Query * ptr(0);
try
{
ptr = new query::InstalledAtRoot(FSEntry(StringValuePtr(root)));
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<query::InstalledAtRoot>::free, ptr));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<Query>::free, ptr));
rb_obj_call_init(tdata, 1, &root);
return tdata;
@@ -179,11 +179,11 @@ namespace
VALUE
repository_new(VALUE self, VALUE repository_name)
{
- query::Repository * ptr(0);
+ Query * ptr(0);
try
{
ptr = new query::Repository(RepositoryName(StringValuePtr(repository_name)));
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<query::Repository>::free, ptr));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<Query>::free, ptr));
rb_obj_call_init(tdata, 1, &repository_name);
return tdata;
}
@@ -203,11 +203,11 @@ namespace
VALUE
all_new(VALUE self)
{
- query::All * ptr(0);
+ Query * ptr(0);
try
{
ptr = new query::All();
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<query::All>::free, ptr));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<Query>::free, ptr));
rb_obj_call_init(tdata, 0, 0);
return tdata;
}
@@ -227,11 +227,11 @@ namespace
VALUE
category_new(VALUE self, VALUE category_name)
{
- query::Category * ptr(0);
+ Query * ptr(0);
try
{
ptr = new query::Category(CategoryNamePart(StringValuePtr(category_name)));
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<query::Category>::free, ptr));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<Query>::free, ptr));
rb_obj_call_init(tdata, 1, &category_name);
return tdata;
}
diff --git a/ruby/repository.cc b/ruby/repository.cc
index 0b733a7..63f1883 100644
--- a/ruby/repository.cc
+++ b/ruby/repository.cc
@@ -54,9 +54,9 @@ namespace
{
if (rb_obj_is_kind_of(v, c_fake_repository_base))
{
- tr1::shared_ptr<FakeRepositoryBase> * v_ptr;
- Data_Get_Struct(v, tr1::shared_ptr<FakeRepositoryBase>, v_ptr);
- return *v_ptr;
+ tr1::shared_ptr<Repository> * v_ptr;
+ Data_Get_Struct(v, tr1::shared_ptr<Repository>, v_ptr);
+ return tr1::static_pointer_cast<FakeRepositoryBase>(*v_ptr);
}
else
{
@@ -839,9 +839,9 @@ namespace
if (2 != argc)
rb_raise(rb_eArgError, "FakeRepository.new expects two arguments, but got %d", argc);
- tr1::shared_ptr<FakeRepository> * r = new tr1::shared_ptr<FakeRepository>(new
+ tr1::shared_ptr<Repository> * r = new tr1::shared_ptr<Repository>(new
FakeRepository(value_to_environment(argv[0]).get(), RepositoryName(StringValuePtr(argv[1]))));
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<FakeRepository> >::free, r));
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<tr1::shared_ptr<Repository> >::free, r));
rb_obj_call_init(tdata, argc, argv);
return tdata;
}