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

ruby-changes:30056

From: nobu <ko1@a...>
Date: Mon, 22 Jul 2013 16:33:04 +0900 (JST)
Subject: [ruby-changes:30056] nobu:r42108 (trunk): vm_eval.c: Check_TypedStruct

nobu	2013-07-22 16:32:52 +0900 (Mon, 22 Jul 2013)

  New Revision: 42108

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

  Log:
    vm_eval.c: Check_TypedStruct
    
    * vm_eval.c (eval_string_with_cref): check by Check_TypedStruct
      instead of rb_obj_is_kind_of.

  Modified files:
    trunk/ChangeLog
    trunk/proc.c
    trunk/vm_core.h
    trunk/vm_eval.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42107)
+++ ChangeLog	(revision 42108)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jul 22 16:32:48 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm_eval.c (eval_string_with_cref): check by Check_TypedStruct
+	  instead of rb_obj_is_kind_of.
+
 Mon Jul 22 13:19:22 2013  Koichi Sasada  <ko1@a...>
 
 	* array.c (ary_resize_capa): use RARRAY_RAWPTR() because
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 42107)
+++ vm_core.h	(revision 42108)
@@ -688,6 +688,8 @@ typedef struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L688
     rb_block_t block;
 } rb_env_t;
 
+extern const rb_data_type_t ruby_binding_data_type;
+
 #define GetBindingPtr(obj, ptr) \
   GetCoreDataFromValue((obj), rb_binding_t, (ptr))
 
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 42107)
+++ vm_eval.c	(revision 42108)
@@ -1202,8 +1202,8 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1202
 	VALUE absolute_path = Qnil;
 
 	if (scope != Qnil) {
-	    if (rb_obj_is_kind_of(scope, rb_cBinding)) {
-		GetBindingPtr(scope, bind);
+	    bind = Check_TypedStruct(scope, &ruby_binding_data_type);
+	    {
 		envval = bind->env;
 		if (strcmp(file, "(eval)") != 0) {
 		    absolute_path = rb_str_new_cstr(file);
@@ -1214,11 +1214,6 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1214
 		    absolute_path = rb_current_realfilepath();
 		}
 	    }
-	    else {
-		rb_raise(rb_eTypeError,
-			 "wrong argument type %s (expected Binding)",
-			 rb_obj_classname(scope));
-	    }
 	    GetEnvPtr(envval, env);
 	    base_block = &env->block;
 	}
Index: proc.c
===================================================================
--- proc.c	(revision 42107)
+++ proc.c	(revision 42108)
@@ -269,7 +269,7 @@ binding_memsize(const void *ptr) https://github.com/ruby/ruby/blob/trunk/proc.c#L269
     return ptr ? sizeof(rb_binding_t) : 0;
 }
 
-static const rb_data_type_t binding_data_type = {
+const rb_data_type_t ruby_binding_data_type = {
     "binding",
     {
 	binding_mark,
@@ -283,7 +283,7 @@ binding_alloc(VALUE klass) https://github.com/ruby/ruby/blob/trunk/proc.c#L283
 {
     VALUE obj;
     rb_binding_t *bind;
-    obj = TypedData_Make_Struct(klass, rb_binding_t, &binding_data_type, bind);
+    obj = TypedData_Make_Struct(klass, rb_binding_t, &ruby_binding_data_type, bind);
     return obj;
 }
 

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

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