summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2016-05-12 16:52:34 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-04 19:50:41 +0900
commit2c60f3714381803218313a6056d3e1dd39782ca1 (patch)
treedb5b73fa58426aedede98fd8d28c7a143aa167d0 /random.c
parentc8b001858ed6911db4285d239193bc2384ff6ce0 (diff)
random_mt_type
* random.c: renamed random_data_type as random_mt_type, and append "MT" to `wrap_struct_name`, respecting the implementation.
Diffstat (limited to 'random.c')
-rw-r--r--random.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/random.c b/random.c
index 2e557fd..dc2f1f2 100644
--- a/random.c
+++ b/random.c
@@ -175,8 +175,8 @@ random_memsize(const void *ptr)
return sizeof(rb_random_t);
}
-static const rb_data_type_t random_data_type = {
- "random",
+static const rb_data_type_t random_mt_type = {
+ "random/MT",
{
random_mark,
random_free,
@@ -189,7 +189,7 @@ static rb_random_t *
get_rnd(VALUE obj)
{
rb_random_t *ptr;
- TypedData_Get_Struct(obj, rb_random_t, &random_data_type, ptr);
+ TypedData_Get_Struct(obj, rb_random_t, &random_mt_type, ptr);
return rand_start(ptr);
}
@@ -199,7 +199,7 @@ try_get_rnd(VALUE obj)
if (obj == rb_cRandom) {
return rand_start(&default_rand);
}
- if (!rb_typeddata_is_kind_of(obj, &random_data_type)) return NULL;
+ if (!rb_typeddata_is_kind_of(obj, &random_mt_type)) return NULL;
return rand_start(DATA_PTR(obj));
}
@@ -208,7 +208,7 @@ static VALUE
random_alloc(VALUE klass)
{
rb_random_t *rnd;
- VALUE obj = TypedData_Make_Struct(klass, rb_random_t, &random_data_type, rnd);
+ VALUE obj = TypedData_Make_Struct(klass, rb_random_t, &random_mt_type, rnd);
rnd->seed = INT2FIX(0);
return obj;
}
@@ -1480,11 +1480,11 @@ init_randomseed(struct MT *mt)
/* construct Random::DEFAULT bits */
static VALUE
-Init_Random_default(void)
+Init_Random_default(VALUE klass)
{
rb_random_t *r = &default_rand;
struct MT *mt = &r->mt;
- VALUE v = TypedData_Wrap_Struct(rb_cRandom, &random_data_type, r);
+ VALUE v = TypedData_Wrap_Struct(klass, &random_mt_type, r);
rb_gc_register_mark_object(v);
r->seed = init_randomseed(mt);
@@ -1545,7 +1545,7 @@ InitVM_Random(void)
{
/* Direct access to Ruby's Pseudorandom number generator (PRNG). */
- VALUE rand_default = Init_Random_default();
+ VALUE rand_default = Init_Random_default(rb_cRandom);
/* The default Pseudorandom number generator. Used by class
* methods of Random. */
rb_define_const(rb_cRandom, "DEFAULT", rand_default);