A generic solution (cont'd) 1 typedef VALUE (*RUBY_VALUE_FUNC)(VALUE); 2 VALUE rb_cpp_protect(RUBY_VALUE_FUNC f, VALUE arg) { 3 int state = 0; 4 VALUE retval = rb_protect(f, arg, &state); 5 if(state != 0) { 6 throw Ruby_Jump_Tag(state); 7 } 8 }