Mercurial > hg > octave-lojdl
changeset 13429:4a1f2d16c0b9
Removed VariableMetaData and replaced passing SymbolRecords directly.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Thu, 14 Apr 2011 07:53:36 +0200 |
parents | 5f16b194d138 |
children | f671cb68a1c0 |
files | gui//src/MainWindow.h gui//src/OctaveLink.cpp gui//src/OctaveLink.h gui//src/VariablesDockWidget.cpp gui//src/VariablesDockWidget.h |
diffstat | 5 files changed, 83 insertions(+), 111 deletions(-) [+] |
line wrap: on
line diff
--- a/gui//src/MainWindow.h +++ b/gui//src/MainWindow.h @@ -157,10 +157,9 @@ while(m_mainWindow->isRunning()) { // Get a full variable list. - QList<OctaveLink::VariableMetaData> variables - = OctaveLink::instance()->variableInfoList(); - if(variables.size()) { - m_mainWindow->variablesDockWidget()->setVariablesList(variables); + QList<SymbolRecord> symbolTable = OctaveLink::instance()->variableInfoList(); + if(symbolTable.size()) { + m_mainWindow->variablesDockWidget()->setVariablesList(symbolTable); } // Check whether any requested variables have been returned.
--- a/gui//src/OctaveLink.cpp +++ b/gui//src/OctaveLink.cpp @@ -21,63 +21,7 @@ // Born July 13, 2007. -//#ifdef HAVE_CONFIG_H -#undef PACKAGE_BUGREPORT -#undef PACKAGE_NAME -#undef PACKAGE_STRING -#undef PACKAGE_TARNAME -#undef PACKAGE_VERSION -#undef PACKAGE_URL -#include <octave/config.h> -//#endif -#include <cassert> -#include <cstdlib> -#include <cstring> -#include <ctime> - -#include <fstream> -#include <iostream> - -#ifdef HAVE_UNISTD_H -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#include <unistd.h> -#endif -#include <sys/time.h> - -#include <sys/time.h> - -#include "octave/cmd-edit.h" -#include "octave/error.h" -#include "octave/file-io.h" -#include "octave/input.h" -#include "octave/lex.h" -#include "octave/load-path.h" -#include "octave/octave.h" -#include "octave/oct-hist.h" -#include "octave/oct-map.h" -#include "octave/oct-obj.h" -#include "octave/ops.h" -#include "octave/ov.h" -#include "octave/ov-usr-fcn.h" -#include "octave/symtab.h" -#include "octave/pt.h" -#include "octave/pt-eval.h" - -#include "octave/toplev.h" -#include "octave/procstream.h" -//#include "octave/prog-args.h" -#include "octave/sighandlers.h" -#include "octave/debug.h" -#include "octave/sysdep.h" -#include "octave/ov.h" -#include "octave/unwind-prot.h" -#include "octave/utils.h" -#include "octave/variables.h" - -#include <readline/readline.h> #include "OctaveLink.h" @@ -129,7 +73,7 @@ *******************************************************************************/ //************************************************************************* -QList<OctaveLink::VariableMetaData> OctaveLink::variableInfoList() { +QList<SymbolRecord> OctaveLink::variableInfoList() { QMutexLocker mutexLocker(&m_internalAccessMutex); return m_variableSymbolTableList; } @@ -251,22 +195,12 @@ //************************************************************************* void OctaveLink::retrieveVariables() { - QList<VariableMetaData> currentVariables; - std::list<symbol_table::symbol_record> allVariables = symbol_table::all_variables(); - std::list<symbol_table::symbol_record>::iterator iterator; - + QList<SymbolRecord> currentVariables; + std::list<SymbolRecord> allVariables = symbol_table::all_variables(); + std::list<SymbolRecord>::iterator iterator; for(iterator = allVariables.begin(); iterator != allVariables.end(); iterator++) { - octave_value octaveVariableValue(iterator->varval()); - - VariableMetaData variableMetaData; - variableMetaData.variableName = QString(iterator->name().c_str()); - variableMetaData.dimensionalSize.push_back(octaveVariableValue.rows()); - variableMetaData.dimensionalSize.push_back(octaveVariableValue.columns()); - variableMetaData.byteSize = octaveVariableValue.byte_size(); - variableMetaData.typeName = QString(octaveVariableValue.type_name().c_str()); - - if(!variableMetaData.variableName.startsWith(".")) - currentVariables.append(variableMetaData); + if(!QString(iterator->name().c_str()).startsWith(".")) + currentVariables.append(*iterator); } m_variableSymbolTableList = currentVariables;
--- a/gui//src/OctaveLink.h +++ b/gui//src/OctaveLink.h @@ -22,7 +22,63 @@ * */ #ifndef OCTAVELINK_H #define OCTAVELINK_H +//#ifdef HAVE_CONFIG_H +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION +#undef PACKAGE_URL +#include <octave/config.h> +//#endif +#include <cassert> +#include <cstdlib> +#include <cstring> +#include <ctime> + +#include <fstream> +#include <iostream> + +#ifdef HAVE_UNISTD_H +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#include <unistd.h> +#endif +#include <sys/time.h> + +#include <sys/time.h> + +#include "octave/cmd-edit.h" +#include "octave/error.h" +#include "octave/file-io.h" +#include "octave/input.h" +#include "octave/lex.h" +#include "octave/load-path.h" +#include "octave/octave.h" +#include "octave/oct-hist.h" +#include "octave/oct-map.h" +#include "octave/oct-obj.h" +#include "octave/ops.h" +#include "octave/ov.h" +#include "octave/ov-usr-fcn.h" +#include "octave/symtab.h" +#include "octave/pt.h" +#include "octave/pt-eval.h" + +#include "octave/toplev.h" +#include "octave/procstream.h" +//#include "octave/prog-args.h" +#include "octave/sighandlers.h" +#include "octave/debug.h" +#include "octave/sysdep.h" +#include "octave/ov.h" +#include "octave/unwind-prot.h" +#include "octave/utils.h" +#include "octave/variables.h" + +#include <readline/readline.h> #undef PACKAGE_BUGREPORT #undef PACKAGE_NAME #undef PACKAGE_STRING @@ -43,6 +99,8 @@ #include <QString> #include <QVector> +typedef symbol_table::symbol_record SymbolRecord; + /** * \class OctaveLink * Manages a link to an octave instance. @@ -92,29 +150,6 @@ octave_value ov; } RequestedVariable; - typedef struct VariableMetaData - { - /** The name of the variable. */ - QString variableName; - - /** The dimensional size of the variable. */ - QVector<int> dimensionalSize; - - /** The size of the variable in bytes. */ - unsigned long long byteSize; - - /** The name of the variable type. */ - QString typeName; - - friend int operator==(const VariableMetaData& left, - const VariableMetaData& right) { - return (left.variableName == right.variableName) && - (left.dimensionalSize == right.dimensionalSize) && - (left.byteSize == right.byteSize) && - (left.typeName == right.typeName); - } - } VariableMetaData; - // Functions used to access data form the client side. /** Debugging related methods. */ @@ -140,7 +175,7 @@ int setBreakpointAction(BreakPointAction action); /** Variable related methods. */ - QList<VariableMetaData> variableInfoList(void); + QList<SymbolRecord> variableInfoList(void); /** TODO: Describe. */ QList<RequestedVariable> requestedVariables(void); @@ -218,7 +253,7 @@ BreakPointAction m_breakPointAction; /** Variable related member variables. */ - QList<VariableMetaData> m_variableSymbolTableList; + QList<SymbolRecord> m_variableSymbolTableList; QList<QString> m_variablesRequestList; // NOTE: Create an overloaded operator<< for octave_value to do the
--- a/gui//src/VariablesDockWidget.cpp +++ b/gui//src/VariablesDockWidget.cpp @@ -28,14 +28,19 @@ m_variablesTreeWidget->expandAll(); } -void VariablesDockWidget::setVariablesList(QList<OctaveLink::VariableMetaData> variablesList) { +void VariablesDockWidget::updateTreeEntry(QTreeWidgetItem *treeItem, SymbolRecord symbolRecord) { + treeItem->setData(0, 0, QString(symbolRecord.name().c_str())); + treeItem->setData(1, 0, QString(symbolRecord.varval().type_name().c_str())); +} + +void VariablesDockWidget::setVariablesList(QList<SymbolRecord> symbolTable) { // This method may be a little bit confusing; variablesList is a complete list of all // variables that are in the workspace currently. QTreeWidgetItem *topLevelItem = m_variablesTreeWidget->topLevelItem(0); // First we check, if any variables that exist in the model tree have to be updated // or created. So we walk the variablesList check against the tree. - foreach(OctaveLink::VariableMetaData variable, variablesList) { + foreach(SymbolRecord symbolRecord, symbolTable) { int childCount = topLevelItem->childCount(); bool alreadyExists = false; QTreeWidgetItem *child; @@ -44,7 +49,7 @@ // will contain the appropriate QTreeWidgetItem* pointing at it. for(int i = 0; i < childCount; i++) { child = topLevelItem->child(i); - if(child->data(0, 0).toString() == variable.variableName) { + if(child->data(0, 0).toString() == QString(symbolRecord.name().c_str())) { alreadyExists = true; break; } @@ -52,13 +57,11 @@ // If it already exists, just update it. if(alreadyExists) { - child->setData(0, 0, variable.variableName); - child->setData(1, 0, variable.typeName); + updateTreeEntry(child, symbolRecord); } else { // It does not exist, so create a new one and set the right values. child = new QTreeWidgetItem(); - child->setData(0, 0, variable.variableName); - child->setData(1, 0, variable.typeName); + updateTreeEntry(child, symbolRecord); topLevelItem->addChild(child); } } @@ -67,8 +70,8 @@ for(int i = 0; i < topLevelItem->childCount(); i++) { bool existsInVariableList = false; QTreeWidgetItem *child = topLevelItem->child(i); - foreach(OctaveLink::VariableMetaData variable, variablesList) { - if(variable.variableName == child->data(0, 0).toString()) { + foreach(SymbolRecord symbolRecord, symbolTable) { + if(QString(symbolRecord.name().c_str()) == child->data(0, 0).toString()) { existsInVariableList = true; } }
--- a/gui//src/VariablesDockWidget.h +++ b/gui//src/VariablesDockWidget.h @@ -9,10 +9,11 @@ { public: VariablesDockWidget(QWidget *parent = 0); - void setVariablesList(QList<OctaveLink::VariableMetaData> variablesList); + void setVariablesList(QList<SymbolRecord> variablesList); private: void construct(); + void updateTreeEntry(QTreeWidgetItem *treeItem, SymbolRecord symbolRecord); QTreeWidget *m_variablesTreeWidget; };