Skip to content

Commit b766732

Browse files
higher level impl of wrap(map)
1 parent 1aebad8 commit b766732

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

inst/include/Rcpp/api/meat/wrap.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ inline SEXP range_wrap_dispatch___impl__pair( InputIterator first, InputIterator
3131
size_t size = std::distance( first, last ) ;
3232
typedef typename Rcpp::traits::storage_type<RTYPE>::type STORAGE ;
3333

34-
Shield<SEXP> names( Rf_allocVector(STRSXP, size) ) ;
35-
Shield<SEXP> x( Rf_allocVector(RTYPE, size) ) ;
36-
STORAGE* ptr = Rcpp::internal::r_vector_start<RTYPE>( x ) ;
34+
CharacterVector names(size) ;
35+
Vector<RTYPE> x(size) ;
3736
Rcpp::String buffer ;
3837
for( size_t i = 0; i < size ; i++, ++first){
39-
buffer = first->first ;
40-
ptr[i] = first->second ;
41-
SET_STRING_ELT( names, i, buffer.get_sexp() ) ;
38+
buffer = first->first ;
39+
x[i] = first->second ;
40+
names[i] = buffer ;
4241
}
43-
::Rf_setAttrib( x, R_NamesSymbol, names) ;
42+
x.attr( "names" ) = names ;
4443
return x ;
4544
}
4645

inst/unitTests/runTests.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if (require("RUnit", quietly = TRUE)) {
4444

4545
## Define tests
4646
testSuite <- defineTestSuite(name=paste(pkg, "unit testing"), dirs = path
47-
# , testFileRegexp = "Vector"
47+
, testFileRegexp = "wrap"
4848
)
4949

5050
## TODO: actually prioritize which ones we want

inst/unitTests/runit.wrap.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,13 @@ test.wrap.map.int.double <- function(){
151151
)
152152
}
153153

154-
# test.wrap.map.double.double <- function(){
155-
# checkEquals(
156-
# map_double_double(),
157-
# c("0" = 2, "1.2" = 3 ),
158-
# msg = "std::map<double,double>"
159-
# )
160-
# }
154+
test.wrap.map.double.double <- function(){
155+
checkEquals(
156+
map_double_double(),
157+
c("0" = 2, "1.2" = 3 ),
158+
msg = "std::map<double,double>"
159+
)
160+
}
161161

162162
test.wrap.map.int.vector_double <- function(){
163163
checkEquals(

0 commit comments

Comments
 (0)