Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# cpp11 (development version)

* Fixed an rchk issue related to `std::initializer_list<named_arg>` (#457, @pachadotdev).

# cpp11 0.5.2

* Fixed an issue related to `-Wdeprecated-literal-operator` (#447, @andrjohns).
Expand All @@ -12,7 +14,7 @@
* Because cpp11 now requires R >=4.0.0, a number of previously optional tools
are now always available, allowing us to remove some dead code. In
particular:

* `R_UnwindProtect()` is always available, so the defines `HAS_UNWIND_PROTECT`
and `CPP11_UNWIND` are no longer useful.

Expand Down
7 changes: 4 additions & 3 deletions inst/include/cpp11/list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,9 @@ template <>
inline r_vector<SEXP>::r_vector(std::initializer_list<named_arg> il)
: cpp11::r_vector<SEXP>(safe[Rf_allocVector](VECSXP, il.size())),
capacity_(il.size()) {
unwind_protect([&] {
SEXP names = Rf_allocVector(STRSXP, capacity_);
Rf_setAttrib(data_, R_NamesSymbol, names);
sexp names = safe[Rf_allocVector](STRSXP, capacity_);

unwind_protect([&] {
auto it = il.begin();

for (R_xlen_t i = 0; i < capacity_; ++i, ++it) {
Expand All @@ -92,6 +91,8 @@ inline r_vector<SEXP>::r_vector(std::initializer_list<named_arg> il)
SET_STRING_ELT(names, i, name);
}
});

safe[Rf_setAttrib](data_, R_NamesSymbol, names);
}

typedef r_vector<SEXP> list;
Expand Down
7 changes: 4 additions & 3 deletions inst/include/cpp11/r_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,10 +864,9 @@ inline r_vector<T>::r_vector(std::initializer_list<named_arg> il)
valid_length(value, 1);
}

unwind_protect([&] {
SEXP names = Rf_allocVector(STRSXP, capacity_);
Rf_setAttrib(data_, R_NamesSymbol, names);
sexp names = safe[Rf_allocVector](STRSXP, capacity_);

unwind_protect([&] {
auto it = il.begin();

for (R_xlen_t i = 0; i < capacity_; ++i, ++it) {
Expand All @@ -891,6 +890,8 @@ inline r_vector<T>::r_vector(std::initializer_list<named_arg> il)
SET_STRING_ELT(names, i, name);
}
});

safe[Rf_setAttrib](data_, R_NamesSymbol, names);
}

template <typename T>
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/_snaps/register.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# get_call_entries: returns an empty string for packages with .Call entries and NAMESPACE files
# get_call_entries / returns an empty string for packages with .Call entries and NAMESPACE files

Code
call_entries
Expand All @@ -11,7 +11,7 @@
[6] " {NULL, NULL, 0}"
[7] "};"

# get_call_entries: works with multiple register functions.
# get_call_entries / works with multiple register functions.

Code
cat(read_file(cpp_bindings))
Expand Down Expand Up @@ -60,7 +60,7 @@
R_forceSymbols(dll, TRUE);
}

# cpp_register: works with a package that registers a single c++ function
# cpp_register / works with a package that registers a single c++ function

Code
cat(read_file(r_bindings))
Expand Down Expand Up @@ -104,7 +104,7 @@
R_forceSymbols(dll, TRUE);
}

# cpp_register: can be run with messages
# cpp_register / can be run with messages

Code
cpp_register(p, quiet = FALSE)
Expand Down
Loading