Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteb5f6f1

Browse files
committed
R 3.0: correctly restore native symbols for plots; provide distinct scratch directory
1 parent194e20d commiteb5f6f1

File tree

3 files changed

+48
-4
lines changed

3 files changed

+48
-4
lines changed

‎src/cpp/r/R/Tools.R‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,33 @@ assign( envir = .rs.Env, ".rs.setVar", function(name, var)
180180
{
181181
load(filename)
182182

183+
# restore native symbols for R >= 3.0
184+
rVersion<- getRversion()
185+
if (rVersion>="3.0")
186+
{
187+
for(iin1:length(plot[[1]]))
188+
{
189+
# get the symbol then test if it's a native symbol
190+
symbol<-plot[[1]][[i]][[2]][[1]]
191+
if("NativeSymbolInfo"%in% class(symbol))
192+
{
193+
# determine the dll that the symbol lives in
194+
if (!is.null(symbol$package))
195+
name=symbol$package[["name"]]
196+
else
197+
name=symbol$dll[["name"]]
198+
pkgDLL<- getLoadedDLLs()[[name]]
199+
200+
# reconstruct the native symbol and assign it into the plot
201+
nativeSymbol<-getNativeSymbolInfo(name=symbol$name,
202+
PACKAGE=pkgDLL,
203+
withRegistrationInfo=TRUE);
204+
plot[[1]][[i]][[2]][[1]]<-nativeSymbol;
205+
}
206+
}
207+
}
183208
# restore native symbols for R >= 2.14
184-
if (getRversion()>="2.14")
209+
elseif (rVersion>="2.14")
185210
{
186211
try({
187212
for(iin1:length(plot[[1]]))

‎src/cpp/r/include/r/session/RSessionUtils.hpp‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ namespace core {
2626
namespacer {
2727
namespacesession {
2828
namespaceutils {
29-
29+
30+
// check for R 3.0
31+
boolisR3();
32+
3033
// user home path
3134
const core::FilePath&userHomePath();
3235

‎src/cpp/r/session/RSession.cpp‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ namespace r {
7676
namespacesession {
7777

7878
namespace {
79-
79+
80+
// is this R 3.0 or greator
81+
bool s_isR3 =false;
82+
8083
// options
8184
ROptions s_options;
8285

@@ -372,6 +375,11 @@ Error initialize()
372375
if (libError)
373376
LOG_ERROR(libError);
374377

378+
// check whether this is R 3.0 or greater
379+
Error r3Error =r::exec::evaluateString("getRversion() >= '3.0.0'", &s_isR3);
380+
if (r3Error)
381+
LOG_ERROR(r3Error);
382+
375383
// initialize console history capacity
376384
r::session::consoleHistory().setCapacityFromRHistsize();
377385

@@ -387,7 +395,10 @@ Error initialize()
387395
FilePath graphicsPath;
388396
if (s_options.serverMode)
389397
{
390-
graphicsPath = s_options.scopedScratchPath.complete(kGraphicsPath);
398+
std::string path =kGraphicsPath;
399+
if (utils::isR3())
400+
path +="-r3";
401+
graphicsPath = s_options.scopedScratchPath.complete(path);
391402
}
392403
else
393404
{
@@ -1578,6 +1589,11 @@ void quit(bool saveWorkspace)
15781589

15791590
namespaceutils {
15801591

1592+
boolisR3()
1593+
{
1594+
return s_isR3;
1595+
}
1596+
15811597
const FilePath&userHomePath()
15821598
{
15831599
return s_options.userHomePath;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp