[Rcpp-commits] r1527 - in pkg/Rcpp/inst: include/Rcpp include/Rcpp/traits unitTests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Jun 13 20:12:57 CEST 2010
Author: romain
Date: 2010-06-13 20:12:56 +0200 (Sun, 13 Jun 2010)
New Revision: 1527
Modified:
pkg/Rcpp/inst/include/Rcpp/algo.h
pkg/Rcpp/inst/include/Rcpp/traits/is_na.h
pkg/Rcpp/inst/unitTests/runit.Module.R
Log:
rename unit test class to avoid clashes
Modified: pkg/Rcpp/inst/include/Rcpp/algo.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/algo.h 2010-06-13 18:00:11 UTC (rev 1526)
+++ pkg/Rcpp/inst/include/Rcpp/algo.h 2010-06-13 18:12:56 UTC (rev 1527)
@@ -158,14 +158,14 @@
template <typename T>
-bool any( const T& t){
+SEXP any( const T& t){
bool seen_na = false ;
int n = t.size() ;
for( int i=0 ; i<n ; i++){
- if( t[i] == TRUE ) return TRUE ;
+ if( t[i] == TRUE ) return Rf_ScalarLogical( TRUE );
if( t[i] == NA_LOGICAL ) seen_na = true;
}
- return seen_na ? NA_LOGICAL : FALSE ;
+ return seen_na ? Rf_ScalarLogical(NA_LOGICAL) : Rf_ScalarLogical(FALSE) ;
}
Modified: pkg/Rcpp/inst/include/Rcpp/traits/is_na.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/is_na.h 2010-06-13 18:00:11 UTC (rev 1526)
+++ pkg/Rcpp/inst/include/Rcpp/traits/is_na.h 2010-06-13 18:12:56 UTC (rev 1527)
@@ -36,7 +36,7 @@
template <>
inline bool is_na<REALSXP>( double x ){
- return x == NA_REAL ;
+ return R_IsNA(x) ;
}
template <>
Modified: pkg/Rcpp/inst/unitTests/runit.Module.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.Module.R 2010-06-13 18:00:11 UTC (rev 1526)
+++ pkg/Rcpp/inst/unitTests/runit.Module.R 2010-06-13 18:12:56 UTC (rev 1527)
@@ -17,6 +17,10 @@
# You should have received a copy of the GNU General Public License
# along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
+.tearDown <- function(){
+ gc()
+}
+
if( Rcpp:::capabilities()[["Rcpp modules"]] ) {
test.Module <- function(){
@@ -213,9 +217,9 @@
test.Module.member <- function(){
inc <- '
- class Num{
+ class Number{
public:
- Num() : x(0.0), y(0){} ;
+ Number() : x(0.0), y(0){} ;
double x ;
int y ;
@@ -224,21 +228,21 @@
RCPP_MODULE(yada){
using namespace Rcpp ;
- class_<Num>( "Num" )
+ class_<Number>( "Number" )
// read and write data member
- .field( "x", &Num::x )
+ .field( "x", &Number::x )
// read only data member
- .field_readonly( "y", &Num::y )
+ .field_readonly( "y", &Number::y )
;
}
'
fx <- cxxfunction( signature(), "" , include = inc, plugin = "Rcpp" )
mod <- Module( "yada", getDynLib(fx) )
- Num <- mod$Num
- w <- new( Num )
+ Number <- mod$Number
+ w <- new( Number )
checkEquals( w$x, 0.0 )
checkEquals( w$y, 0L )
More information about the Rcpp-commits
mailing list