diff --git a/DESCRIPTION b/DESCRIPTION index d668e342..e533fc9f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -55,4 +55,4 @@ Config/Needs/cpp11/cpp_register: vctrs Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.2.2 diff --git a/R/register.R b/R/register.R index 3ea10d52..091432ad 100644 --- a/R/register.R +++ b/R/register.R @@ -89,7 +89,7 @@ cpp_register <- function(path = ".", quiet = !is_interactive(), extension = c(". extra_includes <- character() if (pkg_links_to_rcpp(path)) { - extra_includes <- c(extra_includes, "#include ", "#include ", "using namespace Rcpp;") + extra_includes <- c(extra_includes, "#include ", "#include ", "using namespace Rcpp;") } pkg_types <- c( @@ -114,7 +114,7 @@ cpp_register <- function(path = ".", quiet = !is_interactive(), extension = c(". // clang-format off {extra_includes} - #include "cpp11/declarations.hpp" + #include "headers/declarations.hpp" #include {cpp_functions_definitions} diff --git a/R/source.R b/R/source.R index fc9124d5..c0dc01c9 100644 --- a/R/source.R +++ b/R/source.R @@ -24,7 +24,7 @@ #' @examples #' #' cpp_source( -#' code = '#include "cpp11/integers.hpp" +#' code = '#include "headers/integers.hpp" #' #' [[cpp11::register]] #' int num_odd(cpp11::integers x) { @@ -44,7 +44,7 @@ #' #' cpp_source( #' code = ' -#' #include +#' #include #' #include #' #' [[cpp11::linking_to("progress")]] @@ -113,7 +113,7 @@ cpp_source <- function(file, code = NULL, env = parent.frame(), clean = TRUE, qu cpp_functions_definitions <- generate_cpp_functions(funs, package = package) cpp_path <- file.path(dirname(new_file_path), "cpp11.cpp") - brio::write_lines(c('#include "cpp11/declarations.hpp"', "using namespace ::cpp11;", cpp_functions_definitions), cpp_path) + brio::write_lines(c('#include "headers/declarations.hpp"', "using namespace ::cpp11;", cpp_functions_definitions), cpp_path) linking_to <- union(get_linking_to(all_decorations), "cpp11") diff --git a/R/vendor.R b/R/vendor.R index f7c4b150..c66b6416 100644 --- a/R/vendor.R +++ b/R/vendor.R @@ -4,18 +4,18 @@ #' project is using. It is often used in the go language community. #' #' This function vendors cpp11 into your package by copying the cpp11 -#' headers into the `inst/include` folder of your package and adding -#' 'cpp11 version: XYZ' to the top of the files, where XYZ is the version of -#' cpp11 currently installed on your machine. +#' headers into the `src/vendor` folder and adding 'cpp11 version: XYZ' to the +#' top of the files, where XYZ is the version of cpp11 currently installed on +#' your machine. #' #' If you choose to vendor the headers you should _remove_ `LinkingTo: -#' cpp11` from your DESCRIPTION. +#' cpp11` from your DESCRIPTION. This is done automatically by this function. #' #' **Note**: vendoring places the responsibility of updating the code on #' **you**. Bugfixes and new features in cpp11 will not be available for your #' code until you run `cpp_vendor()` again. #' -#' @inheritParams cpp_register +#' @param path The path to vendor the code into. #' @return The file path to the vendored code (invisibly). #' @export #' @examples @@ -26,12 +26,12 @@ #' # vendor the cpp11 headers into the directory #' cpp_vendor(dir) #' -#' list.files(file.path(dir, "inst", "include", "cpp11")) +#' list.files(file.path(dir, "src", "vendor")) #' #' # cleanup #' unlink(dir, recursive = TRUE) -cpp_vendor <- function(path = ".") { - new <- file.path(path, "inst", "include", "cpp11") +cpp_vendor <- function(path = "./src/vendor") { + new <- file.path(path, "cpp11") if (dir.exists(new)) { stop("'", new, "' already exists\n * run unlink('", new, "', recursive = TRUE)", call. = FALSE) @@ -64,38 +64,62 @@ cpp_vendor <- function(path = ".") { # 1. Check if `src/Makevars` exists makevars_exists <- file.exists("src/Makevars") - # 2. If makevars exists, it should have a line that reads `PKG_CPPFLAGS = -I../inst/include` + # 2. If makevars exists, it should have a line that reads + # `PKG_CPPFLAGS = -I../inst/include` or similar + + vendor_line <- paste0(" -I", new) + if (isTRUE(makevars_exists)) { makevars <- readLines("src/Makevars") - if (!any(grepl("PKG_CPPFLAGS = -I../inst/include", makevars))) { - # add the line - makevars <- c(makevars, "PKG_CPPFLAGS = -I../inst/include") + + if (any(grepl("^PKG_CPPFLAGS", makevars))) { + cat("There is a `PKG_CPPFLAGS` line in src/Makevars. It will be modified.\n") + + # which line contains `PKG_CPPFLAGS`? + cppflags_line <- grep("^PKG_CPPFLAGS", makevars) + + # append the vendoring line + if (!grepl(vendor_line, makevars[cppflags_line])) { + makevars[cppflags_line] <- paste0(makevars[cppflags_line], vendor_line) + } writeLines(makevars, "src/Makevars") + } else { + # add the line + makevars <- c(makevars, paste0("PKG_CPPFLAGS = ", vendor_line)) - # warn about the change - cat("`PKG_CPPFLAGS = -I../inst/include` was added to src/Makevars\n") + writeLines(makevars, "src/Makevars") } + + cat("The existing src/Makevars was modified. Please check it.\n") } else { # create the file - writeLines("PKG_CPPFLAGS = -I../inst/include", "src/Makevars") + writeLines(paste0("PKG_CPPFLAGS = ", vendor_line), "src/Makevars") # warn about the change - cat("A new src/Makevars file was created\n") + cat("A new src/Makevars file was created.\n") } # 3. `DESCRIPTION` now should not have `LinkingTo: cpp11` or `LinkingTo: \n\tcpp11` description <- readLines("DESCRIPTION") + cpp11_in_desc <- any( + grepl("LinkingTo: cpp11", description), + grepl("LinkingTo: ", description), + grepl(" cpp11", description) + ) + + if (isTRUE(cpp11_in_desc)) { # remove the lines - description <- description[!grepl("LinkingTo: cpp11", description)] - description <- description[!grepl("LinkingTo: ", description)] - description <- description[!grepl(" cpp11", description)] + description <- description[!grepl("LinkingTo: cpp11", description)] + description <- description[!grepl("LinkingTo: ", description)] + description <- description[!grepl(" cpp11", description)] - writeLines(description, "DESCRIPTION") + writeLines(description, "DESCRIPTION") - # warn about the change - cat("`LinkingTo: cpp11` was removed from DESCRIPTION\n") + # warn about the change + cat("`LinkingTo: cpp11` was removed from DESCRIPTION.\n") + } invisible(new) } diff --git a/cpp11test/src/add.cpp b/cpp11test/src/add.cpp index 3a3bb4df..95561c25 100644 --- a/cpp11test/src/add.cpp +++ b/cpp11test/src/add.cpp @@ -1,4 +1,4 @@ -#include "cpp11/doubles.hpp" +#include "headers/doubles.hpp" [[cpp11::register]] SEXP cpp11_add_vec_for_(cpp11::writable::doubles x, double num) { R_xlen_t n = x.size(); diff --git a/cpp11test/src/cpp11.cpp b/cpp11test/src/cpp11.cpp index 6120c333..506b2e6d 100644 --- a/cpp11test/src/cpp11.cpp +++ b/cpp11test/src/cpp11.cpp @@ -1,10 +1,10 @@ // Generated by cpp11: do not edit by hand // clang-format off -#include +#include #include using namespace Rcpp; -#include "cpp11/declarations.hpp" +#include "headers/declarations.hpp" #include // add.cpp diff --git a/cpp11test/src/data_frame.cpp b/cpp11test/src/data_frame.cpp index 08729155..fe4a6fc0 100644 --- a/cpp11test/src/data_frame.cpp +++ b/cpp11test/src/data_frame.cpp @@ -1,6 +1,6 @@ -#include "cpp11/integers.hpp" -#include "cpp11/list.hpp" -#include "cpp11/strings.hpp" +#include "headers/integers.hpp" +#include "headers/list.hpp" +#include "headers/strings.hpp" [[cpp11::register]] SEXP data_frame_() { using namespace cpp11::literals; diff --git a/cpp11test/src/errors.cpp b/cpp11test/src/errors.cpp index 79f061ee..a571902f 100644 --- a/cpp11test/src/errors.cpp +++ b/cpp11test/src/errors.cpp @@ -1,5 +1,5 @@ -#include "cpp11/function.hpp" -#include "cpp11/protect.hpp" +#include "headers/function.hpp" +#include "headers/protect.hpp" using namespace cpp11; [[cpp11::register]] void my_stop_n1fmt(std::string mystring) { cpp11::stop(mystring); } diff --git a/cpp11test/src/errors_fmt.cpp b/cpp11test/src/errors_fmt.cpp index 6c3ef8bc..96bf341d 100644 --- a/cpp11test/src/errors_fmt.cpp +++ b/cpp11test/src/errors_fmt.cpp @@ -1,6 +1,6 @@ #define CPP11_USE_FMT -#include "cpp11/function.hpp" -#include "cpp11/protect.hpp" +#include "headers/function.hpp" +#include "headers/protect.hpp" using namespace cpp11; [[cpp11::register]] void my_stop(std::string mystring, int myarg) { diff --git a/cpp11test/src/grow.cpp b/cpp11test/src/grow.cpp index eb3f620b..ba587029 100644 --- a/cpp11test/src/grow.cpp +++ b/cpp11test/src/grow.cpp @@ -1,4 +1,4 @@ -#include "cpp11/doubles.hpp" +#include "headers/doubles.hpp" [[cpp11::register]] cpp11::writable::doubles grow_(R_xlen_t n) { cpp11::writable::doubles x; diff --git a/cpp11test/src/insert.cpp b/cpp11test/src/insert.cpp index 913d71b8..6a71afe6 100644 --- a/cpp11test/src/insert.cpp +++ b/cpp11test/src/insert.cpp @@ -1,4 +1,4 @@ -#include "cpp11/doubles.hpp" +#include "headers/doubles.hpp" [[cpp11::register]] SEXP cpp11_insert_(SEXP num_sxp) { R_xlen_t num = INTEGER(num_sxp)[0]; diff --git a/cpp11test/src/matrix.cpp b/cpp11test/src/matrix.cpp index 10348945..a484bcff 100644 --- a/cpp11test/src/matrix.cpp +++ b/cpp11test/src/matrix.cpp @@ -1,6 +1,6 @@ -#include "cpp11/matrix.hpp" +#include "headers/matrix.hpp" #include "Rmath.h" -#include "cpp11/doubles.hpp" +#include "headers/doubles.hpp" using namespace cpp11; [[cpp11::register]] SEXP gibbs_cpp(int N, int thin) { diff --git a/cpp11test/src/release.cpp b/cpp11test/src/release.cpp index 7b321e45..6be8d514 100644 --- a/cpp11test/src/release.cpp +++ b/cpp11test/src/release.cpp @@ -1,5 +1,5 @@ #include -#include "cpp11/sexp.hpp" +#include "headers/sexp.hpp" #include "Rcpp.h" diff --git a/cpp11test/src/safe.cpp b/cpp11test/src/safe.cpp index 175f24ec..b12d254d 100644 --- a/cpp11test/src/safe.cpp +++ b/cpp11test/src/safe.cpp @@ -1,6 +1,6 @@ #include -#include "cpp11/doubles.hpp" -#include "cpp11/protect.hpp" +#include "headers/doubles.hpp" +#include "headers/protect.hpp" [[cpp11::register]] SEXP cpp11_safe_(SEXP x_sxp) { SEXP err = R_NilValue; diff --git a/cpp11test/src/sum.cpp b/cpp11test/src/sum.cpp index e685c7d1..25cd691c 100644 --- a/cpp11test/src/sum.cpp +++ b/cpp11test/src/sum.cpp @@ -1,5 +1,5 @@ #include -#include "cpp11/doubles.hpp" +#include "headers/doubles.hpp" [[cpp11::register]] double sum_dbl_for_(cpp11::doubles x) { double sum = 0.; diff --git a/cpp11test/src/sum_int.cpp b/cpp11test/src/sum_int.cpp index 922f6e76..79bd22af 100644 --- a/cpp11test/src/sum_int.cpp +++ b/cpp11test/src/sum_int.cpp @@ -1,5 +1,5 @@ #include -#include "cpp11/integers.hpp" +#include "headers/integers.hpp" [[cpp11::register]] double sum_int_for_(cpp11::integers x) { double sum = 0.; diff --git a/cpp11test/src/test-as.cpp b/cpp11test/src/test-as.cpp index ddbb9974..ca087f0b 100644 --- a/cpp11test/src/test-as.cpp +++ b/cpp11test/src/test-as.cpp @@ -2,7 +2,7 @@ #include #include -#include "cpp11/declarations.hpp" +#include "headers/declarations.hpp" #include diff --git a/cpp11test/src/test-data_frame.cpp b/cpp11test/src/test-data_frame.cpp index e692712b..20f67bd9 100644 --- a/cpp11test/src/test-data_frame.cpp +++ b/cpp11test/src/test-data_frame.cpp @@ -1,7 +1,7 @@ -#include "cpp11/data_frame.hpp" -#include "cpp11/function.hpp" -#include "cpp11/integers.hpp" -#include "cpp11/strings.hpp" +#include "headers/data_frame.hpp" +#include "headers/function.hpp" +#include "headers/integers.hpp" +#include "headers/strings.hpp" #include diff --git a/cpp11test/src/test-doubles.cpp b/cpp11test/src/test-doubles.cpp index a7423e1e..31216cc2 100644 --- a/cpp11test/src/test-doubles.cpp +++ b/cpp11test/src/test-doubles.cpp @@ -1,9 +1,9 @@ #include -#include "cpp11/doubles.hpp" -#include "cpp11/function.hpp" -#include "cpp11/integers.hpp" -#include "cpp11/sexp.hpp" -#include "cpp11/strings.hpp" +#include "headers/doubles.hpp" +#include "headers/function.hpp" +#include "headers/integers.hpp" +#include "headers/sexp.hpp" +#include "headers/strings.hpp" #include diff --git a/cpp11test/src/test-environment.cpp b/cpp11test/src/test-environment.cpp index 370b6018..55b2b57a 100644 --- a/cpp11test/src/test-environment.cpp +++ b/cpp11test/src/test-environment.cpp @@ -1,7 +1,7 @@ -#include "cpp11/as.hpp" -#include "cpp11/environment.hpp" -#include "cpp11/function.hpp" -#include "cpp11/strings.hpp" +#include "headers/as.hpp" +#include "headers/environment.hpp" +#include "headers/function.hpp" +#include "headers/strings.hpp" #include diff --git a/cpp11test/src/test-external_pointer.cpp b/cpp11test/src/test-external_pointer.cpp index 897fd4f2..325760c5 100644 --- a/cpp11test/src/test-external_pointer.cpp +++ b/cpp11test/src/test-external_pointer.cpp @@ -1,5 +1,5 @@ #include -#include "cpp11/external_pointer.hpp" +#include "headers/external_pointer.hpp" #include diff --git a/cpp11test/src/test-function.cpp b/cpp11test/src/test-function.cpp index 678a5ee2..c19e4139 100644 --- a/cpp11test/src/test-function.cpp +++ b/cpp11test/src/test-function.cpp @@ -1,4 +1,4 @@ -#include "cpp11/function.hpp" +#include "headers/function.hpp" #include diff --git a/cpp11test/src/test-integers.cpp b/cpp11test/src/test-integers.cpp index 6f876c57..ef4d3896 100644 --- a/cpp11test/src/test-integers.cpp +++ b/cpp11test/src/test-integers.cpp @@ -1,8 +1,8 @@ #include "Rversion.h" -#include "cpp11/doubles.hpp" -#include "cpp11/function.hpp" -#include "cpp11/integers.hpp" -#include "cpp11/strings.hpp" +#include "headers/doubles.hpp" +#include "headers/function.hpp" +#include "headers/integers.hpp" +#include "headers/strings.hpp" #include diff --git a/cpp11test/src/test-list.cpp b/cpp11test/src/test-list.cpp index 0abf6002..51738f62 100644 --- a/cpp11test/src/test-list.cpp +++ b/cpp11test/src/test-list.cpp @@ -1,9 +1,9 @@ -#include "cpp11/doubles.hpp" -#include "cpp11/integers.hpp" -#include "cpp11/list.hpp" -#include "cpp11/logicals.hpp" -#include "cpp11/raws.hpp" -#include "cpp11/strings.hpp" +#include "headers/doubles.hpp" +#include "headers/integers.hpp" +#include "headers/list.hpp" +#include "headers/logicals.hpp" +#include "headers/raws.hpp" +#include "headers/strings.hpp" #include diff --git a/cpp11test/src/test-list_of.cpp b/cpp11test/src/test-list_of.cpp index 08d62dcf..930addfb 100644 --- a/cpp11test/src/test-list_of.cpp +++ b/cpp11test/src/test-list_of.cpp @@ -1,7 +1,7 @@ -#include "cpp11/doubles.hpp" -#include "cpp11/list.hpp" -#include "cpp11/list_of.hpp" -#include "cpp11/strings.hpp" +#include "headers/doubles.hpp" +#include "headers/list.hpp" +#include "headers/list_of.hpp" +#include "headers/strings.hpp" #include diff --git a/cpp11test/src/test-logicals.cpp b/cpp11test/src/test-logicals.cpp index 6c9b136a..170c412e 100644 --- a/cpp11test/src/test-logicals.cpp +++ b/cpp11test/src/test-logicals.cpp @@ -1,4 +1,4 @@ -#include "cpp11/logicals.hpp" +#include "headers/logicals.hpp" #include diff --git a/cpp11test/src/test-matrix.cpp b/cpp11test/src/test-matrix.cpp index 693d6ec7..4b98c9fb 100644 --- a/cpp11test/src/test-matrix.cpp +++ b/cpp11test/src/test-matrix.cpp @@ -1,7 +1,7 @@ -#include "cpp11/doubles.hpp" -#include "cpp11/function.hpp" -#include "cpp11/integers.hpp" -#include "cpp11/matrix.hpp" +#include "headers/doubles.hpp" +#include "headers/function.hpp" +#include "headers/integers.hpp" +#include "headers/matrix.hpp" #include diff --git a/cpp11test/src/test-nas.cpp b/cpp11test/src/test-nas.cpp index a0ca5848..dcaf4024 100644 --- a/cpp11test/src/test-nas.cpp +++ b/cpp11test/src/test-nas.cpp @@ -1,7 +1,7 @@ -#include "cpp11/doubles.hpp" -#include "cpp11/integers.hpp" -#include "cpp11/r_bool.hpp" -#include "cpp11/r_string.hpp" +#include "headers/doubles.hpp" +#include "headers/integers.hpp" +#include "headers/r_bool.hpp" +#include "headers/r_string.hpp" #include diff --git a/cpp11test/src/test-protect-nested.cpp b/cpp11test/src/test-protect-nested.cpp index 2679a5f7..384a62d9 100644 --- a/cpp11test/src/test-protect-nested.cpp +++ b/cpp11test/src/test-protect-nested.cpp @@ -1,5 +1,5 @@ -#include "cpp11/function.hpp" -#include "cpp11/protect.hpp" +#include "headers/function.hpp" +#include "headers/protect.hpp" #include "testthat.h" #ifdef HAS_UNWIND_PROTECT diff --git a/cpp11test/src/test-protect.cpp b/cpp11test/src/test-protect.cpp index 2bd2dadf..323029c6 100644 --- a/cpp11test/src/test-protect.cpp +++ b/cpp11test/src/test-protect.cpp @@ -12,7 +12,7 @@ // clang-format on #define CPP11_USE_FMT -#include "cpp11/protect.hpp" +#include "headers/protect.hpp" #include "testthat.h" #ifdef HAS_UNWIND_PROTECT diff --git a/cpp11test/src/test-raws.cpp b/cpp11test/src/test-raws.cpp index ecae6db6..c3f0fd25 100644 --- a/cpp11test/src/test-raws.cpp +++ b/cpp11test/src/test-raws.cpp @@ -1,4 +1,4 @@ -#include "cpp11/raws.hpp" +#include "headers/raws.hpp" #include diff --git a/cpp11test/src/test-sexp.cpp b/cpp11test/src/test-sexp.cpp index d9e7800e..9acee94a 100644 --- a/cpp11test/src/test-sexp.cpp +++ b/cpp11test/src/test-sexp.cpp @@ -1,4 +1,4 @@ -#include "cpp11/list.hpp" +#include "headers/list.hpp" #include diff --git a/cpp11test/src/test-string.cpp b/cpp11test/src/test-string.cpp index 98661a53..0953744f 100644 --- a/cpp11test/src/test-string.cpp +++ b/cpp11test/src/test-string.cpp @@ -1,4 +1,4 @@ -#include "cpp11/strings.hpp" +#include "headers/strings.hpp" #include diff --git a/cpp11test/src/test-strings.cpp b/cpp11test/src/test-strings.cpp index 3a11e935..7584be1b 100644 --- a/cpp11test/src/test-strings.cpp +++ b/cpp11test/src/test-strings.cpp @@ -1,6 +1,6 @@ #include -#include "cpp11/sexp.hpp" -#include "cpp11/strings.hpp" +#include "headers/sexp.hpp" +#include "headers/strings.hpp" #include diff --git a/inst/include/cpp11.hpp b/inst/include/cpp11.hpp index 71e1cf1d..fa81c052 100644 --- a/inst/include/cpp11.hpp +++ b/inst/include/cpp11.hpp @@ -1,24 +1,24 @@ #pragma once -#include "cpp11/R.hpp" -#include "cpp11/altrep.hpp" -#include "cpp11/as.hpp" -#include "cpp11/attribute_proxy.hpp" -#include "cpp11/data_frame.hpp" -#include "cpp11/doubles.hpp" -#include "cpp11/environment.hpp" -#include "cpp11/external_pointer.hpp" -#include "cpp11/function.hpp" -#include "cpp11/integers.hpp" -#include "cpp11/list.hpp" -#include "cpp11/list_of.hpp" -#include "cpp11/logicals.hpp" -#include "cpp11/matrix.hpp" -#include "cpp11/named_arg.hpp" -#include "cpp11/protect.hpp" -#include "cpp11/r_bool.hpp" -#include "cpp11/r_string.hpp" -#include "cpp11/r_vector.hpp" -#include "cpp11/raws.hpp" -#include "cpp11/sexp.hpp" -#include "cpp11/strings.hpp" +#include "headers/R.hpp" +#include "headers/altrep.hpp" +#include "headers/as.hpp" +#include "headers/attribute_proxy.hpp" +#include "headers/data_frame.hpp" +#include "headers/doubles.hpp" +#include "headers/environment.hpp" +#include "headers/external_pointer.hpp" +#include "headers/function.hpp" +#include "headers/integers.hpp" +#include "headers/list.hpp" +#include "headers/list_of.hpp" +#include "headers/logicals.hpp" +#include "headers/matrix.hpp" +#include "headers/named_arg.hpp" +#include "headers/protect.hpp" +#include "headers/r_bool.hpp" +#include "headers/r_string.hpp" +#include "headers/r_vector.hpp" +#include "headers/raws.hpp" +#include "headers/sexp.hpp" +#include "headers/strings.hpp" diff --git a/inst/include/cpp11/R.hpp b/inst/include/headers/R.hpp similarity index 97% rename from inst/include/cpp11/R.hpp rename to inst/include/headers/R.hpp index 8d6751f1..91f2d40f 100644 --- a/inst/include/cpp11/R.hpp +++ b/inst/include/headers/R.hpp @@ -25,7 +25,7 @@ // clang-format on #include -#include "cpp11/altrep.hpp" +#include "headers/altrep.hpp" namespace cpp11 { namespace literals { diff --git a/inst/include/cpp11/altrep.hpp b/inst/include/headers/altrep.hpp similarity index 100% rename from inst/include/cpp11/altrep.hpp rename to inst/include/headers/altrep.hpp diff --git a/inst/include/cpp11/as.hpp b/inst/include/headers/as.hpp similarity index 98% rename from inst/include/cpp11/as.hpp rename to inst/include/headers/as.hpp index 682f12b5..255ed8cf 100644 --- a/inst/include/cpp11/as.hpp +++ b/inst/include/headers/as.hpp @@ -7,8 +7,8 @@ #include // for string, basic_string #include // for decay, enable_if, is_same, is_convertible -#include "cpp11/R.hpp" // for SEXP, SEXPREC, Rf_xlength, R_xlen_t -#include "cpp11/protect.hpp" // for stop, protect, safe, protect::function +#include "headers/R.hpp" // for SEXP, SEXPREC, Rf_xlength, R_xlen_t +#include "headers/protect.hpp" // for stop, protect, safe, protect::function namespace cpp11 { diff --git a/inst/include/cpp11/attribute_proxy.hpp b/inst/include/headers/attribute_proxy.hpp similarity index 84% rename from inst/include/cpp11/attribute_proxy.hpp rename to inst/include/headers/attribute_proxy.hpp index 64e7436b..c0adf44d 100644 --- a/inst/include/cpp11/attribute_proxy.hpp +++ b/inst/include/headers/attribute_proxy.hpp @@ -3,9 +3,9 @@ #include // for initializer_list #include // for string, basic_string -#include "cpp11/R.hpp" // for SEXP, SEXPREC, Rf_install, PROTECT, Rf_... -#include "cpp11/as.hpp" // for as_sexp -#include "cpp11/protect.hpp" // for protect, safe, protect::function +#include "headers/R.hpp" // for SEXP, SEXPREC, Rf_install, PROTECT, Rf_... +#include "headers/as.hpp" // for as_sexp +#include "headers/protect.hpp" // for protect, safe, protect::function namespace cpp11 { diff --git a/inst/include/cpp11/data_frame.hpp b/inst/include/headers/data_frame.hpp similarity index 90% rename from inst/include/cpp11/data_frame.hpp rename to inst/include/headers/data_frame.hpp index f1caad51..4a652062 100644 --- a/inst/include/cpp11/data_frame.hpp +++ b/inst/include/headers/data_frame.hpp @@ -7,10 +7,10 @@ #include // for move #include "R_ext/Arith.h" // for NA_INTEGER -#include "cpp11/R.hpp" // for Rf_xlength, SEXP, SEXPREC, INTEGER -#include "cpp11/attribute_proxy.hpp" // for attribute_proxy -#include "cpp11/list.hpp" // for list, r_vector<>::r_vector, r_v... -#include "cpp11/r_vector.hpp" // for r_vector +#include "headers/R.hpp" // for Rf_xlength, SEXP, SEXPREC, INTEGER +#include "headers/attribute_proxy.hpp" // for attribute_proxy +#include "headers/list.hpp" // for list, r_vector<>::r_vector, r_v... +#include "headers/r_vector.hpp" // for r_vector namespace cpp11 { diff --git a/inst/include/cpp11/declarations.hpp b/inst/include/headers/declarations.hpp similarity index 100% rename from inst/include/cpp11/declarations.hpp rename to inst/include/headers/declarations.hpp diff --git a/inst/include/cpp11/doubles.hpp b/inst/include/headers/doubles.hpp similarity index 91% rename from inst/include/cpp11/doubles.hpp rename to inst/include/headers/doubles.hpp index 9782346d..ff373bb2 100644 --- a/inst/include/cpp11/doubles.hpp +++ b/inst/include/headers/doubles.hpp @@ -5,12 +5,12 @@ #include // for initializer_list #include "R_ext/Arith.h" // for ISNA -#include "cpp11/R.hpp" // for SEXP, SEXPREC, Rf_allocVector, REAL -#include "cpp11/as.hpp" // for as_sexp -#include "cpp11/named_arg.hpp" // for named_arg -#include "cpp11/protect.hpp" // for SEXP, SEXPREC, REAL_ELT, R_Preserve... -#include "cpp11/r_vector.hpp" // for vector, vector<>::proxy, vector<>::... -#include "cpp11/sexp.hpp" // for sexp +#include "headers/R.hpp" // for SEXP, SEXPREC, Rf_allocVector, REAL +#include "headers/as.hpp" // for as_sexp +#include "headers/named_arg.hpp" // for named_arg +#include "headers/protect.hpp" // for SEXP, SEXPREC, REAL_ELT, R_Preserve... +#include "headers/r_vector.hpp" // for vector, vector<>::proxy, vector<>::... +#include "headers/sexp.hpp" // for sexp // Specializations for doubles diff --git a/inst/include/cpp11/environment.hpp b/inst/include/headers/environment.hpp similarity index 86% rename from inst/include/cpp11/environment.hpp rename to inst/include/headers/environment.hpp index 64fbc553..0b1df9de 100644 --- a/inst/include/cpp11/environment.hpp +++ b/inst/include/headers/environment.hpp @@ -3,17 +3,17 @@ #include // for string, basic_string #include "Rversion.h" // for R_VERSION, R_Version -#include "cpp11/R.hpp" // for SEXP, SEXPREC, Rf_install, Rf_findVarIn... -#include "cpp11/as.hpp" // for as_sexp -#include "cpp11/protect.hpp" // for protect, protect::function, safe, unwin... -#include "cpp11/sexp.hpp" // for sexp +#include "headers/R.hpp" // for SEXP, SEXPREC, Rf_install, Rf_findVarIn... +#include "headers/as.hpp" // for as_sexp +#include "headers/protect.hpp" // for protect, protect::function, safe, unwin... +#include "headers/sexp.hpp" // for sexp #if R_VERSION >= R_Version(4, 0, 0) #define HAS_REMOVE_VAR_FROM_FRAME #endif #ifndef HAS_REMOVE_VAR_FROM_FRAME -#include "cpp11/function.hpp" +#include "headers/function.hpp" #endif namespace cpp11 { diff --git a/inst/include/cpp11/external_pointer.hpp b/inst/include/headers/external_pointer.hpp similarity index 92% rename from inst/include/cpp11/external_pointer.hpp rename to inst/include/headers/external_pointer.hpp index 6956b061..5a83fa42 100644 --- a/inst/include/cpp11/external_pointer.hpp +++ b/inst/include/headers/external_pointer.hpp @@ -4,11 +4,11 @@ #include // for bad_weak_ptr #include // for add_lvalue_reference -#include "cpp11/R.hpp" // for SEXP, SEXPREC, TYPEOF, R_NilValue, R_C... -#include "cpp11/protect.hpp" // for protect, safe, protect::function -#include "cpp11/r_bool.hpp" // for r_bool -#include "cpp11/r_vector.hpp" // for type_error -#include "cpp11/sexp.hpp" // for sexp +#include "headers/R.hpp" // for SEXP, SEXPREC, TYPEOF, R_NilValue, R_C... +#include "headers/protect.hpp" // for protect, safe, protect::function +#include "headers/r_bool.hpp" // for r_bool +#include "headers/r_vector.hpp" // for type_error +#include "headers/sexp.hpp" // for sexp namespace cpp11 { diff --git a/inst/include/cpp11/function.hpp b/inst/include/headers/function.hpp similarity index 90% rename from inst/include/cpp11/function.hpp rename to inst/include/headers/function.hpp index c1679d97..68549dbf 100644 --- a/inst/include/cpp11/function.hpp +++ b/inst/include/headers/function.hpp @@ -6,11 +6,11 @@ #include // for string, basic_string #include // for forward -#include "cpp11/R.hpp" // for SEXP, SEXPREC, CDR, Rf_install, SETCAR -#include "cpp11/as.hpp" // for as_sexp -#include "cpp11/named_arg.hpp" // for named_arg -#include "cpp11/protect.hpp" // for protect, protect::function, safe -#include "cpp11/sexp.hpp" // for sexp +#include "headers/R.hpp" // for SEXP, SEXPREC, CDR, Rf_install, SETCAR +#include "headers/as.hpp" // for as_sexp +#include "headers/named_arg.hpp" // for named_arg +#include "headers/protect.hpp" // for protect, protect::function, safe +#include "headers/sexp.hpp" // for sexp namespace cpp11 { diff --git a/inst/include/cpp11/integers.hpp b/inst/include/headers/integers.hpp similarity index 90% rename from inst/include/cpp11/integers.hpp rename to inst/include/headers/integers.hpp index 1159e2f3..a268841e 100644 --- a/inst/include/cpp11/integers.hpp +++ b/inst/include/headers/integers.hpp @@ -5,13 +5,13 @@ #include // for initializer_list #include "R_ext/Arith.h" // for NA_INTEGER -#include "cpp11/R.hpp" // for SEXP, SEXPREC, Rf_allocVector -#include "cpp11/as.hpp" // for as_sexp -#include "cpp11/attribute_proxy.hpp" // for attribute_proxy -#include "cpp11/named_arg.hpp" // for named_arg -#include "cpp11/protect.hpp" // for preserved -#include "cpp11/r_vector.hpp" // for r_vector, r_vector<>::proxy -#include "cpp11/sexp.hpp" // for sexp +#include "headers/R.hpp" // for SEXP, SEXPREC, Rf_allocVector +#include "headers/as.hpp" // for as_sexp +#include "headers/attribute_proxy.hpp" // for attribute_proxy +#include "headers/named_arg.hpp" // for named_arg +#include "headers/protect.hpp" // for preserved +#include "headers/r_vector.hpp" // for r_vector, r_vector<>::proxy +#include "headers/sexp.hpp" // for sexp // Specializations for integers diff --git a/inst/include/cpp11/list.hpp b/inst/include/headers/list.hpp similarity index 88% rename from inst/include/cpp11/list.hpp rename to inst/include/headers/list.hpp index 64dd987b..72af2fc0 100644 --- a/inst/include/cpp11/list.hpp +++ b/inst/include/headers/list.hpp @@ -2,13 +2,13 @@ #include // for initializer_list -#include "cpp11/R.hpp" // for SEXP, SEXPREC, SET_VECTOR_ELT -#include "cpp11/attribute_proxy.hpp" // for attribute_proxy -#include "cpp11/named_arg.hpp" // for named_arg -#include "cpp11/protect.hpp" // for preserved -#include "cpp11/r_string.hpp" // for r_string -#include "cpp11/r_vector.hpp" // for r_vector, r_vector<>::proxy -#include "cpp11/sexp.hpp" // for sexp +#include "headers/R.hpp" // for SEXP, SEXPREC, SET_VECTOR_ELT +#include "headers/attribute_proxy.hpp" // for attribute_proxy +#include "headers/named_arg.hpp" // for named_arg +#include "headers/protect.hpp" // for preserved +#include "headers/r_string.hpp" // for r_string +#include "headers/r_vector.hpp" // for r_vector, r_vector<>::proxy +#include "headers/sexp.hpp" // for sexp // Specializations for list diff --git a/inst/include/cpp11/list_of.hpp b/inst/include/headers/list_of.hpp similarity index 93% rename from inst/include/cpp11/list_of.hpp rename to inst/include/headers/list_of.hpp index bd5ddd86..8dcdeb1d 100644 --- a/inst/include/cpp11/list_of.hpp +++ b/inst/include/headers/list_of.hpp @@ -2,8 +2,8 @@ #include // for string, basic_string -#include "cpp11/R.hpp" // for R_xlen_t, SEXP, SEXPREC, LONG_VECTOR_SUPPORT -#include "cpp11/list.hpp" // for list +#include "headers/R.hpp" // for R_xlen_t, SEXP, SEXPREC, LONG_VECTOR_SUPPORT +#include "headers/list.hpp" // for list namespace cpp11 { diff --git a/inst/include/cpp11/logicals.hpp b/inst/include/headers/logicals.hpp similarity index 89% rename from inst/include/cpp11/logicals.hpp rename to inst/include/headers/logicals.hpp index 6a4e2cfa..d0e0e78e 100644 --- a/inst/include/cpp11/logicals.hpp +++ b/inst/include/headers/logicals.hpp @@ -4,13 +4,13 @@ #include // for array #include // for initializer_list -#include "cpp11/R.hpp" // for SEXP, SEXPREC, Rf_all... -#include "cpp11/attribute_proxy.hpp" // for attribute_proxy -#include "cpp11/named_arg.hpp" // for named_arg -#include "cpp11/protect.hpp" // for preserved -#include "cpp11/r_bool.hpp" // for r_bool -#include "cpp11/r_vector.hpp" // for r_vector, r_vector<>::proxy -#include "cpp11/sexp.hpp" // for sexp +#include "headers/R.hpp" // for SEXP, SEXPREC, Rf_all... +#include "headers/attribute_proxy.hpp" // for attribute_proxy +#include "headers/named_arg.hpp" // for named_arg +#include "headers/protect.hpp" // for preserved +#include "headers/r_bool.hpp" // for r_bool +#include "headers/r_vector.hpp" // for r_vector, r_vector<>::proxy +#include "headers/sexp.hpp" // for sexp // Specializations for logicals diff --git a/inst/include/cpp11/matrix.hpp b/inst/include/headers/matrix.hpp similarity index 96% rename from inst/include/cpp11/matrix.hpp rename to inst/include/headers/matrix.hpp index 9a8454fe..34942ffc 100644 --- a/inst/include/cpp11/matrix.hpp +++ b/inst/include/headers/matrix.hpp @@ -3,11 +3,11 @@ #include #include // for string -#include "cpp11/R.hpp" // for SEXP, SEXPREC, R_xlen_t, INT... -#include "cpp11/r_bool.hpp" // for r_bool -#include "cpp11/r_string.hpp" // for r_string -#include "cpp11/r_vector.hpp" // for r_vector -#include "cpp11/sexp.hpp" // for sexp +#include "headers/R.hpp" // for SEXP, SEXPREC, R_xlen_t, INT... +#include "headers/r_bool.hpp" // for r_bool +#include "headers/r_string.hpp" // for r_string +#include "headers/r_vector.hpp" // for r_vector +#include "headers/sexp.hpp" // for sexp namespace cpp11 { diff --git a/inst/include/cpp11/named_arg.hpp b/inst/include/headers/named_arg.hpp similarity index 86% rename from inst/include/cpp11/named_arg.hpp rename to inst/include/headers/named_arg.hpp index 1768821a..0fda14ae 100644 --- a/inst/include/cpp11/named_arg.hpp +++ b/inst/include/headers/named_arg.hpp @@ -4,9 +4,9 @@ #include // for initializer_list -#include "cpp11/R.hpp" // for SEXP, SEXPREC, literals -#include "cpp11/as.hpp" // for as_sexp -#include "cpp11/sexp.hpp" // for sexp +#include "headers/R.hpp" // for SEXP, SEXPREC, literals +#include "headers/as.hpp" // for as_sexp +#include "headers/sexp.hpp" // for sexp namespace cpp11 { class named_arg { diff --git a/inst/include/cpp11/protect.hpp b/inst/include/headers/protect.hpp similarity index 98% rename from inst/include/cpp11/protect.hpp rename to inst/include/headers/protect.hpp index 86d7fccc..f1bd0483 100644 --- a/inst/include/cpp11/protect.hpp +++ b/inst/include/headers/protect.hpp @@ -6,8 +6,8 @@ #include // for string, basic_string #include // for tuple, make_tuple -// NB: cpp11/R.hpp must precede R_ext/Error.h to ensure R_NO_REMAP is defined -#include "cpp11/R.hpp" // for SEXP, SEXPREC, CDR, R_NilValue, CAR, R_Pres... +// NB: headers/R.hpp must precede R_ext/Error.h to ensure R_NO_REMAP is defined +#include "headers/R.hpp" // for SEXP, SEXPREC, CDR, R_NilValue, CAR, R_Pres... #include "R_ext/Boolean.h" // for Rboolean #include "R_ext/Error.h" // for Rf_error, Rf_warning diff --git a/inst/include/cpp11/r_bool.hpp b/inst/include/headers/r_bool.hpp similarity index 88% rename from inst/include/cpp11/r_bool.hpp rename to inst/include/headers/r_bool.hpp index a3bb18eb..af1448f8 100644 --- a/inst/include/cpp11/r_bool.hpp +++ b/inst/include/headers/r_bool.hpp @@ -5,11 +5,11 @@ #include // for is_convertible, enable_if #include "R_ext/Boolean.h" // for Rboolean -#include "cpp11/R.hpp" // for SEXP, SEXPREC, ... -#include "cpp11/as.hpp" // for as_sexp -#include "cpp11/protect.hpp" // for unwind_protect, preserved -#include "cpp11/r_vector.hpp" -#include "cpp11/sexp.hpp" // for sexp +#include "headers/R.hpp" // for SEXP, SEXPREC, ... +#include "headers/as.hpp" // for as_sexp +#include "headers/protect.hpp" // for unwind_protect, preserved +#include "headers/r_vector.hpp" +#include "headers/sexp.hpp" // for sexp namespace cpp11 { diff --git a/inst/include/cpp11/r_string.hpp b/inst/include/headers/r_string.hpp similarity index 90% rename from inst/include/cpp11/r_string.hpp rename to inst/include/headers/r_string.hpp index 692b66ea..cf75a087 100644 --- a/inst/include/cpp11/r_string.hpp +++ b/inst/include/headers/r_string.hpp @@ -4,10 +4,10 @@ #include // for is_convertible, enable_if #include "R_ext/Memory.h" // for vmaxget, vmaxset -#include "cpp11/R.hpp" // for SEXP, SEXPREC, Rf_mkCharCE, Rf_translat... -#include "cpp11/as.hpp" // for as_sexp -#include "cpp11/protect.hpp" // for unwind_protect, protect, protect::function -#include "cpp11/sexp.hpp" // for sexp +#include "headers/R.hpp" // for SEXP, SEXPREC, Rf_mkCharCE, Rf_translat... +#include "headers/as.hpp" // for as_sexp +#include "headers/protect.hpp" // for unwind_protect, protect, protect::function +#include "headers/sexp.hpp" // for sexp namespace cpp11 { diff --git a/inst/include/cpp11/r_vector.hpp b/inst/include/headers/r_vector.hpp similarity index 98% rename from inst/include/cpp11/r_vector.hpp rename to inst/include/headers/r_vector.hpp index 4831c2f5..ec97c9cf 100644 --- a/inst/include/cpp11/r_vector.hpp +++ b/inst/include/headers/r_vector.hpp @@ -13,11 +13,11 @@ #include // for decay, is_same, enable_if, is_c... #include // for declval -#include "cpp11/R.hpp" // for R_xlen_t, SEXP, SEXPREC, Rf_xle... -#include "cpp11/attribute_proxy.hpp" // for attribute_proxy -#include "cpp11/protect.hpp" // for preserved -#include "cpp11/r_string.hpp" // for r_string -#include "cpp11/sexp.hpp" // for sexp +#include "headers/R.hpp" // for R_xlen_t, SEXP, SEXPREC, Rf_xle... +#include "headers/attribute_proxy.hpp" // for attribute_proxy +#include "headers/protect.hpp" // for preserved +#include "headers/r_string.hpp" // for r_string +#include "headers/sexp.hpp" // for sexp namespace cpp11 { diff --git a/inst/include/cpp11/raws.hpp b/inst/include/headers/raws.hpp similarity index 90% rename from inst/include/cpp11/raws.hpp rename to inst/include/headers/raws.hpp index a5cb392f..c441126e 100644 --- a/inst/include/cpp11/raws.hpp +++ b/inst/include/headers/raws.hpp @@ -5,12 +5,12 @@ #include // for uint8_t #include // for initializer_list -#include "cpp11/R.hpp" // for RAW, SEXP, SEXPREC, Rf_allocVector -#include "cpp11/attribute_proxy.hpp" // for attribute_proxy -#include "cpp11/named_arg.hpp" // for named_arg -#include "cpp11/protect.hpp" // for preserved -#include "cpp11/r_vector.hpp" // for r_vector, r_vector<>::proxy -#include "cpp11/sexp.hpp" // for sexp +#include "headers/R.hpp" // for RAW, SEXP, SEXPREC, Rf_allocVector +#include "headers/attribute_proxy.hpp" // for attribute_proxy +#include "headers/named_arg.hpp" // for named_arg +#include "headers/protect.hpp" // for preserved +#include "headers/r_vector.hpp" // for r_vector, r_vector<>::proxy +#include "headers/sexp.hpp" // for sexp // Specializations for raws diff --git a/inst/include/cpp11/sexp.hpp b/inst/include/headers/sexp.hpp similarity index 90% rename from inst/include/cpp11/sexp.hpp rename to inst/include/headers/sexp.hpp index 1517c5af..c4d47ef7 100644 --- a/inst/include/cpp11/sexp.hpp +++ b/inst/include/headers/sexp.hpp @@ -4,9 +4,9 @@ #include // for string, basic_string -#include "cpp11/R.hpp" // for SEXP, SEXPREC, REAL_ELT, R_NilV... -#include "cpp11/attribute_proxy.hpp" // for attribute_proxy -#include "cpp11/protect.hpp" // for preserved +#include "headers/R.hpp" // for SEXP, SEXPREC, REAL_ELT, R_NilV... +#include "headers/attribute_proxy.hpp" // for attribute_proxy +#include "headers/protect.hpp" // for preserved namespace cpp11 { diff --git a/inst/include/cpp11/strings.hpp b/inst/include/headers/strings.hpp similarity index 90% rename from inst/include/cpp11/strings.hpp rename to inst/include/headers/strings.hpp index e312c231..886583e5 100644 --- a/inst/include/cpp11/strings.hpp +++ b/inst/include/headers/strings.hpp @@ -3,14 +3,14 @@ #include // for initializer_list #include // for string, basic_string -#include "cpp11/R.hpp" // for SEXP, TYPEOF, SEXPREC, SET_STRI... -#include "cpp11/as.hpp" // for as_sexp -#include "cpp11/attribute_proxy.hpp" // for attribute_proxy -#include "cpp11/named_arg.hpp" // for named_arg -#include "cpp11/protect.hpp" // for preserved -#include "cpp11/r_string.hpp" // for r_string -#include "cpp11/r_vector.hpp" // for r_vector, r_vector<>::proxy -#include "cpp11/sexp.hpp" // for sexp +#include "headers/R.hpp" // for SEXP, TYPEOF, SEXPREC, SET_STRI... +#include "headers/as.hpp" // for as_sexp +#include "headers/attribute_proxy.hpp" // for attribute_proxy +#include "headers/named_arg.hpp" // for named_arg +#include "headers/protect.hpp" // for preserved +#include "headers/r_string.hpp" // for r_string +#include "headers/r_vector.hpp" // for r_vector, r_vector<>::proxy +#include "headers/sexp.hpp" // for sexp // Specializations for strings diff --git a/man/cpp_source.Rd b/man/cpp_source.Rd index 87164ef5..ffe75bd2 100644 --- a/man/cpp_source.Rd +++ b/man/cpp_source.Rd @@ -68,7 +68,7 @@ external packages. This is equivalent to putting those packages in the \examples{ cpp_source( - code = '#include "cpp11/integers.hpp" + code = '#include "headers/integers.hpp" [[cpp11::register]] int num_odd(cpp11::integers x) { @@ -88,7 +88,7 @@ if (interactive() && require("progress")) { cpp_source( code = ' -#include +#include #include [[cpp11::linking_to("progress")]] diff --git a/man/cpp_vendor.Rd b/man/cpp_vendor.Rd index 857e49cf..a02f36de 100644 --- a/man/cpp_vendor.Rd +++ b/man/cpp_vendor.Rd @@ -4,10 +4,10 @@ \alias{cpp_vendor} \title{Vendor the cpp11 dependency} \usage{ -cpp_vendor(path = ".") +cpp_vendor(path = "./src/vendor") } \arguments{ -\item{path}{The path to the package root directory} +\item{path}{The path to vendor the code into.} } \value{ The file path to the vendored code (invisibly). @@ -18,11 +18,11 @@ project is using. It is often used in the go language community. } \details{ This function vendors cpp11 into your package by copying the cpp11 -headers into the \code{inst/include} folder of your package and adding -'cpp11 version: XYZ' to the top of the files, where XYZ is the version of -cpp11 currently installed on your machine. +headers into the \code{src/vendor} folder and adding 'cpp11 version: XYZ' to the +top of the files, where XYZ is the version of cpp11 currently installed on +your machine. -If you choose to vendor the headers you should \emph{remove} \code{LinkingTo: cpp11} from your DESCRIPTION. +If you choose to vendor the headers you should \emph{remove} \code{LinkingTo: cpp11} from your DESCRIPTION. This is done automatically by this function. \strong{Note}: vendoring places the responsibility of updating the code on \strong{you}. Bugfixes and new features in cpp11 will not be available for your @@ -36,7 +36,7 @@ dir.create(dir) # vendor the cpp11 headers into the directory cpp_vendor(dir) -list.files(file.path(dir, "inst", "include", "cpp11")) +list.files(file.path(dir, "src", "vendor")) # cleanup unlink(dir, recursive = TRUE) diff --git a/tests/testthat/_snaps/register.md b/tests/testthat/_snaps/register.md index 0e4b143a..75125c45 100644 --- a/tests/testthat/_snaps/register.md +++ b/tests/testthat/_snaps/register.md @@ -2,7 +2,7 @@ Code cpp_register(p, quiet = FALSE) - Message + Message i 1 functions decorated with [[cpp11::register]] v generated file 'cpp11.R' v generated file 'cpp11.cpp' diff --git a/tests/testthat/_snaps/source.md b/tests/testthat/_snaps/source.md index 15935031..ad9152aa 100644 --- a/tests/testthat/_snaps/source.md +++ b/tests/testthat/_snaps/source.md @@ -2,7 +2,8 @@ Code cpp_source(i_do_not_exist) - Error - Can't find `file` at this path: + Condition + Error: + ! Can't find `file` at this path: {NON_EXISTENT_FILEPATH} diff --git a/tests/testthat/test-register.R b/tests/testthat/test-register.R index 130abcbe..4c50b55d 100644 --- a/tests/testthat/test-register.R +++ b/tests/testthat/test-register.R @@ -83,7 +83,7 @@ describe("get_call_entries", { // clang-format off -#include \"cpp11/declarations.hpp\" +#include \"headers/declarations.hpp\" #include // multiple.cpp @@ -583,7 +583,7 @@ foo <- function() { // clang-format off -#include \"cpp11/declarations.hpp\" +#include \"headers/declarations.hpp\" #include // single.cpp diff --git a/tests/testthat/test-source.R b/tests/testthat/test-source.R index 2945d51d..e997a0c9 100644 --- a/tests/testthat/test-source.R +++ b/tests/testthat/test-source.R @@ -2,7 +2,7 @@ test_that("cpp_source works with the `code` parameter", { skip_on_os("solaris") dll_info <- cpp_source( code = ' - #include "cpp11/integers.hpp" + #include "headers/integers.hpp" [[cpp11::register]] int num_odd(cpp11::integers x) { @@ -131,7 +131,7 @@ test_that("check_valid_attributes does not return an error if all registers are }')) expect_error_free( cpp11::cpp_source(clean = TRUE, - code = '#include + code = '#include #include [[cpp11::linking_to("progress")]] @@ -197,7 +197,7 @@ test_that("check_valid_attributes returns an error if one or more registers is i expect_error( cpp11::cpp_source( code = ' - #include + #include #include [[cpp11::link_to("progress")]] [[cpp11::register]] void show_progress() { diff --git a/tests/testthat/test-vendor.R b/tests/testthat/test-vendor.R index 361c9ad9..c4a37a90 100644 --- a/tests/testthat/test-vendor.R +++ b/tests/testthat/test-vendor.R @@ -24,8 +24,8 @@ describe("cpp_vendor", { cpp_vendor(pkg_path(pkg)) - expect_true(dir.exists(file.path(p, "inst", "include", "cpp11"))) - expect_true(file.exists(file.path(p, "inst", "include", "cpp11.hpp"))) - expect_true(file.exists(file.path(p, "inst", "include", "cpp11", "declarations.hpp"))) + expect_true(dir.exists(file.path(p, "src", "vendor", "cpp11"))) + expect_true(file.exists(file.path(p, "src", "vendor", "cpp11.hpp"))) + expect_true(file.exists(file.path(p, "src", "vendor", "headers", "declarations.hpp"))) }) }) diff --git a/vignettes/converting.Rmd b/vignettes/converting.Rmd index de4b8898..25241059 100644 --- a/vignettes/converting.Rmd +++ b/vignettes/converting.Rmd @@ -26,24 +26,24 @@ It is also a place to highlight some of the largest differences between Rcpp and ## Class comparison table -| Rcpp | cpp11 (read-only) | cpp11 (writable) | cpp11 header | -| --- | --- | --- | --- | -| NumericVector | doubles | writable::doubles | | -| NumericMatrix | doubles_matrix<> | writable::doubles_matrix<> | | -| IntegerVector | integers | writable::integers | | -| IntegerMatrix | integers_matrix<> | writable::integers_matrix<> | | -| CharacterVector | strings | writable::strings | | -| RawVector | raws | writable::raws | | -| List | list | writable::list | | -| RObject | sexp | | | -| XPtr | | external_pointer | | -| Environment | | environment | | -| Function | | function | | -| Environment (namespace) | | package | | -| wrap | | as_sexp | | -| as | | as_cpp | | -| stop | stop | | | -| checkUserInterrupt | check_user_interrupt | | | +| Rcpp | cpp11 (read-only) | cpp11 (writable) | cpp11 header | +| --- | --- | --- | --- | +| NumericVector | doubles | writable::doubles | | +| NumericMatrix | doubles_matrix<> | writable::doubles_matrix<> | | +| IntegerVector | integers | writable::integers | | +| IntegerMatrix | integers_matrix<> | writable::integers_matrix<> | | +| CharacterVector | strings | writable::strings | | +| RawVector | raws | writable::raws | | +| List | list | writable::list | | +| RObject | sexp | | | +| XPtr | | external_pointer | | +| Environment | | environment | | +| Function | | function | | +| Environment (namespace) | | package | | +| wrap | | as_sexp | | +| as | | as_cpp | | +| stop | stop | | | +| checkUserInterrupt | check_user_interrupt | | | ## Incomplete list of Rcpp features not included in cpp11 @@ -186,7 +186,7 @@ You will need to include the appropriate STL header, in this case ``. ### R API includes cpp11 conflicts with macros declared by some R headers unless the macros `R_NO_REMAP` and `STRICT_R_HEADERS` are defined. -If you include `cpp11/R.hpp` before any R headers these macros will be defined appropriately, otherwise you may see errors like +If you include `headers/R.hpp` before any R headers these macros will be defined appropriately, otherwise you may see errors like > R headers were included before cpp11 headers and at least one of R_NO_REMAP or STRICT_R_HEADERS was not defined.