summaryrefslogtreecommitdiffstats
path: root/src/piklab-prog/cli_interactive.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/piklab-prog/cli_interactive.cpp')
-rw-r--r--src/piklab-prog/cli_interactive.cpp88
1 files changed, 39 insertions, 49 deletions
diff --git a/src/piklab-prog/cli_interactive.cpp b/src/piklab-prog/cli_interactive.cpp
index 148ba62..872a53e 100644
--- a/src/piklab-prog/cli_interactive.cpp
+++ b/src/piklab-prog/cli_interactive.cpp
@@ -15,7 +15,7 @@
# include <stdio.h>
#endif
#include <signal.h>
-#include <qtimer.h>
+#include <tqtimer.h>
#include <stdlib.h>
#include "progs/base/generic_prog.h"
@@ -74,8 +74,8 @@ void CLI::Interactive::signalHandler(int n)
_interactive->redisplayPrompt();
}
-CLI::Interactive::Interactive(QObject *parent)
- : QObject(parent, "interactive")
+CLI::Interactive::Interactive(TQObject *tqparent)
+ : TQObject(tqparent, "interactive")
{
setView(_view);
::signal(SIGINT, signalHandler);
@@ -84,7 +84,7 @@ CLI::Interactive::Interactive(QObject *parent)
#else
_stdin.open(IO_ReadOnly, stdin);
#endif
- QTimer::singleShot(0, this, SLOT(displayPrompt()));
+ TQTimer::singleShot(0, this, TQT_SLOT(displayPrompt()));
}
void CLI::Interactive::redisplayPrompt()
@@ -101,7 +101,7 @@ void CLI::Interactive::displayPrompt()
{
#if defined(HAVE_READLINE)
char *line = readline("> ");
- _input = QString(line);
+ _input = TQString(line);
if ( !_input.isEmpty() ) add_history(line);
free(line);
#else
@@ -109,14 +109,14 @@ void CLI::Interactive::displayPrompt()
fflush(stdout);
char buffer[1000];
_stdin.readLine(buffer, 1000);
- _input = QString(buffer);
+ _input = TQString(buffer);
#endif
lineRead();
}
-CLI::ExitCode CLI::Interactive::processLine(const QString &s)
+CLI::ExitCode CLI::Interactive::processLine(const TQString &s)
{
- QStringList words = QStringList::split(" ", s);
+ TQStringList words = TQStringList::split(" ", s);
if ( words.count()==0 ) return ARG_ERROR;
if ( words[0]=="command-list" || words[0]=="property-list" || words[0]=="range-list"
|| isPropertyList(words[0]) ) return static_cast<Main *>(_main)->list(words[0]);
@@ -131,24 +131,24 @@ CLI::ExitCode CLI::Interactive::processLine(const QString &s)
const CommandData *data = findCommandData(words[0]);
if ( words[0]=="quit" ) return EXITING;
if ( words[0]=="set" ) {
- if ( words.count()==2 ) return static_cast<Main *>(_main)->executeSetCommand(words[1], QString::null);
+ if ( words.count()==2 ) return static_cast<Main *>(_main)->executeSetCommand(words[1], TQString());
if ( words.count()!=3 ) return errorExit(i18n("This command takes two arguments."), ARG_ERROR);
return static_cast<Main *>(_main)->executeSetCommand(words[1], words[2]);
}
if ( words[0]=="unset" ) {
if ( words.count()!=2 ) return errorExit(i18n("This command takes one argument."), ARG_ERROR);
- return static_cast<Main *>(_main)->executeSetCommand(words[1], QString::null);
+ return static_cast<Main *>(_main)->executeSetCommand(words[1], TQString());
}
if ( words[0]=="get" ) {
if ( words.count()!=2 ) return errorExit(i18n("This command takes one argument."), ARG_ERROR);
- QString s = static_cast<Main *>(_main)->executeGetCommand(words[1]);
+ TQString s = static_cast<Main *>(_main)->executeGetCommand(words[1]);
if ( !s.isEmpty() ) log(Log::LineType::Normal, words[1] + ": " + s);
return OK;
}
if ( words[0]=="help" ) return static_cast<Main *>(_main)->list("command-list");
if ( words[0]=="x" ) {
if ( words.count()!=2 && words.count()!=3 ) return errorExit(i18n("This command takes one or two argument."), ARG_ERROR);
- return executeRegister(words[1], words.count()==3 ? words[2] : QString::null);
+ return executeRegister(words[1], words.count()==3 ? words[2] : TQString());
}
if ( words[0]=="break" ) {
if ( words.count()==3 ) {
@@ -158,11 +158,11 @@ CLI::ExitCode CLI::Interactive::processLine(const QString &s)
if ( !ok ) return errorExit(i18n("Number format not recognized."), ARG_ERROR);
PURL::Url dummy;
Breakpoint::Data data(dummy, address);
- if ( Breakpoint::list().contains(data) ) return okExit(i18n("Breakpoint already set at %1.").arg(toHexLabel(address, nbChars(NumberBase::Hex, address))));
+ if ( Breakpoint::list().tqcontains(data) ) return okExit(i18n("Breakpoint already set at %1.").tqarg(toHexLabel(address, nbChars(NumberBase::Hex, address))));
Breakpoint::list().append(data);
Breakpoint::list().setAddress(data, address);
Breakpoint::list().setState(data, Breakpoint::Active);
- return okExit(i18n("Breakpoint set at %1.").arg(toHexLabel(address, nbChars(NumberBase::Hex, address))));
+ return okExit(i18n("Breakpoint set at %1.").tqarg(toHexLabel(address, nbChars(NumberBase::Hex, address))));
}
return errorExit(i18n("The first argument should be \"e\"."), ARG_ERROR);
}
@@ -174,11 +174,11 @@ CLI::ExitCode CLI::Interactive::processLine(const QString &s)
if (_device) nbc = _device->nbCharsAddress();
else for (uint i=0; i<nb; i++) {
Address address = Breakpoint::list().address(Breakpoint::list().data(i));
- nbc = QMAX(nbc, nbChars(NumberBase::Hex, address.toUInt()));
+ nbc = TQMAX(nbc, nbChars(NumberBase::Hex, address.toUInt()));
}
for (uint i=0; i<nb; i++) {
Address address = Breakpoint::list().address(Breakpoint::list().data(i));
- log(Log::LineType::Normal, QString(" #%1: %2").arg(i).arg(toHexLabel(address, nbc)));
+ log(Log::LineType::Normal, TQString(" #%1: %2").tqarg(i).tqarg(toHexLabel(address, nbc)));
}
return OK;
}
@@ -198,7 +198,7 @@ CLI::ExitCode CLI::Interactive::processLine(const QString &s)
Breakpoint::Data data = Breakpoint::list().data(i);
Address address = Breakpoint::list().address(data);
Breakpoint::list().remove(data);
- return okExit(i18n("Breakpoint at %1 removed.").arg(toHexLabelAbs(address)));
+ return okExit(i18n("Breakpoint at %1 removed.").tqarg(toHexLabelAbs(address)));
}
if ( words[0]=="raw-com" ) {
if ( words.count()!=2 ) return errorExit(i18n("This command needs a commands filename."), ARG_ERROR);
@@ -225,17 +225,13 @@ CLI::ExitCode CLI::Interactive::processLine(const QString &s)
void CLI::Interactive::lineRead()
{
- QString s = _input.stripWhiteSpace();
- _input = QString::null;
+ TQString s = _input.stripWhiteSpace();
+ _input = TQString();
if ( processLine(s)==EXITING ) {
-#if QT_VERSION<0x040000
- qApp->exit(OK);
-#else
- QCoreApplication::exit(OK);
-#endif
+ tqApp->exit(OK);
return;
}
- QTimer::singleShot(0, this, SLOT(displayPrompt()));
+ TQTimer::singleShot(0, this, TQT_SLOT(displayPrompt()));
}
CLI::ExitCode CLI::Interactive::registerList()
@@ -246,11 +242,11 @@ CLI::ExitCode CLI::Interactive::registerList()
const Coff::Object *coff = Debugger::manager->coff();
const Pic::RegistersData &rdata = data.registersData();
log(Log::LineType::Normal, i18n("Special Function Registers:"));
- QValueVector<Pic::RegisterNameData> list = Pic::sfrList(data);
- for (uint i=0; i<uint(list.count()); i++) log(Log::LineType::Normal, QString(" %1: %2").arg(toHexLabel(list[i].data().address(), rdata.nbCharsAddress())).arg(list[i].label()));
+ TQValueVector<Pic::RegisterNameData> list = Pic::sfrList(data);
+ for (uint i=0; i<uint(list.count()); i++) log(Log::LineType::Normal, TQString(" %1: %2").tqarg(toHexLabel(list[i].data().address(), rdata.nbCharsAddress())).tqarg(list[i].label()));
log(Log::LineType::Normal, i18n("General Purpose Registers:"));
list = Pic::gprList(data, coff);
- for (uint i=0; i<uint(list.count()); i++) log(Log::LineType::Normal, QString(" %1: %2").arg(toHexLabel(list[i].data().address(), rdata.nbCharsAddress())).arg(list[i].label()));
+ for (uint i=0; i<uint(list.count()); i++) log(Log::LineType::Normal, TQString(" %1: %2").tqarg(toHexLabel(list[i].data().address(), rdata.nbCharsAddress())).tqarg(list[i].label()));
return OK;
}
@@ -262,13 +258,13 @@ CLI::ExitCode CLI::Interactive::variableList()
if ( _device->group().name()!="pic" ) return errorExit(i18n("No register."), NOT_SUPPORTED_ERROR);
const Pic::Data &data = static_cast<const Pic::Data &>(*_device);
const Pic::RegistersData &rdata = data.registersData();
- QValueVector<Pic::RegisterNameData> list = Pic::variableList(data, *coff);
+ TQValueVector<Pic::RegisterNameData> list = Pic::variableList(data, *coff);
if ( list.count()==0 ) log(Log::LineType::Normal, i18n("No variable."));
- for (uint i=0; i<uint(list.count()); i++) log(Log::LineType::Normal, QString(" %1: %2").arg(toHexLabel(list[i].data().address(), rdata.nbCharsAddress())).arg(list[i].label()));
+ for (uint i=0; i<uint(list.count()); i++) log(Log::LineType::Normal, TQString(" %1: %2").tqarg(toHexLabel(list[i].data().address(), rdata.nbCharsAddress())).tqarg(list[i].label()));
return OK;
}
-Address CLI::Interactive::findRegisterAddress(const QString &name)
+Address CLI::Interactive::findRegisterAddress(const TQString &name)
{
const Pic::Data &data = static_cast<const Pic::Data &>(*_device);
const Coff::Object *coff = Debugger::manager->coff();
@@ -279,15 +275,15 @@ Address CLI::Interactive::findRegisterAddress(const QString &name)
if ( address>rdata.addressFromIndex(rdata.nbRegisters()-1) ) return Address();
return address;
}
- QValueVector<Pic::RegisterNameData> sfrs = Pic::sfrList(data);
+ TQValueVector<Pic::RegisterNameData> sfrs = Pic::sfrList(data);
for (uint i=0; i<uint(sfrs.count()); i++) if ( name.lower()==sfrs[i].label().lower() ) return sfrs[i].data().address();
if ( coff==0 ) return Address();
- QMap<QString, Address> variables = coff->variables();
- if ( variables.contains(name) ) return variables[name];
+ TQMap<TQString, Address> variables = coff->variables();
+ if ( variables.tqcontains(name) ) return variables[name];
return Address();
}
-CLI::ExitCode CLI::Interactive::executeRegister(const QString &name, const QString &value)
+CLI::ExitCode CLI::Interactive::executeRegister(const TQString &name, const TQString &value)
{
if ( Debugger::manager->debugger()==0 ) return errorExit(i18n("You need to start the debugging session first (with \"start\")."), ARG_ERROR);
const Pic::Data &data = static_cast<const Pic::Data &>(*_device);
@@ -296,7 +292,7 @@ CLI::ExitCode CLI::Interactive::executeRegister(const QString &name, const QStri
bool ok;
ulong v = fromAnyLabel(value, &ok);
if ( !ok ) return errorExit(i18n("Number format not recognized."), ARG_ERROR);
- if ( v>maxValue(NumberBase::Hex, nbChars) ) return errorExit(i18n("The given value is too large (max: %1).").arg(toHexLabel(maxValue(NumberBase::Hex, nbChars), nbChars)), ARG_ERROR);
+ if ( v>maxValue(NumberBase::Hex, nbChars) ) return errorExit(i18n("The given value is too large (max: %1).").tqarg(toHexLabel(maxValue(NumberBase::Hex, nbChars), nbChars)), ARG_ERROR);
Register::TypeData rtd;
if ( name.lower()=="w" || name.lower()=="wreg" )
rtd = static_cast<Debugger::PicBase *>(Debugger::manager->debugger())->deviceSpecific()->wregTypeData();
@@ -309,38 +305,32 @@ CLI::ExitCode CLI::Interactive::executeRegister(const QString &name, const QStri
}
if ( value.isEmpty() ) {
if ( !Debugger::manager->readRegister(rtd) ) return ARG_ERROR;
- return okExit(i18n("%1 = %2").arg(name.upper()).arg(toHexLabel(Register::list().value(rtd), nbChars)));
+ return okExit(i18n("%1 = %2").tqarg(name.upper()).tqarg(toHexLabel(Register::list().value(rtd), nbChars)));
}
return (Debugger::manager->writeRegister(rtd, v) ? OK : EXEC_ERROR);
}
-CLI::ExitCode CLI::Interactive::executeRawCommands(const QString &filename)
+CLI::ExitCode CLI::Interactive::executeRawCommands(const TQString &filename)
{
- QFile file(filename);
- if ( !file.open(IO_ReadOnly) ) return errorExit(i18n("Could not open filename \"%1\".").arg(filename), ARG_ERROR);
+ TQFile file(filename);
+ if ( !file.open(IO_ReadOnly) ) return errorExit(i18n("Could not open filename \"%1\".").tqarg(filename), ARG_ERROR);
if ( Programmer::manager->programmer()==0 ) {
Programmer::manager->createProgrammer(_device);
if ( !Programmer::manager->programmer()->simpleConnectHardware() ) return EXEC_ERROR;
}
Programmer::Base *programmer = Programmer::manager->programmer();
for (;;) {
- QString s;
-#if QT_VERSION<0x040000
+ TQString s;
if ( file.readLine(s, 1000)==-1 ) break;
-#else
- char buffer[1000];
- if ( file.readLine(buffer, 1000)==-1 ) break;
- s += buffer;
-#endif
bool write = !s.startsWith(" ");
s = s.stripWhiteSpace();
if ( s.isEmpty() ) continue;
if (write) {
if ( !programmer->hardware()->rawWrite(s) ) return EXEC_ERROR;
} else {
- QString rs;
+ TQString rs;
if ( !programmer->hardware()->rawRead(s.length(), rs) ) return EXEC_ERROR;
- if ( rs!=s ) log(Log::LineType::Warning, i18n("Read string is different than expected: %1 (%2).").arg(rs).arg(s));
+ if ( rs!=s ) log(Log::LineType::Warning, i18n("Read string is different than expected: %1 (%2).").tqarg(rs).tqarg(s));
}
}
return okExit(i18n("End of command file reached."));