File tree Expand file tree Collapse file tree 5 files changed +28
-47
lines changed
Expand file tree Collapse file tree 5 files changed +28
-47
lines changed Original file line number Diff line number Diff line change 22//
33// Vector.h: Rcpp R/C++ interface class library -- vectors
44//
5- // Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois
5+ // Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
66//
77// This file is part of Rcpp.
88//
@@ -40,7 +40,7 @@ namespace Rcpp{
4040#include < Rcpp/vector/no_init.h>
4141namespace Rcpp {
4242#include < Rcpp/vector/00_forward_proxy.h>
43- #include < Rcpp/vector/00_forward_eval_methods .h>
43+ #include < Rcpp/vector/vector_from_string .h>
4444
4545#include < Rcpp/vector/converter.h>
4646
Original file line number Diff line number Diff line change 2727namespace Rcpp {
2828 namespace internal {
2929
30- SEXP convert_using_rfunction (SEXP x, const char * const fun);
30+ inline SEXP convert_using_rfunction (SEXP x, const char * const fun){
31+ Armor<SEXP> res ;
32+ try {
33+ SEXP funSym = Rf_install (fun);
34+ res = Rcpp_eval ( Rf_lang2 ( funSym, x ) ) ;
35+ } catch ( eval_error& e){
36+ throw not_compatible ( std::string (" could not convert using R function : " ) + fun ) ;
37+ }
38+ return res;
39+ }
3140
3241 // r_true_cast is only meant to be used when the target SEXP type
3342 // is different from the SEXP type of x
Original file line number Diff line number Diff line change @@ -30,8 +30,7 @@ template <bool NA,typename T> class SingleLogicalResult ;
3030template <int RTYPE>
3131class Vector :
3232 public RObject,
33- public VectorBase< RTYPE, true , Vector<RTYPE> >,
34- public internal::eval_methods<RTYPE>
33+ public VectorBase< RTYPE, true , Vector<RTYPE> >
3534{
3635 typename traits::r_vector_cache_type<RTYPE>::type cache ;
3736
@@ -522,6 +521,15 @@ class Vector :
522521
523522 #include < Rcpp/generated/Vector__create.h>
524523
524+ inline SEXP eval () const {
525+ return Rcpp_eval ( Storage::get__ (), R_GlobalEnv ) ;
526+ }
527+
528+ inline SEXP eval (SEXP env) const {
529+ return Rcpp_eval ( Storage::get__ (), env );
530+ }
531+
532+
525533} ; /* Vector */
526534
527535#endif
Original file line number Diff line number Diff line change 11// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
22//
3- // eval_methods .h: Rcpp R/C++ interface class library --
3+ // vector_from_string .h: Rcpp R/C++ interface class library --
44//
5- // Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
5+ // Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
66//
77// This file is part of Rcpp.
88//
1919// You should have received a copy of the GNU General Public License
2020// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
2121
22- #ifndef Rcpp__vector__forward_eval_methods_h
23- #define Rcpp__vector__forward_eval_methods_h
22+ #ifndef Rcpp__vector__forward_vector_from_string_h
23+ #define Rcpp__vector__forward_vector_from_string_h
2424
2525namespace internal {
26+
2627 template <int RTYPE>
2728 SEXP vector_from_string ( const std::string& st ) {
2829 return r_cast<RTYPE>( Rf_mkString ( st.c_str () ) ) ;
@@ -49,13 +50,6 @@ namespace internal{
4950 inline SEXP vector_from_string<EXPRSXP>( const std::string& st ) {
5051 return vector_from_string_expr<EXPRSXP>( st ) ;
5152 }
52-
53- template <int RTYPE> class eval_methods {} ;
54- template <> class eval_methods <EXPRSXP> {
55- public:
56- SEXP eval () ;
57- SEXP eval (SEXP) ;
58- } ;
59-
53+
6054}
6155#endif
Original file line number Diff line number Diff line change @@ -269,36 +269,6 @@ namespace Rcpp {
269269
270270
271271// {{{ utilities (from RcppCommon.cpp)
272-
273- namespace Rcpp {
274- namespace internal {
275-
276- SEXP convert_using_rfunction (SEXP x, const char * const fun) {
277- SEXP res = R_NilValue ;
278- try {
279- SEXP funSym = Rf_install (fun);
280- res = Rcpp_eval ( Rf_lang2 ( funSym, x ) ) ;
281- } catch ( eval_error& e){
282- throw ::Rcpp::not_compatible ( std::string (" could not convert using R function : " ) + fun ) ;
283- }
284- return res;
285- }
286-
287- SEXP eval_methods<EXPRSXP>::eval(){
288- SEXP xp = ( static_cast <ExpressionVector&>(*this ) ).asSexp () ;
289- SEXP evalSym = Rf_install ( " eval" );
290- return Rcpp_eval ( Rf_lang2 ( evalSym, xp ) ) ;
291- }
292-
293- SEXP eval_methods<EXPRSXP>::eval( SEXP env ){
294- SEXP xp = ( static_cast <ExpressionVector&>(*this ) ).asSexp () ;
295- SEXP evalSym = Rf_install ( " eval" );
296- return Rcpp_eval ( Rf_lang3 ( evalSym, xp, env ) ) ;
297- }
298-
299- } // internal
300- } // Rcpp
301-
302272SEXP as_character_externalptr (SEXP xp){
303273 char buffer[20 ] ;
304274 sprintf ( buffer, " %p" , (void *)EXTPTR_PTR (xp) ) ;
You can’t perform that action at this time.
0 commit comments