Skip to content

Commit 420f036

Browse files
committed
roxygen: add minimal roxygen test files
1 parent c9def8e commit 420f036

File tree

2 files changed

+90
-33
lines changed

2 files changed

+90
-33
lines changed

cpp11test/R/cpp11.R

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -160,28 +160,57 @@ notroxcpp1_ <- function(x) {
160160
.Call(`_cpp11test_notroxcpp1_`, x)
161161
}
162162

163+
#' @title Roxygenise C++ function II
164+
#' @param x numeric value
165+
#' @description Dummy function to test roxygen2. It adds 2.0 to a double.
166+
#' @export
167+
#' @examples roxcpp2_(1.0)
163168
roxcpp2_ <- function(x) {
164-
.Call(`_cpp11test_roxcpp2_`, x)
169+
.Call(`_cpp11test_roxcpp2_`, x)
165170
}
166171

172+
#' @title Roxygenise C++ function III
173+
#' @param x numeric value
174+
#' @description Dummy function to test roxygen2. It adds 3.0 to a double.
175+
#' @export
176+
#' @examples roxcpp3_(1.0)
167177
roxcpp3_ <- function(x) {
168-
.Call(`_cpp11test_roxcpp3_`, x)
178+
.Call(`_cpp11test_roxcpp3_`, x)
169179
}
170180

181+
#' @title Roxygenise C++ function IV
182+
#' @param x numeric value
183+
#' @description Dummy function to test roxygen2. It adds 4.0 to a double.
184+
#' @export
185+
#' @examples roxcpp4_(1.0)
171186
roxcpp4_ <- function(x) {
172-
.Call(`_cpp11test_roxcpp4_`, x)
187+
.Call(`_cpp11test_roxcpp4_`, x)
173188
}
174189

190+
#' @title Roxygenise C++ function V
191+
#' @param x numeric value
192+
#' @description Dummy function to test roxygen2. It adds 5.0 to a double.
193+
#' @export
194+
#' @examples roxcpp5_(1.0)
175195
roxcpp5_ <- function(x) {
176-
.Call(`_cpp11test_roxcpp5_`, x)
196+
.Call(`_cpp11test_roxcpp5_`, x)
177197
}
178198

179199
notroxcpp6_ <- function(x) {
180200
.Call(`_cpp11test_notroxcpp6_`, x)
181201
}
182202

203+
#' @title Roxygenise C++ function VII
204+
#' @param x numeric value
205+
#' @description Dummy function to test roxygen2. It adds 7.0 to a double.
206+
#' @export
207+
#' @examples
208+
#' my_fun <- function(x) {
209+
#' roxcpp7_(x)
210+
#' }
211+
#' @seealso \code{\link{roxcpp1_}}
183212
roxcpp7_ <- function(x) {
184-
.Call(`_cpp11test_roxcpp7_`, x)
213+
.Call(`_cpp11test_roxcpp7_`, x)
185214
}
186215

