Skip to content

Commit e3f8692

Browse files
committed
push minor update to gitignore and ChangeLog from a few days ago
2 parents 9ac1aba + 7e0218c commit e3f8692

File tree

5 files changed

+31
-3
lines changed

5 files changed

+31
-3
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2014-05-28 Kevin Ushey <[email protected]>
2+
3+
* inst/include/Rcpp/vector/vector_from_string.h: Protect result of
4+
Rf_mkString
5+
16
2014-05-24 Dirk Eddelbuettel <[email protected]>
27

38
* .Rbuildignore: Add .dir-locals.el

inst/include/Rcpp/vector/ListOf.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ class ListOf {
3131

3232
ListOf(): list(R_NilValue) {}
3333

34-
ListOf(SEXP data_): list(data_) {}
34+
ListOf(SEXP data_): list(data_) {
35+
std::transform(list.begin(), list.end(), list.begin(), as<T>);
36+
}
3537

3638
template <typename U>
37-
ListOf(const U& data_): list(data_) {}
39+
ListOf(const U& data_): list(data_) {
40+
std::transform(list.begin(), list.end(), list.begin(), as<T>);
41+
}
3842

3943
ListOf(const ListOf& other): list(other.list) {}
4044

inst/include/Rcpp/vector/vector_from_string.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ namespace internal{
2727

2828
template <int RTYPE>
2929
inline SEXP vector_from_string( const std::string& st ) {
30-
return r_cast<RTYPE>( Rf_mkString( st.c_str() ) ) ;
30+
Shield<SEXP> str(Rf_mkString(st.c_str()));
31+
return r_cast<RTYPE>(str) ;
3132
}
3233

3334
template <int RTYPE>

inst/unitTests/cpp/ListOf.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,8 @@ int test_sub_calls(NVList x) {
9393
NumericVector test_nested_listof(ListOf< ListOf<NumericVector> > x) {
9494
return x[0][0];
9595
}
96+
97+
// [[Rcpp::export]]
98+
ListOf<IntegerVector> test_return_IVList(List x) {
99+
return x;
100+
}

inst/unitTests/runit.ListOf.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,17 @@ if (.runThisTest) {
7474
)
7575
}
7676

77+
test.ListOf.convert.implicit <- function() {
78+
checkEquals(
79+
test_return_IVList(list(1, 2, 3)),
80+
list(1L, 2L, 3L)
81+
)
82+
}
83+
84+
test.ListOf.convert.fail <- function() {
85+
checkException(
86+
test_return_IVList(list("a", "b", "c"))
87+
)
88+
}
89+
7790
}

0 commit comments

Comments
 (0)