Skip to content

Commit 2943c72

Browse files
committed
don't use cpp_source!
1 parent 217fe66 commit 2943c72

39 files changed

+1052
-1324
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Suggests:
4747
VignetteBuilder:
4848
knitr
4949
Config/testthat/edition: 3
50-
Config/Needs/cpp4r/cpp_register:
50+
Config/Needs/cpp4r/register:
5151
brio,
5252
cli,
5353
decor,

NAMESPACE

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Generated by roxygen2: do not edit by hand
22

3-
export(cpp_eval)
4-
export(cpp_function)
5-
export(cpp_register)
6-
export(cpp_source)
7-
export(cpp_vendor)
3+
export(register)
4+
export(unvendor)
5+
export(vendor)

R/knitr.R

Lines changed: 0 additions & 15 deletions
This file was deleted.

R/register.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
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 `cpp_register()` the `cli`, `decor`, `desc`, `glue`,
10+
#' In order to use `register()` the `cli`, `decor`, `desc`, `glue`,
1111
#' `tibble` and `vctrs` packages must also be installed.
1212
#' @param path The path to the package root directory
1313
#' @param quiet If `TRUE` suppresses output from this function
@@ -28,16 +28,16 @@
2828
#' writeLines("[[cpp4r::register]] int one() { return 1; }", file.path(dir, "src", "one.cpp"))
2929
#'
3030
#' # register the functions in the package
31-
#' cpp_register(dir)
31+
#' register(dir)
3232
#'
3333
#' # Files generated by registration
3434
#' file.exists(file.path(dir, "R", "cpp4r.R"))
3535
#' file.exists(file.path(dir, "src", "cpp4r.cpp"))
3636
#'
3737
#' # cleanup
3838
#' unlink(dir, recursive = TRUE)
39-
cpp_register <- function(path = ".", quiet = !is_interactive(), extension = c(".cpp", ".cc")) {
40-
stop_unless_installed(get_cpp_register_needs())
39+
register <- function(path = ".", quiet = !is_interactive(), extension = c(".cpp", ".cc")) {
40+
stop_unless_installed(get_register_needs())
4141
extension <- match.arg(extension)
4242

4343
r_path <- file.path(path, "R", "cpp4r.R")
@@ -300,8 +300,8 @@ pkg_links_to_rcpp <- function(path) {
300300
any(deps$type == "LinkingTo" & deps$package == "Rcpp")
301301
}
302302

303-
get_cpp_register_needs <- function() {
304-
res <- read.dcf(system.file("DESCRIPTION", package = "cpp4r"))[, "Config/Needs/cpp4r/cpp_register"]
303+
get_register_needs <- function() {
304+
res <- read.dcf(system.file("DESCRIPTION", package = "cpp4r"))[, "Config/Needs/cpp4r/register"]
305305
strsplit(res, "[[:space:]]*,[[:space:]]*")[[1]]
306306
}
307307

R/source.R

Lines changed: 0 additions & 239 deletions
This file was deleted.

R/unvendor.R

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#' Unvendor the cpp4r headers
2+
#'
3+
#' This function removes the vendored cpp4r headers from your package and
4+
#' restores the `LinkingTo: cpp4r` field in the DESCRIPTION file if it was removed.
5+
#'
6+
#' @inheritParams register
7+
#' @return The file path to the unvendored code (invisibly).
8+
#' @export
9+
#' @examples
10+
#' # create a new directory
11+
#' dir <- tempfile()
12+
#' dir.create(dir)
13+
#'
14+
#' # vendor the cpp4r headers into the directory
15+
#' vendor(dir)
16+
#'
17+
#' # unvendor the cpp4r headers from the directory
18+
#' unvendor(dir)
19+
#'
20+
#' list.files(file.path(dir, "inst", "include", "cpp4r"))
21+
#'
22+
#' # cleanup
23+
#' unlink(dir, recursive = TRUE)
24+
unvendor <- function(path = ".") {
25+
new <- file.path(path, "inst", "include", "cpp4r")
26+
27+
if (!dir.exists(new)) {
28+
stop("'", new, "' does not exist", call. = FALSE)
29+
}
30+
31+
unlink(new, recursive = TRUE)
32+
33+
cpp4r_hpp <- file.path(dirname(new), "cpp4r.hpp")
34+
if (file.exists(cpp4r_hpp)) {
35+
unlink(cpp4r_hpp)
36+
}
37+
38+
invisible(new)
39+
}

0 commit comments

Comments
 (0)