| 156 | } // namespace internal |
| 157 | |
| 158 | template <int TARGET> SEXP r_cast(SEXP x) { // #nocov start |
| 159 | if (TYPEOF(x) == TARGET) { |
| 160 | return x; |
| 161 | } else { |
| 162 | #ifdef RCPP_WARN_ON_COERCE |
| 163 | Shield<SEXP> result( internal::r_true_cast<TARGET>(x) ); |
| 164 | ::Rcpp::warning("Coerced object from '%s' to '%s'.", |
| 165 | Rf_type2char(TYPEOF(x)), |
| 166 | Rf_type2char(TARGET) |
| 167 | ); |
| 168 | return result; |
| 169 | #else |
| 170 | return internal::r_true_cast<TARGET>(x); // #nocov end |
| 171 | #endif |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | } // namespace Rcpp |
| 176 |