32 SEXP funSym = Rf_install(fun);
35 }
catch( eval_error& e) {
36 const char* fmt =
"Could not convert using R function: %s.";
37 throw not_compatible(fmt, fun);
47 const char* fmt =
"Not compatible conversion to target: "
48 "[type=%s; target=%s].";
50 throw not_compatible(fmt,
51 Rf_type2char(TYPEOF(x)),
52 Rf_type2char(TARGET));
59 if( TYPEOF(x) == RTYPE )
return x;
66 return Rf_coerceVector(x, RTYPE);
68 const char* fmt =
"Not compatible with requested type: "
69 "[type=%s; target=%s].";
72 Rf_type2char(TYPEOF(x)),
76 throw ::Rcpp::not_compatible(fmt,
77 Rf_type2char(TYPEOF(x)),
116 Shield<SEXP> call( Rf_lang2( Rf_install(
"as.character" ), x ) );
121 return Rf_ScalarString( x );
123 return Rf_ScalarString( PRINTNAME( x ) );
125 const char* fmt =
"Not compatible with STRSXP: [type=%s].";
127 REprintf(fmt, Rf_type2char(TYPEOF(x)));
130 throw ::Rcpp::not_compatible(fmt, Rf_type2char(TYPEOF(x)));
145 if (TYPEOF(x) == LANGSXP) {
146 return Rf_cons(CAR(x), CDR(x));
158 template <
int TARGET> SEXP
r_cast(SEXP x) {
159 if (TYPEOF(x) == TARGET) {
162 #ifdef RCPP_WARN_ON_COERCE
165 Rf_type2char(TYPEOF(x)),
internal implementation details
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)
SEXP Rcpp_fast_eval(SEXP expr, SEXP env)
void warning(const std::string &message)