Skip to content

Commit ce023b8

Browse files
committed
Automatically generate native routine registrations during compileAttributes
1 parent 4e0f79c commit ce023b8

File tree

6 files changed

+151
-35
lines changed

6 files changed

+151
-35
lines changed

ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2017-05-16 JJ Allaire <[email protected]>
2+
3+
* R/Attributes.R: Automatically generate native routine registrations.
4+
* src/attributes.cpp: Automatically generate native routine registrations.
5+
* R/Rcpp.package.skeleton.R: Don't generate native routines when creating
6+
a package using attributes.
7+
18
2017-05-09 Dirk Eddelbuettel <[email protected]>
29

310
* R/Rcpp.package.skeleton.R (Rcpp.package.skeleton): Under R 3.4.0, run

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: Rcpp
22
Title: Seamless R and C++ Integration
3-
Version: 0.12.10.4
3+
Version: 0.12.10.5
44
Date: 2017-05-07
55
Author: Dirk Eddelbuettel, Romain Francois, JJ Allaire, Kevin Ushey, Qiang Kou,
66
Nathan Russell, Douglas Bates and John Chambers

R/Attributes.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,13 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {
404404
depends <- unique(.splitDepends(depends))
405405
depends <- depends[depends != "R"]
406406

407+
# check the NAMESPACE file to see if dynamic registration is enabled
408+
namespaceFile <- file.path(pkgdir, "NAMESPACE")
409+
if (!file.exists(namespaceFile))
410+
stop("pkgdir must refer to the directory containing an R package")
411+
pkgNamespace <- readLines(namespaceFile, warn = FALSE)
412+
registration <- any(grepl("^\\s*useDynLib.*\\.registration\\s*=\\s*TRUE.*$", pkgNamespace))
413+
407414
# determine source directory
408415
srcDir <- file.path(pkgdir, "src")
409416
if (!file.exists(srcDir))
@@ -449,7 +456,7 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {
449456

450457
# generate exports
451458
invisible(.Call("compileAttributes", PACKAGE="Rcpp",
452-
pkgdir, pkgname, depends, cppFiles, cppFileBasenames,
459+
pkgdir, pkgname, depends, registration, cppFiles, cppFileBasenames,
453460
includes, verbose, .Platform))
454461
}
455462

R/Rcpp.package.skeleton.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(),
185185
message(" >> copied the example module file ")
186186
}
187187

188-
if (getRversion() >= "3.4.0") {
188+
# generate native routines if we aren't using attributes (which already generate
189+
# them automatically) and we have at least R 3.4
190+
if (!attributes && getRversion() >= "3.4.0") {
189191
con <- file(file.path(src, "init.c"), "wt")
190192
tools::package_native_routine_registration_skeleton(root, con=con)
191193
close(con)

inst/NEWS.Rd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
}
4141
\item Changes in Rcpp Attributes:
4242
\itemize{
43+
\item Automatically generate native routine registrations.
4344
\item The plugins for C++11, C++14, C++17 now set the values R 3.4.0 or
4445
later expects; a plugin for C++98 was added (Dirk in \ghpr{684} addressing
4546
\ghit{683}).

0 commit comments

Comments
 (0)