Skip to content
Closed
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
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ all:
@Rscript -e 'devtools::load_all("cpp11test")'
@echo "make: Leaving directory 'cpp11test/src'"

install:
@Rscript -e 'devtools::document()'
@Rscript -e 'devtools::install()'

test: all
@echo "make: Entering directory 'cpp11test/tests/testthat'"
@echo "make: Entering directory 'cpp11test'"
@Rscript -e 'devtools::document("cpp11test")'
@Rscript -e 'devtools::test("cpp11test")'
@echo "make: Leaving directory 'cpp11test/tests/testthat'"

Expand Down
2 changes: 1 addition & 1 deletion cpp11test/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ Suggests:
xml2
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
RoxygenNote: 7.3.2
68 changes: 68 additions & 0 deletions cpp11test/R/cpp11.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ grow_ <- function(n) {
.Call(`_cpp11test_grow_`, n)
}

grow_cplx_ <- function(n) {
.Call(`_cpp11test_grow_cplx_`, n)
}

cpp11_insert_ <- function(num_sxp) {
.Call(`_cpp11test_cpp11_insert_`, num_sxp)
}
Expand Down Expand Up @@ -156,6 +160,34 @@ rcpp_release_ <- function(n) {
invisible(.Call(`_cpp11test_rcpp_release_`, n))
}

notroxcpp1_ <- function(x) {
.Call(`_cpp11test_notroxcpp1_`, x)
}

roxcpp2_ <- function(x) {
.Call(`_cpp11test_roxcpp2_`, x)
}

roxcpp3_ <- function(x) {
.Call(`_cpp11test_roxcpp3_`, x)
}

roxcpp4_ <- function(x) {
.Call(`_cpp11test_roxcpp4_`, x)
}

roxcpp5_ <- function(x) {
.Call(`_cpp11test_roxcpp5_`, x)
}

notroxcpp6_ <- function(x) {
.Call(`_cpp11test_notroxcpp6_`, x)
}

roxcpp7_ <- function(x) {
.Call(`_cpp11test_roxcpp7_`, x)
}

cpp11_safe_ <- function(x_sxp) {
.Call(`_cpp11test_cpp11_safe_`, x_sxp)
}
Expand Down Expand Up @@ -196,6 +228,42 @@ sum_dbl_accumulate2_ <- function(x_sxp) {
.Call(`_cpp11test_sum_dbl_accumulate2_`, x_sxp)
}

sum_cplx_for_ <- function(x) {
.Call(`_cpp11test_sum_cplx_for_`, x)
}

sum_cplx_for_2_ <- function(x) {
.Call(`_cpp11test_sum_cplx_for_2_`, x)
}

sum_cplx_for_3_ <- function(x_sxp) {
.Call(`_cpp11test_sum_cplx_for_3_`, x_sxp)
}

sum_cplx_for_4_ <- function(x_sxp) {
.Call(`_cpp11test_sum_cplx_for_4_`, x_sxp)
}

sum_cplx_for_5_ <- function(x_sxp) {
.Call(`_cpp11test_sum_cplx_for_5_`, x_sxp)
}

sum_cplx_for_6_ <- function(x_sxp) {
.Call(`_cpp11test_sum_cplx_for_6_`, x_sxp)
}

sum_cplx_foreach_ <- function(x) {
.Call(`_cpp11test_sum_cplx_foreach_`, x)
}

sum_cplx_accumulate_ <- function(x) {
.Call(`_cpp11test_sum_cplx_accumulate_`, x)
}

sum_cplx_for2_ <- function(x_sxp) {
.Call(`_cpp11test_sum_cplx_for2_`, x_sxp)
}

