Skip to content

rework is_na() #318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 54 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
e8c9dc0
include integers.hpp before doubles.hpp
romainfrancois May 17, 2023
03dc96b
Revert "include integers.hpp before doubles.hpp"
romainfrancois May 17, 2023
eff355b
integers.hpp includes doubles.hpp, for is_na<double>
romainfrancois May 17, 2023
cc6174d
move doubles.hpp below
romainfrancois May 17, 2023
4826918
define is_na<double> in R.hpp
romainfrancois May 22, 2023
bbe9e25
unnecessary include
romainfrancois May 22, 2023
d022c62
proably not needed
romainfrancois May 22, 2023
b2c481b
try different approach
romainfrancois May 22, 2023
162b51c
not using references :shurg:
romainfrancois May 22, 2023
e50563c
sfinae for is_na so that implementations double and !double are separate
romainfrancois May 23, 2023
25b877a
making it easier to open both cpp11 and cpp11test in separate rstudio
romainfrancois May 23, 2023
cd441d8
make format
romainfrancois May 23, 2023
fd6e1e0
const&
romainfrancois May 23, 2023
62d6bef
Revert "const&"
romainfrancois May 23, 2023
f6743fe
const T&
romainfrancois May 23, 2023
e96ebb0
try a dispatch based approach
romainfrancois May 23, 2023
2db6423
Revert "try a dispatch based approach"
romainfrancois May 23, 2023
91f41c7
use explciit is_na<> specializations
romainfrancois May 23, 2023
52000a0
specify is_na on tests
romainfrancois May 23, 2023
cd873a2
+ expect_true(ISNA(na2[0]))
romainfrancois May 23, 2023
55e63d9
na.push_back(NA_INTEGER);
romainfrancois May 23, 2023
36e0407
test na
romainfrancois May 23, 2023
5067d9b
cast proxy
romainfrancois May 23, 2023
8a84170
na{NA_INBTEGER}
romainfrancois May 23, 2023
78ca043
use NA_REAL and NA_INTEGER in as_doubles()
romainfrancois May 23, 2023
09c199c
na2 =
romainfrancois May 23, 2023
a55592e
as_cpp<doubles>(ret)
romainfrancois May 23, 2023
4e16ae0
r_vector(r_vector&& rhs)
romainfrancois May 23, 2023
a316393
sexp& operator=(sexp&&)
romainfrancois May 23, 2023
6abb94a
sexp& operator=(sexp&& rhs)
romainfrancois May 23, 2023
a2b0565
avoid hoops
romainfrancois May 23, 2023
ff20930
both versions
romainfrancois May 23, 2023
9909967
is_na()
romainfrancois May 23, 2023
3947b26
cpp11::integers na4 = cpp11::as_cpp<cpp11::integers>(na);
romainfrancois May 23, 2023
9a9a2c2
expect_true(na3.size() == 1);
romainfrancois May 23, 2023
cb25d63
expect_true(ISNA(na5[0]));
romainfrancois May 23, 2023
ba11c0d
expect_true(el == NA_INTEGER);
romainfrancois May 23, 2023
2e7e8fe
expect_true(ISNA(na6[0]));
romainfrancois May 23, 2023
94cf731
cpp11::sexp na(Rf_ScalarReal(NA_INTEGER));
romainfrancois May 24, 2023
0d4b92c
cpp11::sexp na(Rf_ScalarInteger(NA_INTEGER));
romainfrancois May 24, 2023
8c47148
...
romainfrancois May 24, 2023
b671935
typeof
romainfrancois May 24, 2023
dc9d601
-
romainfrancois May 24, 2023
5eade3e
order of preserve/release
romainfrancois May 24, 2023
7abccea
...
romainfrancois May 24, 2023
7082f36
cpp11::integers na3(Rf_ScalarInteger(NA_INTEGER));
romainfrancois May 24, 2023
c6a14ab
move as_doubles to test file ???
romainfrancois May 24, 2023
1bb6e3e
+++
romainfrancois May 24, 2023
8b7f075
Revert "avoid need for R_NilValue checks in protect code (#285)"
romainfrancois May 24, 2023
b59982f
as_integers()
romainfrancois May 24, 2023
b614853
...
romainfrancois May 24, 2023
b67c145
-as_cpp
romainfrancois May 24, 2023
1373226
conversion ops back
romainfrancois May 24, 2023
9b0a954
SEXP as_doubles(SEXP x)
romainfrancois May 24, 2023
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
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ test: all

