[education/rkward] rkward/rbackend: Fix compilation for R < 4.0.0
Thomas Friedrichsmeier
null at kde.org
Sun May 29 08:14:01 BST 2022
Git commit e9c7eb41be2e6ff8b62a8a311b841b4b7c6d2aa2 by Thomas Friedrichsmeier.
Committed on 29/05/2022 at 07:13.
Pushed by tfry into branch 'master'.
Fix compilation for R < 4.0.0
M +17 -1 rkward/rbackend/rkrsupport.cpp
https://invent.kde.org/education/rkward/commit/e9c7eb41be2e6ff8b62a8a311b841b4b7c6d2aa2
diff --git a/rkward/rbackend/rkrsupport.cpp b/rkward/rbackend/rkrsupport.cpp
index 69abc1b8..1d07f4bd 100644
--- a/rkward/rbackend/rkrsupport.cpp
+++ b/rkward/rbackend/rkrsupport.cpp
@@ -335,6 +335,22 @@ void RKRShadowEnvironment::updateSymbolCache(const QString& name) {
UNPROTECT(2);
}
+static void unbindSymbolWrapper(SEXP name, SEXP env) {
+#if R_VERSION >= R_Version(4, 0, 0)
+ R_removeVarFromFrame(name, env);
+#else
+ SEXP call = PROTECT(Rf_allocVector(LANGSXP, 3));
+ SETCAR(call, Rf_install("rm"));
+ SEXP s = CDR(call);
+ SETCAR(s, name);
+ s = CDR(s);
+ SETCAR(s, env);
+ SET_TAG(s, Rf_install("pos"));
+ Rf_eval(call, R_BaseEnv);
+ UNPROTECT(1);
+#endif
+}
+
RKRShadowEnvironment::Result RKRShadowEnvironment::diffAndUpdate() {
RK_TRACE (RBACKEND);
Result res;
@@ -373,7 +389,7 @@ RKRShadowEnvironment::Result RKRShadowEnvironment::diffAndUpdate() {
SEXP main = Rf_findVar(name, baseenvir);
if (main == R_UnboundValue) {
res.removed.append(RKRSupport::SEXPToString(name));
- R_removeVarFromFrame(name, shadowenvir);
+ unbindSymbolWrapper(name, shadowenvir);
if (++count >= count2) i = count2; // end loop
}
UNPROTECT(1);
More information about the rkward-tracker
mailing list