Skip to content

Commit

Permalink
Do some obvious cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisVaughan committed Aug 9, 2024
1 parent 6548717 commit dccd4f6
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 30 deletions.
9 changes: 4 additions & 5 deletions inst/include/cpp11/doubles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ inline typename r_vector<double>::underlying_type* r_vector<double>::get_p(bool
}

template <>
inline void r_vector<double>::get_region(
SEXP x, R_xlen_t i, R_xlen_t n,
typename traits::get_underlying_type<double>::type* buf) {
inline void r_vector<double>::get_region(SEXP x, R_xlen_t i, R_xlen_t n,
typename r_vector::underlying_type* buf) {
// NOPROTECT: likely too costly to unwind protect here
REAL_GET_REGION(x, i, n, buf);
};
Expand All @@ -66,8 +65,8 @@ inline SEXPTYPE r_vector<double>::get_sexptype() {
}

template <>
inline void r_vector<double>::set_elt(
SEXP x, R_xlen_t i, typename traits::get_underlying_type<double>::type value) {
inline void r_vector<double>::set_elt(SEXP x, R_xlen_t i,
typename r_vector::underlying_type value) {
SET_REAL_ELT(x, i, value);
}

Expand Down
9 changes: 4 additions & 5 deletions inst/include/cpp11/integers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ inline typename r_vector<int>::underlying_type* r_vector<int>::get_p(bool is_alt
}

template <>
inline void r_vector<int>::get_region(
SEXP x, R_xlen_t i, R_xlen_t n,
typename traits::get_underlying_type<int>::type* buf) {
inline void r_vector<int>::get_region(SEXP x, R_xlen_t i, R_xlen_t n,
typename r_vector::underlying_type* buf) {
// NOPROTECT: likely too costly to unwind protect here
INTEGER_GET_REGION(x, i, n, buf);
};
Expand All @@ -67,8 +66,8 @@ inline SEXPTYPE r_vector<int>::get_sexptype() {
}

template <>
inline void r_vector<int>::set_elt(
SEXP x, R_xlen_t i, typename traits::get_underlying_type<int>::type value) {
inline void r_vector<int>::set_elt(SEXP x, R_xlen_t i,
typename r_vector::underlying_type value) {
SET_INTEGER_ELT(x, i, value);
}

Expand Down
9 changes: 4 additions & 5 deletions inst/include/cpp11/list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ inline typename r_vector<SEXP>::underlying_type* r_vector<SEXP>::get_p(bool, SEX
}

template <>
inline void r_vector<SEXP>::get_region(
SEXP x, R_xlen_t i, R_xlen_t n,
typename traits::get_underlying_type<SEXP>::type* buf) {
inline void r_vector<SEXP>::get_region(SEXP x, R_xlen_t i, R_xlen_t n,
typename r_vector::underlying_type* buf) {
cpp11::stop("Unreachable!");
};

Expand All @@ -76,8 +75,8 @@ inline SEXPTYPE r_vector<SEXP>::get_sexptype() {
}

template <>
inline void r_vector<SEXP>::set_elt(
SEXP x, R_xlen_t i, typename traits::get_underlying_type<SEXP>::type value) {
inline void r_vector<SEXP>::set_elt(SEXP x, R_xlen_t i,
typename r_vector::underlying_type value) {
SET_VECTOR_ELT(x, i, value);
}

Expand Down
9 changes: 4 additions & 5 deletions inst/include/cpp11/logicals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ inline typename r_vector<r_bool>::underlying_type* r_vector<r_bool>::get_p(bool
}

template <>
inline void r_vector<r_bool>::get_region(
SEXP x, R_xlen_t i, R_xlen_t n,
typename traits::get_underlying_type<r_bool>::type* buf) {
inline void r_vector<r_bool>::get_region(SEXP x, R_xlen_t i, R_xlen_t n,
typename r_vector::underlying_type* buf) {
// NOPROTECT: likely too costly to unwind protect here
LOGICAL_GET_REGION(x, i, n, buf);
};
Expand All @@ -65,8 +64,8 @@ inline SEXPTYPE r_vector<r_bool>::get_sexptype() {
}

template <>
inline void r_vector<r_bool>::set_elt(
SEXP x, R_xlen_t i, typename traits::get_underlying_type<r_bool>::type value) {
inline void r_vector<r_bool>::set_elt(SEXP x, R_xlen_t i,
typename r_vector::underlying_type value) {
SET_LOGICAL_ELT(x, i, value);
}

Expand Down
9 changes: 4 additions & 5 deletions inst/include/cpp11/raws.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ inline typename r_vector<uint8_t>::underlying_type* r_vector<uint8_t>::get_p(
}

template <>
inline void r_vector<uint8_t>::get_region(
SEXP x, R_xlen_t i, R_xlen_t n,
typename traits::get_underlying_type<uint8_t>::type* buf) {
inline void r_vector<uint8_t>::get_region(SEXP x, R_xlen_t i, R_xlen_t n,
typename r_vector::underlying_type* buf) {
// NOPROTECT: likely too costly to unwind protect here
RAW_GET_REGION(x, i, n, buf);
};
Expand All @@ -74,8 +73,8 @@ inline SEXPTYPE r_vector<uint8_t>::get_sexptype() {
}

template <>
inline void r_vector<uint8_t>::set_elt(
SEXP x, R_xlen_t i, typename traits::get_underlying_type<uint8_t>::type value) {
inline void r_vector<uint8_t>::set_elt(SEXP x, R_xlen_t i,
typename r_vector::underlying_type value) {
#if R_VERSION >= R_Version(4, 2, 0)
SET_RAW_ELT(x, i, value);
#else
Expand Down
9 changes: 4 additions & 5 deletions inst/include/cpp11/strings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ inline typename r_vector<r_string>::underlying_type* r_vector<r_string>::get_p(b
}

template <>
inline void r_vector<r_string>::get_region(
SEXP x, R_xlen_t i, R_xlen_t n,
typename traits::get_underlying_type<r_string>::type* buf) {
inline void r_vector<r_string>::get_region(SEXP x, R_xlen_t i, R_xlen_t n,
typename r_vector::underlying_type* buf) {
cpp11::stop("Unreachable!");
};

Expand All @@ -66,8 +65,8 @@ inline SEXPTYPE r_vector<r_string>::get_sexptype() {
}

template <>
inline void r_vector<r_string>::set_elt(
SEXP x, R_xlen_t i, typename traits::get_underlying_type<r_string>::type value) {
inline void r_vector<r_string>::set_elt(SEXP x, R_xlen_t i,
typename r_vector::underlying_type value) {
SET_STRING_ELT(x, i, value);
}

Expand Down

0 comments on commit dccd4f6

Please sign in to comment.