[rkward-cvs] SF.net SVN: rkward:[3469] trunk/rkward/rkward/rbackend
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Mon Mar 7 14:00:23 UTC 2011
Revision: 3469
http://rkward.svn.sourceforge.net/rkward/?rev=3469&view=rev
Author: tfry
Date: 2011-03-07 14:00:23 +0000 (Mon, 07 Mar 2011)
Log Message:
-----------
Aesthethics
Modified Paths:
--------------
trunk/rkward/rkward/rbackend/rkstructuregetter.cpp
trunk/rkward/rkward/rbackend/rkstructuregetter.h
Modified: trunk/rkward/rkward/rbackend/rkstructuregetter.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkstructuregetter.cpp 2011-03-07 10:43:47 UTC (rev 3468)
+++ trunk/rkward/rkward/rbackend/rkstructuregetter.cpp 2011-03-07 14:00:23 UTC (rev 3469)
@@ -80,8 +80,6 @@
RData *RKStructureGetter::getStructure (SEXP toplevel, SEXP name, SEXP envlevel, SEXP namespacename) {
RK_TRACE (RBACKEND);
- nesting_depth = INTEGER (envlevel)[0];
-
QString name_string = RKRSupport::SEXPToString (name);
// resolve namespace, if needed
@@ -102,7 +100,7 @@
RData *ret = new RData;
- getStructureSafe (toplevel, name_string, false, ret);
+ getStructureSafe (toplevel, name_string, false, ret, INTEGER (envlevel)[0]);
if (with_namespace) {
UNPROTECT (1); /* namespace_envir */
@@ -111,7 +109,7 @@
return ret;
}
-void RKStructureGetter::getStructureSafe (SEXP value, const QString &name, bool misplaced, RData *storage) {
+void RKStructureGetter::getStructureSafe (SEXP value, const QString &name, bool misplaced, RData *storage, int nesting_depth) {
RK_TRACE (RBACKEND);
GetStructureWorkerArgs args;
@@ -120,20 +118,21 @@
args.misplaced = misplaced;
args.storage = storage;
args.getter = this;
+ args.nesting_depth = nesting_depth;
Rboolean ok = R_ToplevelExec ((void (*)(void*)) getStructureWrapper, &args);
if (ok != TRUE) {
storage->discardData();
Rf_warning ("failure to get object %s", name.toLatin1().data ());
- getStructureWorker (R_NilValue, name, misplaced, storage);
+ getStructureWorker (R_NilValue, name, misplaced, storage, nesting_depth);
}
}
void RKStructureGetter::getStructureWrapper (GetStructureWorkerArgs *data) {
RK_TRACE (RBACKEND);
- data->getter->getStructureWorker (data->toplevel, data->name, data->misplaced, data->storage);
+ data->getter->getStructureWorker (data->toplevel, data->name, data->misplaced, data->storage, data->nesting_depth);
}
SEXP RKStructureGetter::resolvePromise (SEXP from) {
@@ -164,13 +163,13 @@
extern "C" {
// TODO: split out some of the large blocks into helper functions, to make this easier to read
-void RKStructureGetter::getStructureWorker (SEXP val, const QString &name, bool misplaced, RData *storage) {
+void RKStructureGetter::getStructureWorker (SEXP val, const QString &name, bool misplaced, RData *storage, int nesting_depth) {
RK_TRACE (RBACKEND);
bool is_function = false;
bool is_container = false;
bool is_environment = false;
- bool no_recurse = false;
+ bool no_recurse = (nesting_depth >= 2); // TODO: should be configurable
unsigned int type = 0;
RK_DO (qDebug ("fetching '%s': %p, s-type %d", name.toLatin1().data(), val, TYPEOF (val)), RBACKEND, DL_DEBUG);
@@ -238,8 +237,7 @@
}
if (misplaced) type |= RObject::Misplaced;
if (is_container) {
- if (++nesting_depth >= 3) { // TODO: Should be configurable
- no_recurse = true;
+ if (no_recurse) {
type |= RObject::Incomplete;
RK_DO (qDebug ("Depth limit reached. Will not recurse into %s", name.toLatin1().data ()), RBACKEND, DL_DEBUG);
}
@@ -343,7 +341,7 @@
}
}
- getStructureSafe (child, childnames[i], child_misplaced, children[i]);
+ getStructureSafe (child, childnames[i], child_misplaced, children[i], nesting_depth + 1);
UNPROTECT (2); /* current_childname, child */
}
} else if (do_cont) {
@@ -354,13 +352,13 @@
if (Rf_isList (value) && (!may_be_special)) { // old style list
for (int i = 0; i < childcount; ++i) {
SEXP child = CAR (value);
- getStructureSafe (child, childnames[i], false, children[i]);
+ getStructureSafe (child, childnames[i], false, children[i], nesting_depth + 1);
CDR (value);
}
} else if (Rf_isNewList (value) && (!may_be_special)) { // new style list
for (int i = 0; i < childcount; ++i) {
SEXP child = VECTOR_ELT(value, i);
- getStructureSafe (child, childnames[i], false, children[i]);
+ getStructureSafe (child, childnames[i], false, children[i], nesting_depth + 1);
}
} else { // probably an S4 object disguised as a list
SEXP index = Rf_allocVector(INTSXP, 1);
@@ -368,7 +366,7 @@
for (int i = 0; i < childcount; ++i) {
INTEGER (index)[0] = (i + 1);
SEXP child = RKRSupport::callSimpleFun2 (double_brackets_fun, value, index, R_BaseEnv);
- getStructureSafe (child, childnames[i], false, children[i]);
+ getStructureSafe (child, childnames[i], false, children[i], nesting_depth + 1);
}
UNPROTECT (1); /* index */
}
@@ -402,8 +400,6 @@
RK_ASSERT (!res.contains (0));
storage->setData (res);
-
- if (is_container) --nesting_depth; // Ugly! should be a function parameter, instead
}
} /* extern "C" */
Modified: trunk/rkward/rkward/rbackend/rkstructuregetter.h
===================================================================
--- trunk/rkward/rkward/rbackend/rkstructuregetter.h 2011-03-07 10:43:47 UTC (rev 3468)
+++ trunk/rkward/rkward/rbackend/rkstructuregetter.h 2011-03-07 14:00:23 UTC (rev 3469)
@@ -37,13 +37,14 @@
QString name;
bool misplaced;
RData *storage;
+ int nesting_depth;
RKStructureGetter *getter;
};
- void getStructureWorker (SEXP value, const QString &name, bool misplaced, RData *storage);
+ void getStructureWorker (SEXP value, const QString &name, bool misplaced, RData *storage, int nesting_depth);
/** needed to wrap things inside an R_ToplevelExec */
static void getStructureWrapper (GetStructureWorkerArgs *data);
- void getStructureSafe (SEXP value, const QString &name, bool misplaced, RData *storage);
+ void getStructureSafe (SEXP value, const QString &name, bool misplaced, RData *storage, int nesting_depth);
SEXP resolvePromise (SEXP from);
SEXP prefetch_fun (const char *name, bool from_base=true);
@@ -72,9 +73,6 @@
int num_prefetched_funs;
bool keep_evalled_promises;
-
- /** current depth of recursion into environments */
- int nesting_depth;
};
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list