[Rcpp-commits] r3856 - in pkg/Rcpp: . inst/include/Rcpp inst/include/Rcpp/module

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Oct 30 09:21:54 CET 2012


Author: romain
Date: 2012-10-30 09:21:54 +0100 (Tue, 30 Oct 2012)
New Revision: 3856

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/include/Rcpp/as.h
   pkg/Rcpp/inst/include/Rcpp/module/Module_generated_Factory.h
Log:
bare_as

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2012-10-29 15:38:01 UTC (rev 3855)
+++ pkg/Rcpp/ChangeLog	2012-10-30 08:21:54 UTC (rev 3856)
@@ -1,3 +1,8 @@
+2012-10-30  Romain Francois <romain at r-enthusiasts.com>
+
+        * include/Rcpp/as.h: new bare_as to simplify uses of as
+        * include/Rcpp/module/Module_generated_Factory.h: using bare_as
+
 2012-10-29  Dirk Eddelbuettel  <edd at debian.org>
 
 	* inst/include/Rcpp/Rmath.h: More Rmath functions

Modified: pkg/Rcpp/inst/include/Rcpp/as.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/as.h	2012-10-29 15:38:01 UTC (rev 3855)
+++ pkg/Rcpp/inst/include/Rcpp/as.h	2012-10-30 08:21:54 UTC (rev 3856)
@@ -90,7 +90,12 @@
     template <typename T> T as( SEXP m_sexp) {
         return internal::as<T>( m_sexp, typename traits::r_type_traits<T>::r_category() ) ;
     }
-
+    
+    template <typename T> 
+    inline typename traits::remove_const_and_reference<T>::type bare_as( SEXP m_sexp ){
+        return as< typename traits::remove_const_and_reference<T>::type >( m_sexp ) ;
+    }
+    
     template<> inline SEXP as(SEXP m_sexp) { return m_sexp ; }
 
 } // Rcpp 

Modified: pkg/Rcpp/inst/include/Rcpp/module/Module_generated_Factory.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/module/Module_generated_Factory.h	2012-10-29 15:38:01 UTC (rev 3855)
+++ pkg/Rcpp/inst/include/Rcpp/module/Module_generated_Factory.h	2012-10-30 08:21:54 UTC (rev 3856)
@@ -49,7 +49,7 @@
 public:
   Factory_1( Class* (*fun)(U0) ) :ptr_fun(fun){}
   virtual Class* get_new( SEXP* args, int nargs ){
-      return ptr_fun( as<U0>(args[0]) ) ;
+      return ptr_fun( bare_as<U0>(args[0]) ) ;
   }
   virtual int nargs(){ return 1 ; }
   virtual void signature(std::string& s, const std::string& class_name ){
@@ -64,8 +64,8 @@
   Factory_2( Class* (*fun)(U0, U1) ) :ptr_fun(fun){}
   virtual Class* get_new( SEXP* args, int nargs ){
       return ptr_fun( 
-          as<U0>(args[0]), 
-          as<U1>(args[1]) 
+          bare_as<U0>(args[0]), 
+          bare_as<U1>(args[1]) 
           ) ;
   }
   virtual int nargs(){ return 2 ; }
@@ -81,9 +81,9 @@
   Factory_3( Class* (*fun)(U0, U1, U2) ) :ptr_fun(fun){} 
   virtual Class* get_new( SEXP* args, int nargs ){
       return ptr_fun( 
-          as<U0>(args[0]), 
-          as<U1>(args[1]), 
-          as<U2>(args[2]) 
+          bare_as<U0>(args[0]), 
+          bare_as<U1>(args[1]), 
+          bare_as<U2>(args[2]) 
           ) ;
   }
   virtual int nargs(){ return 3 ; }
@@ -99,10 +99,10 @@
   Factory_4( Class* (*fun)(U0, U1, U2, U3) ) :ptr_fun(fun){} 
   virtual Class* get_new( SEXP* args, int nargs ){
       return ptr_fun( 
-          as<U0>(args[0]), 
-          as<U1>(args[1]), 
-          as<U2>(args[2]), 
-          as<U3>(args[3]) 
+          bare_as<U0>(args[0]), 
+          bare_as<U1>(args[1]), 
+          bare_as<U2>(args[2]), 
+          bare_as<U3>(args[3]) 
           ) ;
   }
   virtual int nargs(){ return 4 ; }
@@ -118,11 +118,11 @@
   Factory_5( Class* (*fun)(U0, U1, U2, U3, U4) ) :ptr_fun(fun){} 
   virtual Class* get_new( SEXP* args, int nargs ){
       return ptr_fun( 
-          as<U0>(args[0]), 
-          as<U1>(args[1]), 
-          as<U2>(args[2]), 
-          as<U3>(args[3]), 
-          as<U4>(args[4]) 
+          bare_as<U0>(args[0]), 
+          bare_as<U1>(args[1]), 
+          bare_as<U2>(args[2]), 
+          bare_as<U3>(args[3]), 
+          bare_as<U4>(args[4]) 
           ) ;
   }
   virtual int nargs(){ return 5 ; }
@@ -138,12 +138,12 @@
   Factory_6( Class* (*fun)(U0, U1, U2, U3, U4, U5) ) :ptr_fun(fun){} 
   virtual Class* get_new( SEXP* args, int nargs ){
       return ptr_fun( 
-          as<U0>(args[0]), 
-          as<U1>(args[1]), 
-          as<U2>(args[2]), 
-          as<U3>(args[3]), 
-          as<U4>(args[4]),
-          as<U5>(args[5]) 
+          bare_as<U0>(args[0]), 
+          bare_as<U1>(args[1]), 
+          bare_as<U2>(args[2]), 
+          bare_as<U3>(args[3]), 
+          bare_as<U4>(args[4]),
+          bare_as<U5>(args[5]) 
           ) ;
   }
   virtual int nargs(){ return 6 ; }
@@ -159,13 +159,13 @@
   Factory_7( Class* (*fun)(U0, U1, U2, U3, U4, U5, U6) ) :ptr_fun(fun){} 
   virtual Class* get_new( SEXP* args, int nargs ){
       return ptr_fun( 
-          as<U0>(args[0]), 
-          as<U1>(args[1]), 
-          as<U2>(args[2]), 
-          as<U3>(args[3]), 
-          as<U4>(args[4]),
-          as<U5>(args[5]),
-          as<U6>(args[6]) 
+          bare_as<U0>(args[0]), 
+          bare_as<U1>(args[1]), 
+          bare_as<U2>(args[2]), 
+          bare_as<U3>(args[3]), 
+          bare_as<U4>(args[4]),
+          bare_as<U5>(args[5]),
+          bare_as<U6>(args[6]) 
           ) ;
   }
   virtual int nargs(){ return 7 ; }



More information about the Rcpp-commits mailing list