1
1
2
- # Copyright (C) 2012 - 2019 JJ Allaire, Dirk Eddelbuettel and Romain Francois
2
+ # Copyright (C) 2012 - 2020 JJ Allaire, Dirk Eddelbuettel and Romain Francois
3
3
#
4
4
# This file is part of Rcpp.
5
5
#
@@ -83,7 +83,7 @@ sourceCpp <- function(file = "",
83
83
84
84
# print output for verbose mode
85
85
if (verbose )
86
- .printVerboseOutput(context )
86
+ .printVerboseOutput(context ) # #nocov
87
87
88
88
# variables used to hold completed state (passed to completed hook)
89
89
succeeded <- FALSE
@@ -115,7 +115,7 @@ sourceCpp <- function(file = "",
115
115
# on.exit handler calls hook and restores environment and working dir
116
116
on.exit({
117
117
if (! succeeded )
118
- .showBuildFailureDiagnostics()
118
+ .showBuildFailureDiagnostics() # #nocov
119
119
.callBuildCompleteHook(succeeded , output )
120
120
setwd(cwd )
121
121
.restoreEnvironment(envRestore )
@@ -139,7 +139,7 @@ sourceCpp <- function(file = "",
139
139
shQuote(context $ cppSourceFilename ), " " ,
140
140
sep = " " )
141
141
if (showOutput )
142
- cat(cmd , " \n " )
142
+ cat(cmd , " \n " ) # #nocov
143
143
144
144
# execute the build -- suppressWarnings b/c when showOutput = FALSE
145
145
# we are going to explicitly check for an error and print the output
@@ -176,14 +176,14 @@ sourceCpp <- function(file = "",
176
176
on.exit({
177
177
setwd(cwd )
178
178
})
179
- if (verbose )
179
+ if (verbose ) # #nocov start
180
180
cat(" \n No rebuild required (use rebuild = TRUE to " ,
181
181
" force a rebuild)\n\n " , sep = " " )
182
182
}
183
183
184
184
# return immediately if this was a dry run
185
185
if (dryRun )
186
- return (invisible (NULL ))
186
+ return (invisible (NULL )) # #nocov end
187
187
188
188
# load the module if we have exported symbols
189
189
if (length(context $ exportedFunctions ) > 0 || length(context $ modules ) > 0 ) {
@@ -211,7 +211,7 @@ sourceCpp <- function(file = "",
211
211
212
212
# cleanup the cache dir if requested
213
213
if (cleanupCacheDir )
214
- cleanupSourceCppCache(cacheDir , context $ cppSourcePath , context $ buildDirectory )
214
+ cleanupSourceCppCache(cacheDir , context $ cppSourcePath , context $ buildDirectory ) # #nocov
215
215
216
216
# return (invisibly) a list containing exported functions and modules
217
217
invisible (list (functions = context $ exportedFunctions ,
@@ -295,13 +295,13 @@ cppFunction <- function(code,
295
295
" \n --------------------------------------------------------\n\n " )
296
296
cat(code )
297
297
cat(" \n " )
298
- } # #nocov end
298
+ }
299
299
300
300
# source cpp into specified environment. if env is set to NULL
301
301
# then create a new one (the caller can get a hold of the function
302
302
# via the return value)
303
303
if (is.null(env ))
304
- env <- new.env()
304
+ env <- new.env() # #nocov end
305
305
exported <- sourceCpp(code = code ,
306
306
env = env ,
307
307
rebuild = rebuild ,
@@ -311,9 +311,9 @@ cppFunction <- function(code,
311
311
312
312
# verify that a single function was exported and return it
313
313
if (length(exported $ functions ) == 0 )
314
- stop(" No function definition found" )
314
+ stop(" No function definition found" ) # #nocov
315
315
else if (length(exported $ functions ) > 1 )
316
- stop(" More than one function definition" )
316
+ stop(" More than one function definition" ) # #nocov
317
317
else {
318
318
functionName <- exported $ functions [[1 ]]
319
319
invisible (get(functionName , env ))
@@ -405,7 +405,7 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {
405
405
pkgdir <- normalizePath(pkgdir , winslash = " /" )
406
406
descFile <- file.path(pkgdir ," DESCRIPTION" )
407
407
if (! file.exists(descFile ))
408
- stop(" pkgdir must refer to the directory containing an R package" )
408
+ stop(" pkgdir must refer to the directory containing an R package" ) # #nocov
409
409
pkgDesc <- read.dcf(descFile )[1 ,]
410
410
pkgname = .readPkgDescField(pkgDesc , " Package" )
411
411
depends <- c(.readPkgDescField(pkgDesc , " Depends" , character ()),
@@ -417,14 +417,14 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {
417
417
# check the NAMESPACE file to see if dynamic registration is enabled
418
418
namespaceFile <- file.path(pkgdir , " NAMESPACE" )
419
419
if (! file.exists(namespaceFile ))
420
- stop(" pkgdir must refer to the directory containing an R package" )
420
+ stop(" pkgdir must refer to the directory containing an R package" ) # #nocov
421
421
pkgNamespace <- readLines(namespaceFile , warn = FALSE )
422
422
registration <- any(grepl(" ^\\ s*useDynLib.*\\ .registration\\ s*=\\ s*TRUE.*$" , pkgNamespace ))
423
423
424
424
# determine source directory
425
425
srcDir <- file.path(pkgdir , " src" )
426
426
if (! file.exists(srcDir ))
427
- return (FALSE )
427
+ return (FALSE ) # #nocov
428
428
429
429
# create R directory if it doesn't already exist
430
430
rDir <- file.path(pkgdir , " R" )
@@ -474,7 +474,7 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {
474
474
pkgHeaderPath <- file.path(pkgdir , " src" , pkgHeader )
475
475
pkgHeader <- pkgHeader [file.exists(pkgHeaderPath )]
476
476
if (length(pkgHeader ) > 0 )
477
- includes <- c(paste0(" #include \" " , pkgHeader ," \" " ), includes )
477
+ includes <- c(paste0(" #include \" " , pkgHeader ," \" " ), includes ) # #nocov
478
478
479
479
# generate exports
480
480
invisible (.Call(" compileAttributes" , PACKAGE = " Rcpp" ,
@@ -638,7 +638,7 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
638
638
# Split the depends field of a package description
639
639
.splitDepends <- function (x ) {
640
640
if (! length(x ))
641
- return (character ())
641
+ return (character ()) # #nocov
642
642
x <- unlist(strsplit(x , " ," ))
643
643
x <- sub(" [[:space:]]+$" , " " , x )
644
644
x <- unique(sub(" ^[[:space:]]*(.*)" , " \\ 1" , x ))
@@ -665,9 +665,9 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
665
665
666
666
plugin <- .plugins [[pluginName ]]
667
667
if (is.null(plugin ))
668
- stop(" Inline plugin '" , pluginName , " ' could not be found " ,
668
+ stop(" Inline plugin '" , pluginName , " ' could not be found " , # #nocov start
669
669
" within the Rcpp package. You should be " ,
670
- " sure to call registerPlugin before using a plugin." )
670
+ " sure to call registerPlugin before using a plugin." ) # #nocov end
671
671
672
672
return (plugin )
673
673
}
@@ -693,7 +693,7 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
693
693
buildEnv [[name ]] <<- value
694
694
}
695
695
# if it's not identical then append
696
- else if (! identical(buildEnv [[name ]], value )) {
696
+ else if (! identical(buildEnv [[name ]], value )) { # #nocov
697
697
buildEnv [[name ]] <<- paste(buildEnv [[name ]], value ) # #nocov
698
698
}
699
699
else {
@@ -875,7 +875,7 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
875
875
# variables to reset
876
876
setVars <- restore [! is.na(restore )]
877
877
if (length(setVars ))
878
- do.call(Sys.setenv , setVars )
878
+ do.call(Sys.setenv , setVars ) # #nocov
879
879
880
880
# variables to remove
881
881
removeVars <- names(restore [is.na(restore )])
@@ -934,7 +934,7 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
934
934
.getHooksList <- function (name ) {
935
935
hooks <- getHook(name )
936
936
if (! is.list(hooks ))
937
- hooks <- list (hooks )
937
+ hooks <- list (hooks ) # #nocov
938
938
hooks
939
939
}
940
940
@@ -948,7 +948,7 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
948
948
949
949
# This field can be NULL or empty -- in that case just return Rcpp.h
950
950
if (is.null(linkingTo ) || ! nzchar(linkingTo ))
951
- return (c(" #include <Rcpp.h>" ))
951
+ return (c(" #include <Rcpp.h>" )) # #nocov
952
952
953
953
# Look for Rcpp inline plugins within the list or LinkedTo packages
954
954
include.before <- character ()
@@ -1033,7 +1033,7 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
1033
1033
.parseLinkingTo <- function (linkingTo ) {
1034
1034
1035
1035
if (is.null(linkingTo ))
1036
- return (character ())
1036
+ return (character ()) # #nocov
1037
1037
1038
1038
linkingTo <- strsplit(linkingTo , " \\ s*\\ ," )[[1 ]]
1039
1039
result <- gsub(" \\ s" , " " , linkingTo )
@@ -1217,15 +1217,15 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
1217
1217
matches <- regexec(' ^\\ s+\\ {"([^"]+)",.*$' , code )
1218
1218
matches <- regmatches(code , matches )
1219
1219
matches <- Filter(x = matches , function (x ) {
1220
- length(x ) > 0
1220
+ length(x ) > 0 # #nocov start
1221
1221
})
1222
1222
for (match in matches ) {
1223
1223
routine <- match [[2 ]]
1224
1224
if (! routine %in% routines ) {
1225
1225
declaration <- grep(sprintf(" ^extern .* %s\\ (.*$" , routine ), code ,
1226
1226
value = TRUE )
1227
1227
declarations <- c(declarations , sub(" ^extern" , " RcppExport" , declaration ))
1228
- call_entries <- c(call_entries , match [[1 ]])
1228
+ call_entries <- c(call_entries , match [[1 ]]) # #nocov end
1229
1229
}
1230
1230
}
1231
1231
}
0 commit comments