[rkward-cvs] SF.net SVN: rkward-code:[4537] trunk/rkward/rkward/core
tfry at users.sf.net
tfry at users.sf.net
Sun Feb 17 08:42:11 UTC 2013
Revision: 4537
http://sourceforge.net/p/rkward/code/4537
Author: tfry
Date: 2013-02-17 08:42:10 +0000 (Sun, 17 Feb 2013)
Log Message:
-----------
Slight reorganization of slots and namespaces objects. More to come.
This is in preparation for adding another pseudo object listing loaded namespaces which do not belong to a loaded package.
Modified Paths:
--------------
trunk/rkward/rkward/core/CMakeLists.txt
trunk/rkward/rkward/core/rcontainerobject.cpp
trunk/rkward/rkward/core/renvironmentobject.cpp
trunk/rkward/rkward/core/robject.cpp
trunk/rkward/rkward/core/robject.h
Added Paths:
-----------
trunk/rkward/rkward/core/rkpseudoobjects.cpp
trunk/rkward/rkward/core/rkpseudoobjects.h
Removed Paths:
-------------
trunk/rkward/rkward/core/rslotspseudoobject.cpp
trunk/rkward/rkward/core/rslotspseudoobject.h
Modified: trunk/rkward/rkward/core/CMakeLists.txt
===================================================================
--- trunk/rkward/rkward/core/CMakeLists.txt 2013-02-16 17:28:26 UTC (rev 4536)
+++ trunk/rkward/rkward/core/CMakeLists.txt 2013-02-17 08:42:10 UTC (rev 4537)
@@ -12,7 +12,7 @@
rfunctionobject.cpp
renvironmentobject.cpp
rkrownames.cpp
- rslotspseudoobject.cpp
+ rkpseudoobjects.cpp
)
QT4_AUTOMOC(${core_STAT_SRCS})
Modified: trunk/rkward/rkward/core/rcontainerobject.cpp
===================================================================
--- trunk/rkward/rkward/core/rcontainerobject.cpp 2013-02-16 17:28:26 UTC (rev 4536)
+++ trunk/rkward/rkward/core/rcontainerobject.cpp 2013-02-17 08:42:10 UTC (rev 4537)
@@ -20,7 +20,7 @@
#include "../rbackend/rinterface.h"
#include "robjectlist.h"
-#include "rslotspseudoobject.h"
+#include "rkpseudoobjects.h"
#include "rkvariable.h"
#include "rfunctionobject.h"
#include "renvironmentobject.h"
Modified: trunk/rkward/rkward/core/renvironmentobject.cpp
===================================================================
--- trunk/rkward/rkward/core/renvironmentobject.cpp 2013-02-16 17:28:26 UTC (rev 4536)
+++ trunk/rkward/rkward/core/renvironmentobject.cpp 2013-02-17 08:42:10 UTC (rev 4537)
@@ -21,6 +21,7 @@
#include <klocale.h>
#include "robjectlist.h"
+#include "rkpseudoobjects.h"
#include "../rbackend/rinterface.h"
#include "../settings/rksettingsmoduleobjectbrowser.h"
#include "rkmodificationtracker.h"
@@ -58,7 +59,6 @@
if (type & GlobalEnv) return name; // .GlobalEnv
if (type & ToplevelEnv) return ("as.environment (" + rQuote (name) + ")");
- if (isPackageNamespace ()) return ("asNamespace (" + rQuote (static_cast<REnvironmentObject*>(parent)->packageName ()) + ")");
return parent->makeChildName (name, type & Misplaced);
}
@@ -83,7 +83,6 @@
if ((type & PackageEnv) && (!misplaced)) return (packageName () + "::" + safe_name);
return (getFullName () + '$' + safe_name);
}
- if (isPackageNamespace ()) return (static_cast<REnvironmentObject*>(parent)->packageName () + ":::" + safe_name);
return (getFullName () + '$' + safe_name);
}
@@ -91,7 +90,6 @@
RK_TRACE (OBJECTS);
if (type & ToplevelEnv) return (short_child_name);
- if (isPackageNamespace ()) return (static_cast<REnvironmentObject*>(parent)->packageName () + ":::" + short_child_name);
return (name + '$' + short_child_name);
}
@@ -187,7 +185,7 @@
RK_ASSERT (new_data->getDataType () == RData::StructureVector);
bool added = false;
if (!namespace_envir) {
- namespace_envir = new REnvironmentObject (this, "NAMESPACE");
+ namespace_envir = new RKNamespaceObject (this);
added = true;
RKGlobals::tracker ()->lockUpdates (true);
}
Copied: trunk/rkward/rkward/core/rkpseudoobjects.cpp (from rev 4515, trunk/rkward/rkward/core/rslotspseudoobject.cpp)
===================================================================
--- trunk/rkward/rkward/core/rkpseudoobjects.cpp (rev 0)
+++ trunk/rkward/rkward/core/rkpseudoobjects.cpp 2013-02-17 08:42:10 UTC (rev 4537)
@@ -0,0 +1,71 @@
+/***************************************************************************
+ rkpseudoobjects - description
+ -------------------
+ begin : Fri Mar 11 2011
+ copyright : (C) 2011-2013 by Thomas Friedrichsmeier
+ email : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "rkpseudoobjects.h"
+
+#include "../debug.h"
+
+RSlotsPseudoObject::RSlotsPseudoObject (RObject *parent) : RContainerObject (parent, "SLOTS") {
+ RK_TRACE (OBJECTS);
+ pseudo_object_types.insert (this, SlotsObject);
+}
+
+RSlotsPseudoObject::~RSlotsPseudoObject () {
+ RK_TRACE (OBJECTS);
+ pseudo_object_types.remove (this);
+}
+
+QString RSlotsPseudoObject::getFullName () const {
+ RK_TRACE (OBJECTS);
+
+ return (".rk.get.slots (" + parent->getFullName () + ")");
+}
+
+QString RSlotsPseudoObject::makeChildName (const QString &short_child_name, bool) const {
+ RK_TRACE (OBJECTS);
+
+ QString safe_name = short_child_name;
+ if (irregularShortName (safe_name)) safe_name = rQuote (short_child_name);
+ return (parent->getFullName () + "@" + safe_name);
+}
+
+RKNamespaceObject::RKNamespaceObject (REnvironmentObject* package) : REnvironmentObject (package, "NAMESPACE") {
+ RK_TRACE (OBJECTS);
+ pseudo_object_types.insert (this, NamespaceObject);
+}
+
+RKNamespaceObject::~RKNamespaceObject () {
+ RK_TRACE (OBJECTS);
+ pseudo_object_types.remove (this);
+}
+
+QString RKNamespaceObject::getFullName () const {
+ RK_TRACE (OBJECTS);
+ return ("asNamespace (" + rQuote (static_cast<REnvironmentObject*>(parent)->packageName ()) + ")");
+}
+
+QString RKNamespaceObject::makeChildName (const QString& short_child_name, bool) const {
+ RK_TRACE (OBJECTS);
+ QString safe_name = short_child_name;
+ if (irregularShortName (safe_name)) safe_name = rQuote (short_child_name);
+ return (static_cast<REnvironmentObject*>(parent)->packageName () + ":::" + safe_name);
+}
+
+QString RKNamespaceObject::makeChildBaseName (const QString& short_child_name) const {
+ RK_TRACE (OBJECTS);
+ return (static_cast<REnvironmentObject*>(parent)->packageName () + ":::" + short_child_name);
+}
Copied: trunk/rkward/rkward/core/rkpseudoobjects.h (from rev 4515, trunk/rkward/rkward/core/rslotspseudoobject.h)
===================================================================
--- trunk/rkward/rkward/core/rkpseudoobjects.h (rev 0)
+++ trunk/rkward/rkward/core/rkpseudoobjects.h 2013-02-17 08:42:10 UTC (rev 4537)
@@ -0,0 +1,63 @@
+/***************************************************************************
+ rkpseudoobjects - description
+ -------------------
+ begin : Fri Mar 11 2011
+ copyright : (C) 2011-2013 by Thomas Friedrichsmeier
+ email : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef RKPSEUDOOBJECTS_H
+#define RKPSEUDOOBJECTS_H
+
+#include "rcontainerobject.h"
+#include "renvironmentobject.h"
+
+/** TODO:
+ * - use QHashes, instead of class memebers to store slots objects and package namespace objects (and rownames objects)
+ * - implement OrphanNamepacesObject
+ * - override getObjectDescription()
+ * - namespace objects should keep track of their namespace name, themselves
+ * - internally store namespace objects by name, not attached to a package
+ * */
+
+/**
+This class represents a "pseudo" list of the S4 slots of the corresponding parent object. In R, no such object exists.
+
+ at author Thomas Friedrichsmeier
+*/
+class RSlotsPseudoObject : public RContainerObject {
+public:
+ RSlotsPseudoObject (RObject *parent);
+ ~RSlotsPseudoObject ();
+
+ QString getFullName () const;
+ QString makeChildName (const QString &short_child_name, bool misplaced=false) const;
+};
+
+/**
+This class represents the namespace environment of a loaded package. While the namespace environment exists in R, it is not
+actually a logical child of the package environment, which is why we call it a pseudo object in RKWard (actually, perhaps we should
+rather call it a "special" object, instead).
+
+ at author Thomas Friedrichsmeier
+*/
+class RKNamespaceObject : public REnvironmentObject {
+public:
+ RKNamespaceObject (REnvironmentObject* package);
+ ~RKNamespaceObject ();
+
+ QString getFullName () const;
+ QString makeChildName (const QString &short_child_name, bool misplaced=false) const;
+ QString makeChildBaseName (const QString &short_child_name) const;
+};
+
+#endif
+
Modified: trunk/rkward/rkward/core/robject.cpp
===================================================================
--- trunk/rkward/rkward/core/robject.cpp 2013-02-16 17:28:26 UTC (rev 4536)
+++ trunk/rkward/rkward/core/robject.cpp 2013-02-17 08:42:10 UTC (rev 4537)
@@ -26,7 +26,7 @@
#include "../rkglobals.h"
#include "robjectlist.h"
#include "rcontainerobject.h"
-#include "rslotspseudoobject.h"
+#include "rkpseudoobjects.h"
#include "rkvariable.h"
#include "renvironmentobject.h"
#include "rfunctionobject.h"
@@ -39,6 +39,9 @@
QVector<qint32> dim_null (1, 0);
}
+// static
+QHash<const RObject*, RObject::PseudoObjectType> RObject::pseudo_object_types;
+
RObject::RObject (RObject *parent, const QString &name) {
RK_TRACE (OBJECTS);
@@ -473,7 +476,7 @@
RK_ASSERT (new_data->getDataType () == RData::StructureVector);
bool added = false;
if (!slots_pseudo_object) {
- slots_pseudo_object = new RSlotsPseudoObject (this, QString ());
+ slots_pseudo_object = new RSlotsPseudoObject (this);
added = true;
RKGlobals::tracker ()->lockUpdates (true);
}
Modified: trunk/rkward/rkward/core/robject.h
===================================================================
--- trunk/rkward/rkward/core/robject.h 2013-02-16 17:28:26 UTC (rev 4536)
+++ trunk/rkward/rkward/core/robject.h 2013-02-17 08:42:10 UTC (rev 4537)
@@ -21,6 +21,7 @@
#include <qstring.h>
#include <qmap.h>
+#include <QHash>
#include "../rbackend/rcommandreceiver.h"
@@ -98,6 +99,13 @@
StorageSizeBasicInfo = 6,
};
+ enum PseudoObjectType {
+ SlotsObject,
+ NamespaceObject,
+ OrphanNamespacesObject,
+ InvalidPseudoObject
+ };
+
#define ROBJECT_TYPE_INTERNAL_MASK (RObject::Container | RObject::Variable | RObject::Workspace | RObject::Environment | RObject::Function)
/** @returns false if an object of the given old type cannot represent an object of the given new type (e.g. (new_type & RObjectType::Variable), but (old_type & RObjectType::Container)). */
static bool isMatchingType (int old_type, int new_type) { return ((old_type & ROBJECT_TYPE_INTERNAL_MASK) == (new_type & ROBJECT_TYPE_INTERNAL_MASK)); };
@@ -118,8 +126,9 @@
/** see RObjectType */
bool isType (int type) const { return (RObject::type & type); };
bool isPseudoObject () const { return isType (PseudoObject); };
- bool isSlotsPseudoObject () const { return (this && parent && ((void*) parent->slots_pseudo_object == (void*) this)); };
- bool isPackageNamespace () const { return (this && isPseudoObject () && (name == "NAMESPACE")); };
+ static PseudoObjectType getPseudoObjectType (const RObject *object) { return pseudo_object_types.value (object, InvalidPseudoObject); };
+ bool isSlotsPseudoObject () const { return (this && isPseudoObject () && (getPseudoObjectType (this) == SlotsObject)); };
+ bool isPackageNamespace () const { return (this && isPseudoObject () && (getPseudoObjectType (this) == NamespaceObject)); };
bool hasMetaObject () const { return (meta_map); };
/** see RObjectType::Pending */
bool isPending () const { return type & Pending; };
@@ -277,6 +286,10 @@
virtual void endEdit ();
void rCommandDone (RCommand *command);
+friend class RSlotsPseudoObject;
+friend class RKPackageNamespaceObject;
+friend class RKOrphanNamespacesObject;
+ static QHash<const RObject*, PseudoObjectType> pseudo_object_types;
};
#endif
Deleted: trunk/rkward/rkward/core/rslotspseudoobject.cpp
===================================================================
--- trunk/rkward/rkward/core/rslotspseudoobject.cpp 2013-02-16 17:28:26 UTC (rev 4536)
+++ trunk/rkward/rkward/core/rslotspseudoobject.cpp 2013-02-17 08:42:10 UTC (rev 4537)
@@ -1,45 +0,0 @@
-/***************************************************************************
- rslotspseudoobject - description
- -------------------
- begin : Fri Mar 11 2011
- copyright : (C) 2011 by Thomas Friedrichsmeier
- email : tfry at users.sourceforge.net
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
-#include "rslotspseudoobject.h"
-
-#include "../debug.h"
-
-RSlotsPseudoObject::RSlotsPseudoObject (RObject *parent, const QString &name) : RContainerObject (parent, name) {
- RK_TRACE (OBJECTS);
- RObject::name = "SLOTS";
- type |= RObject::PseudoObject;
-}
-
-RSlotsPseudoObject::~RSlotsPseudoObject () {
- RK_TRACE (OBJECTS);
-}
-
-QString RSlotsPseudoObject::getFullName () const {
- RK_TRACE (OBJECTS);
-
- return (".rk.get.slots (" + parent->getFullName () + ")");
-}
-
-QString RSlotsPseudoObject::makeChildName (const QString &short_child_name, bool) const {
- RK_TRACE (OBJECTS);
-
- QString safe_name = short_child_name;
- if (irregularShortName (safe_name)) safe_name = rQuote (short_child_name);
- return (parent->getFullName () + "@" + safe_name);
-}
-
Deleted: trunk/rkward/rkward/core/rslotspseudoobject.h
===================================================================
--- trunk/rkward/rkward/core/rslotspseudoobject.h 2013-02-16 17:28:26 UTC (rev 4536)
+++ trunk/rkward/rkward/core/rslotspseudoobject.h 2013-02-17 08:42:10 UTC (rev 4537)
@@ -1,39 +0,0 @@
-/***************************************************************************
- rslotspseudoobject - description
- -------------------
- begin : Fri Mar 11 2011
- copyright : (C) 2011 by Thomas Friedrichsmeier
- email : tfry at users.sourceforge.net
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-#ifndef RSLOTSPSEUDOOBJECT_H
-#define RSLOTSPSEUDOOBJECT_H
-
-#include "rcontainerobject.h"
-
-class RCommand;
-class RCommandChain;
-
-/**
-This class represents a "pseudo" list of the S4 slots of the corresponding parent object. In R, no such object exists.
-
- at author Thomas Friedrichsmeier
-*/
-class RSlotsPseudoObject : public RContainerObject {
-public:
- RSlotsPseudoObject (RObject *parent, const QString &name);
- ~RSlotsPseudoObject ();
-
- QString getFullName () const;
- QString makeChildName (const QString &short_child_name, bool misplaced=false) const;
-};
-
-#endif
More information about the rkward-tracker
mailing list