33 SEXP funSym = Rf_install(fun);
36 }
catch( eval_error& e) {
37 const char* fmt =
"Could not convert using R function: %s.";
38 throw not_compatible(fmt, fun);
48 const char* fmt =
"Not compatible conversion to target: "
49 "[type=%s; target=%s].";
51 throw not_compatible(fmt,
52 Rf_type2char(TYPEOF(x)),
53 Rf_type2char(TARGET));
60 if( TYPEOF(x) == RTYPE )
return x;
67 return Rf_coerceVector(x, RTYPE);
69 const char* fmt =
"Not compatible with requested type: "
70 "[type=%s; target=%s].";
73 Rf_type2char(TYPEOF(x)),
77 throw ::Rcpp::not_compatible(fmt,
78 Rf_type2char(TYPEOF(x)),
87 return basic_cast<INTSXP>(x);
91 return basic_cast<REALSXP>(x);
95 return basic_cast<RAWSXP>(x);
99 return basic_cast<CPLXSXP>(x);
103 return basic_cast<LGLSXP>(x);
117 Shield<SEXP> call( Rf_lang2( Rf_install(
"as.character" ), x ) );
122 return Rf_ScalarString( x );
124 return Rf_ScalarString( PRINTNAME( x ) );
126 const char* fmt =
"Not compatible with STRSXP: [type=%s].";
128 REprintf(fmt, Rf_type2char(TYPEOF(x)));
131 throw ::Rcpp::not_compatible(fmt, Rf_type2char(TYPEOF(x)));
150 SET_TYPEOF(y,LISTSXP);
164 template <
int TARGET> SEXP
r_cast(SEXP x) {
165 if (TYPEOF(x) == TARGET) {
168 #ifdef RCPP_WARN_ON_COERCE
171 Rf_type2char(TYPEOF(x)),
176 return internal::r_true_cast<TARGET>(x);
SEXP r_true_cast< EXPRSXP >(SEXP x)
SEXP r_true_cast< STRSXP >(SEXP x)
SEXP r_true_cast< CPLXSXP >(SEXP x)
SEXP r_true_cast< LISTSXP >(SEXP x)
SEXP r_true_cast< REALSXP >(SEXP x)
SEXP convert_using_rfunction(SEXP x, const char *const fun)
SEXP r_true_cast< LANGSXP >(SEXP x)
SEXP r_true_cast< VECSXP >(SEXP x)
SEXP r_true_cast< LGLSXP >(SEXP x)
SEXP r_true_cast< INTSXP >(SEXP x)
SEXP r_true_cast< RAWSXP >(SEXP x)
void warning(const char *fmt, Args &&... args)
SEXP Rcpp_fast_eval(SEXP expr, SEXP env)