Skip to content

Commit 18f4b8a

Browse files
committed
Merge branch 'master' of https://github.com/thirdwing/Rcpp into feature/r_xlen_t-vector-length
2 parents 0a43747 + f617e37 commit 18f4b8a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+678
-545
lines changed

inst/include/Rcpp/Benchmark/Timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ namespace Rcpp{
110110
}
111111

112112
operator SEXP() const {
113-
size_t n = data.size();
113+
R_xlen_t n = data.size();
114114
NumericVector out(n);
115115
CharacterVector names(n);
116116
for (size_t i=0; i<n; i++) {

inst/include/Rcpp/DataFrame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ namespace Rcpp{
103103
bool use_default_strings_as_factors = true ;
104104
bool strings_as_factors = true ;
105105
int strings_as_factors_index = -1 ;
106-
int n = obj.size() ;
106+
R_xlen_t n = obj.size() ;
107107
CharacterVector names = obj.attr( "names" ) ;
108108
if( !names.isNULL() ){
109109
for( int i=0; i<n; i++){

inst/include/Rcpp/DottedPairImpl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ namespace Rcpp{
6363
template <typename T>
6464
void replace( const int& index, const T& object ) ;
6565

66-
inline R_len_t length() const {
67-
return ::Rf_length(static_cast<const CLASS&>(*this).get__()) ;
66+
inline R_xlen_t length() const {
67+
return ::Rf_xlength(static_cast<const CLASS&>(*this).get__()) ;
6868
}
6969

70-
inline R_len_t size() const {
71-
return ::Rf_length(static_cast<const CLASS&>(*this).get__()) ;
70+
inline R_xlen_t size() const {
71+
return ::Rf_xlength(static_cast<const CLASS&>(*this).get__()) ;
7272
}
7373

7474
/**

inst/include/Rcpp/Fast.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ class Fast {
3030

3131
Fast( const VECTOR& v_) : v(v_), data( v_.begin() ){}
3232

33-
inline value_type& operator[]( int i){ return data[i] ; }
34-
inline const value_type& operator[]( int i) const { return data[i] ; }
35-
inline int size() const { return v.size() ; }
33+
inline value_type& operator[]( R_xlen_t i){ return data[i] ; }
34+
inline const value_type& operator[]( R_xlen_t i) const { return data[i] ; }
35+
inline R_xlen_t size() const { return v.size() ; }
3636

3737
private:
3838
const VECTOR& v ;

inst/include/Rcpp/Language.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ namespace Rcpp{
180180
class unary_call : public std::unary_function<T,RESULT_TYPE> {
181181
public:
182182
unary_call( Language call_ ) : call(call_), proxy(call_,1) {}
183-
unary_call( Language call_, int index ) : call(call_), proxy(call_,index){}
183+
unary_call( Language call_, R_xlen_t index ) : call(call_), proxy(call_,index){}
184184
unary_call( Function fun ) : call( fun, R_NilValue), proxy(call,1) {}
185185

186186
RESULT_TYPE operator()( const T& object ){
@@ -197,7 +197,7 @@ namespace Rcpp{
197197
class binary_call : public std::binary_function<T1,T2,RESULT_TYPE> {
198198
public:
199199
binary_call( Language call_ ) : call(call_), proxy1(call_,1), proxy2(call_,2) {}
200-
binary_call( Language call_, int index1, int index2 ) : call(call_), proxy1(call_,index1), proxy2(call_,index2){}
200+
binary_call( Language call_, R_xlen_t index1, R_xlen_t index2 ) : call(call_), proxy1(call_,index1), proxy2(call_,index2){}
201201
binary_call( Function fun) : call(fun, R_NilValue, R_NilValue), proxy1(call,1), proxy2(call,2){}
202202

203203
RESULT_TYPE operator()( const T1& o1, const T2& o2 ){

inst/include/Rcpp/api/meat/DottedPairImpl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace Rcpp{
5353
} else {
5454
if( ref.isNULL( ) ) throw index_out_of_bounds() ;
5555

56-
if( static_cast<R_len_t>(index) > ::Rf_length(ref.get__()) ) throw index_out_of_bounds() ;
56+
if( static_cast<R_xlen_t>(index) > ::Rf_xlength(ref.get__()) ) throw index_out_of_bounds() ;
5757

5858
size_t i=1;
5959
SEXP x = ref.get__() ;
@@ -70,7 +70,7 @@ namespace Rcpp{
7070
template <typename T>
7171
void DottedPairImpl<CLASS>::replace( const int& index, const T& object ) {
7272
CLASS& ref = static_cast<CLASS&>(*this) ;
73-
if( static_cast<R_len_t>(index) >= ::Rf_length(ref.get__()) ) throw index_out_of_bounds() ;
73+
if( static_cast<R_xlen_t>(index) >= ::Rf_xlength(ref.get__()) ) throw index_out_of_bounds() ;
7474

7575
Shield<SEXP> x( pairlist( object ) );
7676
SEXP y = ref.get__() ;
@@ -84,7 +84,7 @@ namespace Rcpp{
8484
template <typename CLASS>
8585
void DottedPairImpl<CLASS>::remove( const size_t& index ) {
8686
CLASS& ref = static_cast<CLASS&>(*this) ;
87-
if( static_cast<R_len_t>(index) >= Rf_length(ref.get__()) ) throw index_out_of_bounds() ;
87+
if( static_cast<R_xlen_t>(index) >= Rf_xlength(ref.get__()) ) throw index_out_of_bounds() ;
8888
if( index == 0 ){
8989
ref.set__( CDR( ref.get__() ) ) ;
9090
} else{

inst/include/Rcpp/api/meat/export.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ namespace internal{
2727

2828
template <typename InputIterator, typename value_type>
2929
void export_range__dispatch( SEXP x, InputIterator first, ::Rcpp::traits::r_type_generic_tag ) {
30-
R_len_t n = ::Rf_length(x) ;
31-
for( R_len_t i=0; i<n; i++, ++first ){
30+
R_xlen_t n = ::Rf_xlength(x) ;
31+
for( R_xlen_t i=0; i<n; i++, ++first ){
3232
*first = ::Rcpp::as<value_type>( VECTOR_ELT(x, i) ) ;
3333
}
3434
}
@@ -49,9 +49,9 @@ namespace internal{
4949
Container get(){
5050
if( TYPEOF(object) == RTYPE ){
5151
T* start = Rcpp::internal::r_vector_start<RTYPE>(object) ;
52-
return Container( start, start + Rf_length(object) ) ;
52+
return Container( start, start + Rf_xlength(object) ) ;
5353
}
54-
Container vec( ::Rf_length(object) );
54+
Container vec( ::Rf_xlength(object) );
5555
::Rcpp::internal::export_range( object, vec.begin() ) ;
5656
return vec ;
5757
}

inst/include/Rcpp/api/meat/wrap.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ namespace internal{
2828
template <typename InputIterator, typename KEY, typename VALUE, int RTYPE>
2929
inline SEXP range_wrap_dispatch___impl__pair( InputIterator first, InputIterator last, Rcpp::traits::true_type ){
3030
RCPP_DEBUG_3( "range_wrap_dispatch___impl__pair<KEY = %s, VALUE = %s, RTYPE = %d>\n", DEMANGLE(KEY), DEMANGLE(VALUE), RTYPE)
31-
size_t size = std::distance( first, last ) ;
31+
R_xlen_t size = std::distance( first, last ) ;
3232
//typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
3333

3434
CharacterVector names(size) ;
3535
Vector<RTYPE> x(size) ;
3636
Rcpp::String buffer ;
37-
for( size_t i = 0; i < size ; i++, ++first){
37+
for( R_xlen_t i = 0; i < size ; i++, ++first){
3838
buffer = first->first ;
3939
x[i] = first->second ;
4040
names[i] = buffer ;
@@ -45,12 +45,12 @@ inline SEXP range_wrap_dispatch___impl__pair( InputIterator first, InputIterator
4545

4646
template <typename InputIterator, typename KEY, typename VALUE, int RTYPE>
4747
inline SEXP range_wrap_dispatch___impl__pair( InputIterator first, InputIterator last, Rcpp::traits::false_type ){
48-
size_t size = std::distance( first, last ) ;
48+
R_xlen_t size = std::distance( first, last ) ;
4949

5050
Shield<SEXP> names( Rf_allocVector(STRSXP, size) ) ;
5151
Shield<SEXP> x( Rf_allocVector(VECSXP, size) ) ;
5252
Rcpp::String buffer ;
53-
for( size_t i = 0; i < size ; i++, ++first){
53+
for( R_xlen_t i = 0; i < size ; i++, ++first){
5454
buffer = first->first ;
5555
SET_VECTOR_ELT( x, i, Rcpp::wrap(first->second) );
5656
SET_STRING_ELT( names, i, buffer.get_sexp() ) ;

inst/include/Rcpp/internal/Proxy_Iterator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class Proxy_Iterator {
112112

113113
inline int index() const { return proxy.index ; }
114114

115-
inline PROXY operator[](int i){ return PROXY(*proxy.parent, proxy.index + i) ; }
115+
inline PROXY operator[](R_xlen_t i){ return PROXY(*proxy.parent, proxy.index + i) ; }
116116

117117
private:
118118
PROXY proxy ;

inst/include/Rcpp/internal/export.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ namespace Rcpp{
2828

2929

3030
template <typename T>
31-
std::wstring as_string_elt__impl( SEXP x, R_len_t i, Rcpp::traits::true_type ){
31+
std::wstring as_string_elt__impl( SEXP x, R_xlen_t i, Rcpp::traits::true_type ){
3232
const char* y = char_get_string_elt( x, i ) ;
3333
return std::wstring(y, y+strlen(y) ) ;
3434
}
3535

3636
template <typename T>
37-
std::string as_string_elt__impl( SEXP x, R_len_t i, Rcpp::traits::false_type ){
37+
std::string as_string_elt__impl( SEXP x, R_xlen_t i, Rcpp::traits::false_type ){
3838
return char_get_string_elt( x, i ) ;
3939
}
4040

4141
template <typename T>
4242
const std::basic_string< typename Rcpp::traits::char_type<T>::type >
43-
as_string_elt( SEXP x, R_len_t i ){
43+
as_string_elt( SEXP x, R_xlen_t i ){
4444
return as_string_elt__impl<T>( x, i, typename Rcpp::traits::is_wide_string<T>::type() ) ;
4545
}
4646

@@ -52,7 +52,7 @@ namespace Rcpp{
5252
typedef typename ::Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
5353
Shield<SEXP> y( ::Rcpp::r_cast<RTYPE>(x) ) ;
5454
STORAGE* start = ::Rcpp::internal::r_vector_start<RTYPE>(y) ;
55-
std::copy( start, start + ::Rf_length(y), first ) ;
55+
std::copy( start, start + ::Rf_xlength(y), first ) ;
5656
}
5757

5858
template <typename InputIterator, typename value_type>
@@ -61,7 +61,7 @@ namespace Rcpp{
6161
typedef typename ::Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
6262
Shield<SEXP> y( ::Rcpp::r_cast<RTYPE>(x) ) ;
6363
STORAGE* start = ::Rcpp::internal::r_vector_start<RTYPE>(y) ;
64-
std::transform( start, start + ::Rf_length(y) , first, caster<STORAGE,value_type> ) ;
64+
std::transform( start, start + ::Rf_xlength(y) , first, caster<STORAGE,value_type> ) ;
6565
}
6666

6767
// implemented in meat
@@ -80,8 +80,8 @@ namespace Rcpp{
8080
template <typename InputIterator, typename value_type>
8181
void export_range__dispatch( SEXP x, InputIterator first, ::Rcpp::traits::r_type_string_tag ) {
8282
if( ! ::Rf_isString( x) ) throw ::Rcpp::not_compatible( "expecting a string vector" ) ;
83-
R_len_t n = ::Rf_length(x) ;
84-
for( R_len_t i=0; i<n; i++, ++first ){
83+
R_xlen_t n = ::Rf_xlength(x) ;
84+
for( R_xlen_t i=0; i<n; i++, ++first ){
8585
*first = as_string_elt<typename std::iterator_traits<InputIterator>::value_type> ( x, i ) ;
8686
}
8787
}
@@ -104,8 +104,8 @@ namespace Rcpp{
104104
typedef typename ::Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
105105
Shield<SEXP> y( ::Rcpp::r_cast<RTYPE>(x) ) ;
106106
STORAGE* start = ::Rcpp::internal::r_vector_start<RTYPE>(y) ;
107-
R_len_t size = ::Rf_length(y) ;
108-
for( R_len_t i=0; i<size; i++){
107+
R_xlen_t size = ::Rf_xlength(y) ;
108+
for( R_xlen_t i=0; i<size; i++){
109109
res[i] = start[i] ;
110110
}
111111
}
@@ -116,8 +116,8 @@ namespace Rcpp{
116116
typedef typename ::Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
117117
Shield<SEXP> y( ::Rcpp::r_cast<RTYPE>(x) );
118118
STORAGE* start = ::Rcpp::internal::r_vector_start<RTYPE>(y) ;
119-
R_len_t size = ::Rf_length(y) ;
120-
for( R_len_t i=0; i<size; i++){
119+
R_xlen_t size = ::Rf_xlength(y) ;
120+
for( R_xlen_t i=0; i<size; i++){
121121
res[i] = caster<STORAGE,value_type>(start[i]) ;
122122
}
123123
}
@@ -134,8 +134,8 @@ namespace Rcpp{
134134
template <typename T, typename value_type>
135135
void export_indexing__dispatch( SEXP x, T& res, ::Rcpp::traits::r_type_string_tag ) {
136136
if( ! ::Rf_isString( x) ) throw Rcpp::not_compatible( "expecting a string vector" ) ;
137-
R_len_t n = ::Rf_length(x) ;
138-
for( R_len_t i=0; i<n; i++ ){
137+
R_xlen_t n = ::Rf_xlength(x) ;
138+
for( R_xlen_t i=0; i<n; i++ ){
139139
res[i] = as_string_elt< value_type >( x, i) ;
140140
}
141141
}

0 commit comments

Comments
 (0)