| 27 | namespace internal { |
| 28 | |
| 29 | inline SEXP convert_using_rfunction(SEXP x, const char* const fun) { // #nocov start |
| 30 | Armor<SEXP> res; |
| 31 | try{ |
| 32 | SEXP funSym = Rf_install(fun); |
| 33 | Shield<SEXP> call(Rf_lang2(funSym, x)); |
| 34 | res = Rcpp_fast_eval(call, R_GlobalEnv); |
| 35 | } catch( eval_error& e) { |
| 36 | const char* fmt = "Could not convert using R function: %s."; |
| 37 | throw not_compatible(fmt, fun); |
| 38 | } |
| 39 | return res; // #nocov end |
| 40 | } |
| 41 | |
| 42 | // r_true_cast is only meant to be used when the target SEXP type |
| 43 | // is different from the SEXP type of x |
no test coverage detected