sum_int_for_ <- function(x) {
.Call(`_cpp11test_sum_int_for_`, x)
}
Expand Down
136 changes: 136 additions & 0 deletions cpp11test/src/cpp11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ extern "C" SEXP _cpp11test_grow_(SEXP n) {
return cpp11::as_sexp(grow_(cpp11::as_cpp<cpp11::decay_t<R_xlen_t>>(n)));
END_CPP11
}
// grow.cpp
cpp11::writable::complexes grow_cplx_(R_xlen_t n);
extern "C" SEXP _cpp11test_grow_cplx_(SEXP n) {
BEGIN_CPP11
return cpp11::as_sexp(grow_cplx_(cpp11::as_cpp<cpp11::decay_t<R_xlen_t>>(n)));
END_CPP11
}
// insert.cpp
SEXP cpp11_insert_(SEXP num_sxp);
extern "C" SEXP _cpp11test_cpp11_insert_(SEXP num_sxp) {
Expand Down Expand Up @@ -303,6 +310,55 @@ extern "C" SEXP _cpp11test_rcpp_release_(SEXP n) {
return R_NilValue;
END_CPP11
}
// roxygen1.cpp
double notroxcpp1_(double x);
extern "C" SEXP _cpp11test_notroxcpp1_(SEXP x) {
BEGIN_CPP11
return cpp11::as_sexp(notroxcpp1_(cpp11::as_cpp<cpp11::decay_t<double>>(x)));
END_CPP11
}
// roxygen1.cpp
double roxcpp2_(double x);
extern "C" SEXP _cpp11test_roxcpp2_(SEXP x) {
BEGIN_CPP11
return cpp11::as_sexp(roxcpp2_(cpp11::as_cpp<cpp11::decay_t<double>>(x)));
END_CPP11
}
// roxygen2.cpp
double roxcpp3_(double x);
extern "C" SEXP _cpp11test_roxcpp3_(SEXP x) {
BEGIN_CPP11
return cpp11::as_sexp(roxcpp3_(cpp11::as_cpp<cpp11::decay_t<double>>(x)));
END_CPP11
}
// roxygen2.cpp
double roxcpp4_(double x);
extern "C" SEXP _cpp11test_roxcpp4_(SEXP x) {
BEGIN_CPP11
return cpp11::as_sexp(roxcpp4_(cpp11::as_cpp<cpp11::decay_t<double>>(x)));
END_CPP11
}
// roxygen3.cpp
double roxcpp5_(double x);
extern "C" SEXP _cpp11test_roxcpp5_(SEXP x) {
BEGIN_CPP11
return cpp11::as_sexp(roxcpp5_(cpp11::as_cpp<cpp11::decay_t<double>>(x)));
END_CPP11
}
// roxygen3.cpp
double notroxcpp6_(double x);
extern "C" SEXP _cpp11test_notroxcpp6_(SEXP x) {
BEGIN_CPP11
return cpp11::as_sexp(notroxcpp6_(cpp11::as_cpp<cpp11::decay_t<double>>(x)));
END_CPP11
}
// roxygen3.cpp
double roxcpp7_(double x);
extern "C" SEXP _cpp11test_roxcpp7_(SEXP x) {
BEGIN_CPP11
return cpp11::as_sexp(roxcpp7_(cpp11::as_cpp<cpp11::decay_t<double>>(x)));
END_CPP11
}
// safe.cpp
SEXP cpp11_safe_(SEXP x_sxp);
extern "C" SEXP _cpp11test_cpp11_safe_(SEXP x_sxp) {
Expand Down Expand Up @@ -373,6 +429,69 @@ extern "C" SEXP _cpp11test_sum_dbl_accumulate2_(SEXP x_sxp) {
return cpp11::as_sexp(sum_dbl_accumulate2_(cpp11::as_cpp<cpp11::decay_t<SEXP>>(x_sxp)));
END_CPP11
}
// sum.cpp
cpp11::r_complex sum_cplx_for_(cpp11::complexes x);
extern "C" SEXP _cpp11test_sum_cplx_for_(SEXP x) {
BEGIN_CPP11
return cpp11::as_sexp(sum_cplx_for_(cpp11::as_cpp<cpp11::decay_t<cpp11::complexes>>(x)));
END_CPP11
}
// sum.cpp
cpp11::complexes sum_cplx_for_2_(cpp11::complexes x);
extern "C" SEXP _cpp11test_sum_cplx_for_2_(SEXP x) {
BEGIN_CPP11
return cpp11::as_sexp(sum_cplx_for_2_(cpp11::as_cpp<cpp11::decay_t<cpp11::complexes>>(x)));
END_CPP11
}
// sum.cpp
std::complex<double> sum_cplx_for_3_(cpp11::complexes x_sxp);
extern "C" SEXP _cpp11test_sum_cplx_for_3_(SEXP x_sxp) {
BEGIN_CPP11
return cpp11::as_sexp(sum_cplx_for_3_(cpp11::as_cpp<cpp11::decay_t<cpp11::complexes>>(x_sxp)));
END_CPP11
}
// sum.cpp
std::complex<double> sum_cplx_for_4_(SEXP x_sxp);
extern "C" SEXP _cpp11test_sum_cplx_for_4_(SEXP x_sxp) {
BEGIN_CPP11
return cpp11::as_sexp(sum_cplx_for_4_(cpp11::as_cpp<cpp11::decay_t<SEXP>>(x_sxp)));
END_CPP11
}
// sum.cpp
SEXP sum_cplx_for_5_(SEXP x_sxp);
extern "C" SEXP _cpp11test_sum_cplx_for_5_(SEXP x_sxp) {
BEGIN_CPP11
return cpp11::as_sexp(sum_cplx_for_5_(cpp11::as_cpp<cpp11::decay_t<SEXP>>(x_sxp)));
END_CPP11
}
// sum.cpp
cpp11::complexes sum_cplx_for_6_(SEXP x_sxp);
extern "C" SEXP _cpp11test_sum_cplx_for_6_(SEXP x_sxp) {
BEGIN_CPP11
return cpp11::as_sexp(sum_cplx_for_6_(cpp11::as_cpp<cpp11::decay_t<SEXP>>(x_sxp)));
END_CPP11
}
// sum.cpp
std::complex<double> sum_cplx_foreach_(cpp11::complexes x);
extern "C" SEXP _cpp11test_sum_cplx_foreach_(SEXP x) {
BEGIN_CPP11
return cpp11::as_sexp(sum_cplx_foreach_(cpp11::as_cpp<cpp11::decay_t<cpp11::complexes>>(x)));
END_CPP11
}
// sum.cpp
std::complex<double> sum_cplx_accumulate_(cpp11::complexes x);
extern "C" SEXP _cpp11test_sum_cplx_accumulate_(SEXP x) {
BEGIN_CPP11
return cpp11::as_sexp(sum_cplx_accumulate_(cpp11::as_cpp<cpp11::decay_t<cpp11::complexes>>(x)));
END_CPP11
}
// sum.cpp
std::complex<double> sum_cplx_for2_(SEXP x_sxp);
extern "C" SEXP _cpp11test_sum_cplx_for2_(SEXP x_sxp) {
BEGIN_CPP11
return cpp11::as_sexp(sum_cplx_for2_(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 @@ -488,6 +607,7 @@ static const R_CallMethodDef CallEntries[] = {
{"_cpp11test_gibbs_rcpp", (DL_FUNC) &_cpp11test_gibbs_rcpp, 2},
{"_cpp11test_gibbs_rcpp2", (DL_FUNC) &_cpp11test_gibbs_rcpp2, 2},
{"_cpp11test_grow_", (DL_FUNC) &_cpp11test_grow_, 1},
{"_cpp11test_grow_cplx_", (DL_FUNC) &_cpp11test_grow_cplx_, 1},
{"_cpp11test_my_message", (DL_FUNC) &_cpp11test_my_message, 2},
{"_cpp11test_my_message_n1", (DL_FUNC) &_cpp11test_my_message_n1, 1},
{"_cpp11test_my_message_n1fmt", (DL_FUNC) &_cpp11test_my_message_n1fmt, 1},
Expand All @@ -500,6 +620,8 @@ static const R_CallMethodDef CallEntries[] = {
{"_cpp11test_my_warning_n1", (DL_FUNC) &_cpp11test_my_warning_n1, 1},
{"_cpp11test_my_warning_n1fmt", (DL_FUNC) &_cpp11test_my_warning_n1fmt, 1},
{"_cpp11test_my_warning_n2fmt", (DL_FUNC) &_cpp11test_my_warning_n2fmt, 2},
{"_cpp11test_notroxcpp1_", (DL_FUNC) &_cpp11test_notroxcpp1_, 1},
{"_cpp11test_notroxcpp6_", (DL_FUNC) &_cpp11test_notroxcpp6_, 1},
{"_cpp11test_protect_many_", (DL_FUNC) &_cpp11test_protect_many_, 1},
{"_cpp11test_protect_many_cpp11_", (DL_FUNC) &_cpp11test_protect_many_cpp11_, 1},
{"_cpp11test_protect_many_preserve_", (DL_FUNC) &_cpp11test_protect_many_preserve_, 1},
Expand All @@ -518,8 +640,22 @@ static const R_CallMethodDef CallEntries[] = {
{"_cpp11test_rcpp_sum_int_for_", (DL_FUNC) &_cpp11test_rcpp_sum_int_for_, 1},
{"_cpp11test_remove_altrep", (DL_FUNC) &_cpp11test_remove_altrep, 1},
{"_cpp11test_row_sums", (DL_FUNC) &_cpp11test_row_sums, 1},
{"_cpp11test_roxcpp2_", (DL_FUNC) &_cpp11test_roxcpp2_, 1},
{"_cpp11test_roxcpp3_", (DL_FUNC) &_cpp11test_roxcpp3_, 1},
{"_cpp11test_roxcpp4_", (DL_FUNC) &_cpp11test_roxcpp4_, 1},
{"_cpp11test_roxcpp5_", (DL_FUNC) &_cpp11test_roxcpp5_, 1},
{"_cpp11test_roxcpp7_", (DL_FUNC) &_cpp11test_roxcpp7_, 1},
{"_cpp11test_string_proxy_assignment_", (DL_FUNC) &_cpp11test_string_proxy_assignment_, 0},
{"_cpp11test_string_push_back_", (DL_FUNC) &_cpp11test_string_push_back_, 0},
{"_cpp11test_sum_cplx_accumulate_", (DL_FUNC) &_cpp11test_sum_cplx_accumulate_, 1},
{"_cpp11test_sum_cplx_for2_", (DL_FUNC) &_cpp11test_sum_cplx_for2_, 1},
{"_cpp11test_sum_cplx_for_", (DL_FUNC) &_cpp11test_sum_cplx_for_, 1},
{"_cpp11test_sum_cplx_for_2_", (DL_FUNC) &_cpp11test_sum_cplx_for_2_, 1},
{"_cpp11test_sum_cplx_for_3_", (DL_FUNC) &_cpp11test_sum_cplx_for_3_, 1},
{"_cpp11test_sum_cplx_for_4_", (DL_FUNC) &_cpp11test_sum_cplx_for_4_, 1},
{"_cpp11test_sum_cplx_for_5_", (DL_FUNC) &_cpp11test_sum_cplx_for_5_, 1},
{"_cpp11test_sum_cplx_for_6_", (DL_FUNC) &_cpp11test_sum_cplx_for_6_, 1},
{"_cpp11test_sum_cplx_foreach_", (DL_FUNC) &_cpp11test_sum_cplx_foreach_, 1},
{"_cpp11test_sum_dbl_accumulate2_", (DL_FUNC) &_cpp11test_sum_dbl_accumulate2_, 1},
{"_cpp11test_sum_dbl_accumulate_", (DL_FUNC) &_cpp11test_sum_dbl_accumulate_, 1},
{"_cpp11test_sum_dbl_for2_", (DL_FUNC) &_cpp11test_sum_dbl_for2_, 1},
Expand Down
12 changes: 12 additions & 0 deletions cpp11test/src/grow.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "cpp11/complexes.hpp"
#include "cpp11/doubles.hpp"

[[cpp11::register]] cpp11::writable::doubles grow_(R_xlen_t n) {
Expand All @@ -9,3 +10,14 @@

return x;
}

[[cpp11::register]] cpp11::writable::complexes grow_cplx_(R_xlen_t n) {
cpp11::writable::complexes x;
R_xlen_t i = 0;
while (i < n) {
x.push_back(std::complex<double>(i, i));
i++;
}

return x;
}
22 changes: 22 additions & 0 deletions cpp11test/src/roxygen1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "cpp11/doubles.hpp"
using namespace cpp11;

// Test: not documented + documented

// Not Roxygenised C++ function I
[[cpp11::register]] double notroxcpp1_(double x) {
double y = x + 1.0;
return y;
}

/* roxygen start
@title Roxygenise C++ function II
@param x numeric value
@description Dummy function to test roxygen2. It adds 2.0 to a double.
@export
@examples roxcpp2_(1.0)
roxygen end */
[[cpp11::register]] double roxcpp2_(double x) {
double y = x + 2.0;
return y;
}
28 changes: 28 additions & 0 deletions cpp11test/src/roxygen2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "cpp11/doubles.hpp"
using namespace cpp11;

// Test: documented + documented

/* roxygen start
@title Roxygenise C++ function III
@param x numeric value
@description Dummy function to test roxygen2. It adds 3.0 to a double.
@export
@examples roxcpp3_(1.0)
roxygen end */
[[cpp11::register]] double roxcpp3_(double x) {
double y = x + 3.0;
return y;
}

/* roxygen start
@title Roxygenise C++ function IV
@param x numeric value
@description Dummy function to test roxygen2. It adds 4.0 to a double.
@export
@examples roxcpp4_(1.0)
roxygen end */
[[cpp11::register]] double roxcpp4_(double x) {
double y = x + 4.0;
return y;
}
Loading
Loading