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

ruby-changes:5577

From: ko1 <ko1@a...>
Date: Wed, 11 Jun 2008 01:34:25 +0900 (JST)
Subject: [ruby-changes:5577] Ruby:r17081 (trunk): * include/ruby/intern.h, proc.c: revert rb_proc_call() and

ko1	2008-06-11 01:33:51 +0900 (Wed, 11 Jun 2008)

  New Revision: 17081

  Modified files:
    trunk/ChangeLog
    trunk/eval_jump.c
    trunk/include/ruby/intern.h
    trunk/include/ruby/ruby.h
    trunk/proc.c
    trunk/thread.c
    trunk/version.h
    trunk/vm_insnhelper.c

  Log:
    * include/ruby/intern.h, proc.c: revert rb_proc_call() and
      create rb_proc_call_with_block() instaed.
    * include/ruby/ruby.h, eval_jump.c, thread.c, vm_insnhelper.c:
      rb_blockptr should not be exposed.
    


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/ruby.h?r1=17081&r2=17080&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/version.h?r1=17081&r2=17080&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=17081&r2=17080&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/thread.c?r1=17081&r2=17080&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/eval_jump.c?r1=17081&r2=17080&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/proc.c?r1=17081&r2=17080&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/vm_insnhelper.c?r1=17081&r2=17080&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/include/ruby/intern.h?r1=17081&r2=17080&diff_format=u

Index: include/ruby/intern.h
===================================================================
--- include/ruby/intern.h	(revision 17080)
+++ include/ruby/intern.h	(revision 17081)
@@ -272,7 +272,8 @@
 VALUE rb_block_proc(void);
 VALUE rb_f_lambda(void);
 VALUE rb_proc_new(VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE);
-VALUE rb_proc_call(VALUE, VALUE, rb_blockptr);
+VALUE rb_proc_call(VALUE, VALUE);
+VALUE rb_proc_call_with_block(VALUE, int argc, VALUE *argv, VALUE);
 int rb_proc_arity(VALUE);
 VALUE rb_binding_new(void);
 VALUE rb_obj_method(VALUE, VALUE);
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 17080)
+++ include/ruby/ruby.h	(revision 17081)
@@ -824,8 +824,6 @@
 PRINTF_ARGS(void rb_warn(const char*, ...), 1, 2);
 PRINTF_ARGS(void rb_compile_warn(const char *, int, const char*, ...), 3, 4);
 
-typedef struct rb_block_struct *rb_blockptr;
-
 typedef VALUE rb_block_call_func(VALUE, VALUE, int, VALUE*);
 
 VALUE rb_each(VALUE);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 17080)
+++ ChangeLog	(revision 17081)
@@ -1,3 +1,11 @@
+Wed Jun 11 01:28:12 2008  Koichi Sasada  <ko1@a...>
+
+	* include/ruby/intern.h, proc.c: revert rb_proc_call() and
+	  create rb_proc_call_with_block() instaed.
+
+	* include/ruby/ruby.h, eval_jump.c, thread.c, vm_insnhelper.c: 
+	  rb_blockptr should not be exposed.
+
 Tue Jun 10 21:07:19 2008  Kazuhiro NISHIYAMA  <zn@m...>
 
 	* test/ruby/test_float.rb: add tests. [ruby-dev:35009]
Index: proc.c
===================================================================
--- proc.c	(revision 17080)
+++ proc.c	(revision 17081)
@@ -507,14 +507,28 @@
 }
 
 VALUE
-rb_proc_call(VALUE self, VALUE args, rb_blockptr blockptr)
+rb_proc_call(VALUE self, VALUE args)
 {
     rb_proc_t *proc;
     GetProcPtr(self, proc);
     return vm_invoke_proc(GET_THREAD(), proc, proc->block.self,
-			  RARRAY_LEN(args), RARRAY_PTR(args), blockptr);
+			  RARRAY_LEN(args), RARRAY_PTR(args), 0);
 }
 
