[macruby-changes] [4793] MacRuby/trunk/eval.c

source_changes at macosforge.org source_changes at macosforge.org
Wed Oct 13 14:30:25 PDT 2010


Revision: 4793
          http://trac.macosforge.org/projects/ruby/changeset/4793
Author:   lsansonetti at apple.com
Date:     2010-10-13 14:30:23 -0700 (Wed, 13 Oct 2010)
Log Message:
-----------
fix conformance bugs in rb_protect() and add rb_jump_tag()

Modified Paths:
--------------
    MacRuby/trunk/eval.c

Modified: MacRuby/trunk/eval.c
===================================================================
--- MacRuby/trunk/eval.c	2010-10-13 07:58:53 UTC (rev 4792)
+++ MacRuby/trunk/eval.c	2010-10-13 21:30:23 UTC (rev 4793)
@@ -484,15 +484,40 @@
 		      (VALUE)0);
 }
 
+// XXX not thread-safe, but it doesn't matter, since clients are C extensions
+// which are not reentrant anyways.
+static VALUE protect_exc = Qnil;
+
+static VALUE
+protect_rescue(VALUE obj, VALUE exc)
+{
+    *(int *)obj = 1;
+    GC_RETAIN(exc);
+    protect_exc = exc;
+    return Qnil;
+}
+
 VALUE
-rb_protect(VALUE (* proc) (VALUE), VALUE data, int *state)
+rb_protect(VALUE (*proc) (VALUE), VALUE data, int *state)
 {
     if (state != NULL) {
 	*state = 0;
     }
-    return rb_rescue2(proc, data, NULL, 0, rb_eStandardError, (VALUE)0);
+    return rb_rescue2(proc, data, protect_rescue, (VALUE)state,
+	    rb_eStandardError, (VALUE)0);
 }
 
+void
+rb_jump_tag(int state)
+{
+    assert(state > 0);
+    VALUE exc = protect_exc;
+    assert(exc != Qnil);
+    protect_exc = Qnil;
+    GC_RELEASE(exc);
+    rb_exc_raise(exc);
+}
+
 ID
 rb_frame_this_func(void)
 {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101013/381dcbd8/attachment.html>


More information about the macruby-changes mailing list