Skip to content

Commit

Permalink
Add VECTOR_PTR_RO for consistency with STRING_PTR_RO.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@86694 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
luke committed Jun 5, 2024
1 parent 640573e commit d499fab
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/include/Defn.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ typedef union { VECTOR_SEXPREC s; double align; } SEXPREC_ALIGN;
#define COMPLEX_RO(x) ((const Rcomplex *) DATAPTR_RO(x))
#define REAL_RO(x) ((const double *) DATAPTR_RO(x))
#define STRING_PTR_RO(x)((const SEXP *) DATAPTR_RO(x))
#define VECTOR_PTR_RO(x)((const SEXP *) DATAPTR_RO(x))

/* List Access Macros */
/* These also work for ... objects */
Expand Down
1 change: 1 addition & 0 deletions src/include/Rinternals.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ void SET_STRING_ELT(SEXP x, R_xlen_t i, SEXP v);
SEXP SET_VECTOR_ELT(SEXP x, R_xlen_t i, SEXP v);
SEXP *(STRING_PTR)(SEXP x);
const SEXP *(STRING_PTR_RO)(SEXP x);
const SEXP *(VECTOR_PTR_RO)(SEXP x);
NORET SEXP * (VECTOR_PTR)(SEXP x);

R_xlen_t INTEGER_GET_REGION(SEXP sx, R_xlen_t i, R_xlen_t n, int *buf);
Expand Down
8 changes: 8 additions & 0 deletions src/main/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -4216,6 +4216,14 @@ NORET SEXP * (VECTOR_PTR)(SEXP x)
error(_("not safe to return vector pointer"));
}

const SEXP *(VECTOR_PTR_RO)(SEXP x) {
if(TYPEOF(x) != VECSXP)
error("%s() can only be applied to a '%s', not a '%s'",
"STRING_PTR_RO", "list", R_typeToChar(x));
CHKZLN(x);
return VECTOR_PTR_RO(x);
}

void (SET_STRING_ELT)(SEXP x, R_xlen_t i, SEXP v) {
if(TYPEOF(CHK(x)) != STRSXP)
error("%s() can only be applied to a '%s', not a '%s'",
Expand Down

0 comments on commit d499fab

Please sign in to comment.