aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2007-12-15 23:17:25 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2007-12-15 23:17:25 +0000
commit693622cedcfea20d3775efe7e2ddf9b541c0af9f (patch)
tree0187d93b6662f975843e435fb8f29672ca9144e0
parente0eecd0b51d1835a9cdfd37cb7a8d2fb8d196c79 (diff)
downloadpaludis-693622cedcfea20d3775efe7e2ddf9b541c0af9f.tar.gz
paludis-693622cedcfea20d3775efe7e2ddf9b541c0af9f.tar.xz
Partial commit
-rw-r--r--ruby/metadata_key.cc20
-rw-r--r--ruby/repository.cc16
2 files changed, 35 insertions, 1 deletions
diff --git a/ruby/metadata_key.cc b/ruby/metadata_key.cc
index e5bcaa2..421e307 100644
--- a/ruby/metadata_key.cc
+++ b/ruby/metadata_key.cc
@@ -45,6 +45,7 @@ namespace
static VALUE c_metadata_iuse_flag_set_key;
static VALUE c_metadata_string_set_key;
static VALUE c_metadata_package_id_sequence_key;
+ static VALUE c_metadata_fsentry_key;
static VALUE c_metadata_fsentry_sequence_key;
static VALUE c_metadata_key_type;
static VALUE c_metadata_provide_spec_tree_key;
@@ -120,7 +121,8 @@ namespace
void visit(const MetadataFSEntryKey &)
{
- value = Qnil;
+ value = Data_Wrap_Struct(c_metadata_fsentry_key, 0, &Common<tr1::shared_ptr<const MetadataKey> >::free,
+ new tr1::shared_ptr<const MetadataKey>(mm));
}
void visit(const MetadataSectionKey &)
@@ -244,6 +246,14 @@ namespace
}
VALUE
+ metadata_fsentry_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(stringify((tr1::static_pointer_cast<const MetadataFSEntryKey>(*self_ptr))->value()).c_str());
+ }
+
+ VALUE
metadata_time_key_value(VALUE self)
{
tr1::shared_ptr<const MetadataKey> * self_ptr;
@@ -368,6 +378,14 @@ namespace
rb_define_method(c_metadata_string_key, "value", RUBY_FUNC_CAST(&metadata_string_key_value), 0);
/*
+ * Document-class: Paludis::MetadataFSEntryKey
+ *
+ * Metadata class for FSEntry
+ */
+ c_metadata_fsentry_key = rb_define_class_under(paludis_module(), "MetadataFSEntryKey", c_metadata_key);
+ rb_define_method(c_metadata_fsentry_key, "value", RUBY_FUNC_CAST(&metadata_fsentry_key_value), 0);
+
+ /*
* Document-class: Paludis::MetadataTimeKey
*
* Metadata class for Time
diff --git a/ruby/repository.cc b/ruby/repository.cc
index e31825f..f1a0fa0 100644
--- a/ruby/repository.cc
+++ b/ruby/repository.cc
@@ -872,6 +872,18 @@ namespace
return Qnil;
}
+ template <typename T_, const tr1::shared_ptr<const T_> (Repository::* m_) () const>
+ struct RepositoryKey
+ {
+ static VALUE
+ fetch(VALUE self)
+ {
+ tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<Repository>, self_ptr);
+ return metadata_key_to_value(((**self_ptr).*m_)());
+ }
+ };
+
void do_register_repository()
{
/*
@@ -929,6 +941,10 @@ namespace
rb_define_method(c_repository, "check_qa", RUBY_FUNC_CAST(&repository_check_qa),5);
rb_define_method(c_repository, "each_metadata", RUBY_FUNC_CAST(&repository_each_metadata), 0);
+ rb_define_method(c_repository, "format_key",
+ RUBY_FUNC_CAST((&RepositoryKey<MetadataStringKey, &Repository::format_key>::fetch)), 0);
+ rb_define_method(c_repository, "installed_root_key",
+ RUBY_FUNC_CAST((&RepositoryKey<MetadataFSEntryKey, &Repository::installed_root_key>::fetch)), 0);
/*
* Document-class: Paludis::ProfilesDescLine