Skip to content
Browse files

R 3.0: correctly restore native symbols for plots; provide distinct s…

…cratch directory
  • Loading branch information...
1 parent 194e20d commit eb5f6f1db4717132c2ff111f068ffa6e8b2a5f0b @jjallaire jjallaire committed Mar 21, 2013
Showing with 48 additions and 4 deletions.
  1. +26 −1 src/cpp/r/R/Tools.R
  2. +4 −1 src/cpp/r/include/r/session/RSessionUtils.hpp
  3. +18 −2 src/cpp/r/session/RSession.cpp
View
27 src/cpp/r/R/Tools.R
@@ -180,8 +180,33 @@ assign( envir = .rs.Env, ".rs.setVar", function(name, var)
{
load(filename)
+ # restore native symbols for R >= 3.0
+ rVersion <- getRversion()
+ if (rVersion >= "3.0")
+ {
+ for(i in 1:length(plot[[1]]))
+ {
+ # get the symbol then test if it's a native symbol
+ symbol <- plot[[1]][[i]][[2]][[1]]
+ if("NativeSymbolInfo" %in% class(symbol))
+ {
+ # determine the dll that the symbol lives in
+ if (!is.null(symbol$package))
+ name = symbol$package[["name"]]
+ else
+ name = symbol$dll[["name"]]
+ pkgDLL <- getLoadedDLLs()[[name]]
+
+ # reconstruct the native symbol and assign it into the plot
+ nativeSymbol <-getNativeSymbolInfo(name = symbol$name,
+ PACKAGE = pkgDLL,
+ withRegistrationInfo = TRUE);
+ plot[[1]][[i]][[2]][[1]] <- nativeSymbol;
+ }
+ }
+ }
# restore native symbols for R >= 2.14
- if (getRversion() >= "2.14")
+ else if (rVersion >= "2.14")
{
try({
for(i in 1:length(plot[[1]]))
View
5 src/cpp/r/include/r/session/RSessionUtils.hpp
@@ -26,7 +26,10 @@ namespace core {
namespace r {
namespace session {
namespace utils {
-
+
+// check for R 3.0
+bool isR3();
+
// user home path
const core::FilePath& userHomePath();
View
20 src/cpp/r/session/RSession.cpp
@@ -76,7 +76,10 @@ namespace r {
namespace session {
namespace {
-
+
+// is this R 3.0 or greator
+bool s_isR3 = false;
+
// options
ROptions s_options;
@@ -372,6 +375,11 @@ Error initialize()
if (libError)
LOG_ERROR(libError);
+ // check whether this is R 3.0 or greater
+ Error r3Error = r::exec::evaluateString("getRversion() >= '3.0.0'", &s_isR3);
+ if (r3Error)
+ LOG_ERROR(r3Error);
+
// initialize console history capacity
r::session::consoleHistory().setCapacityFromRHistsize();
@@ -387,7 +395,10 @@ Error initialize()
FilePath graphicsPath;
if (s_options.serverMode)
{
- graphicsPath = s_options.scopedScratchPath.complete(kGraphicsPath);
+ std::string path = kGraphicsPath;
+ if (utils::isR3())
+ path += "-r3";
+ graphicsPath = s_options.scopedScratchPath.complete(path);
}
else
{
@@ -1578,6 +1589,11 @@ void quit(bool saveWorkspace)
namespace utils {
+bool isR3()
+{
+ return s_isR3;
+}
+
const FilePath& userHomePath()
{
return s_options.userHomePath;

0 comments on commit eb5f6f1

Please sign in to comment.
Something went wrong with that request. Please try again.