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

ruby-changes:36881

From: nobu <ko1@a...>
Date: Wed, 24 Dec 2014 12:16:57 +0900 (JST)
Subject: [ruby-changes:36881] nobu:r48962 (trunk): ruby.h: parent in rb_data_type_t

nobu	2014-12-24 12:16:31 +0900 (Wed, 24 Dec 2014)

  New Revision: 48962

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48962

  Log:
    ruby.h: parent in rb_data_type_t
    
    * ruby.h (rb_data_type_t): revert r48647 and revise parent member.
      [ruby-core:66969] [Bug #10621]

  Modified files:
    trunk/ChangeLog
    trunk/error.c
    trunk/include/ruby/ruby.h
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 48961)
+++ include/ruby/ruby.h	(revision 48962)
@@ -973,7 +973,7 @@ struct rb_data_type_struct { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L973
 	void *reserved[2]; /* For future extension.
 			      This array *must* be filled with ZERO. */
     } function;
-    void *const reserved;
+    const rb_data_type_t *parent;
     void *data;        /* This area can be used for any purpose
                           by a programmer who define the type. */
     VALUE flags;       /* FL_WB_PROTECTED */
@@ -981,6 +981,7 @@ struct rb_data_type_struct { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L981
 
 #define HAVE_TYPE_RB_DATA_TYPE_T 1
 #define HAVE_RB_DATA_TYPE_T_FUNCTION 1
+#define HAVE_RB_DATA_TYPE_T_PARENT 1
 
 struct RTypedData {
     struct RBasic basic;
@@ -1009,6 +1010,7 @@ typedef void (*RUBY_DATA_FUNC)(void*); https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1010
 #endif
 VALUE rb_data_object_alloc(VALUE,void*,RUBY_DATA_FUNC,RUBY_DATA_FUNC);
 VALUE rb_data_typed_object_alloc(VALUE klass, void *datap, const rb_data_type_t *);
+int rb_typeddata_inherited_p(const rb_data_type_t *child, const rb_data_type_t *parent);
 int rb_typeddata_is_kind_of(VALUE, const rb_data_type_t *);
 void *rb_check_typeddata(VALUE, const rb_data_type_t *);
 #define Check_TypedStruct(v,t) rb_check_typeddata((VALUE)(v),(t))
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48961)
+++ ChangeLog	(revision 48962)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Dec 24 12:16:19 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* ruby.h (rb_data_type_t): revert r48647 and revise parent member.
+	  [ruby-core:66969] [Bug #10621]
+
 Wed Dec 24 05:40:52 2014  NARUSE, Yui  <naruse@r...>
 
 	* tool/downloader.rb: use config.guess in gcc repo.
@@ -694,13 +699,6 @@ Sat Nov 29 16:53:14 2014  Nobuyoshi Naka https://github.com/ruby/ruby/blob/trunk/ChangeLog#L699
 	  metacharacters would match multibyte characters.
 	  [ruby-dev:48752] [Bug #10555]
 
-Sat Nov 29 16:14:50 2014  Nobuyoshi Nakada  <nobu@r...>
-
-	* error.c (rb_typeddata_is_kind_of, rb_check_typeddata): ditto.
-
-	* error.c (rb_typeddata_inherited_p): deprecate. still keep for
-	  potential binary compatibility.
-
 Sat Nov 29 10:49:23 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* win32/win32.c (win32_direct_conv, rb_w32_readdir): convert UTF-8
Index: error.c
===================================================================
--- error.c	(revision 48961)
+++ error.c	(revision 48962)
@@ -541,8 +541,10 @@ rb_check_type(VALUE x, int t) https://github.com/ruby/ruby/blob/trunk/error.c#L541
 int
 rb_typeddata_inherited_p(const rb_data_type_t *child, const rb_data_type_t *parent)
 {
-    rb_warn("rb_typeddata_inherited_p() is deprecated");
-    if (child == parent) return 1;
+    while (child) {
+	if (child == parent) return 1;
+	child = child->parent;
+    }
     return 0;
 }
 
@@ -550,7 +552,7 @@ int https://github.com/ruby/ruby/blob/trunk/error.c#L552
 rb_typeddata_is_kind_of(VALUE obj, const rb_data_type_t *data_type)
 {
     if (!RB_TYPE_P(obj, T_DATA) ||
-	!RTYPEDDATA_P(obj) || RTYPEDDATA_TYPE(obj) != data_type) {
+	!RTYPEDDATA_P(obj) || !rb_typeddata_inherited_p(RTYPEDDATA_TYPE(obj), data_type)) {
 	return 0;
     }
     return 1;
@@ -570,7 +572,7 @@ rb_check_typeddata(VALUE obj, const rb_d https://github.com/ruby/ruby/blob/trunk/error.c#L572
 	etype = rb_obj_classname(obj);
 	rb_raise(rb_eTypeError, mesg, etype, data_type->wrap_struct_name);
     }
-    else if (RTYPEDDATA_TYPE(obj) != data_type) {
+    else if (!rb_typeddata_inherited_p(RTYPEDDATA_TYPE(obj), data_type)) {
 	etype = RTYPEDDATA_TYPE(obj)->wrap_struct_name;
 	rb_raise(rb_eTypeError, mesg, etype, data_type->wrap_struct_name);
     }

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

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