[Rcpp-commits] r590 - in pkg: inst src src/Rcpp
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Feb 6 11:29:05 CET 2010
Author: romain
Date: 2010-02-06 11:29:03 +0100 (Sat, 06 Feb 2010)
New Revision: 590
Modified:
pkg/inst/ChangeLog
pkg/src/DottedPair.cpp
pkg/src/Rcpp/DottedPair.h
pkg/src/Rcpp/VectorBase.h
pkg/src/VectorBase.cpp
pkg/src/as.cpp
Log:
using R_len_t instead of int when dealing with length of vectors, etc ... to anticipate future changes in R
Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog 2010-02-06 08:58:07 UTC (rev 589)
+++ pkg/inst/ChangeLog 2010-02-06 10:29:03 UTC (rev 590)
@@ -1,5 +1,12 @@
2010-02-06 Romain Francois <francoisromain at free.fr>
+ * src/Rcpp/DottedPair.h : using R_len_t instead of int
+ to anticipate future changes in R
+ * src/Rcpp/VectorBase.h: idem
+ * src/DottedPair.cpp: idem
+ * src/VectorBase.cpp: idem
+ * src/as.cpp: idem
+
* src/Rcpp/SimpleVector.h: SimpleVector is now only parameterized
by the SEXP type. The c type is automatically retrieved using
the storage_type trait class.
Modified: pkg/src/DottedPair.cpp
===================================================================
--- pkg/src/DottedPair.cpp 2010-02-06 08:58:07 UTC (rev 589)
+++ pkg/src/DottedPair.cpp 2010-02-06 10:29:03 UTC (rev 590)
@@ -27,7 +27,7 @@
DottedPair::DottedPair() : RObject(){}
void DottedPair::remove( const size_t& index ) throw(index_out_of_bounds) {
- if( index < 0 || index >= static_cast<size_t>(Rf_length(m_sexp)) ) throw index_out_of_bounds() ;
+ if( static_cast<R_len_t>(index) >= Rf_length(m_sexp) ) throw index_out_of_bounds() ;
if( index == 0 ){
setSEXP( CDR( m_sexp) ) ;
} else{
@@ -39,7 +39,7 @@
}
DottedPair::Proxy::Proxy( DottedPair& v, const size_t& index_ ) throw(index_out_of_bounds) : node(){
- if( index_ >= v.length() ) throw index_out_of_bounds() ;
+ if( static_cast<R_len_t>(index_) >= v.length() ) throw index_out_of_bounds() ;
SEXP x = v ; /* implicit conversion */
size_t i = 0 ;
while( i<index_) {
Modified: pkg/src/Rcpp/DottedPair.h
===================================================================
--- pkg/src/Rcpp/DottedPair.h 2010-02-06 08:58:07 UTC (rev 589)
+++ pkg/src/Rcpp/DottedPair.h 2010-02-06 10:29:03 UTC (rev 590)
@@ -107,16 +107,16 @@
* @param object object to wrap
*/
template <typename T>
- void insert( const int& index, const T& object) throw(index_out_of_bounds) {
+ void insert( const size_t& index, const T& object) throw(index_out_of_bounds) {
if( index == 0 ) {
push_front( object ) ;
} else{
if( index < 0 ) throw index_out_of_bounds() ;
if( isNULL( ) ) throw index_out_of_bounds() ;
- if( index < 0 || index > ::Rf_length(m_sexp) ) throw index_out_of_bounds() ;
+ if( static_cast<R_len_t>(index) > ::Rf_length(m_sexp) ) throw index_out_of_bounds() ;
- int i=1;
+ size_t i=1;
SEXP x = m_sexp ;
while( i < index ){
x = CDR(x) ;
@@ -136,7 +136,7 @@
*/
template <typename T>
void replace( const int& index, const T& object ) throw(index_out_of_bounds){
- if( index < 0 || index >= ::Rf_length(m_sexp) ) throw index_out_of_bounds() ;
+ if( static_cast<R_len_t>(index) >= ::Rf_length(m_sexp) ) throw index_out_of_bounds() ;
/* pretend we do a pairlist so that we get Named to work for us */
SEXP x = PROTECT(pairlist( object ));
@@ -149,8 +149,8 @@
UNPROTECT(1) ;
}
- inline size_t length() const { return ::Rf_length(m_sexp) ; }
- inline size_t size() const { return ::Rf_length(m_sexp) ; }
+ inline R_len_t length() const { return ::Rf_length(m_sexp) ; }
+ inline R_len_t size() const { return ::Rf_length(m_sexp) ; }
/**
* Remove the element at the given position
Modified: pkg/src/Rcpp/VectorBase.h
===================================================================
--- pkg/src/Rcpp/VectorBase.h 2010-02-06 08:58:07 UTC (rev 589)
+++ pkg/src/Rcpp/VectorBase.h 2010-02-06 10:29:03 UTC (rev 590)
@@ -43,12 +43,12 @@
/**
* the length of the vector, uses Rf_length
*/
- inline int length() const { return ::Rf_length( m_sexp ) ; }
+ inline R_len_t length() const { return ::Rf_length( m_sexp ) ; }
/**
* alias of length
*/
- inline int size() const { return ::Rf_length( m_sexp ) ; }
+ inline R_len_t size() const { return ::Rf_length( m_sexp ) ; }
/**
* offset based on the dimensions of this vector
Modified: pkg/src/VectorBase.cpp
===================================================================
--- pkg/src/VectorBase.cpp 2010-02-06 08:58:07 UTC (rev 589)
+++ pkg/src/VectorBase.cpp 2010-02-06 10:29:03 UTC (rev 590)
@@ -38,7 +38,7 @@
}
size_t VectorBase::offset(const size_t& i) const throw(RObject::index_out_of_bounds){
- if( i >= static_cast<size_t>(Rf_length(m_sexp)) ) throw RObject::index_out_of_bounds() ;
+ if( static_cast<R_len_t>(i) >= Rf_length(m_sexp) ) throw RObject::index_out_of_bounds() ;
return i ;
}
Modified: pkg/src/as.cpp
===================================================================
--- pkg/src/as.cpp 2010-02-06 08:58:07 UTC (rev 589)
+++ pkg/src/as.cpp 2010-02-06 10:29:03 UTC (rev 590)
@@ -110,7 +110,7 @@
}
template<> std::vector<bool> as< std::vector<bool> >(SEXP m_sexp) {
- int n = Rf_length(m_sexp);
+ R_len_t n = Rf_length(m_sexp);
std::vector<bool> v(n);
switch( TYPEOF(m_sexp) ){
case LGLSXP:
@@ -133,7 +133,7 @@
template<> std::vector<int> as< std::vector<int> >(SEXP m_sexp){
- int n = Rf_length(m_sexp);
+ R_len_t n = Rf_length(m_sexp);
std::vector<int> v(n);
switch( TYPEOF(m_sexp) ){
case INTSXP:
@@ -155,7 +155,7 @@
}
template<> std::vector<Rbyte> as< std::vector<Rbyte> >(SEXP m_sexp) {
- int n = Rf_length(m_sexp);
+ R_len_t n = Rf_length(m_sexp);
std::vector<Rbyte> v(n);
switch( TYPEOF(m_sexp) ){
case LGLSXP:
@@ -177,7 +177,7 @@
}
template<> std::vector<double> as< std::vector<double> >(SEXP m_sexp){
- int n = Rf_length(m_sexp);
+ R_len_t n = Rf_length(m_sexp);
std::vector<double> v(n);
switch( TYPEOF(m_sexp) ){
case LGLSXP:
@@ -200,7 +200,7 @@
template<> std::vector<std::string> as< std::vector<std::string> >(SEXP m_sexp){
- int n = Rf_length(m_sexp);
+ R_len_t n = Rf_length(m_sexp);
std::vector<std::string> v(n);
if (!Rf_isString(m_sexp)) {
throw std::range_error("as< vector<string> >: expects string");
More information about the Rcpp-commits
mailing list