clean:
@Rscript -e 'devtools::clean_dll()'
@Rscript -e 'devtools::clean_dll("cpp11test")'

clang_format=`which clang-format`
format: $(shell find . -name '*.hpp') $(shell find . -name '*.cpp')
ifeq ($(findstring version 10,$(shell ${clang_format} --version 2>/dev/null)),)
@echo "clang-format 10 is required"
else
@${clang_format} -i $?
endif
2 changes: 2 additions & 0 deletions cpp11test/.Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
^.*\.Rproj$
^\.Rproj\.user$
104 changes: 52 additions & 52 deletions cpp11test/R/cpp11.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,6 @@ data_frame_ <- function() {
.Call(`_cpp11test_data_frame_`)
}

my_stop <- function(mystring, myarg) {
invisible(.Call(`_cpp11test_my_stop`, mystring, myarg))
}

my_stop_n1 <- function(mystring) {
invisible(.Call(`_cpp11test_my_stop_n1`, mystring))
}

my_warning <- function(mystring, myarg) {
invisible(.Call(`_cpp11test_my_warning`, mystring, myarg))
}

my_warning_n1 <- function(mystring) {
invisible(.Call(`_cpp11test_my_warning_n1`, mystring))
}

my_message <- function(mystring, myarg) {
invisible(.Call(`_cpp11test_my_message`, mystring, myarg))
}

my_message_n1 <- function(mystring) {
invisible(.Call(`_cpp11test_my_message_n1`, mystring))
}

my_stop_n1fmt <- function(mystring) {
invisible(.Call(`_cpp11test_my_stop_n1fmt`, mystring))
}
Expand All @@ -56,6 +32,30 @@ my_message_n2fmt <- function(mystring, myarg) {
invisible(.Call(`_cpp11test_my_message_n2fmt`, mystring, myarg))
}

my_stop <- function(mystring, myarg) {
invisible(.Call(`_cpp11test_my_stop`, mystring, myarg))
}

my_stop_n1 <- function(mystring) {
invisible(.Call(`_cpp11test_my_stop_n1`, mystring))
}

my_warning <- function(mystring, myarg) {
invisible(.Call(`_cpp11test_my_warning`, mystring, myarg))
}

my_warning_n1 <- function(mystring) {
invisible(.Call(`_cpp11test_my_warning_n1`, mystring))
}

my_message <- function(mystring, myarg) {
invisible(.Call(`_cpp11test_my_message`, mystring, myarg))
}

my_message_n1 <- function(mystring) {
invisible(.Call(`_cpp11test_my_message_n1`, mystring))
}

remove_altrep <- function(x) {
.Call(`_cpp11test_remove_altrep`, x)
}
Expand Down Expand Up @@ -160,6 +160,34 @@ cpp11_safe_ <- function(x_sxp) {
.Call(`_cpp11test_cpp11_safe_`, x_sxp)
}

sum_dbl_for_ <- function(x) {
.Call(`_cpp11test_sum_dbl_for_`, x)
}

sum_dbl_for2_ <- function(x_sxp) {
.Call(`_cpp11test_sum_dbl_for2_`, x_sxp)
}

sum_dbl_for3_ <- function(x_sxp) {
.Call(`_cpp11test_sum_dbl_for3_`, x_sxp)
}

sum_dbl_foreach_ <- function(x) {
.Call(`_cpp11test_sum_dbl_foreach_`, x)
}

sum_dbl_foreach2_ <- function(x_sxp) {
.Call(`_cpp11test_sum_dbl_foreach2_`, x_sxp)
}

sum_dbl_accumulate_ <- function(x) {
.Call(`_cpp11test_sum_dbl_accumulate_`, x)
}

sum_dbl_accumulate2_ <- function(x_sxp) {
.Call(`_cpp11test_sum_dbl_accumulate2_`, x_sxp)
}

