summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-28 18:42:47 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-02-28 18:42:47 +0000
commitbc4f7332e35278c751c654b44b2cc34d0b0c9344 (patch)
tree5e892bed764b2341ed2728e0674f90681c43df80 /ext
parentbc6ef3dc20acd005554c0666111c09dc72ef6eb4 (diff)
* 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
Diffstat (limited to 'ext')
-rw-r--r--ext/digest/digest.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/ext/digest/digest.c b/ext/digest/digest.c
index 07484f8..92a925c 100644
--- a/ext/digest/digest.c
+++ b/ext/digest/digest.c
@@ -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);