[rkward-cvs] SF.net SVN: rkward:[3460] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Mar 2 17:58:18 UTC 2011


Revision: 3460
          http://rkward.svn.sourceforge.net/rkward/?rev=3460&view=rev
Author:   tfry
Date:     2011-03-02 17:58:18 +0000 (Wed, 02 Mar 2011)

Log Message:
-----------
Now that RKWard will fetch child info on demand, limit the amount of pro-active recursion into lists and other containers.

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/rbackend/rkstructuregetter.cpp
    trunk/rkward/rkward/rbackend/rkstructuregetter.h

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2011-03-02 16:48:59 UTC (rev 3459)
+++ trunk/rkward/ChangeLog	2011-03-02 17:58:18 UTC (rev 3460)
@@ -1,3 +1,4 @@
+- Be less pro-active about fetching structure information on R objects in the workspace		TODO: verify that this fixes our issues with rXML
 - Allow to browse arbitrarily deeply nested environments in the object browser
 
 --- Version 0.5.5 - XXX-XX-2011

Modified: trunk/rkward/rkward/rbackend/rkstructuregetter.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkstructuregetter.cpp	2011-03-02 16:48:59 UTC (rev 3459)
+++ trunk/rkward/rkward/rbackend/rkstructuregetter.cpp	2011-03-02 17:58:18 UTC (rev 3460)
@@ -2,7 +2,7 @@
                           rkstructuregetter  -  description
                              -------------------
     begin                : Wed Apr 11 2007
-    copyright            : (C) 2007, 2009, 2010 by Thomas Friedrichsmeier
+    copyright            : (C) 2007, 2009, 2010, 2011 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -80,8 +80,7 @@
 RData *RKStructureGetter::getStructure (SEXP toplevel, SEXP name, SEXP envlevel, SEXP namespacename) {
 	RK_TRACE (RBACKEND);
 
-	// TODO: accept an envlevel parameter
-	envir_depth = INTEGER (envlevel)[0];
+	nesting_depth = INTEGER (envlevel)[0];
 
 	QString name_string = RKRSupport::SEXPToString (name);
 
@@ -142,7 +141,8 @@
 
 	SEXP ret = from;
 	if (TYPEOF (from) == PROMSXP) {
-		if (PRVALUE(from) == R_UnboundValue) {
+		ret = PRVALUE(from);
+		if (ret == R_UnboundValue) {
 			RK_DO (qDebug ("temporarily resolving unbound promise"), RBACKEND, DL_DEBUG);
 
 			PROTECT (from);
@@ -188,7 +188,7 @@
 	// get classes
 	SEXP classes_s;
 
-	if (TYPEOF (value) == LANGSXP) {	// if it's a call, we should NEVER send it through eval
+	if ((TYPEOF (value) == LANGSXP) || (TYPEOF (value) == SYMSXP)) {	// if it's a call, we should NEVER send it through eval
 		extern SEXP R_data_class (SEXP, Rboolean);
 		classes_s = R_data_class (value, (Rboolean) 0);
 
@@ -228,10 +228,6 @@
 			is_container = true;
 			type |= RObject::Environment;
 			is_environment = true;
-			if (++envir_depth >= 2) {
-				no_recurse = true;
-				type |= RObject::Incomplete;
-			}
 		} else {
 			type |= RObject::Variable;
 			if (RKRSupport::callSimpleBool (is_factor_fun, value, R_BaseEnv)) type |= RObject::Factor;
@@ -241,6 +237,13 @@
 		}
 	}
 	if (misplaced) type |= RObject::Misplaced;
+	if (is_container) {
+		if (++nesting_depth >= 3) {		// TODO: Should be configurable
+			no_recurse = true;
+			type |= RObject::Incomplete;
+			RK_DO (qDebug ("Depth limit reached. Will not recurse into %s", name.toLatin1().data ()), RBACKEND, DL_DEBUG);
+		}
+	}
 
 	// get meta data, if any
 	RData *metadata = new RData;
@@ -301,7 +304,7 @@
 	// now add the extra info for containers and functions
 	if (is_container) {
 		bool do_env = (is_environment && (!no_recurse));
-		bool do_cont = is_container && (!is_environment);
+		bool do_cont = is_container && (!is_environment) && (!no_recurse);
 
 		// fetch list of child names
 		SEXP childnames_s;
@@ -401,6 +404,8 @@
 
 	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-02 16:48:59 UTC (rev 3459)
+++ trunk/rkward/rkward/rbackend/rkstructuregetter.h	2011-03-02 17:58:18 UTC (rev 3460)
@@ -2,7 +2,7 @@
                           rkstructuregetter  -  description
                              -------------------
     begin                : Wed Apr 11 2007
-    copyright            : (C) 2007, 2009, 2010 by Thomas Friedrichsmeier
+    copyright            : (C) 2007, 2009, 2010, 2011 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -74,7 +74,7 @@
 	bool keep_evalled_promises;
 
 	/** current depth of recursion into environments */
-	int envir_depth;
+	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