summaryrefslogtreecommitdiff
path: root/ext/digest/sha2
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2024-01-26 12:15:59 +0900
committergit <svn-admin@ruby-lang.org>2024-01-28 06:49:28 +0000
commitd3e6bcd37fd10a0356a0d07d079670bb7247299b (patch)
tree209d956730d950c614370ccadfb49858c4defc5f /ext/digest/sha2
parent81702b4b873c0e2b4247095b3b9462bcf34166ff (diff)
[ruby/digest] [DOC] Expand `Digest::SHA2` definitions for RDoc
Since RDoc searches `var = rb_define_class_under(...)` statements literally, they cannot be built by macros. https://github.com/ruby/digest/commit/d39b684f91
Diffstat (limited to 'ext/digest/sha2')
-rw-r--r--ext/digest/sha2/sha2init.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/ext/digest/sha2/sha2init.c b/ext/digest/sha2/sha2init.c
index ec48f3d8e6..3923e3724c 100644
--- a/ext/digest/sha2/sha2init.c
+++ b/ext/digest/sha2/sha2init.c
@@ -25,32 +25,50 @@ static const rb_digest_metadata_t sha##bitlen = { \
FOREACH_BITLEN(DEFINE_ALGO_METADATA)
/*
+ * Document-class: Digest::SHA256 < Digest::Base
+ *
* Classes for calculating message digests using the SHA-256/384/512
* Secure Hash Algorithm(s) by NIST (the US' National Institute of
* Standards and Technology), described in FIPS PUB 180-2.
+ *
+ * See SHA2.
+ */
+/*
+ * Document-class: Digest::SHA384 < Digest::Base
+ *
+ * Classes for calculating message digests using the SHA-256/384/512
+ * Secure Hash Algorithm(s) by NIST (the US' National Institute of
+ * Standards and Technology), described in FIPS PUB 180-2.
+ *
+ * See SHA2.
+ */
+/*
+ * Document-class: Digest::SHA512 < Digest::Base
+ *
+ * Classes for calculating message digests using the SHA-256/384/512
+ * Secure Hash Algorithm(s) by NIST (the US' National Institute of
+ * Standards and Technology), described in FIPS PUB 180-2.
+ *
+ * See SHA2.
*/
void
Init_sha2(void)
{
- VALUE mDigest, cDigest_Base;
+ VALUE mDigest, cDigest_Base, cDigest_SHA2;
ID id_metadata = rb_id_metadata();
-#define DECLARE_ALGO_CLASS(bitlen) \
- VALUE cDigest_SHA##bitlen;
-
- FOREACH_BITLEN(DECLARE_ALGO_CLASS)
-
#if 0
mDigest = rb_define_module("Digest"); /* let rdoc know */
#endif
mDigest = rb_digest_namespace();
cDigest_Base = rb_const_get(mDigest, rb_intern_const("Base"));
-#define DEFINE_ALGO_CLASS(bitlen) \
- cDigest_SHA##bitlen = rb_define_class_under(mDigest, "SHA" #bitlen, cDigest_Base); \
-\
- rb_ivar_set(cDigest_SHA##bitlen, id_metadata, \
- rb_digest_make_metadata(&sha##bitlen));
+ cDigest_SHA2 = rb_define_class_under(mDigest, "SHA256", cDigest_Base);
+ rb_ivar_set(cDigest_SHA2, id_metadata, rb_digest_make_metadata(&sha256));
+
+ cDigest_SHA2 = rb_define_class_under(mDigest, "SHA384", cDigest_Base);
+ rb_ivar_set(cDigest_SHA2, id_metadata, rb_digest_make_metadata(&sha384));
- FOREACH_BITLEN(DEFINE_ALGO_CLASS)
+ cDigest_SHA2 = rb_define_class_under(mDigest, "SHA512", cDigest_Base);
+ rb_ivar_set(cDigest_SHA2, id_metadata, rb_digest_make_metadata(&sha512));
}