[Rcpp-commits] r4399 - in pkg/Rcpp/inst: include/Rcpp unitTests/cpp

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jul 23 19:01:42 CEST 2013


Author: romain
Date: 2013-07-23 19:01:42 +0200 (Tue, 23 Jul 2013)
New Revision: 4399

Modified:
   pkg/Rcpp/inst/include/Rcpp/String.h
   pkg/Rcpp/inst/include/Rcpp/as.h
   pkg/Rcpp/inst/unitTests/cpp/Module.cpp
Log:
more as<> support

Modified: pkg/Rcpp/inst/include/Rcpp/String.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/String.h	2013-07-23 15:04:47 UTC (rev 4398)
+++ pkg/Rcpp/inst/include/Rcpp/String.h	2013-07-23 17:01:42 UTC (rev 4399)
@@ -331,6 +331,9 @@
         bool operator==( const Rcpp::String& other) const {
             return get_sexp() == other.get_sexp() ;   
         }
+        bool operator!=( const Rcpp::String& other) const {
+            return get_sexp() != other.get_sexp() ;   
+        }
         
         bool operator>( const Rcpp::String& other ) const {
             return strcmp( get_cstring(), other.get_cstring() ) > 0;   

Modified: pkg/Rcpp/inst/include/Rcpp/as.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/as.h	2013-07-23 15:04:47 UTC (rev 4398)
+++ pkg/Rcpp/inst/include/Rcpp/as.h	2013-07-23 17:01:42 UTC (rev 4399)
@@ -91,7 +91,7 @@
         /** handling object<T> */ 
         template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_module_object_const_pointer_tag ) {
             typedef typename Rcpp::traits::remove_const<T>::type T_NON_CONST ;
-            return const_cast<T>( as_module_object<T_NON_CONST>( x ) ) ;
+            return const_cast<T>( (T_NON_CONST)as_module_object_internal(x) ) ;
         }
         
         template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_module_object_pointer_tag ) {
@@ -105,7 +105,8 @@
         }
         
         /** handling T such that T is a reference of a class handled by a module */
-        template <typename T> T as(SEXP x, ::Rcpp::traits::r_type_module_object_reference_tag ){
+        template <typename T> 
+        T as(SEXP x, ::Rcpp::traits::r_type_module_object_reference_tag ){
             typedef typename traits::remove_reference<T>::type KLASS ;
             KLASS* obj = as_module_object<KLASS>(x) ;
             return *obj ;

Modified: pkg/Rcpp/inst/unitTests/cpp/Module.cpp
===================================================================
--- pkg/Rcpp/inst/unitTests/cpp/Module.cpp	2013-07-23 15:04:47 UTC (rev 4398)
+++ pkg/Rcpp/inst/unitTests/cpp/Module.cpp	2013-07-23 17:01:42 UTC (rev 4399)
@@ -98,22 +98,15 @@
     double min, max ;
 } ;
 
-// [[Rcpp::export]]
 double Number_get_x_const_ref( const Number& x){
     return x.x ;    
 }
-
-// [[Rcpp::export]]
 double Number_get_x_ref( Number& x){
     return x.x ;    
 }
-
-// [[Rcpp::export]]
 double Number_get_x_const_pointer( const Number* x){
     return x->x ;    
 }
-
-// [[Rcpp::export]]
 double Number_get_x_pointer( Number* x){
     return x->x ;    
 }
@@ -154,8 +147,13 @@
         
         	// read only data member
         	.field_readonly( "y", &Number::y )
-    ; 
+    ;
+    function( "Number_get_x_const_ref", Number_get_x_const_ref ); 
+    function( "Number_get_x_ref", Number_get_x_ref ); 
+    function( "Number_get_x_const_pointer", Number_get_x_const_pointer ); 
+    function( "Number_get_x_pointer", Number_get_x_pointer ); 
     
+    
     class_<Randomizer>( "Randomizer" )
         // No default: .default_constructor()
         .constructor<double,double>()



More information about the Rcpp-commits mailing list