void Rf_warning(const char *format, ...) { char buf[8192]; va_list(ap); va_start(ap,format); Rvsnprintf(buf, BUFSIZE - 1, format, ap); va_end(ap); unimplemented("Rf_warning"); }
void Rprintf(const char *format, ...) { char buf[8192]; va_list(ap); va_start(ap,format); Rvsnprintf(buf, BUFSIZE - 1, format, ap); va_end(ap); JNIEnv *thisenv = getEnv(); jstring string = (*thisenv)->NewStringUTF(thisenv, buf); (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, RprintfMethodID, string); }
void Rprintf(const char *format, ...) { char buf[8192]; va_list(ap); va_start(ap,format); Rvsnprintf(buf, BUFSIZE - 1, format, ap); va_end(ap); void *str = truffle_read_string(buf); IMPORT_CALLHELPER(); truffle_invoke(obj, "printf", str); }
/* REprintf is used by the error handler do not add anything unless you're sure it won't cause problems */ void REprintf(const char *format, ...) { // TODO: determine correct target for this message char buf[8192]; va_list(ap); va_start(ap,format); Rvsnprintf(buf, BUFSIZE - 1, format, ap); va_end(ap); unimplemented("REprintf"); }
void Rf_error(const char *format, ...) { // This is a bit tricky. The usual error handling model in Java is "throw RError.error(...)" but // RError.error does quite a lot of stuff including potentially searching for R condition handlers // and, if it finds any, does not return, but throws a different exception than RError. // We definitely need to exit the FFI call and we certainly cannot return to our caller. // So we call CallRFFIHelper.Rf_error to throw the RError exception. When the pending // exception (whatever it is) is observed by JNI, the call to Rf_error will return where we do a // non-local transfer of control back to the entry point (which will cleanup). char buf[8192]; va_list(ap); va_start(ap,format); Rvsnprintf(buf, BUFSIZE - 1, format, ap); va_end(ap); unimplemented("Rf_error"); }
void Rf_error(const char *format, ...) { // This is a bit tricky. The usual error handling model in Java is "throw RError.error(...)" but // RError.error does quite a lot of stuff including potentially searching for R condition handlers // and, if it finds any, does not return, but throws a different exception than RError. // We definitely need to exit the FFI call and we certainly cannot return to our caller. // So we call CallRFFIHelper.Rf_error to throw the RError exception. When the pending // exception (whatever it is) is observed by JNI, the call to Rf_error will return where we do a // non-local transfer of control back to the entry point (which will cleanup). char buf[8192]; va_list(ap); va_start(ap,format); Rvsnprintf(buf, BUFSIZE - 1, format, ap); va_end(ap); JNIEnv *thisenv = getEnv(); jstring string = (*thisenv)->NewStringUTF(thisenv, buf); // This will set a pending exception (*thisenv)->CallStaticObjectMethod(thisenv, CallRFFIHelperClass, Rf_errorMethodID, string); // just transfer back which will cleanup and exit the entire JNI call longjmp(*getErrorJmpBuf(), 1); }