[Rinside-commits] r263 - in pkg: . inst inst/examples/qt inst/examples/wt inst/include src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Oct 12 02:48:11 CEST 2012
Author: edd
Date: 2012-10-12 02:48:11 +0200 (Fri, 12 Oct 2012)
New Revision: 263
Modified:
pkg/ChangeLog
pkg/inst/NEWS.Rd
pkg/inst/examples/qt/qtdensity.cpp
pkg/inst/examples/wt/wtdensity.cpp
pkg/inst/include/RInside.h
pkg/src/RInside.cpp
Log:
added new non-throwing parseEval() / parseEvalQ() variants
update Qt and Wt density app example to resist bad user input which no longer brings the app down
Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog 2012-10-11 02:04:21 UTC (rev 262)
+++ pkg/ChangeLog 2012-10-12 00:48:11 UTC (rev 263)
@@ -1,3 +1,14 @@
+2012-10-11 Dirk Eddelbuettel <edd at debian.org>
+
+ * inst/include/RInside.h: Added non-throwing variants of parseEval()
+ and parseEvalQ() (which add 'NT' to the function name)
+ * src/RInside.cpp: Implementation of non-throwing parseEval() variants
+
+ * inst/examples/qt/qtdensity.cpp: Made more tolerant of bad user
+ input by evaluating via non-calling function, and assigning to a
+ temporary variable first.
+ * inst/examples/wt/wtdensity.cpp: Dito
+
2012-10-10 Dirk Eddelbuettel <edd at debian.org>
* src/RInside.cpp: Applied (modified) patch by Theodore Lytras which
Modified: pkg/inst/NEWS.Rd
===================================================================
--- pkg/inst/NEWS.Rd 2012-10-11 02:04:21 UTC (rev 262)
+++ pkg/inst/NEWS.Rd 2012-10-12 00:48:11 UTC (rev 263)
@@ -13,6 +13,9 @@
\item Applied (modified) patch by Theodore Lytras which lets RInside
recover from some parsing errors and makes RInside applications more
tolerant of errors
+ \item Added non-throwing variants of parseEval() and parseEvalQ()
+ \item Modified Qt and Wt examples of density estimation applications
+ to be much more resilient to bad user input
}
}
\section{Changes in RInside version 0.2.8 (2012-09-07)}{
Modified: pkg/inst/examples/qt/qtdensity.cpp
===================================================================
--- pkg/inst/examples/qt/qtdensity.cpp 2012-10-11 02:04:21 UTC (rev 262)
+++ pkg/inst/examples/qt/qtdensity.cpp 2012-10-12 00:48:11 UTC (rev 263)
@@ -125,8 +125,8 @@
}
void QtDensity::runRandomDataCmd(void) {
- std::string cmd = "y <- " + m_cmd.toStdString();
- m_R.parseEvalQ(cmd);
+ std::string cmd = "y2 <- " + m_cmd.toStdString() + "; y <- y2";
+ m_R.parseEvalQNT(cmd);
plot(); // after each random draw, update plot with estimate
}
Modified: pkg/inst/examples/wt/wtdensity.cpp
===================================================================
--- pkg/inst/examples/wt/wtdensity.cpp 2012-10-11 02:04:21 UTC (rev 262)
+++ pkg/inst/examples/wt/wtdensity.cpp 2012-10-12 00:48:11 UTC (rev 263)
@@ -155,8 +155,8 @@
void DensityApp::reportEdit() {
cmd_ = codeEdit_->text().toUTF8(); // get text written in box, as UTF-8, assigned to string
- std::string rng = "y <- " + cmd_ + ";";
- R_.parseEvalQ(rng); // evaluates expression, assigns to 'y'
+ std::string rng = "y2 <- " + cmd_ + "; y <- y2";
+ R_.parseEvalQNT(rng); // evaluates expression, assigns to 'y'
Yvec_ = R_["y"]; // cache the y vector
plot();
}
Modified: pkg/inst/include/RInside.h
===================================================================
--- pkg/inst/include/RInside.h 2012-10-11 02:04:21 UTC (rev 262)
+++ pkg/inst/include/RInside.h 2012-10-12 00:48:11 UTC (rev 263)
@@ -54,7 +54,8 @@
public:
int parseEval(const std::string & line, SEXP &ans); // parse line, return in ans; error code rc
- void parseEvalQ(const std::string & line); // parse line, no return (throws on error)
+ void parseEvalQ(const std::string & line); // parse line, no return (throws on error)
+ void parseEvalQNT(const std::string & line); // parse line, no return (no throw)
class Proxy {
public:
@@ -68,7 +69,8 @@
Rcpp::RObject x;
};
- Proxy parseEval(const std::string & line); // parse line, return SEXP (throws on error)
+ Proxy parseEval(const std::string & line); // parse line, return SEXP (throws on error)
+ Proxy parseEvalNT(const std::string & line); // parse line, return SEXP (no throw)
template <typename T>
void assign(const T& object, const std::string& nam) {
Modified: pkg/src/RInside.cpp
===================================================================
--- pkg/src/RInside.cpp 2012-10-11 02:04:21 UTC (rev 262)
+++ pkg/src/RInside.cpp 2012-10-12 00:48:11 UTC (rev 263)
@@ -378,6 +378,11 @@
}
}
+void RInside::parseEvalQNT(const std::string & line) {
+ SEXP ans;
+ parseEval(line, ans);
+}
+
RInside::Proxy RInside::parseEval(const std::string & line) {
SEXP ans;
int rc = parseEval(line, ans);
@@ -387,6 +392,12 @@
return Proxy( ans );
}
+RInside::Proxy RInside::parseEvalNT(const std::string & line) {
+ SEXP ans;
+ parseEval(line, ans);
+ return Proxy( ans );
+}
+
Rcpp::Environment::Binding RInside::operator[]( const std::string& name ){
return global_env_m[name];
}
More information about the Rinside-commits
mailing list