[rkward-cvs] SF.net SVN: rkward-code:[4569] trunk/rkward
tfry at users.sf.net
tfry at users.sf.net
Thu Mar 7 15:53:06 UTC 2013
Revision: 4569
http://sourceforge.net/p/rkward/code/4569
Author: tfry
Date: 2013-03-07 15:53:05 +0000 (Thu, 07 Mar 2013)
Log Message:
-----------
Refinements to handling of loaded namespaces without corrsponding packages on the search path.
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/rkward/core/rkpseudoobjects.cpp
trunk/rkward/rkward/core/rkpseudoobjects.h
trunk/rkward/rkward/core/robject.h
trunk/rkward/rkward/core/robjectlist.cpp
trunk/rkward/rkward/core/robjectlist.h
trunk/rkward/rkward/misc/rkobjectlistview.cpp
trunk/rkward/rkward/rbackend/rinterface.cpp
trunk/rkward/rkward/rbackend/rkrbackend.cpp
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2013-03-06 17:02:26 UTC (rev 4568)
+++ trunk/rkward/ChangeLog 2013-03-07 15:53:05 UTC (rev 4569)
@@ -1,5 +1,4 @@
- Added support for loaded namespaces that are not attached to a loaded package
- - TODO: Currently works only after clicking "Update" in the workspace view. Make it work automatically!
- Pluginmaps can specify their "priority". Pluginmaps with low priority will not be added automatically, when found.
- Pluginmaps can <require> other pluginmaps based on their id (for cross-package inclusion)
- TODO: test
Modified: trunk/rkward/rkward/core/rkpseudoobjects.cpp
===================================================================
--- trunk/rkward/rkward/core/rkpseudoobjects.cpp 2013-03-06 17:02:26 UTC (rev 4568)
+++ trunk/rkward/rkward/core/rkpseudoobjects.cpp 2013-03-07 15:53:05 UTC (rev 4569)
@@ -81,7 +81,7 @@
#include "rkmodificationtracker.h"
#include "../rkglobals.h"
-RKOrphanNamespacesObject::RKOrphanNamespacesObject (RObjectList* parent) : REnvironmentObject (parent, "." + i18nc ("Note: namespaces is a technical term, should not be translated", "Orphan Namespaces")) { // HACK: Name prefixed with "." to treat object as hidden.
+RKOrphanNamespacesObject::RKOrphanNamespacesObject (RObjectList* parent) : REnvironmentObject (parent, i18nc ("Note: 'namespace' is a technical term, should not be translated", "Orphan Namespaces")) {
RK_TRACE (OBJECTS);
type |= PseudoObject;
pseudo_object_types.insert (this, OrphanNamespacesObject);
@@ -150,3 +150,10 @@
return 0;
}
+QString RKOrphanNamespacesObject::getObjectDescription () const {
+ RK_TRACE (OBJECTS);
+
+ QString desc = RObject::getObjectDescription ();
+ desc.append ("<p>This special object does not actually exist anywhere in R. It is used, here, to list namespaces which are loaded, but not attached to a package on the search path. These are typically 'imported' namespaces.</p>");
+ return desc;
+}
Modified: trunk/rkward/rkward/core/rkpseudoobjects.h
===================================================================
--- trunk/rkward/rkward/core/rkpseudoobjects.h 2013-03-06 17:02:26 UTC (rev 4568)
+++ trunk/rkward/rkward/core/rkpseudoobjects.h 2013-03-07 15:53:05 UTC (rev 4569)
@@ -78,6 +78,7 @@
QString getFullName () const;
QString makeChildName (const QString &short_child_name, bool misplaced=false) const;
QString makeChildBaseName (const QString &short_child_name) const;
+ QString getObjectDescription () const;
RKNamespaceObject *findOrphanNamespace (const QString &name) const;
Modified: trunk/rkward/rkward/core/robject.h
===================================================================
--- trunk/rkward/rkward/core/robject.h 2013-03-06 17:02:26 UTC (rev 4568)
+++ trunk/rkward/rkward/core/robject.h 2013-03-07 15:53:05 UTC (rev 4569)
@@ -198,7 +198,7 @@
/** Returns the given string in quotes, taking care of escaping quotation marks inside the string. */
static QString rQuote (const QString &string);
/** Returns a pretty description of the object, and its most important properties. TODO should this be virtual or not? I suppose, it's a close call. For now, we do all work here with casts */
- QString getObjectDescription () const;
+ virtual QString getObjectDescription () const;
/** Parses an object path (such as package::name[["a"]]$b at slot) into its components, returning them as a list (in this case 'package', '::' 'name', '$', 'a', '$', 'b', '@', 'slot'). */
static QStringList parseObjectPath (const QString &path);
/** Tests whether the given name is "irregular", i.e. contains spaces, quotes, operators, or the like. @see RContainerObject::validizeName () */
Modified: trunk/rkward/rkward/core/robjectlist.cpp
===================================================================
--- trunk/rkward/rkward/core/robjectlist.cpp 2013-03-06 17:02:26 UTC (rev 4568)
+++ trunk/rkward/rkward/core/robjectlist.cpp 2013-03-07 15:53:05 UTC (rev 4569)
@@ -18,8 +18,8 @@
#define UPDATE_DELAY_INTERVAL 500
-#define ROBJECTLIST_UDPATE_ENVIRONMENTS_COMMAND 1
-#define ROBJECTLIST_UDPATE_COMPLETE_COMMAND 2
+#define ROBJECTLIST_UPDATE_ENVIRONMENTS_COMMAND 1
+#define ROBJECTLIST_UPDATE_COMPLETE_COMMAND 2
#include <qtimer.h>
#include <qstringlist.h>
@@ -110,11 +110,11 @@
emit (updateStarted ());
update_chain = RKGlobals::rInterface ()->startChain (chain);
- RCommand *command = new RCommand ("list (search (), loadedNamespaces ())", RCommand::App | RCommand::Sync | RCommand::GetStructuredData, QString::null, this, ROBJECTLIST_UDPATE_ENVIRONMENTS_COMMAND);
+ RCommand *command = new RCommand ("list (search (), loadedNamespaces ())", RCommand::App | RCommand::Sync | RCommand::GetStructuredData, QString (), this, ROBJECTLIST_UPDATE_ENVIRONMENTS_COMMAND);
RKGlobals::rInterface ()->issueCommand (command, update_chain);
}
-void RObjectList::updateFromR (RCommandChain *chain, const QStringList ¤t_searchpath) {
+void RObjectList::updateFromR (RCommandChain *chain, const QStringList ¤t_searchpath, const QStringList ¤t_namespaces) {
RK_TRACE (OBJECTS);
// TODO: can this happen? when?
@@ -129,20 +129,15 @@
update_chain = RKGlobals::rInterface ()->startChain (chain);
updateEnvironments (current_searchpath, false);
-#warning TODO
-#warning TODO
-#warning TODO
-#warning TODO
-#warning TODO
-#warning TODO
-#warning TODO
- RKGlobals::rInterface ()->issueCommand (QString (), RCommand::App | RCommand::Sync | RCommand::EmptyCommand, QString (), this, ROBJECTLIST_UDPATE_COMPLETE_COMMAND, update_chain);
+ updateNamespaces (current_namespaces);
+
+ RKGlobals::rInterface ()->issueCommand (QString (), RCommand::App | RCommand::Sync | RCommand::EmptyCommand, QString (), this, ROBJECTLIST_UPDATE_COMPLETE_COMMAND, update_chain);
}
void RObjectList::rCommandDone (RCommand *command) {
RK_TRACE (OBJECTS);
- if (command->getFlags () == ROBJECTLIST_UDPATE_ENVIRONMENTS_COMMAND) {
+ if (command->getFlags () == ROBJECTLIST_UPDATE_ENVIRONMENTS_COMMAND) {
RK_ASSERT (command->getDataType () == RData::StructureVector);
const RData::RDataStorage & data = command->structureVector ();
RK_ASSERT (data.size () == 2);
@@ -153,8 +148,8 @@
updateEnvironments (new_environments, true);
updateNamespaces (data[1]->stringVector ());
- RKGlobals::rInterface ()->issueCommand (QString (), RCommand::App | RCommand::Sync | RCommand::EmptyCommand, QString (), this, ROBJECTLIST_UDPATE_COMPLETE_COMMAND, update_chain);
- } else if (command->getFlags () == ROBJECTLIST_UDPATE_COMPLETE_COMMAND) {
+ RKGlobals::rInterface ()->issueCommand (QString (), RCommand::App | RCommand::Sync | RCommand::EmptyCommand, QString (), this, ROBJECTLIST_UPDATE_COMPLETE_COMMAND, update_chain);
+ } else if (command->getFlags () == ROBJECTLIST_UPDATE_COMPLETE_COMMAND) {
RK_ASSERT (update_chain);
RKGlobals::rInterface ()->closeChain (update_chain);
update_chain = 0;
Modified: trunk/rkward/rkward/core/robjectlist.h
===================================================================
--- trunk/rkward/rkward/core/robjectlist.h 2013-03-06 17:02:26 UTC (rev 4568)
+++ trunk/rkward/rkward/core/robjectlist.h 2013-03-07 15:53:05 UTC (rev 4569)
@@ -49,7 +49,7 @@
void updateFromR (RCommandChain *chain);
/** like updateFromR, but only adjusts to new / missing environments, but does not update the .GlobalEnv. Designed to be used from the backend, when packages were loaded/unloaded . */
- void updateFromR (RCommandChain *chain, const QStringList ¤t_searchpath);
+ void updateFromR (RCommandChain *chain, const QStringList ¤t_searchpath, const QStringList ¤t_namespaces);
QString getFullName () const { return QString (); };
QString getBaseName () const { return QString (); };
Modified: trunk/rkward/rkward/misc/rkobjectlistview.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkobjectlistview.cpp 2013-03-06 17:02:26 UTC (rev 4568)
+++ trunk/rkward/rkward/misc/rkobjectlistview.cpp 2013-03-07 15:53:05 UTC (rev 4569)
@@ -2,7 +2,7 @@
rkobjectlistview - description
-------------------
begin : Wed Sep 1 2004
- copyright : (C) 2004, 2006, 2007, 2010, 2011 by Thomas Friedrichsmeier
+ copyright : (C) 2004-2013 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -240,6 +240,7 @@
if (!settings[ShowObjectsHidden]) {
if (object->getShortName ().startsWith ('.')) return false;
+ if (object == reinterpret_cast<RObject*> (RObjectList::getObjectList ()->orphanNamespacesObject ())) return false;
}
bool base_filter = QSortFilterProxyModel::filterAcceptsRow (source_row, source_parent);
Modified: trunk/rkward/rkward/rbackend/rinterface.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rinterface.cpp 2013-03-06 17:02:26 UTC (rev 4568)
+++ trunk/rkward/rkward/rbackend/rinterface.cpp 2013-03-07 15:53:05 UTC (rev 4569)
@@ -655,7 +655,8 @@
}
} else if (call == "syncenvs") {
RK_DEBUG (RBACKEND, DL_DEBUG, "triggering update of object list");
- RObjectList::getObjectList ()->updateFromR (in_chain, calllist.mid (1));
+ int search_len = calllist.value (1).toInt ();
+ RObjectList::getObjectList ()->updateFromR (in_chain, calllist.mid (2, search_len), calllist.mid (2 + search_len));
} else if (call == "syncglobal") {
RK_DEBUG (RBACKEND, DL_DEBUG, "triggering update of globalenv");
RObjectList::getGlobalEnv ()->updateFromR (in_chain, calllist.mid (1));
Modified: trunk/rkward/rkward/rbackend/rkrbackend.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkrbackend.cpp 2013-03-06 17:02:26 UTC (rev 4568)
+++ trunk/rkward/rkward/rbackend/rkrbackend.cpp 2013-03-07 15:53:05 UTC (rev 4569)
@@ -1593,8 +1593,12 @@
delete dummy;
if (search_update_needed) { // this includes an update of the globalenv, even if not needed
- QStringList call = toplevel_env_names;
- call.prepend ("syncenvs"); // should be faster than the reverse
+ QStringList call ("syncenvs");
+ call.append (QString::number (toplevel_env_names.size ()));
+ call.append (toplevel_env_names);
+ dummy = runDirectCommand ("loadedNamespaces ()\n", RCommand::GetStringVector);
+ call.append (dummy->stringVector ());
+ delete dummy;
handleHistoricalSubstackRequest (call);
}
if (globalenv_update_needed) {
More information about the rkward-tracker
mailing list