Skip to content

Commit ea348f5

Browse files
committed
Remove calls to non-exported functions from the tools package
1 parent 1157eb2 commit ea348f5

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2013-09-16 JJ Allaire <jj@rstudio.org>
2+
3+
* R/Attributes.R : Remove calls to non-exported functions from the tools package
4+
15
2013-09-16 Romain Francois <romain@r-enthusiasts.com>
26

37
* include/Rcpp/internal/Exporter.h : Specific handling of containers (std::vector,

R/Attributes.R

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,13 +309,12 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {
309309
descFile <- file.path(pkgdir,"DESCRIPTION")
310310
if (!file.exists(descFile))
311311
stop("pkgdir must refer to the directory containing an R package")
312-
313-
pkgInfo <- tools:::.split_description(tools:::.read_description(descFile))
314-
pkgname <- as.character(pkgInfo$DESCRIPTION["Package"])
315-
depends <- unique(names(pkgInfo$Depends))
316-
if (is.null(depends))
317-
depends <- character()
318-
312+
pkgDesc <- read.dcf(descFile)[1,]
313+
pkgname = .readPkgDescField(pkgDesc, "Package")
314+
depends <- .readPkgDescField(pkgDesc, "Depends", character())
315+
depends <- unique(.splitDepends(depends))
316+
depends <- depends[depends != "R"]
317+
319318
# determine source directory
320319
srcDir <- file.path(pkgdir, "src")
321320
if (!file.exists(srcDir))
@@ -330,15 +329,15 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {
330329
cppFiles <- list.files(srcDir, pattern=glob2rx("*.c*"))
331330

332331
# derive base names (will be used for modules)
333-
cppFileBasenames <- tools:::file_path_sans_ext(cppFiles)
332+
cppFileBasenames <- tools::file_path_sans_ext(cppFiles)
334333

335334
# expend them to their full paths
336335
cppFiles <- file.path(srcDir, cppFiles)
337336
cppFiles <- normalizePath(cppFiles, winslash = "/")
338337

339338
# generate the includes list based on LinkingTo. Specify plugins-only
340339
# because we only need as/wrap declarations
341-
linkingTo <- as.character(pkgInfo$DESCRIPTION["LinkingTo"])
340+
linkingTo <- .readPkgDescField(pkgDesc, "LinkingTo")
342341
includes <- .linkingToIncludes(linkingTo, TRUE)
343342

344343
# if a master include file is defined for the package then include it
@@ -450,6 +449,24 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
450449
}
451450
}
452451

452+
# Split the depends field of a package description
453+
.splitDepends <- function(x) {
454+
if (!length(x))
455+
return(character())
456+
x <- unlist(strsplit(x, ","))
457+
x <- sub("[[:space:]]+$", "", x)
458+
x <- unique(sub("^[[:space:]]*(.*)", "\\1", x))
459+
sub("^([[:alnum:].]+).*$", "\\1", x)
460+
}
461+
462+
# read a field from a named package description character vector
463+
.readPkgDescField <- function(pkgDesc, name, default = NULL) {
464+
if (name %in% names(pkgDesc))
465+
pkgDesc[[name]]
466+
else
467+
default
468+
}
469+
453470

454471
# Get the inline plugin for the specified package (return NULL if none found)
455472
.getInlinePlugin <- function(package) {

inst/NEWS.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
For users, it means that for the parameters of function exported by modules,
4848
we can now use references, pointers and const versions of them.
4949
The file \code{Module.cpp} file has an example.
50+
\item{No longer call non-exported functions from the tools package}
5051
}
5152
\item Changes in Modules:
5253
\itemize{

0 commit comments

Comments
 (0)