class Paludis::Contents

A package's contents. Includes Enumerable, but not Comparable.

Public Class Methods

new() click to toggle source
VALUE
    contents_new(VALUE self)
    {
        std::shared_ptr<Contents> * ptr(0);
        try
        {
            ptr = new std::shared_ptr<Contents>(new Contents());
            VALUE tdata(Data_Wrap_Struct(self, 0, &Common<std::shared_ptr<Contents> >::free, ptr));
            rb_obj_call_init(tdata, 0, 0);
            return tdata;
        }
        catch (const std::exception & e)
        {
            delete ptr;
            exception_to_ruby_exception(e);
        }
    }

    /*
     * call-seq:
     *     add(contents_entry)
     *
     * Add a new entry.
    */
    VALUE contents_add(VALUE self, VALUE v)
    {
        if (rb_obj_is_kind_of(v, c_contents_entry))
        {
            try
            {
                std::shared_ptr<Contents> * self_ptr;
                Data_Get_Struct(self, std::shared_ptr<Contents>, self_ptr);
                std::shared_ptr<const ContentsEntry> * v_ptr;
                Data_Get_Struct(v, std::shared_ptr<const ContentsEntry>, v_ptr);
                (*self_ptr)->add(*v_ptr);
                return self;
            }
            catch (const std::exception & e)
            {
                exception_to_ruby_exception(e);
            }
        }
        else
        {
            rb_raise(rb_eTypeError, "Can't convert %s into ContentsEntry", rb_obj_classname(v));
        }
    }

    /*
     * call-seq:
     *     each {|contents_entry| block}
     *
     * Iterate through our entries.
     */
    VALUE
    contents_each(VALUE self)
    {
        std::shared_ptr<Contents> * ptr;
        Data_Get_Struct(self, std::shared_ptr<Contents>, ptr);

        for (Contents::ConstIterator i ((*ptr)->begin()), i_end((*ptr)->end()) ; i != i_end; ++i)
            rb_yield(contents_entry_to_value(*i));
        return self;
    }

    VALUE
    contents_entry_init(int, VALUE *, VALUE self)
    {
        return self;
    }

    template <typename A_>
    struct ContentsNew
    {
        static VALUE
        contents_entry_new(int argc, VALUE * argv, VALUE self)
        {
            typename std::shared_ptr<const ContentsEntry> * ptr(0);
            try
            {
                if (1 == argc)
                {
                    ptr = new std::shared_ptr<const ContentsEntry>(std::make_shared<A_>(
                                FSPath(StringValuePtr(argv[0]))));
                }
                else
                {
                    rb_raise(rb_eArgError, "ContentsEntry expects one argument, 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);
            }
        }
    };

    VALUE contents_file_entry_new(int argc, VALUE * argv, VALUE self)
    {
        std::shared_ptr<const ContentsEntry> * ptr(0);
        try
        {
            if (2 == argc)
            {
                ptr = new std::shared_ptr<const ContentsEntry>(std::make_shared<ContentsFileEntry>(
                            FSPath(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<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);
        }
    }

    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 (ContentsEntry::MetadataConstIterator it((*self_ptr)->begin_metadata()),
                it_end((*self_ptr)->end_metadata()); it_end != it; ++it)
        {
            VALUE val(metadata_key_to_value(*it));
            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_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_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_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_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_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

add(contents_entry) click to toggle source

Add a new entry.

VALUE contents_add(VALUE self, VALUE v)
    {
        if (rb_obj_is_kind_of(v, c_contents_entry))
        {
            try
            {
                std::shared_ptr<Contents> * self_ptr;
                Data_Get_Struct(self, std::shared_ptr<Contents>, self_ptr);
                std::shared_ptr<const ContentsEntry> * v_ptr;
                Data_Get_Struct(v, std::shared_ptr<const ContentsEntry>, v_ptr);
                (*self_ptr)->add(*v_ptr);
                return self;
            }
            catch (const std::exception & e)
            {
                exception_to_ruby_exception(e);
            }
        }
        else
        {
            rb_raise(rb_eTypeError, "Can't convert %s into ContentsEntry", rb_obj_classname(v));
        }
    }

    /*
     * call-seq:
     *     each {|contents_entry| block}
     *
     * Iterate through our entries.
     */
    VALUE
    contents_each(VALUE self)
    {
        std::shared_ptr<Contents> * ptr;
        Data_Get_Struct(self, std::shared_ptr<Contents>, ptr);

        for (Contents::ConstIterator i ((*ptr)->begin()), i_end((*ptr)->end()) ; i != i_end; ++i)
            rb_yield(contents_entry_to_value(*i));
        return self;
    }

    VALUE
    contents_entry_init(int, VALUE *, VALUE self)
    {
        return self;
    }

    template <typename A_>
    struct ContentsNew
    {
        static VALUE
        contents_entry_new(int argc, VALUE * argv, VALUE self)
        {
            typename std::shared_ptr<const ContentsEntry> * ptr(0);
            try
            {
                if (1 == argc)
                {
                    ptr = new std::shared_ptr<const ContentsEntry>(std::make_shared<A_>(
                                FSPath(StringValuePtr(argv[0]))));
                }
                else
                {
                    rb_raise(rb_eArgError, "ContentsEntry expects one argument, 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);
            }
        }
    };

    VALUE contents_file_entry_new(int argc, VALUE * argv, VALUE self)
    {
        std::shared_ptr<const ContentsEntry> * ptr(0);
        try
        {
            if (2 == argc)
            {
                ptr = new std::shared_ptr<const ContentsEntry>(std::make_shared<ContentsFileEntry>(
                            FSPath(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<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);
        }
    }

    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 (ContentsEntry::MetadataConstIterator it((*self_ptr)->begin_metadata()),
                it_end((*self_ptr)->end_metadata()); it_end != it; ++it)
        {
            VALUE val(metadata_key_to_value(*it));
            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_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_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_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_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_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);
    }
}
each {|contents_entry| block} click to toggle source

Iterate through our entries.

VALUE
    contents_each(VALUE self)
    {
        std::shared_ptr<Contents> * ptr;
        Data_Get_Struct(self, std::shared_ptr<Contents>, ptr);

        for (Contents::ConstIterator i ((*ptr)->begin()), i_end((*ptr)->end()) ; i != i_end; ++i)
            rb_yield(contents_entry_to_value(*i));
        return self;
    }

    VALUE
    contents_entry_init(int, VALUE *, VALUE self)
    {
        return self;
    }

    template <typename A_>
    struct ContentsNew
    {
        static VALUE
        contents_entry_new(int argc, VALUE * argv, VALUE self)
        {
            typename std::shared_ptr<const ContentsEntry> * ptr(0);
            try
            {
                if (1 == argc)
                {
                    ptr = new std::shared_ptr<const ContentsEntry>(std::make_shared<A_>(
                                FSPath(StringValuePtr(argv[0]))));
                }
                else
                {
                    rb_raise(rb_eArgError, "ContentsEntry expects one argument, 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);
            }
        }
    };

    VALUE contents_file_entry_new(int argc, VALUE * argv, VALUE self)
    {
        std::shared_ptr<const ContentsEntry> * ptr(0);
        try
        {
            if (2 == argc)
            {
                ptr = new std::shared_ptr<const ContentsEntry>(std::make_shared<ContentsFileEntry>(
                            FSPath(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<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);
        }
    }

    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 (ContentsEntry::MetadataConstIterator it((*self_ptr)->begin_metadata()),
                it_end((*self_ptr)->end_metadata()); it_end != it; ++it)
        {
            VALUE val(metadata_key_to_value(*it));
            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_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_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_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_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_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);
    }
}