class Paludis::ContentsSymEntry
A symlink ContentsEntry
Public Class Methods
Source
VALUE contents_sym_entry_new(int argc, VALUE * argv, VALUE self)
{
std::shared_ptr<const ContentsEntry> * ptr(0);
try
{
if (3 == argc)
{
ptr = new std::shared_ptr<const ContentsEntry>(std::make_shared<ContentsSymEntry>(
FSPath(StringValuePtr(argv[0])), StringValuePtr(argv[1]), StringValuePtr(argv[2])));
}
else
{
rb_raise(rb_eArgError, "ContentsSymEntry expects three arguments, but got %d",argc);
}
VALUE tdata(Data_Wrap_Struct(self, 0, &Common<std::shared_ptr<const ContentsEntry> >::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: location_key
*
* Returns our location
*/
static VALUE
contents_entry_location_key(VALUE self)
{
std::shared_ptr<const ContentsEntry> * ptr;
Data_Get_Struct(self, std::shared_ptr<const ContentsEntry>, ptr);
return metadata_key_to_value((*ptr)->location_key());
}
static VALUE
contents_file_entry_part_key(VALUE self)
{
std::shared_ptr<const ContentsEntry> * ptr;
Data_Get_Struct(self, std::shared_ptr<const ContentsEntry>, ptr);
return metadata_key_to_value((std::static_pointer_cast<const ContentsFileEntry>(*ptr))->part_key());
}
/*
* Document-method: target_key
*
* Returns our target (as per readlink)
*/
static VALUE
contents_sym_entry_target_key(VALUE self)
{
std::shared_ptr<const ContentsEntry> * ptr;
Data_Get_Struct(self, std::shared_ptr<const ContentsEntry>, ptr);
return metadata_key_to_value((std::static_pointer_cast<const ContentsSymEntry>(*ptr))->target_key());
}
static VALUE
contents_sym_entry_part_key(VALUE self)
{
std::shared_ptr<const ContentsEntry> * ptr;
Data_Get_Struct(self, std::shared_ptr<const ContentsEntry>, ptr);
return metadata_key_to_value((std::static_pointer_cast<const ContentsSymEntry>(*ptr))->part_key());
}
/*
* call-seq:
* each_metadata {|key| block } -> Nil
*
* Our metadata.
*/
VALUE
contents_entry_each_metadata(VALUE self)
{
std::shared_ptr<const ContentsEntry> * self_ptr;
Data_Get_Struct(self, std::shared_ptr<const ContentsEntry>, self_ptr);
for (const auto & key : (*self_ptr)->metadata())
{
VALUE val(metadata_key_to_value(key));
if (Qnil != val)
rb_yield(val);
}
return Qnil;
}
void do_register_contents()
{
/*
* Document-class: Paludis::Contents
*
* A package's contents. Includes Enumerable[http://www.ruby-doc.org/core/classes/Enumerable.html],
* but not Comparable.
*/
c_contents = rb_define_class_under(c_paludis_module, "Contents", rb_cObject);
rb_undef_alloc_func(c_contents);
rb_include_module(c_contents, rb_mEnumerable);
rb_define_singleton_method(c_contents, "new", contents_new, 0);
rb_define_method(c_contents, "initialize", contents_init, 0);
rb_define_method(c_contents, "each", contents_each, 0);
rb_define_method(c_contents, "add", contents_add, 1);
/*
* Document-class: Paludis::ContentsEntry
*
* Base class for a ContentsEntry
*/
c_contents_entry = rb_define_class_under(c_paludis_module, "ContentsEntry", rb_cObject);
rb_funcall(c_contents_entry, rb_intern("private_class_method"), 1, rb_str_new2("new"));
rb_define_method(c_contents_entry, "location_key", contents_entry_location_key, 0);
rb_define_method(c_contents_entry, "initialize", contents_entry_init,-1);
rb_define_method(c_contents_entry, "each_metadata", contents_entry_each_metadata, 0);
/*
* Document-class: Paludis::ContentsFileEntry
*
* A file ContentsEntry
*/
c_contents_file_entry = rb_define_class_under(c_paludis_module, "ContentsFileEntry", c_contents_entry);
rb_undef_alloc_func(c_contents_file_entry);
rb_define_singleton_method(c_contents_file_entry, "new", contents_file_entry_new, -1);
rb_define_method(c_contents_file_entry, "part_key", contents_file_entry_part_key, 0);
/*
* Document-class: Paludis::ContentsDirEntry
*
* A directory ContentsEntry
*/
c_contents_dir_entry = rb_define_class_under(c_paludis_module, "ContentsDirEntry", c_contents_entry);
rb_undef_alloc_func(c_contents_dir_entry);
rb_define_singleton_method(c_contents_dir_entry, "new", template_methods, -1);
/*
* Document-class: Paludis::ContentsOtherEntry
*
* An 'other' ContentsEntry
*/
c_contents_other_entry = rb_define_class_under(c_paludis_module, "ContentsOtherEntry", c_contents_entry);
rb_undef_alloc_func(c_contents_other_entry);
rb_define_singleton_method(c_contents_other_entry, "new", template_methods, -1);
/*
* Document-class: Paludis::ContentsSymEntry
*
* A symlink ContentsEntry
*/
c_contents_sym_entry = rb_define_class_under(c_paludis_module, "ContentsSymEntry", c_contents_entry);
rb_undef_alloc_func(c_contents_sym_entry);
rb_define_singleton_method(c_contents_sym_entry, "new", contents_sym_entry_new, -1);
rb_define_method(c_contents_sym_entry, "target_key", contents_sym_entry_target_key, 0);
rb_define_method(c_contents_sym_entry, "part_key", contents_sym_entry_part_key, 0);
}
}
Public Instance Methods
Source
static VALUE
contents_sym_entry_part_key(VALUE self)
{
std::shared_ptr<const ContentsEntry> * ptr;
Data_Get_Struct(self, std::shared_ptr<const ContentsEntry>, ptr);
return metadata_key_to_value((std::static_pointer_cast<const ContentsSymEntry>(*ptr))->part_key());
}
/*
* call-seq:
* each_metadata {|key| block } -> Nil
*
* Our metadata.
*/
VALUE
contents_entry_each_metadata(VALUE self)
{
std::shared_ptr<const ContentsEntry> * self_ptr;
Data_Get_Struct(self, std::shared_ptr<const ContentsEntry>, self_ptr);
for (const auto & key : (*self_ptr)->metadata())
{
VALUE val(metadata_key_to_value(key));
if (Qnil != val)
rb_yield(val);
}
return Qnil;
}
void do_register_contents()
{
/*
* Document-class: Paludis::Contents
*
* A package's contents. Includes Enumerable[http://www.ruby-doc.org/core/classes/Enumerable.html],
* but not Comparable.
*/
c_contents = rb_define_class_under(c_paludis_module, "Contents", rb_cObject);
rb_undef_alloc_func(c_contents);
rb_include_module(c_contents, rb_mEnumerable);
rb_define_singleton_method(c_contents, "new", contents_new, 0);
rb_define_method(c_contents, "initialize", contents_init, 0);
rb_define_method(c_contents, "each", contents_each, 0);
rb_define_method(c_contents, "add", contents_add, 1);
/*
* Document-class: Paludis::ContentsEntry
*
* Base class for a ContentsEntry
*/
c_contents_entry = rb_define_class_under(c_paludis_module, "ContentsEntry", rb_cObject);
rb_funcall(c_contents_entry, rb_intern("private_class_method"), 1, rb_str_new2("new"));
rb_define_method(c_contents_entry, "location_key", contents_entry_location_key, 0);
rb_define_method(c_contents_entry, "initialize", contents_entry_init,-1);
rb_define_method(c_contents_entry, "each_metadata", contents_entry_each_metadata, 0);
/*
* Document-class: Paludis::ContentsFileEntry
*
* A file ContentsEntry
*/
c_contents_file_entry = rb_define_class_under(c_paludis_module, "ContentsFileEntry", c_contents_entry);
rb_undef_alloc_func(c_contents_file_entry);
rb_define_singleton_method(c_contents_file_entry, "new", contents_file_entry_new, -1);
rb_define_method(c_contents_file_entry, "part_key", contents_file_entry_part_key, 0);
/*
* Document-class: Paludis::ContentsDirEntry
*
* A directory ContentsEntry
*/
c_contents_dir_entry = rb_define_class_under(c_paludis_module, "ContentsDirEntry", c_contents_entry);
rb_undef_alloc_func(c_contents_dir_entry);
rb_define_singleton_method(c_contents_dir_entry, "new", template_methods, -1);
/*
* Document-class: Paludis::ContentsOtherEntry
*
* An 'other' ContentsEntry
*/
c_contents_other_entry = rb_define_class_under(c_paludis_module, "ContentsOtherEntry", c_contents_entry);
rb_undef_alloc_func(c_contents_other_entry);
rb_define_singleton_method(c_contents_other_entry, "new", template_methods, -1);
/*
* Document-class: Paludis::ContentsSymEntry
*
* A symlink ContentsEntry
*/
c_contents_sym_entry = rb_define_class_under(c_paludis_module, "ContentsSymEntry", c_contents_entry);
rb_undef_alloc_func(c_contents_sym_entry);
rb_define_singleton_method(c_contents_sym_entry, "new", contents_sym_entry_new, -1);
rb_define_method(c_contents_sym_entry, "target_key", contents_sym_entry_target_key, 0);
rb_define_method(c_contents_sym_entry, "part_key", contents_sym_entry_part_key, 0);
}
}
Source
static VALUE
contents_sym_entry_target_key(VALUE self)
{
std::shared_ptr<const ContentsEntry> * ptr;
Data_Get_Struct(self, std::shared_ptr<const ContentsEntry>, ptr);
return metadata_key_to_value((std::static_pointer_cast<const ContentsSymEntry>(*ptr))->target_key());
}
static VALUE
contents_sym_entry_part_key(VALUE self)
{
std::shared_ptr<const ContentsEntry> * ptr;
Data_Get_Struct(self, std::shared_ptr<const ContentsEntry>, ptr);
return metadata_key_to_value((std::static_pointer_cast<const ContentsSymEntry>(*ptr))->part_key());
}
/*
* call-seq:
* each_metadata {|key| block } -> Nil
*
* Our metadata.
*/
VALUE
contents_entry_each_metadata(VALUE self)
{
std::shared_ptr<const ContentsEntry> * self_ptr;
Data_Get_Struct(self, std::shared_ptr<const ContentsEntry>, self_ptr);
for (const auto & key : (*self_ptr)->metadata())
{
VALUE val(metadata_key_to_value(key));
if (Qnil != val)
rb_yield(val);
}
return Qnil;
}
void do_register_contents()
{
/*
* Document-class: Paludis::Contents
*
* A package's contents. Includes Enumerable[http://www.ruby-doc.org/core/classes/Enumerable.html],
* but not Comparable.
*/
c_contents = rb_define_class_under(c_paludis_module, "Contents", rb_cObject);
rb_undef_alloc_func(c_contents);
rb_include_module(c_contents, rb_mEnumerable);
rb_define_singleton_method(c_contents, "new", contents_new, 0);
rb_define_method(c_contents, "initialize", contents_init, 0);
rb_define_method(c_contents, "each", contents_each, 0);
rb_define_method(c_contents, "add", contents_add, 1);
/*
* Document-class: Paludis::ContentsEntry
*
* Base class for a ContentsEntry
*/
c_contents_entry = rb_define_class_under(c_paludis_module, "ContentsEntry", rb_cObject);
rb_funcall(c_contents_entry, rb_intern("private_class_method"), 1, rb_str_new2("new"));
rb_define_method(c_contents_entry, "location_key", contents_entry_location_key, 0);
rb_define_method(c_contents_entry, "initialize", contents_entry_init,-1);
rb_define_method(c_contents_entry, "each_metadata", contents_entry_each_metadata, 0);
/*
* Document-class: Paludis::ContentsFileEntry
*
* A file ContentsEntry
*/
c_contents_file_entry = rb_define_class_under(c_paludis_module, "ContentsFileEntry", c_contents_entry);
rb_undef_alloc_func(c_contents_file_entry);
rb_define_singleton_method(c_contents_file_entry, "new", contents_file_entry_new, -1);
rb_define_method(c_contents_file_entry, "part_key", contents_file_entry_part_key, 0);
/*
* Document-class: Paludis::ContentsDirEntry
*
* A directory ContentsEntry
*/
c_contents_dir_entry = rb_define_class_under(c_paludis_module, "ContentsDirEntry", c_contents_entry);
rb_undef_alloc_func(c_contents_dir_entry);
rb_define_singleton_method(c_contents_dir_entry, "new", template_methods, -1);
/*
* Document-class: Paludis::ContentsOtherEntry
*
* An 'other' ContentsEntry
*/
c_contents_other_entry = rb_define_class_under(c_paludis_module, "ContentsOtherEntry", c_contents_entry);
rb_undef_alloc_func(c_contents_other_entry);
rb_define_singleton_method(c_contents_other_entry, "new", template_methods, -1);
/*
* Document-class: Paludis::ContentsSymEntry
*
* A symlink ContentsEntry
*/
c_contents_sym_entry = rb_define_class_under(c_paludis_module, "ContentsSymEntry", c_contents_entry);
rb_undef_alloc_func(c_contents_sym_entry);
rb_define_singleton_method(c_contents_sym_entry, "new", contents_sym_entry_new, -1);
rb_define_method(c_contents_sym_entry, "target_key", contents_sym_entry_target_key, 0);
rb_define_method(c_contents_sym_entry, "part_key", contents_sym_entry_part_key, 0);
}
}
Returns our target (as per readlink)