1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/digest/digest.c (get_digest_base_metadata): Allow inheriting

Digest::Base subclasses, which was unintentionally made
  impossible while restructuring Digest classes.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@11950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2007-02-28 18:42:47 +00:00
parent bc6ef3dc20
commit bc4f7332e3
2 changed files with 14 additions and 4 deletions

View file

@ -423,15 +423,19 @@ rb_digest_class_s_hexdigest(int argc, VALUE *argv, VALUE klass)
static rb_digest_metadata_t *
get_digest_base_metadata(VALUE klass)
{
VALUE p;
VALUE obj;
rb_digest_metadata_t *algo;
if (rb_ivar_defined(klass, id_metadata) == Qfalse) {
/* This class should not be subclassed in Ruby */
rb_notimplement();
for (p = klass; p; p = RCLASS(p)->super) {
if (rb_ivar_defined(p, id_metadata)) {
obj = rb_ivar_get(p, id_metadata);
break;
}
}
obj = rb_ivar_get(klass, id_metadata);
if (!p)
rb_raise(rb_eRuntimeError, "Digest::Base cannot be directly inherited in Ruby");
Data_Get_Struct(obj, rb_digest_metadata_t, algo);