Skip to content

Commit 084cf6d

Browse files
committed
check Clang/GCC and CXX11/14/17/20/23 combinations locally
1 parent 19d39e2 commit 084cf6d

File tree

6 files changed

+34
-48
lines changed

6 files changed

+34
-48
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ benchmarks/Rcppbenchmark/src/Makevars
2626
benchmarks/cpp4rbenchmark/src/Makevars
2727
benchmarks/cpp11benchmark/src/Makevars
2828
benchmarks/bench_data.rds
29+
cpp4rtest_0.1.0.tar.gz

DESCRIPTION

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ BugReports: https://github.com/pachadotdev/cpp4r/issues
2020
Depends:
2121
R (>= 4.0.0)
2222
Imports:
23-
brio,
24-
cli,
2523
decor,
2624
desc,
2725
glue,
@@ -34,7 +32,6 @@ Suggests:
3432
mockery,
3533
roxygen2,
3634
testthat (>= 3.2.0)
37-
Config/Needs/cpp4r/register: brio, cli, decor, desc, glue, tibble, vctrs
3835
Config/testthat/edition: 3
3936
Encoding: UTF-8
4037
Roxygen: list(markdown = TRUE)

R/register.R

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
#' Note registered functions will not be *exported* from your package unless
88
#' you also add a `@export` roxygen2 directive for them.
99
#'
10-
#' In order to use `register()` the `cli`, `decor`, `desc`, `glue`,
11-
#' `tibble` and `vctrs` packages must also be installed.
12-
#'
1310
#' @param path The path to the package root directory. The default is `NULL`,
1411
#' @param quiet If `TRUE` suppresses output from this function
1512
#' @param extension The file extension to use for the generated src/cpp4r file.
@@ -40,7 +37,6 @@
4037
register <- function(path = NULL, quiet = !is_interactive(), extension = c(".cpp", ".cc")) {
4138
stopifnot(!is.null(path), dir.exists(path))
4239

43-
stop_unless_installed(get_register_needs())
4440
extension <- match.arg(extension)
4541

4642
r_path <- file.path(path, "R", "cpp4r.R")
@@ -70,13 +66,13 @@ register <- function(path = NULL, quiet = !is_interactive(), extension = c(".cpp
7066

7167
dir.create(dirname(r_path), recursive = TRUE, showWarnings = FALSE)
7268

73-
brio::write_lines(path = r_path, glue::glue("
69+
writeLines(text = glue::glue("
7470
# Generated by cpp4r: do not edit by hand
7571
7672
{r_functions}
77-
"))
73+
"), con = r_path)
7874
if (!quiet) {
79-
cli::cli_alert_success("generated file {.file {basename(r_path)}}")
75+
message(" Generated file '", basename(r_path), "'")
8076
}
8177

8278
call_entries <- get_call_entries(path, funs$name, package)
@@ -107,7 +103,7 @@ register <- function(path = NULL, quiet = !is_interactive(), extension = c(".cpp
107103

108104
extra_includes <- paste0(extra_includes, collapse = "\n")
109105

110-
brio::write_lines(path = cpp_path, glue::glue('
106+
writeLines(text = glue::glue('
111107
// Generated by cpp4r: do not edit by hand
112108
// clang-format off
113109
@@ -128,10 +124,10 @@ register <- function(path = NULL, quiet = !is_interactive(), extension = c(".cpp
128124
}}
129125
',
130126
call_entries = glue::glue_collapse(call_entries, "\n")
131-
))
127+
), con = cpp_path)
132128

133129
if (!quiet) {
134-
cli::cli_alert_success("generated file {.file {basename(cpp_path)}}")
130+
message(" Generated file '", basename(cpp_path), "'")
135131
}
136132

137133
invisible(c(r_path, cpp_path))
@@ -154,7 +150,7 @@ get_registered_functions <- function(decorations, tag, quiet = !is_interactive()
154150
n <- nrow(out)
155151

156152
if (!quiet && n > 0) {
157-
cli::cli_alert_info(glue::glue("{n} functions decorated with [[{tag}]]"))
153+
message("i ", n, " functions decorated with [[", tag, "]]")
158154
}
159155

160156
out
@@ -474,11 +470,6 @@ get_call_entries <- function(path, names, package) {
474470
res[seq(mid, end)]
475471
}
476472

477-
get_register_needs <- function() {
478-
res <- read.dcf(system.file("DESCRIPTION", package = "cpp4r"))[, "Config/Needs/cpp4r/register"]
479-
strsplit(res, "[[:space:]]*,[[:space:]]*")[[1]]
480-
}
481-
482473
check_valid_attributes <- function(decorations, file = decorations$file) {
483474
bad_decor <- startsWith(decorations$decoration, "cpp4r::") &
484475
(!decorations$decoration %in% c("cpp4r::register", "cpp4r::init", "cpp4r::linking_to"))

cpp4rtest/src/test-complex.h

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ context("complexes-C++") {
1010

1111
test_that("complexes::r_vector::const_iterator()") {
1212
cpp4r::complexes x(Rf_allocVector(CPLXSXP, 100));
13-
COMPLEX(x)[0] = {1, 1};
14-
COMPLEX(x)[1] = {2, 2};
15-
COMPLEX(x)[2] = {3, 3};
16-
COMPLEX(x)[3] = {4, 4};
17-
COMPLEX(x)[4] = {5, 5};
18-
COMPLEX(x)[97] = {98, 98};
19-
COMPLEX(x)[98] = {99, 99};
20-
COMPLEX(x)[99] = {100, 100};
13+
COMPLEX(x)[0] = {{1, 1}};
14+
COMPLEX(x)[1] = {{2, 2}};
15+
COMPLEX(x)[2] = {{3, 3}};
16+
COMPLEX(x)[3] = {{4, 4}};
17+
COMPLEX(x)[4] = {{5, 5}};
18+
COMPLEX(x)[97] = {{98, 98}};
19+
COMPLEX(x)[98] = {{99, 99}};
20+
COMPLEX(x)[99] = {{100, 100}};
2121
expect_true(x.size() == 100);
2222

2323
auto it = x.begin();
@@ -179,13 +179,13 @@ context("complexes-C++") {
179179
}
180180

181181
test_that("writable::complexes(SEXP)") {
182-
Rcomplex one{1, 1};
183-
Rcomplex two{2, 2};
184-
Rcomplex three{3, 3};
185-
Rcomplex four{4, 4};
186-
Rcomplex five{5, 5};
187-
Rcomplex six{6, 6};
188-
Rcomplex seven{7, 7};
182+
Rcomplex one{{1, 1}};
183+
Rcomplex two{{2, 2}};
184+
Rcomplex three{{3, 3}};
185+
Rcomplex four{{4, 4}};
186+
Rcomplex five{{5, 5}};
187+
Rcomplex six{{6, 6}};
188+
Rcomplex seven{{7, 7}};
189189

190190
SEXP x = PROTECT(Rf_allocVector(CPLXSXP, 5));
191191

@@ -217,7 +217,7 @@ context("complexes-C++") {
217217
UNPROTECT(1);
218218
}
219219
test_that("writable::complexes(SEXP, bool)") {
220-
Rcomplex five{5, 5};
220+
Rcomplex five{{5, 5}};
221221
SEXP x = PROTECT(Rf_ScalarComplex(five));
222222
cpp4r::writable::complexes y(x, false);
223223

@@ -292,8 +292,8 @@ context("complexes-C++") {
292292

293293
test_that("complexes::attr") {
294294
cpp4r::complexes x(PROTECT(Rf_allocVector(CPLXSXP, 2)));
295-
COMPLEX(x)[0] = {1, 1};
296-
COMPLEX(x)[1] = {2, 2};
295+
COMPLEX(x)[0] = {{1, 1}};
296+
COMPLEX(x)[1] = {{2, 2}};
297297

298298
SEXP foo = Rf_install("foo");
299299
Rf_setAttrib(x, foo, Rf_mkString("bar"));
@@ -360,16 +360,16 @@ context("complexes-C++") {
360360
cpp4r::complexes diff_length(Rf_allocVector(CPLXSXP, 1));
361361
cpp4r::complexes diff_values(Rf_allocVector(CPLXSXP, 2));
362362

363-
COMPLEX(base)[0] = {1, 1};
364-
COMPLEX(base)[1] = {2, 2};
363+
COMPLEX(base)[0] = {{1, 1}};
364+
COMPLEX(base)[1] = {{2, 2}};
365365

366-
COMPLEX(same_values)[0] = {1, 1};
367-
COMPLEX(same_values)[1] = {2, 2};
366+
COMPLEX(same_values)[0] = {{1, 1}};
367+
COMPLEX(same_values)[1] = {{2, 2}};
368368

369-
COMPLEX(diff_length)[0] = {1, 1};
369+
COMPLEX(diff_length)[0] = {{1, 1}};
370370

371-
COMPLEX(diff_values)[0] = {1, 1};
372-
COMPLEX(diff_values)[1] = {3, 3};
371+
COMPLEX(diff_values)[0] = {{1, 1}};
372+
COMPLEX(diff_values)[1] = {{3, 3}};
373373

374374
expect_true(base == base);
375375
expect_true(base == same_values);

cpp4rtest/src/test-r_complex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ context("r_complex-C++") {
2626
}
2727

2828
test_that("explicit construction from Rcomplex") {
29-
Rcomplex x{1, 2};
29+
Rcomplex x{{1, 2}};
3030
cpp4r::r_complex y(x);
3131
expect_true(y.real() == x.r);
3232
expect_true(y.imag() == x.i);

man/register.Rd

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)