sum_int_for_ <- function(x) {
.Call(`_cpp11test_sum_int_for_`, x)
}
Expand Down Expand Up @@ -195,31 +223,3 @@ rcpp_sum_dbl_accumulate_ <- function(x_sxp) {
rcpp_grow_ <- function(n_sxp) {
.Call(`_cpp11test_rcpp_grow_`, n_sxp)
}

sum_dbl_for_ <- function(x) {
.Call(`_cpp11test_sum_dbl_for_`, x)
}

sum_dbl_for2_ <- function(x_sxp) {
.Call(`_cpp11test_sum_dbl_for2_`, x_sxp)
}

sum_dbl_for3_ <- function(x_sxp) {
.Call(`_cpp11test_sum_dbl_for3_`, x_sxp)
}

sum_dbl_foreach_ <- function(x) {
.Call(`_cpp11test_sum_dbl_foreach_`, x)
}

sum_dbl_foreach2_ <- function(x_sxp) {
.Call(`_cpp11test_sum_dbl_foreach2_`, x_sxp)
}

sum_dbl_accumulate_ <- function(x) {
.Call(`_cpp11test_sum_dbl_accumulate_`, x)
}

sum_dbl_accumulate2_ <- function(x_sxp) {
.Call(`_cpp11test_sum_dbl_accumulate2_`, x_sxp)
}
20 changes: 20 additions & 0 deletions cpp11test/cpp11test.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
194 changes: 97 additions & 97 deletions cpp11test/src/cpp11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,54 +21,6 @@ extern "C" SEXP _cpp11test_data_frame_() {
return cpp11::as_sexp(data_frame_());
END_CPP11
}
// errors_fmt.cpp
void my_stop(std::string mystring, int myarg);
extern "C" SEXP _cpp11test_my_stop(SEXP mystring, SEXP myarg) {
BEGIN_CPP11
my_stop(cpp11::as_cpp<cpp11::decay_t<std::string>>(mystring), cpp11::as_cpp<cpp11::decay_t<int>>(myarg));
return R_NilValue;
END_CPP11
}
// errors_fmt.cpp
void my_stop_n1(std::string mystring);
extern "C" SEXP _cpp11test_my_stop_n1(SEXP mystring) {
BEGIN_CPP11
my_stop_n1(cpp11::as_cpp<cpp11::decay_t<std::string>>(mystring));
return R_NilValue;
END_CPP11
}
// errors_fmt.cpp
void my_warning(std::string mystring, std::string myarg);
extern "C" SEXP _cpp11test_my_warning(SEXP mystring, SEXP myarg) {
BEGIN_CPP11
my_warning(cpp11::as_cpp<cpp11::decay_t<std::string>>(mystring), cpp11::as_cpp<cpp11::decay_t<std::string>>(myarg));
return R_NilValue;
END_CPP11
}
// errors_fmt.cpp
void my_warning_n1(std::string mystring);
extern "C" SEXP _cpp11test_my_warning_n1(SEXP mystring) {
BEGIN_CPP11
my_warning_n1(cpp11::as_cpp<cpp11::decay_t<std::string>>(mystring));
return R_NilValue;
END_CPP11
}
// errors_fmt.cpp
void my_message(std::string mystring, std::string myarg);
extern "C" SEXP _cpp11test_my_message(SEXP mystring, SEXP myarg) {
BEGIN_CPP11
my_message(cpp11::as_cpp<cpp11::decay_t<std::string>>(mystring), cpp11::as_cpp<cpp11::decay_t<std::string>>(myarg));
return R_NilValue;
END_CPP11
}
// errors_fmt.cpp
void my_message_n1(std::string mystring);
extern "C" SEXP _cpp11test_my_message_n1(SEXP mystring) {
BEGIN_CPP11
my_message_n1(cpp11::as_cpp<cpp11::decay_t<std::string>>(mystring));
return R_NilValue;
END_CPP11
}
// errors.cpp
void my_stop_n1fmt(std::string mystring);
extern "C" SEXP _cpp11test_my_stop_n1fmt(SEXP mystring) {
Expand Down Expand Up @@ -117,6 +69,54 @@ extern "C" SEXP _cpp11test_my_message_n2fmt(SEXP mystring, SEXP myarg) {
return R_NilValue;
END_CPP11
}
// errors_fmt.cpp
void my_stop(std::string mystring, int myarg);
extern "C" SEXP _cpp11test_my_stop(SEXP mystring, SEXP myarg) {
BEGIN_CPP11
my_stop(cpp11::as_cpp<cpp11::decay_t<std::string>>(mystring), cpp11::as_cpp<cpp11::decay_t<int>>(myarg));
return R_NilValue;
END_CPP11
}
// errors_fmt.cpp
void my_stop_n1(std::string mystring);
extern "C" SEXP _cpp11test_my_stop_n1(SEXP mystring) {
BEGIN_CPP11
my_stop_n1(cpp11::as_cpp<cpp11::decay_t<std::string>>(mystring));
return R_NilValue;
END_CPP11
}
// errors_fmt.cpp
void my_warning(std::string mystring, std::string myarg);
extern "C" SEXP _cpp11test_my_warning(SEXP mystring, SEXP myarg) {
BEGIN_CPP11
my_warning(cpp11::as_cpp<cpp11::decay_t<std::string>>(mystring), cpp11::as_cpp<cpp11::decay_t<std::string>>(myarg));
return R_NilValue;
END_CPP11
}
// errors_fmt.cpp
void my_warning_n1(std::string mystring);
extern "C" SEXP _cpp11test_my_warning_n1(SEXP mystring) {
BEGIN_CPP11
my_warning_n1(cpp11::as_cpp<cpp11::decay_t<std::string>>(mystring));
return R_NilValue;
END_CPP11
}
// errors_fmt.cpp
void my_message(std::string mystring, std::string myarg);
extern "C" SEXP _cpp11test_my_message(SEXP mystring, SEXP myarg) {
BEGIN_CPP11
my_message(cpp11::as_cpp<cpp11::decay_t<std::string>>(mystring), cpp11::as_cpp<cpp11::decay_t<std::string>>(myarg));
return R_NilValue;
END_CPP11
}
// errors_fmt.cpp
void my_message_n1(std::string mystring);
extern "C" SEXP _cpp11test_my_message_n1(SEXP mystring) {
BEGIN_CPP11
my_message_n1(cpp11::as_cpp<cpp11::decay_t<std::string>>(mystring));
return R_NilValue;
END_CPP11
}
// find-intervals.cpp
SEXP remove_altrep(SEXP x);
extern "C" SEXP _cpp11test_remove_altrep(SEXP x) {
Expand Down Expand Up @@ -310,6 +310,55 @@ extern "C" SEXP _cpp11test_cpp11_safe_(SEXP x_sxp) {
return cpp11::as_sexp(cpp11_safe_(cpp11::as_cpp<cpp11::decay_t<SEXP>>(x_sxp)));
END_CPP11
}
// sum.cpp
double sum_dbl_for_(cpp11::doubles x);
extern "C" SEXP _cpp11test_sum_dbl_for_(SEXP x) {
BEGIN_CPP11
return cpp11::as_sexp(sum_dbl_for_(cpp11::as_cpp<cpp11::decay_t<cpp11::doubles>>(x)));
END_CPP11
}
// sum.cpp
double sum_dbl_for2_(SEXP x_sxp);
extern "C" SEXP _cpp11test_sum_dbl_for2_(SEXP x_sxp) {
BEGIN_CPP11
return cpp11::as_sexp(sum_dbl_for2_(cpp11::as_cpp<cpp11::decay_t<SEXP>>(x_sxp)));
END_CPP11
}
// sum.cpp
double sum_dbl_for3_(SEXP x_sxp);
extern "C" SEXP _cpp11test_sum_dbl_for3_(SEXP x_sxp) {
BEGIN_CPP11
return cpp11::as_sexp(sum_dbl_for3_(cpp11::as_cpp<cpp11::decay_t<SEXP>>(x_sxp)));
END_CPP11
}
// sum.cpp
double sum_dbl_foreach_(cpp11::doubles x);
extern "C" SEXP _cpp11test_sum_dbl_foreach_(SEXP x) {
BEGIN_CPP11
return cpp11::as_sexp(sum_dbl_foreach_(cpp11::as_cpp<cpp11::decay_t<cpp11::doubles>>(x)));
END_CPP11
}
// sum.cpp
double sum_dbl_foreach2_(SEXP x_sxp);
extern "C" SEXP _cpp11test_sum_dbl_foreach2_(SEXP x_sxp) {
BEGIN_CPP11
return cpp11::as_sexp(sum_dbl_foreach2_(cpp11::as_cpp<cpp11::decay_t<SEXP>>(x_sxp)));
END_CPP11
}
// sum.cpp
double sum_dbl_accumulate_(cpp11::doubles x);
extern "C" SEXP _cpp11test_sum_dbl_accumulate_(SEXP x) {
BEGIN_CPP11
return cpp11::as_sexp(sum_dbl_accumulate_(cpp11::as_cpp<cpp11::decay_t<cpp11::doubles>>(x)));
END_CPP11
}
// sum.cpp
double sum_dbl_accumulate2_(SEXP x_sxp);
extern "C" SEXP _cpp11test_sum_dbl_accumulate2_(SEXP x_sxp) {
BEGIN_CPP11
return cpp11::as_sexp(sum_dbl_accumulate2_(cpp11::as_cpp<cpp11::decay_t<SEXP>>(x_sxp)));
END_CPP11
}
// sum_int.cpp
double sum_int_for_(cpp11::integers x);
extern "C" SEXP _cpp11test_sum_int_for_(SEXP x) {
Expand Down Expand Up @@ -373,55 +422,6 @@ extern "C" SEXP _cpp11test_rcpp_grow_(SEXP n_sxp) {
return cpp11::as_sexp(rcpp_grow_(cpp11::as_cpp<cpp11::decay_t<SEXP>>(n_sxp)));
END_CPP11
}
// sum.cpp
double sum_dbl_for_(cpp11::doubles x);
extern "C" SEXP _cpp11test_sum_dbl_for_(SEXP x) {
BEGIN_CPP11
return cpp11::as_sexp(sum_dbl_for_(cpp11::as_cpp<cpp11::decay_t<cpp11::doubles>>(x)));
END_CPP11
}
// sum.cpp
double sum_dbl_for2_(SEXP x_sxp);
extern "C" SEXP _cpp11test_sum_dbl_for2_(SEXP x_sxp) {
BEGIN_CPP11
return cpp11::as_sexp(sum_dbl_for2_(cpp11::as_cpp<cpp11::decay_t<SEXP>>(x_sxp)));
END_CPP11
}
// sum.cpp
double sum_dbl_for3_(SEXP x_sxp);
extern "C" SEXP _cpp11test_sum_dbl_for3_(SEXP x_sxp) {
BEGIN_CPP11
return cpp11::as_sexp(sum_dbl_for3_(cpp11::as_cpp<cpp11::decay_t<SEXP>>(x_sxp)));
END_CPP11
}
// sum.cpp
double sum_dbl_foreach_(cpp11::doubles x);
extern "C" SEXP _cpp11test_sum_dbl_foreach_(SEXP x) {
BEGIN_CPP11
return cpp11::as_sexp(sum_dbl_foreach_(cpp11::as_cpp<cpp11::decay_t<cpp11::doubles>>(x)));
END_CPP11
}
// sum.cpp
double sum_dbl_foreach2_(SEXP x_sxp);
extern "C" SEXP _cpp11test_sum_dbl_foreach2_(SEXP x_sxp) {
BEGIN_CPP11
return cpp11::as_sexp(sum_dbl_foreach2_(cpp11::as_cpp<cpp11::decay_t<SEXP>>(x_sxp)));
END_CPP11
}
// sum.cpp
double sum_dbl_accumulate_(cpp11::doubles x);
extern "C" SEXP _cpp11test_sum_dbl_accumulate_(SEXP x) {
BEGIN_CPP11
return cpp11::as_sexp(sum_dbl_accumulate_(cpp11::as_cpp<cpp11::decay_t<cpp11::doubles>>(x)));
END_CPP11
}
// sum.cpp
double sum_dbl_accumulate2_(SEXP x_sxp);
extern "C" SEXP _cpp11test_sum_dbl_accumulate2_(SEXP x_sxp) {
BEGIN_CPP11
return cpp11::as_sexp(sum_dbl_accumulate2_(cpp11::as_cpp<cpp11::decay_t<SEXP>>(x_sxp)));
END_CPP11
}

extern "C" {
/* .Call calls */
Expand Down
Loading