mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[digest] Added rb_digest_make_metadata to wrap metadata
https://github.com/ruby/digest/commit/7046fe6005
This commit is contained in:
parent
5b2cf7eac8
commit
feacae193c
5 changed files with 12 additions and 15 deletions
|
@ -62,3 +62,11 @@ rb_id_metadata(void)
|
|||
{
|
||||
return rb_intern_const("metadata");
|
||||
}
|
||||
|
||||
static inline VALUE
|
||||
rb_digest_make_metadata(const rb_digest_metadata_t *meta)
|
||||
{
|
||||
#undef RUBY_UNTYPED_DATA_WARNING
|
||||
#define RUBY_UNTYPED_DATA_WARNING 0
|
||||
return rb_obj_freeze(Data_Wrap_Struct(0, 0, 0, (void *)meta));
|
||||
}
|
||||
|
|
|
@ -57,8 +57,5 @@ Init_md5(void)
|
|||
|
||||
cDigest_MD5 = rb_define_class_under(mDigest, "MD5", cDigest_Base);
|
||||
|
||||
#undef RUBY_UNTYPED_DATA_WARNING
|
||||
#define RUBY_UNTYPED_DATA_WARNING 0
|
||||
rb_iv_set(cDigest_MD5, "metadata",
|
||||
Data_Wrap_Struct(0, 0, 0, (void *)&md5));
|
||||
rb_iv_set(cDigest_MD5, "metadata", rb_digest_make_metadata(&md5));
|
||||
}
|
||||
|
|
|
@ -53,8 +53,5 @@ Init_rmd160(void)
|
|||
|
||||
cDigest_RMD160 = rb_define_class_under(mDigest, "RMD160", cDigest_Base);
|
||||
|
||||
#undef RUBY_UNTYPED_DATA_WARNING
|
||||
#define RUBY_UNTYPED_DATA_WARNING 0
|
||||
rb_iv_set(cDigest_RMD160, "metadata",
|
||||
Data_Wrap_Struct(0, 0, 0, (void *)&rmd160));
|
||||
rb_iv_set(cDigest_RMD160, "metadata", rb_digest_make_metadata(&rmd160));
|
||||
}
|
||||
|
|
|
@ -59,8 +59,5 @@ Init_sha1(void)
|
|||
|
||||
cDigest_SHA1 = rb_define_class_under(mDigest, "SHA1", cDigest_Base);
|
||||
|
||||
#undef RUBY_UNTYPED_DATA_WARNING
|
||||
#define RUBY_UNTYPED_DATA_WARNING 0
|
||||
rb_iv_set(cDigest_SHA1, "metadata",
|
||||
Data_Wrap_Struct(0, 0, 0, (void *)&sha1));
|
||||
rb_iv_set(cDigest_SHA1, "metadata", rb_digest_make_metadata(&sha1));
|
||||
}
|
||||
|
|
|
@ -47,9 +47,7 @@ Init_sha2(void)
|
|||
cDigest_SHA##bitlen = rb_define_class_under(mDigest, "SHA" #bitlen, cDigest_Base); \
|
||||
\
|
||||
rb_ivar_set(cDigest_SHA##bitlen, id_metadata, \
|
||||
Data_Wrap_Struct(0, 0, 0, (void *)&sha##bitlen));
|
||||
rb_digest_make_metadata(&sha##bitlen));
|
||||
|
||||
#undef RUBY_UNTYPED_DATA_WARNING
|
||||
#define RUBY_UNTYPED_DATA_WARNING 0
|
||||
FOREACH_BITLEN(DEFINE_ALGO_CLASS)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue