From 6b7865db2bf4c75936b8a44fdaea3fae4bbe378c Mon Sep 17 00:00:00 2001 From: Qiang Kou Date: Tue, 18 Oct 2016 18:32:49 -0400 Subject: [PATCH] Change string_elt/vector_elt to accept R_xlen_t --- ChangeLog | 6 ++++++ inst/include/Rcpp/barrier.h | 12 ++++++------ inst/include/Rcpp/routines.h | 36 ++++++++++++++++++------------------ src/barrier.cpp | 12 ++++++------ 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/ChangeLog b/ChangeLog index 273dc0d80..589a7f3b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-10-21 Qiang Kou + + * inst/include/Rcpp/barrier.h: Change string_elt/vector_elt to accept R_xlen_t + * inst/include/Rcpp/routines.h: Ditto + * src/barrier.cpp: Ditto + 2016-10-19 Dirk Eddelbuettel * inst/include/Rcpp/date_datetime/Datetime.h (Rcpp): Additional diff --git a/inst/include/Rcpp/barrier.h b/inst/include/Rcpp/barrier.h index cd23d3d47..04775bd0a 100644 --- a/inst/include/Rcpp/barrier.h +++ b/inst/include/Rcpp/barrier.h @@ -22,14 +22,14 @@ #ifndef Rcpp__barrier__h #define Rcpp__barrier__h -SEXP get_string_elt(SEXP, int) ; -const char* char_get_string_elt(SEXP, int) ; -void set_string_elt(SEXP, int, SEXP) ; -void char_set_string_elt(SEXP, int, const char*) ; +SEXP get_string_elt(SEXP, R_xlen_t) ; +const char* char_get_string_elt(SEXP, R_xlen_t) ; +void set_string_elt(SEXP, R_xlen_t, SEXP) ; +void char_set_string_elt(SEXP, R_xlen_t, const char*) ; SEXP* get_string_ptr(SEXP) ; -SEXP get_vector_elt(SEXP, int) ; -void set_vector_elt(SEXP, int, SEXP ) ; +SEXP get_vector_elt(SEXP, R_xlen_t) ; +void set_vector_elt(SEXP, R_xlen_t, SEXP ) ; SEXP* get_vector_ptr(SEXP) ; const char* char_nocheck( SEXP ) ; void* dataptr(SEXP) ; diff --git a/inst/include/Rcpp/routines.h b/inst/include/Rcpp/routines.h index 4184e736e..1f89d4f6b 100644 --- a/inst/include/Rcpp/routines.h +++ b/inst/include/Rcpp/routines.h @@ -44,13 +44,13 @@ std::string demangle(const std::string& name); const char* short_file_name(const char* ); int* get_cache(int n); SEXP stack_trace( const char *file, int line); -SEXP get_string_elt(SEXP s, int i); -const char* char_get_string_elt(SEXP s, int i); -void set_string_elt(SEXP s, int i, SEXP v); -void char_set_string_elt(SEXP s, int i, const char* v); +SEXP get_string_elt(SEXP s, R_xlen_t i); +const char* char_get_string_elt(SEXP s, R_xlen_t i); +void set_string_elt(SEXP s, R_xlen_t i, SEXP v); +void char_set_string_elt(SEXP s, R_xlen_t i, const char* v); SEXP* get_string_ptr(SEXP s); -SEXP get_vector_elt(SEXP v, int i); -void set_vector_elt(SEXP v, int i, SEXP x); +SEXP get_vector_elt(SEXP v, R_xlen_t i); +void set_vector_elt(SEXP v, R_xlen_t i, SEXP x); SEXP* get_vector_ptr(SEXP v); const char* char_nocheck(SEXP x); void* dataptr(SEXP x); @@ -149,26 +149,26 @@ inline attribute_hidden SEXP stack_trace( const char *file, int line){ return fun(file, line); } -inline attribute_hidden SEXP get_string_elt(SEXP s, int i){ - typedef SEXP (*Fun)(SEXP, int); +inline attribute_hidden SEXP get_string_elt(SEXP s, R_xlen_t i){ + typedef SEXP (*Fun)(SEXP, R_xlen_t); static Fun fun = GET_CALLABLE("get_string_elt"); return fun(s, i); } -inline attribute_hidden const char* char_get_string_elt(SEXP s, int i){ - typedef const char* (*Fun)(SEXP, int); +inline attribute_hidden const char* char_get_string_elt(SEXP s, R_xlen_t i){ + typedef const char* (*Fun)(SEXP, R_xlen_t); static Fun fun = GET_CALLABLE("char_get_string_elt"); return fun(s, i); } -inline attribute_hidden void set_string_elt(SEXP s, int i, SEXP v){ - typedef void (*Fun)(SEXP,int,SEXP); +inline attribute_hidden void set_string_elt(SEXP s, R_xlen_t i, SEXP v){ + typedef void (*Fun)(SEXP, R_xlen_t, SEXP); static Fun fun = GET_CALLABLE("set_string_elt"); fun(s, i, v); } -inline attribute_hidden void char_set_string_elt(SEXP s, int i, const char* v){ - typedef void (*Fun)(SEXP,int, const char*); +inline attribute_hidden void char_set_string_elt(SEXP s, R_xlen_t i, const char* v){ + typedef void (*Fun)(SEXP, R_xlen_t, const char*); static Fun fun = GET_CALLABLE("char_set_string_elt"); fun(s, i, v ); } @@ -179,14 +179,14 @@ inline attribute_hidden SEXP* get_string_ptr(SEXP s){ return fun(s); } -inline attribute_hidden SEXP get_vector_elt(SEXP v, int i){ - typedef SEXP (*Fun)(SEXP, int ); +inline attribute_hidden SEXP get_vector_elt(SEXP v, R_xlen_t i){ + typedef SEXP (*Fun)(SEXP, R_xlen_t); static Fun fun = GET_CALLABLE("get_vector_elt"); return fun(v, i); } -inline attribute_hidden void set_vector_elt(SEXP v, int i, SEXP x){ - typedef void (*Fun)(SEXP, int, SEXP); +inline attribute_hidden void set_vector_elt(SEXP v, R_xlen_t i, SEXP x){ + typedef void (*Fun)(SEXP, R_xlen_t, SEXP); static Fun fun = GET_CALLABLE("set_vector_elt"); fun(v, i, x); } diff --git a/src/barrier.cpp b/src/barrier.cpp index 0d65ee2a7..8f0f49fe1 100644 --- a/src/barrier.cpp +++ b/src/barrier.cpp @@ -31,22 +31,22 @@ namespace Rcpp { SEXP Rcpp_eval(SEXP, SEXP); } // [[Rcpp::register]] -SEXP get_string_elt(SEXP x, int i) { +SEXP get_string_elt(SEXP x, R_xlen_t i) { return STRING_ELT(x, i); } // [[Rcpp::register]] -const char* char_get_string_elt(SEXP x, int i) { +const char* char_get_string_elt(SEXP x, R_xlen_t i) { return CHAR(STRING_ELT(x, i)); } // [[Rcpp::register]] -void set_string_elt(SEXP x, int i, SEXP value) { +void set_string_elt(SEXP x, R_xlen_t i, SEXP value) { SET_STRING_ELT(x, i, value); } // [[Rcpp::register]] -void char_set_string_elt(SEXP x, int i, const char* value) { +void char_set_string_elt(SEXP x, R_xlen_t i, const char* value) { SET_STRING_ELT(x, i, Rf_mkChar(value)); } @@ -56,12 +56,12 @@ SEXP* get_string_ptr(SEXP x) { } // [[Rcpp::register]] -SEXP get_vector_elt(SEXP x, int i) { +SEXP get_vector_elt(SEXP x, R_xlen_t i) { return VECTOR_ELT(x, i); } // [[Rcpp::register]] -void set_vector_elt(SEXP x, int i, SEXP value) { +void set_vector_elt(SEXP x, R_xlen_t i, SEXP value) { SET_VECTOR_ELT(x, i, value); }