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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Jun 24 12:16:44 UTC 2009


Revision: 2544
          http://rkward.svn.sourceforge.net/rkward/?rev=2544&view=rev
Author:   tfry
Date:     2009-06-24 12:16:44 +0000 (Wed, 24 Jun 2009)

Log Message:
-----------
Correct handling for objects with irregular names inside .GlobalEnv.

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/core/rcontainerobject.cpp
    trunk/rkward/rkward/core/renvironmentobject.cpp
    trunk/rkward/rkward/core/robject.cpp
    trunk/rkward/rkward/core/robject.h
    trunk/rkward/tests/import_export_plugins.R

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2009-06-23 20:48:52 UTC (rev 2543)
+++ trunk/rkward/ChangeLog	2009-06-24 12:16:44 UTC (rev 2544)
@@ -13,8 +13,8 @@
 - Add convenience function "makeHeaderCode()" for use inside plugins	TODO: document, adjust for tests (->rk.describe.alternative())
 - Adjust some icons
 - Plugins can be invoked from R code (mostly for internal purposes)
-- Add "Run again" link for plugin generated output		TODO: revisit plugins without header
-- Fixed: All objects in .Globalenv would be revisited if a single object was added / removed		TODO: backport? (r2466, 2473)
+- Add "Run again" link for plugin generated output
+- Fixed: All objects in .Globalenv would be revisited if a single object was added / removed
 - Fixed: Screen device in rkward was not seen as interactive by R
 
 --- Version 0.5.0d - May-10-2009

Modified: trunk/rkward/rkward/core/rcontainerobject.cpp
===================================================================
--- trunk/rkward/rkward/core/rcontainerobject.cpp	2009-06-23 20:48:52 UTC (rev 2543)
+++ trunk/rkward/rkward/core/rcontainerobject.cpp	2009-06-24 12:16:44 UTC (rev 2544)
@@ -2,7 +2,7 @@
                           rcontainerobject  -  description
                              -------------------
     begin                : Thu Aug 19 2004
-    copyright            : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2009 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -281,7 +281,7 @@
 			RObject* child = childmap[i];
 			if (child->getShortName ().startsWith (current_level)) {
 				QString base_name = child->getBaseName ();
-				if (current_list->contains (base_name)) {
+				if (current_list->contains (base_name) || irregularShortName (base_name)) {
 					current_list->insert (child->getFullName (), child);
 				} else {
 					current_list->insert (base_name, child);
@@ -302,7 +302,6 @@
 	RObject *ret;
 	if (container) {
 		ret = new RContainerObject (this, name);
-		ret->type = Container;
 		if (data_frame) {
 			ret->type |= DataFrame | List | Array | Matrix;
 		}

Modified: trunk/rkward/rkward/core/renvironmentobject.cpp
===================================================================
--- trunk/rkward/rkward/core/renvironmentobject.cpp	2009-06-23 20:48:52 UTC (rev 2543)
+++ trunk/rkward/rkward/core/renvironmentobject.cpp	2009-06-24 12:16:44 UTC (rev 2544)
@@ -59,7 +59,12 @@
 QString REnvironmentObject::makeChildName (const QString &short_child_name, bool misplaced) const {
 	RK_TRACE (OBJECTS);
 
-	if (type & GlobalEnv) return (short_child_name);
+	if (type & GlobalEnv) {
+		if (irregularShortName (short_child_name)) {
+			return (getShortName () + "$" + RObject::rQuote (short_child_name));
+		}
+		return (short_child_name);
+	}
 	if (type & ToplevelEnv) {
 /* Some items are placed outside of their native namespace. E.g. in package:boot item "motor". It can be retrieved using as.environment ("package:boot")$motor. This is extremly ugly. We need to give them (and only them) this special treatment. */
 // TODO: hopefully one day operator "::" will work even in those cases. So check back later, and remove after a sufficient amount of backwards compatibility time

Modified: trunk/rkward/rkward/core/robject.cpp
===================================================================
--- trunk/rkward/rkward/core/robject.cpp	2009-06-23 20:48:52 UTC (rev 2543)
+++ trunk/rkward/rkward/core/robject.cpp	2009-06-24 12:16:44 UTC (rev 2544)
@@ -2,7 +2,7 @@
                           robject  -  description
                              -------------------
     begin                : Thu Aug 19 2004
-    copyright            : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2009 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -53,6 +53,12 @@
 	delete [] classnames;
 }
 
+bool RObject::irregularShortName (const QString &name) {
+	// no trace
+	static const QRegExp invalidChars ("[^a-zA-z0-9\\._]");
+	return (name.contains (invalidChars));
+}
+
 QString RObject::getFullName () const {
 	RK_TRACE (OBJECTS);
 	return parent->makeChildName (RObject::name, type & Misplaced);

Modified: trunk/rkward/rkward/core/robject.h
===================================================================
--- trunk/rkward/rkward/core/robject.h	2009-06-23 20:48:52 UTC (rev 2543)
+++ trunk/rkward/rkward/core/robject.h	2009-06-24 12:16:44 UTC (rev 2544)
@@ -2,7 +2,7 @@
                           robject  -  description
                              -------------------
     begin                : Thu Aug 19 2004
-    copyright            : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2009 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -162,6 +162,8 @@
 /** Returns a canonified name given a non-canoified name. Warning! This is not (necessarily) suitable for submission to
 R, only for internal lookup. For submission to R, always use RObject::getFullName (), as it will apply more complicated (and correct) rules depending on object type */
 	static QString canonifyName (const QString &from);
+/** Tests whether the given name is "irregular", i.e. contains spaces, quotes, operators, or the like. @see RContainerObject::validizeName () */
+	static bool irregularShortName (const QString &name);
 /** Function for code completion: given the partial name, find all objects matching this partial name
 @param partial_name The partial name to look up
 @param current_list A pointer to a valid (but probably initially empty) RObjectMap. Matches will be added to this list

Modified: trunk/rkward/tests/import_export_plugins.R
===================================================================
--- trunk/rkward/tests/import_export_plugins.R	2009-06-23 20:48:52 UTC (rev 2543)
+++ trunk/rkward/tests/import_export_plugins.R	2009-06-24 12:16:44 UTC (rev 2544)
@@ -28,4 +28,4 @@
 
 y <- rktest.runRKTestSuite (suite)
 
-y
\ No newline at end of file
+print (y)


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