[Rinside-commits] r260 - in pkg: . inst inst/include src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Sep 16 00:32:07 CEST 2012
Author: edd
Date: 2012-09-16 00:32:06 +0200 (Sun, 16 Sep 2012)
New Revision: 260
Modified:
pkg/ChangeLog
pkg/DESCRIPTION
pkg/inst/NEWS.Rd
pkg/inst/include/RInside.h
pkg/src/RInside.cpp
Log:
trying to set R_HOME on Windows via get_R_HOME()
renamed private member variable global_env to global_env_m to make it more explicit that it is class local
Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog 2012-09-14 00:45:57 UTC (rev 259)
+++ pkg/ChangeLog 2012-09-15 22:32:06 UTC (rev 260)
@@ -1,3 +1,8 @@
+2012-09-15 Dirk Eddelbuettel <edd at debian.org>
+
+ * src/RInside.cpp (initialize): On Windows, if R_HOME is not set as
+ an environment variable, use R's get_R_HOME() to get it from registry
+
2012-09-13 Dirk Eddelbuettel <edd at debian.org>
* inst/examples/standard/Makefile.win: Added more explicit statement
Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION 2012-09-14 00:45:57 UTC (rev 259)
+++ pkg/DESCRIPTION 2012-09-15 22:32:06 UTC (rev 260)
@@ -1,6 +1,6 @@
Package: RInside
Title: C++ classes to embed R in C++ applications
-Version: 0.2.8
+Version: 0.2.8.1
Date: $Date$
Author: Dirk Eddelbuettel and Romain Francois
Maintainer: Dirk Eddelbuettel <edd at debian.org>
Modified: pkg/inst/NEWS.Rd
===================================================================
--- pkg/inst/NEWS.Rd 2012-09-14 00:45:57 UTC (rev 259)
+++ pkg/inst/NEWS.Rd 2012-09-15 22:32:06 UTC (rev 260)
@@ -8,6 +8,8 @@
need to be set to run the executables -- so either export your local
value, or re-install RInside from source to have it reflected in the
library build of libRinside
+ \item On Windows, have RInside use R's get_R_HOME() function to get
+ R_HOME value from registry if not set by user
}
}
\section{Changes in RInside version 0.2.8 (2012-09-07)}{
Modified: pkg/inst/include/RInside.h
===================================================================
--- pkg/inst/include/RInside.h 2012-09-14 00:45:57 UTC (rev 259)
+++ pkg/inst/include/RInside.h 2012-09-15 22:32:06 UTC (rev 260)
@@ -2,8 +2,8 @@
//
// RInside.h: R/C++ interface class library -- Easier R embedding into C++
//
-// Copyright (C) 2009 Dirk Eddelbuettel
-// Copyright (C) 2010 Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2009 Dirk Eddelbuettel
+// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois
//
// This file is part of RInside.
//
@@ -29,7 +29,7 @@
class RInside {
private:
MemBuf mb_m;
- Rcpp::Environment global_env ;
+ Rcpp::Environment global_env_m;
bool verbose_m; // private switch
@@ -72,7 +72,7 @@
template <typename T>
void assign(const T& object, const std::string& nam) {
- global_env.assign( nam, object ) ;
+ global_env_m.assign( nam, object ) ;
}
RInside() ;
Modified: pkg/src/RInside.cpp
===================================================================
--- pkg/src/RInside.cpp 2012-09-14 00:45:57 UTC (rev 259)
+++ pkg/src/RInside.cpp 2012-09-15 22:32:06 UTC (rev 260)
@@ -31,7 +31,6 @@
#include <unistd.h> // getpid()
-
bool verbose = false;
const char *programName = "RInside";
@@ -120,6 +119,18 @@
// generated from Makevars{.win}
#include "RInsideEnvVars.h"
+ #ifdef WIN32
+ // we need a special case for Windows where users may deploy an RInside binary from CRAN
+ // which will have R_HOME set at compile time to CRAN's value -- so let's try to correct
+ // this here: a) allow user's setting of R_HOME and b) use R's get_R_HOME() function
+ if (getenv("R_HOME") == NULL) { // if on Windows and not set
+ char *rhome = get_R_HOME(); // query it, including registry
+ if (rhome != NULL) { // if something was found
+ setenv("R_HOME", get_R_HOME(), 1); // store what we got as R_HOME
+ } // this will now be used in next blocks
+ }
+ #endif
+
for (int i = 0; R_VARS[i] != NULL; i+= 2) {
if (getenv(R_VARS[i]) == NULL) { // if env variable is not yet set
if (setenv(R_VARS[i],R_VARS[i+1],1) != 0){
@@ -163,7 +174,7 @@
#endif
R_SetParams(&Rst);
- global_env = R_GlobalEnv ;
+ global_env_m = R_GlobalEnv ;
if (loadRcpp) { // if asked for, load Rcpp (before the autoloads)
// Rf_install is used best by first assigning like this so that symbols get into the symbol table
@@ -261,8 +272,8 @@
Rcpp::Language delayed_assign_call(Rcpp::Function("delayedAssign"),
R_NilValue, // arg1: assigned in loop
R_NilValue, // arg2: assigned in loop
- global_env,
- global_env.find(".AutoloadEnv")
+ global_env_m,
+ global_env_m.find(".AutoloadEnv")
);
Rcpp::Language::Proxy delayed_assign_name = delayed_assign_call[1];
@@ -317,7 +328,8 @@
case PARSE_OK:
// Loop is needed here as EXPSEXP might be of length > 1
for(i = 0; i < Rf_length(cmdexpr); i++){
- ans = R_tryEval(VECTOR_ELT(cmdexpr, i),NULL,&errorOccurred);
+ ans = R_tryEval(VECTOR_ELT(cmdexpr, i), global_env_m, &errorOccurred);
+ // NB: we never actually get here if interactice is set to FALSE as it is above
if (errorOccurred) {
Rf_error("%s: Error in evaluating R code (%d)\n", programName, status);
UNPROTECT(2);
@@ -373,7 +385,7 @@
}
Rcpp::Environment::Binding RInside::operator[]( const std::string& name ){
- return global_env[name];
+ return global_env_m[name];
}
RInside& RInside::instance(){
More information about the Rinside-commits
mailing list