File tree Expand file tree Collapse file tree 1 file changed +11
-16
lines changed Expand file tree Collapse file tree 1 file changed +11
-16
lines changed Original file line number Diff line number Diff line change 9
9
10
10
namespace cpp11 {
11
11
12
- inline integers as_doubles (SEXP x) {
13
- /* if (TYPEOF(x) == REALSXP) {
14
- return as_cpp<doubles>(x);
15
- } else
16
- */
17
- if (TYPEOF (x) == INTSXP) {
12
+ inline doubles as_doubles (SEXP x) {
13
+ if (TYPEOF (x) == REALSXP) {
14
+ return as_cpp<doubles>(x);
15
+ } else if (TYPEOF (x) == INTSXP) {
18
16
integers xn = as_cpp<integers>(x);
19
- return xn;
20
- /*
21
17
R_xlen_t len = xn.size ();
22
18
writable::doubles ret (len);
23
19
for (R_xlen_t i = 0 ; i < len; ++i) {
24
- int el = xn[i];
25
- if (el == NA_INTEGER) {
26
- ret[i] = NA_REAL;
27
- } else {
28
- ret[i] = static_cast<double>(el);
29
- }
20
+ int el = xn[i];
21
+ if (el == NA_INTEGER) {
22
+ ret[i] = NA_REAL;
23
+ } else {
24
+ ret[i] = static_cast <double >(el);
25
+ }
30
26
}
31
27
return ret;
32
- */
33
28
}
34
29
35
30
throw type_error (REALSXP, TYPEOF (x));
@@ -409,7 +404,7 @@ context("doubles-C++") {
409
404
// cpp11::writable::integers na{NA_INTEGER};
410
405
// cpp11::sexp na();
411
406
412
- cpp11::integers na3 (cpp11::as_doubles (Rf_ScalarInteger (NA_INTEGER)));
407
+ cpp11::doubles na3 (cpp11::as_doubles (Rf_ScalarInteger (NA_INTEGER)));
413
408
expect_true (na3.size () == 1 );
414
409
// expect_true(ISNA(na3[0]));
415
410
// expect_true(cpp11::is_na<double>(na3[0]));
You can’t perform that action at this time.
0 commit comments