diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-28 18:24:25 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-02-28 18:24:25 +0000 |
commit | 04cd7cc62d8b16da8ccdff92f46e54e62ff26fab (patch) | |
tree | fce5a8c824470bb4e423fbb2e4b9fd8eac970d5e | |
parent | 50d3ece900d8592907eb06b8eb77b4612e7e5020 (diff) | |
download | ruby-04cd7cc62d8b16da8ccdff92f46e54e62ff26fab.tar.gz |
* 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/trunk@11947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ext/digest/digest.c | 12 |
2 files changed, 14 insertions, 4 deletions
@@ -1,3 +1,9 @@ +Thu Mar 1 02:55:25 2007 Akinori MUSHA <knu@iDaemons.org> + + * ext/digest/digest.c (get_digest_base_metadata): Allow inheriting + Digest::Base subclasses, which was unintentionally made + impossible while restructuring Digest classes. + Thu Mar 1 02:05:17 2007 Nobuyoshi Nakada <nobu@ruby-lang.org> * mkconfig.rb (patchlevel): read from version.h. diff --git a/ext/digest/digest.c b/ext/digest/digest.c index 07484f897f..c239be294f 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 inherited in Ruby"); Data_Get_Struct(obj, rb_digest_metadata_t, algo); |