[Rcpp-commits] r415 - in pkg/src: . Rcpp
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jan 20 14:13:12 CET 2010
Author: romain
Date: 2010-01-20 14:13:12 +0100 (Wed, 20 Jan 2010)
New Revision: 415
Modified:
pkg/src/ComplexVector.cpp
pkg/src/IntegerVector.cpp
pkg/src/LogicalVector.cpp
pkg/src/NumericVector.cpp
pkg/src/RObject.cpp
pkg/src/Rcpp/ComplexVector.h
pkg/src/Rcpp/IntegerVector.h
pkg/src/Rcpp/LogicalVector.h
pkg/src/Rcpp/NumericVector.h
pkg/src/Rcpp/RObject.h
pkg/src/Rcpp/RawVector.h
Log:
make update private virtual in RObject and couple it with setSEXP so that it gets called automatically, instead of manually
Modified: pkg/src/ComplexVector.cpp
===================================================================
--- pkg/src/ComplexVector.cpp 2010-01-20 09:29:48 UTC (rev 414)
+++ pkg/src/ComplexVector.cpp 2010-01-20 13:13:12 UTC (rev 415)
@@ -30,14 +30,12 @@
switch( TYPEOF( x ) ){
case CPLXSXP:
setSEXP( x ) ;
- update() ;
break ;
case REALSXP:
case LGLSXP:
case RAWSXP:
case INTSXP:
setSEXP( Rf_coerceVector( x, CPLXSXP) ) ;
- update() ;
break ;
default:
throw not_compatible( "cannot convert to complex vector" ) ;
@@ -46,7 +44,6 @@
ComplexVector::ComplexVector(int size) : VectorBase(), start(0) {
setSEXP( Rf_allocVector(CPLXSXP, size) ) ;
- update() ;
}
} // namespace
Modified: pkg/src/IntegerVector.cpp
===================================================================
--- pkg/src/IntegerVector.cpp 2010-01-20 09:29:48 UTC (rev 414)
+++ pkg/src/IntegerVector.cpp 2010-01-20 13:13:12 UTC (rev 415)
@@ -29,13 +29,11 @@
switch( TYPEOF( x ) ){
case INTSXP:
setSEXP( x ) ;
- update();
break ;
case REALSXP:
case LGLSXP:
case RAWSXP:
setSEXP( Rf_coerceVector( x, INTSXP) ) ;
- update() ;
break ;
default:
throw not_compatible( "cannot convert to intrger vector" ) ;
@@ -44,7 +42,6 @@
IntegerVector::IntegerVector(int size) : VectorBase(), start(0) {
setSEXP( Rf_allocVector(INTSXP, size) ) ;
- update() ;
}
} // namespace
Modified: pkg/src/LogicalVector.cpp
===================================================================
--- pkg/src/LogicalVector.cpp 2010-01-20 09:29:48 UTC (rev 414)
+++ pkg/src/LogicalVector.cpp 2010-01-20 13:13:12 UTC (rev 415)
@@ -30,13 +30,11 @@
switch( TYPEOF( x ) ){
case LGLSXP:
setSEXP( x ) ;
- update() ;
break ;
case RAWSXP:
case INTSXP:
case REALSXP:
setSEXP( Rf_coerceVector( x, LGLSXP) ) ;
- update();
break ;
default:
throw not_compatible( "cannot convert to intrger vector" ) ;
@@ -45,7 +43,6 @@
LogicalVector::LogicalVector(int size) : VectorBase() {
setSEXP( Rf_allocVector(LGLSXP, size) ) ;
- update() ;
}
} // namespace
Modified: pkg/src/NumericVector.cpp
===================================================================
--- pkg/src/NumericVector.cpp 2010-01-20 09:29:48 UTC (rev 414)
+++ pkg/src/NumericVector.cpp 2010-01-20 13:13:12 UTC (rev 415)
@@ -29,13 +29,11 @@
switch( TYPEOF( x ) ){
case REALSXP:
setSEXP( x ) ;
- update() ;
break ;
case INTSXP:
case LGLSXP:
case RAWSXP:
setSEXP( Rf_coerceVector( x, REALSXP) ) ;
- update() ;
break ;
default:
throw not_compatible( "cannot convert to numeric vector" ) ;
@@ -44,7 +42,6 @@
NumericVector::NumericVector(int size) : VectorBase(), start(0) {
setSEXP( Rf_allocVector(REALSXP, size) ) ;
- update() ;
}
} // namespace
Modified: pkg/src/RObject.cpp
===================================================================
--- pkg/src/RObject.cpp 2010-01-20 09:29:48 UTC (rev 414)
+++ pkg/src/RObject.cpp 2010-01-20 13:13:12 UTC (rev 415)
@@ -40,6 +40,8 @@
/* the new SEXP is not NULL, so preserve it */
preserve() ;
+
+ update() ;
}
}
Modified: pkg/src/Rcpp/ComplexVector.h
===================================================================
--- pkg/src/Rcpp/ComplexVector.h 2010-01-20 09:29:48 UTC (rev 414)
+++ pkg/src/Rcpp/ComplexVector.h 2010-01-20 13:13:12 UTC (rev 415)
@@ -53,7 +53,7 @@
private:
Rcomplex* start ;
- inline void update(){ start = COMPLEX(m_sexp);}
+ virtual void update(){ start = COMPLEX(m_sexp);}
template <typename InputIterator>
void fill( InputIterator first, InputIterator last){
@@ -61,7 +61,6 @@
SEXP x = PROTECT( Rf_allocVector( CPLXSXP, size ) ) ;
std::copy( first, last, COMPLEX(x) ) ;
setSEXP(x) ;
- update() ;
UNPROTECT( 1 ); /* x */
}
} ;
Modified: pkg/src/Rcpp/IntegerVector.h
===================================================================
--- pkg/src/Rcpp/IntegerVector.h 2010-01-20 09:29:48 UTC (rev 414)
+++ pkg/src/Rcpp/IntegerVector.h 2010-01-20 13:13:12 UTC (rev 415)
@@ -56,7 +56,7 @@
private:
int* start ;
- inline void update(){ start = INTEGER(m_sexp) ;}
+ virtual void update(){ start = INTEGER(m_sexp) ;}
// simple is when there is no need for coercion
template <typename InputIterator>
@@ -66,7 +66,6 @@
std::copy( first, last, INTEGER(x) ) ;
setSEXP( x ) ;
UNPROTECT(1) ;
- update() ;
}
// need to coerce to int
@@ -79,7 +78,6 @@
std::copy( first, last, INTEGER(x) ) ;
setSEXP( x ) ;
UNPROTECT(1) ;
- update() ;
}
} ;
Modified: pkg/src/Rcpp/LogicalVector.h
===================================================================
--- pkg/src/Rcpp/LogicalVector.h 2010-01-20 09:29:48 UTC (rev 414)
+++ pkg/src/Rcpp/LogicalVector.h 2010-01-20 13:13:12 UTC (rev 415)
@@ -59,7 +59,7 @@
private:
int* start ;
- inline void update(){ start=LOGICAL(m_sexp); }
+ virtual void update(){ start=LOGICAL(m_sexp); }
// called when there is no need for coercion
template <typename InputIterator>
@@ -68,7 +68,6 @@
SEXP x = PROTECT( Rf_allocVector( LGLSXP, size ) ) ;
std::copy( first, last, LOGICAL(x) );
setSEXP(x) ;
- update() ;
UNPROTECT( 1 ); /* x */
}
@@ -80,7 +79,6 @@
// std::transform( first, last, LOGICAL(x), coerce_to_logical ) ;
std::copy( first, last, LOGICAL(x) );
setSEXP(x) ;
- update() ;
UNPROTECT( 1 ); /* x */
}
Modified: pkg/src/Rcpp/NumericVector.h
===================================================================
--- pkg/src/Rcpp/NumericVector.h 2010-01-20 09:29:48 UTC (rev 414)
+++ pkg/src/Rcpp/NumericVector.h 2010-01-20 13:13:12 UTC (rev 415)
@@ -57,7 +57,7 @@
private:
double *start ;
- inline void update(){ start = REAL(m_sexp);}
+ virtual void update(){ start = REAL(m_sexp);}
// simple is when there is no need for coercion
// called only when the input container contains doubles
@@ -68,7 +68,6 @@
std::copy( first, last, REAL(x) ) ;
setSEXP( x ) ;
UNPROTECT(1) ;
- update() ;
}
// need to coerce to double
@@ -81,7 +80,6 @@
std::copy( first, last, REAL(x) ) ;
setSEXP( x ) ;
UNPROTECT(1) ;
- update() ;
}
Modified: pkg/src/Rcpp/RObject.h
===================================================================
--- pkg/src/Rcpp/RObject.h 2010-01-20 09:29:48 UTC (rev 414)
+++ pkg/src/Rcpp/RObject.h 2010-01-20 13:13:12 UTC (rev 415)
@@ -228,7 +228,7 @@
void preserve(){ if( m_sexp != R_NilValue ) R_PreserveObject(m_sexp) ; }
void release() { if( m_sexp != R_NilValue ) R_ReleaseObject(m_sexp) ; }
-
+ virtual void update() {} ;
};
} // namespace Rcpp
Modified: pkg/src/Rcpp/RawVector.h
===================================================================
--- pkg/src/Rcpp/RawVector.h 2010-01-20 09:29:48 UTC (rev 414)
+++ pkg/src/Rcpp/RawVector.h 2010-01-20 13:13:12 UTC (rev 415)
@@ -56,7 +56,7 @@
private:
Rbyte* start ;
- inline void update(){ start=RAW(m_sexp); }
+ virtual void update(){ start=RAW(m_sexp); }
// simple is when there is no need for coercion
// called only when the input container contains raw bytes
@@ -67,7 +67,6 @@
std::copy( first, last, RAW(x) ) ;
setSEXP( x ) ;
UNPROTECT(1) ;
- update() ;
}
// need to coerce to raw bytes
@@ -80,7 +79,6 @@
std::copy( first, last, RAW(x) ) ;
setSEXP( x ) ;
UNPROTECT(1) ;
- update() ;
}
} ;
More information about the Rcpp-commits
mailing list