[Rcpp-commits] r4494 - in pkg/Rcpp: . R inst

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Sep 16 14:06:42 CEST 2013


Author: jjallaire
Date: 2013-09-16 14:06:41 +0200 (Mon, 16 Sep 2013)
New Revision: 4494

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/R/Attributes.R
   pkg/Rcpp/inst/NEWS.Rd
Log:
Remove calls to non-exported functions from the tools package

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2013-09-16 09:54:18 UTC (rev 4493)
+++ pkg/Rcpp/ChangeLog	2013-09-16 12:06:41 UTC (rev 4494)
@@ -1,3 +1,7 @@
+2013-09-16 JJ Allaire <jj at rstudio.org>
+
+        * R/Attributes.R : Remove calls to non-exported functions from the tools package
+
 2013-09-16 Romain Francois <romain at r-enthusiasts.com>
 
         * include/Rcpp/internal/Exporter.h : Specific handling of containers (std::vector,

Modified: pkg/Rcpp/R/Attributes.R
===================================================================
--- pkg/Rcpp/R/Attributes.R	2013-09-16 09:54:18 UTC (rev 4493)
+++ pkg/Rcpp/R/Attributes.R	2013-09-16 12:06:41 UTC (rev 4494)
@@ -309,13 +309,12 @@
     descFile <- file.path(pkgdir,"DESCRIPTION")
     if (!file.exists(descFile))
         stop("pkgdir must refer to the directory containing an R package")
-
-    pkgInfo <- tools:::.split_description(tools:::.read_description(descFile))
-    pkgname <- as.character(pkgInfo$DESCRIPTION["Package"])
-    depends <- unique(names(pkgInfo$Depends))
-    if (is.null(depends))
-        depends <- character()
-
+    pkgDesc <- read.dcf(descFile)[1,]
+    pkgname = .readPkgDescField(pkgDesc, "Package")
+    depends <- .readPkgDescField(pkgDesc, "Depends", character())
+    depends <- unique(.splitDepends(depends)) 
+    depends <- depends[depends != "R"]
+        
     # determine source directory
     srcDir <- file.path(pkgdir, "src")
     if (!file.exists(srcDir))
@@ -330,7 +329,7 @@
     cppFiles <- list.files(srcDir, pattern=glob2rx("*.c*"))
 
     # derive base names (will be used for modules)
-    cppFileBasenames <- tools:::file_path_sans_ext(cppFiles)
+    cppFileBasenames <- tools::file_path_sans_ext(cppFiles)
 
     # expend them to their full paths
     cppFiles <- file.path(srcDir, cppFiles)
@@ -338,7 +337,7 @@
 
     # generate the includes list based on LinkingTo. Specify plugins-only
     # because we only need as/wrap declarations
-    linkingTo <- as.character(pkgInfo$DESCRIPTION["LinkingTo"])
+    linkingTo <- .readPkgDescField(pkgDesc, "LinkingTo")
     includes <- .linkingToIncludes(linkingTo, TRUE)
 
     # if a master include file is defined for the package then include it
@@ -450,7 +449,25 @@
     }
 }
 
+# Split the depends field of a package description
+.splitDepends <- function(x) {
+    if (!length(x)) 
+        return(character())
+    x <- unlist(strsplit(x, ","))
+    x <- sub("[[:space:]]+$", "", x)
+    x <- unique(sub("^[[:space:]]*(.*)", "\\1", x))
+    sub("^([[:alnum:].]+).*$", "\\1", x)
+}
 
+# read a field from a named package description character vector
+.readPkgDescField <- function(pkgDesc, name, default = NULL) {
+    if (name %in% names(pkgDesc))
+        pkgDesc[[name]]
+    else
+        default
+}
+
+
 # Get the inline plugin for the specified package (return NULL if none found)
 .getInlinePlugin <- function(package) {
     tryCatch(get("inlineCxxPlugin", asNamespace(package)),

Modified: pkg/Rcpp/inst/NEWS.Rd
===================================================================
--- pkg/Rcpp/inst/NEWS.Rd	2013-09-16 09:54:18 UTC (rev 4493)
+++ pkg/Rcpp/inst/NEWS.Rd	2013-09-16 12:06:41 UTC (rev 4494)
@@ -47,6 +47,7 @@
       For users, it means that for the parameters of function exported by modules, 
       we can now use references, pointers and const versions of them.
       The file \code{Module.cpp} file has an example. 
+      \item{No longer call non-exported functions from the tools package}
     }
     \item Changes in Modules:
     \itemize{



More information about the Rcpp-commits mailing list