187216
cpp11_safe_ <- function(x_sxp) {
@@ -196,26 +225,6 @@ string_push_back_ <- function() {
196225
.Call(`_cpp11test_string_push_back_`)
197226
}
198227

199-
grow_strings_cpp11_ <- function(n, seed) {
200-
.Call(`_cpp11test_grow_strings_cpp11_`, n, seed)
201-
}
202-
203-
grow_strings_rcpp_ <- function(n, seed) {
204-
.Call(`_cpp11test_grow_strings_rcpp_`, n, seed)
205-
}
206-
207-
grow_strings_manual_ <- function(n, seed) {
208-
.Call(`_cpp11test_grow_strings_manual_`, n, seed)
209-
}
210-
211-
assign_cpp11_ <- function(n, seed) {
212-
.Call(`_cpp11test_assign_cpp11_`, n, seed)
213-
}
214-
215-
assign_rcpp_ <- function(n, seed) {
216-
.Call(`_cpp11test_assign_rcpp_`, n, seed)
217-
}
218-
219228
sum_dbl_for_ <- function(x) {
220229
.Call(`_cpp11test_sum_dbl_for_`, x)
221230
}
@@ -284,14 +293,6 @@ rcpp_push_and_truncate_ <- function(size_sxp) {
284293
.Call(`_cpp11test_rcpp_push_and_truncate_`, size_sxp)
285294
}
286295

287-
nullable_extptr_1 <- function() {
288-
.Call(`_cpp11test_nullable_extptr_1`)
289-
}
290-
291-
nullable_extptr_2 <- function() {
292-
.Call(`_cpp11test_nullable_extptr_2`)
293-
}
294-
295296
test_destruction_inner <- function() {
296297
invisible(.Call(`_cpp11test_test_destruction_inner`))
297298
}

cpp11test/src/cpp11.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,55 @@ extern "C" SEXP _cpp11test_rcpp_release_(SEXP n) {
303303
return R_NilValue;
304304
END_CPP11
305305
}
306+
// roxygen1.cpp
307+
double notroxcpp1_(double x);
308+
extern "C" SEXP _cpp11test_notroxcpp1_(SEXP x) {
309+
BEGIN_CPP11
310+
return cpp11::as_sexp(notroxcpp1_(cpp11::as_cpp<cpp11::decay_t<double>>(x)));
311+
END_CPP11
312+
}
313+
// roxygen1.cpp
314+
double roxcpp2_(double x);
315+
extern "C" SEXP _cpp11test_roxcpp2_(SEXP x) {
316+
BEGIN_CPP11
317+
return cpp11::as_sexp(roxcpp2_(cpp11::as_cpp<cpp11::decay_t<double>>(x)));
318+
END_CPP11
319+
}
320+
// roxygen2.cpp
321+
double roxcpp3_(double x);
322+
extern "C" SEXP _cpp11test_roxcpp3_(SEXP x) {
323+
BEGIN_CPP11
324+
return cpp11::as_sexp(roxcpp3_(cpp11::as_cpp<cpp11::decay_t<double>>(x)));
325+
END_CPP11
326+
}
327+
// roxygen2.cpp
328+
double roxcpp4_(double x);
329+
extern "C" SEXP _cpp11test_roxcpp4_(SEXP x) {
330+
BEGIN_CPP11
331+
return cpp11::as_sexp(roxcpp4_(cpp11::as_cpp<cpp11::decay_t<double>>(x)));
332+
END_CPP11
333+
}
334+
// roxygen3.cpp
335+
double roxcpp5_(double x);
336+
extern "C" SEXP _cpp11test_roxcpp5_(SEXP x) {
337+
BEGIN_CPP11
338+
return cpp11::as_sexp(roxcpp5_(cpp11::as_cpp<cpp11::decay_t<double>>(x)));
339+
END_CPP11
340+
}
341+
// roxygen3.cpp
342+
double notroxcpp6_(double x);
343+
extern "C" SEXP _cpp11test_notroxcpp6_(SEXP x) {
344+
BEGIN_CPP11
345+
return cpp11::as_sexp(notroxcpp6_(cpp11::as_cpp<cpp11::decay_t<double>>(x)));
346+
END_CPP11
347+
}
348+
// roxygen3.cpp
349+
double roxcpp7_(double x);
350+
extern "C" SEXP _cpp11test_roxcpp7_(SEXP x) {
351+
BEGIN_CPP11
352+
return cpp11::as_sexp(roxcpp7_(cpp11::as_cpp<cpp11::decay_t<double>>(x)));
353+
END_CPP11
354+
}
306355
// safe.cpp
307356
SEXP cpp11_safe_(SEXP x_sxp);
308357
extern "C" SEXP _cpp11test_cpp11_safe_(SEXP x_sxp) {
@@ -500,6 +549,8 @@ static const R_CallMethodDef CallEntries[] = {
500549
{"_cpp11test_my_warning_n1", (DL_FUNC) &_cpp11test_my_warning_n1, 1},
501550
{"_cpp11test_my_warning_n1fmt", (DL_FUNC) &_cpp11test_my_warning_n1fmt, 1},
502551
{"_cpp11test_my_warning_n2fmt", (DL_FUNC) &_cpp11test_my_warning_n2fmt, 2},
552+
{"_cpp11test_notroxcpp1_", (DL_FUNC) &_cpp11test_notroxcpp1_, 1},
553+
{"_cpp11test_notroxcpp6_", (DL_FUNC) &_cpp11test_notroxcpp6_, 1},
503554
{"_cpp11test_protect_many_", (DL_FUNC) &_cpp11test_protect_many_, 1},
504555
{"_cpp11test_protect_many_cpp11_", (DL_FUNC) &_cpp11test_protect_many_cpp11_, 1},
505556
{"_cpp11test_protect_many_preserve_", (DL_FUNC) &_cpp11test_protect_many_preserve_, 1},
@@ -518,6 +569,11 @@ static const R_CallMethodDef CallEntries[] = {
518569
{"_cpp11test_rcpp_sum_int_for_", (DL_FUNC) &_cpp11test_rcpp_sum_int_for_, 1},
519570
{"_cpp11test_remove_altrep", (DL_FUNC) &_cpp11test_remove_altrep, 1},
520571
{"_cpp11test_row_sums", (DL_FUNC) &_cpp11test_row_sums, 1},
572+
{"_cpp11test_roxcpp2_", (DL_FUNC) &_cpp11test_roxcpp2_, 1},
573+
{"_cpp11test_roxcpp3_", (DL_FUNC) &_cpp11test_roxcpp3_, 1},
574+
{"_cpp11test_roxcpp4_", (DL_FUNC) &_cpp11test_roxcpp4_, 1},
575+
{"_cpp11test_roxcpp5_", (DL_FUNC) &_cpp11test_roxcpp5_, 1},
576+
{"_cpp11test_roxcpp7_", (DL_FUNC) &_cpp11test_roxcpp7_, 1},
521577
{"_cpp11test_string_proxy_assignment_", (DL_FUNC) &_cpp11test_string_proxy_assignment_, 0},
522578
{"_cpp11test_string_push_back_", (DL_FUNC) &_cpp11test_string_push_back_, 0},
523579
{"_cpp11test_sum_dbl_accumulate2_", (DL_FUNC) &_cpp11test_sum_dbl_accumulate2_, 1},

0 commit comments

Comments
 (0)