1- # Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois
1+ # Copyright (C) 2010 - 2019 Dirk Eddelbuettel and Romain Francois
22#
33# This file is part of Rcpp.
44#
@@ -24,11 +24,11 @@ forceAssignInNamespace <- function(x, value, env) {
2424 is_ns <- isNamespace(env )
2525 unlocker <- get(" unlockBinding" , baseenv())
2626 if (is_ns && exists(x , env ) && bindingIsLocked(x , env )) {
27- unlocker(x , env )
27+ unlocker(x , env ) # #nocov
2828 }
2929 assign(x , value , env )
3030 if (is_ns ) {
31- lockBinding(x , env )
31+ lockBinding(x , env ) # #nocov
3232 }
3333}
3434
@@ -48,3 +48,28 @@ asBuildPath <- function(path) {
4848
4949 return (path )
5050}
51+
52+
53+ # #' Helper function to report the package version of the R installation.
54+ # #'
55+ # #' While \code{packageVersion(Rcpp)} exports the version registers in
56+ # #' {DESCRIPTION}, this version does get incremented more easily
57+ # #' during development and can therefore be higher than the released
58+ # #' version. The actual \code{#define} long used at the C++ level
59+ # #' corresponds more to an \sQuote{API Version} which is now provided
60+ # #' by this function, and use for example in the package skeleton
61+ # #' generator.
62+ # #'
63+ # #' @title Export the Rcpp (API) Package Version
64+ # #' @param devel An logical value indicating if the development or
65+ # #' release version number should be returned, default is release.
66+ # #' @return A \code{package_version} object with either the release
67+ # #' or development version.
68+ # #' @author Dirk Eddelbuettel
69+ # #' @seealso \code{\link{packageVersion}},
70+ # #' \code{\link{Rcpp.package.skeleton}}
71+ # #' @examples getRcppVersion()
72+ getRcppVersion <- function (devel = FALSE ) {
73+ rcpp <- .Call(" getRcppVersionStrings" , PACKAGE = " Rcpp" )
74+ package_version(rcpp [if (devel ) 2 else 1 ])
75+ }
0 commit comments