[前][次][番号順一覧][スレッド一覧]

ruby-changes:56001

From: Nobuyoshi <ko1@a...>
Date: Tue, 4 Jun 2019 19:55:04 +0900 (JST)
Subject: [ruby-changes:56001] Nobuyoshi Nakada: 2c60f37143 (trunk): random_mt_type

https://git.ruby-lang.org/ruby.git/commit/?id=2c60f37143

From 2c60f3714381803218313a6056d3e1dd39782ca1 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 12 May 2016 16:52:34 +0900
Subject: random_mt_type

* random.c: renamed random_data_type as random_mt_type, and append
  "MT" to `wrap_struct_name`, respecting the implementation.

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) https://github.com/ruby/ruby/blob/trunk/random.c#L175
     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 * https://github.com/ruby/ruby/blob/trunk/random.c#L189
 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) https://github.com/ruby/ruby/blob/trunk/random.c#L199
     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 https://github.com/ruby/ruby/blob/trunk/random.c#L208
 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) https://github.com/ruby/ruby/blob/trunk/random.c#L1480
 
 /* 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) https://github.com/ruby/ruby/blob/trunk/random.c#L1545
 
     {
 	/* 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);
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]