+VALUE
+rb_proc_call_with_block(VALUE self, int argc, VALUE *argv, VALUE pass_procval)
+{
+    rb_proc_t *proc, *pass_proc = 0;
+    GetProcPtr(self, proc);
+
+    if (!NIL_P(pass_procval)) {
+	GetProcPtr(pass_procval, pass_proc);
+    }
+
+    return vm_invoke_proc(GET_THREAD(), proc, proc->block.self,
+			  argc, argv, &pass_proc->block);
+}
+
 /*
  *  call-seq:
  *     prc.arity -> fixnum
@@ -1584,7 +1598,7 @@
     return bindval;
 }
 
-static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv, rb_blockptr blockptr);
+static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc);
 
 static VALUE
 make_curry_proc(VALUE proc, VALUE passed, VALUE arity)
@@ -1600,7 +1614,7 @@
 }
 
 static VALUE
-curry(VALUE dummy, VALUE args, int argc, VALUE *argv, rb_blockptr blockptr)
+curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc)
 {
     VALUE proc, passed, arity;
     proc = RARRAY_PTR(args)[0];
@@ -1609,15 +1623,17 @@
 
     passed = rb_ary_plus(passed, rb_ary_new4(argc, argv));
     rb_ary_freeze(passed);
+
     if(RARRAY_LEN(passed) < FIX2INT(arity)) {
-	if (blockptr) {
+	if (!NIL_P(passed_proc)) {
 	    rb_warn("given block not used");
 	}
 	arity = make_curry_proc(proc, passed, arity);
 	return arity;
     }
-    arity = rb_proc_call(proc, passed, blockptr);
-    return arity;
+    else {
+	return rb_proc_call_with_block(proc, RARRAY_LEN(passed), RARRAY_PTR(passed), passed_proc);
+    }
 }
 
  /*
Index: thread.c
===================================================================
--- thread.c	(revision 17080)
+++ thread.c	(revision 17081)
@@ -3079,6 +3079,7 @@
     struct call_trace_func_args *p = (struct call_trace_func_args *)args;
     VALUE eventname = rb_str_new2(get_event_name(p->event));
     VALUE filename = rb_str_new2(rb_sourcefile());
+    VALUE argv[6];
     int line = rb_sourceline();
     ID id = 0;
     VALUE klass = 0;
@@ -3101,11 +3102,15 @@
 	    klass = rb_iv_get(klass, "__attached__");
 	}
     }
-    return rb_proc_call(p->proc, rb_ary_new3(6,
-					     eventname, filename, INT2FIX(line),
-					     id ? ID2SYM(id) : Qnil,
-					     p->self ? rb_binding_new() : Qnil,
-					     klass ? klass : Qnil), 0);
+
+    argv[0] = eventname;
+    argv[1] = filename;
+    argv[2] = INT2FIX(line);
+    argv[3] = id ? ID2SYM(id) : Qnil;
+    argv[4] = p->self ? rb_binding_new() : Qnil;
+    argv[5] = klass ? klass : Qnil;
+    
+    return rb_proc_call_with_block(p->proc, 6, argv, Qnil);
 }
 
 static void
Index: eval_jump.c
===================================================================
--- eval_jump.c	(revision 17080)
+++ eval_jump.c	(revision 17081)
@@ -10,7 +10,7 @@
 void
 rb_call_end_proc(VALUE data)
 {
-    rb_proc_call(data, rb_ary_new(), 0);
+    rb_proc_call(data, rb_ary_new());
 }
 
 /*
Index: version.h
===================================================================
--- version.h	(revision 17080)
+++ version.h	(revision 17081)
@@ -1,7 +1,7 @@
 #define RUBY_VERSION "1.9.0"
-#define RUBY_RELEASE_DATE "2008-06-10"
+#define RUBY_RELEASE_DATE "2008-06-11"
 #define RUBY_VERSION_CODE 190
-#define RUBY_RELEASE_CODE 20080610
+#define RUBY_RELEASE_CODE 20080611
 #define RUBY_PATCHLEVEL 0
 
 #define RUBY_VERSION_MAJOR 1
@@ -9,7 +9,7 @@
 #define RUBY_VERSION_TEENY 0
 #define RUBY_RELEASE_YEAR 2008
 #define RUBY_RELEASE_MONTH 6
-#define RUBY_RELEASE_DAY 10
+#define RUBY_RELEASE_DAY 11
 
 #ifdef RUBY_EXTERN
 RUBY_EXTERN const char ruby_version[];
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 17080)
+++ vm_insnhelper.c	(revision 17081)
@@ -655,8 +655,7 @@
 		    const rb_block_t *blockptr)
 {
     NODE *ifunc = (NODE *) block->iseq;
-    VALUE val;
-    VALUE arg;
+    VALUE val, arg, blockarg;
     int lambda = block_proc_is_lambda(block->proc);
 
     if (lambda) {
@@ -669,11 +668,18 @@
 	arg = argv[0];
     }
 
+    if (blockptr) {
+	blockarg = vm_make_proc(th, th->cfp, blockptr);
+    }
+    else {
+	blockarg = Qnil;
+    }
+
     vm_push_frame(th, 0, FRAME_MAGIC_IFUNC,
 		  self, (VALUE)block->dfp,
 		  0, th->cfp->sp, block->lfp, 1);
 
-    val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, argc, argv, blockptr);
+    val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, argc, argv, blockarg);
 
     th->cfp++;
     return val;

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

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