Skip to content

Commit 3af3036

Browse files
authored
Merge pull request #963 from RcppCore/feature/version_string
Feature/version string
2 parents 7f4e64d + b35f1a8 commit 3af3036

File tree

10 files changed

+115
-11
lines changed

10 files changed

+115
-11
lines changed

ChangeLog

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
2019-04-26 Dirk Eddelbuettel <[email protected]>
2+
3+
* DESCRIPTION (Version, Date): Roll minor version
4+
5+
* R/tools.R (getRcppVersion): More idiomatic code
6+
7+
2019-04-25 Dirk Eddelbuettel <[email protected]>
8+
9+
* R/tools.R (getRcppVersion): Export R (and dev) package version
10+
* man/getRcppVersion.Rd: Documentation for new function
11+
12+
* inst/include/Rcpp/config.h (RCPP_VERSION_STRING): New version
13+
and development version string #define
14+
* src/api.cpp (getRcppVersionStrings): Expose new versions strings
15+
* src/internal.h: Register new version string exporter
16+
* src/rcpp_init.cpp (callEntries[]): Idem
17+
18+
* inst/unitTests/runit.misc.R (test.getRcppVersion): test new function
19+
120
2019-03-23 Ralf Stubner <[email protected]>
221

322
* vignettes/Rcpp-modules.Rmd: Describe RCPP_EXPOSED_* macros

DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: Rcpp
22
Title: Seamless R and C++ Integration
3-
Version: 1.0.1.2
4-
Date: 2019-03-20
3+
Version: 1.0.1.3
4+
Date: 2019-04-26
55
Author: Dirk Eddelbuettel, Romain Francois, JJ Allaire, Kevin Ushey, Qiang Kou,
66
Nathan Russell, Douglas Bates and John Chambers
77
Maintainer: Dirk Eddelbuettel <[email protected]>
@@ -22,4 +22,4 @@ URL: http://www.rcpp.org, http://dirk.eddelbuettel.com/code/rcpp.html, https://g
2222
License: GPL (>= 2)
2323
BugReports: https://github.com/RcppCore/Rcpp/issues
2424
MailingList: Please send questions and comments regarding Rcpp to [email protected]
25-
RoxygenNote: 6.0.1
25+
RoxygenNote: 6.1.1

NAMESPACE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export(Module,
3232
sizeof,
3333
cpp_object_initializer,
3434
cpp_object_dummy,
35-
Rcpp.plugin.maker
35+
Rcpp.plugin.maker,
36+
getRcppVersion
3637
)
3738
S3method(print, bytes)
3839
S3method(format, Rcpp_stack_trace)

R/tools.R

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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+
}

inst/include/Rcpp/config.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
#define RcppDevVersion(maj, min, rev, dev) (((maj)*1000000) + ((min)*10000) + ((rev)*100) + (dev))
2727

2828
// the currently released version
29-
#define RCPP_VERSION Rcpp_Version(1,0,1)
29+
#define RCPP_VERSION Rcpp_Version(1,0,1)
30+
#define RCPP_VERSION_STRING "1.0.1"
3031

3132
// the current source snapshot
32-
#define RCPP_DEV_VERSION RcppDevVersion(1,0,1,0)
33+
#define RCPP_DEV_VERSION RcppDevVersion(1,0,1,0)
34+
#define RCPP_DEV_VERSION_STRING "1.0.1.0"
3335

3436
#endif

inst/unitTests/runit.misc.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env r
22
#
3-
# Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois
3+
# Copyright (C) 2010 - 2019 Dirk Eddelbuettel and Romain Francois
44
#
55
# This file is part of Rcpp.
66
#
@@ -214,4 +214,11 @@ if (.runThisTest) {
214214
checkTrue(nchar(Rcpp:::bib()) > 0, msg="bib file")
215215
}
216216

217+
test.getRcppVersion <- function() {
218+
checkTrue(inherits(getRcppVersion(), "package_version"),
219+
msg="package_version object")
220+
checkTrue(getRcppVersion(devel=TRUE) >= getRcppVersion(devel=FALSE),
221+
msg="dev greater equal release")
222+
}
223+
217224
}

man/getRcppVersion.Rd

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,11 @@ SEXP stack_trace(const char* file, int line) {
325325

326326
// }}}
327327

328+
329+
// [[Rcpp::internal]]
330+
SEXP getRcppVersionStrings() {
331+
Shield<SEXP> versionstring(Rf_allocVector(STRSXP,2));
332+
SET_STRING_ELT(versionstring, 0, Rf_mkChar(RCPP_VERSION_STRING));
333+
SET_STRING_ELT(versionstring, 1, Rf_mkChar(RCPP_DEV_VERSION_STRING));
334+
return versionstring;
335+
}

src/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ CALLFUN_0(rcpp_capabilities);
128128
CALLFUN_0(rcpp_can_use_cxx0x);
129129
CALLFUN_0(rcpp_can_use_cxx11);
130130

131+
CALLFUN_0(getRcppVersionStrings);
132+
131133
/* .External functions */
132134
EXTFUN(CppMethod__invoke);
133135
EXTFUN(CppMethod__invoke_void);

src/rcpp_init.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ static R_CallMethodDef callEntries[] = {
5757
CALLDEF(rcpp_capabilities,0),
5858
CALLDEF(rcpp_can_use_cxx0x,0),
5959
CALLDEF(rcpp_can_use_cxx11,0),
60+
61+
CALLDEF(getRcppVersionStrings,0),
6062
{NULL, NULL, 0}
6163
};
6264

@@ -130,7 +132,7 @@ extern "C" void R_unload_Rcpp(DllInfo *) { // #nocov start
130132
extern "C" void R_init_Rcpp(DllInfo* dllinfo) {
131133
setCurrentScope(0);
132134

133-
registerFunctions(); // call wrapper to register export symbols
135+
registerFunctions(); // call wrapper to register export symbols
134136

135137
R_useDynamicSymbols(dllinfo, FALSE); // set up symbol symbol lookup (cf R 3.4.0)
136138

0 commit comments

Comments
 (0)