# HG changeset patch # User jeandet # Date 2014-06-03 11:46:12 # Node ID 81145171ec94a35d559dd185cfb3591015c3bab6 # Parent 10bc9884d69697d188932f9c08ee089bb4ab6e43 SREC file perser WIP. diff --git a/src/common/PySocExplorer.h b/src/common/PySocExplorer.h --- a/src/common/PySocExplorer.h +++ b/src/common/PySocExplorer.h @@ -11,3 +11,4 @@ #include "elf/elffilewidget.h" #include "elf/elfinfowdgt.h" #include "QCustomPlot/qcustomplot.h" +#include "srec/srecfile.h" diff --git a/src/common/abstractexecfile.h b/src/common/abstractexecfile.h --- a/src/common/abstractexecfile.h +++ b/src/common/abstractexecfile.h @@ -45,7 +45,7 @@ public: virtual QList getFragments()=0; protected: - QString p_fileName; + QString p_fileName; }; #endif // ABSTRACTEXECFILE_H diff --git a/src/common/common.pro b/src/common/common.pro --- a/src/common/common.pro +++ b/src/common/common.pro @@ -41,7 +41,8 @@ header.files = \ elf/elffilewidget.h \ qipdialogbox.h \ lppserial/src/RS232.h \ - qtablewidgetintitem.h + qtablewidgetintitem.h \ + srec/srecfile.h win32{ elfheader.path = $$[QT_INSTALL_HEADERS]/SocExplorer/common/libelf @@ -87,7 +88,8 @@ HEADERS += \ PySocExplorer.h \ SocExplorerPlot.h \ elf/elffilewidget.h \ - qtablewidgetintitem.h + qtablewidgetintitem.h \ + srec/srecfile.h SOURCES += \ @@ -107,7 +109,8 @@ SOURCES += \ qipdialogbox.cpp \ SocExplorerPlot.cpp \ elf/elffilewidget.cpp \ - qtablewidgetintitem.cpp + qtablewidgetintitem.cpp \ + srec/srecfile.cpp FORMS += \ elf/elffilewidget.ui diff --git a/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.cpp b/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.cpp --- a/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.cpp +++ b/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -6910,3 +6911,158 @@ int PythonQtWrapper_elfparser::setFilen } + +PythonQtShell_srecFile::~PythonQtShell_srecFile() { + PythonQtPrivate* priv = PythonQt::priv(); + if (priv) { priv->shellClassDeleted(this); } +} +int PythonQtShell_srecFile::closeFile() +{ +if (_wrapper) { + PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "closeFile"); + PyErr_Clear(); + if (obj && !PythonQtSlotFunction_Check(obj)) { + static const char* argumentList[] ={"int"}; + static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList); + int returnValue; + void* args[1] = {NULL}; + PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true); + if (result) { + args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue); + if (args[0]!=&returnValue) { + if (args[0]==NULL) { + PythonQt::priv()->handleVirtualOverloadReturnError("closeFile", methodInfo, result); + } else { + returnValue = *((int*)args[0]); + } + } + } + if (result) { Py_DECREF(result); } + Py_DECREF(obj); + return returnValue; + } +} + return srecFile::closeFile(); +} +QList PythonQtShell_srecFile::getFragments() +{ +if (_wrapper) { + PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "getFragments"); + PyErr_Clear(); + if (obj && !PythonQtSlotFunction_Check(obj)) { + static const char* argumentList[] ={"QList"}; + static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList); + QList returnValue; + void* args[1] = {NULL}; + PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true); + if (result) { + args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue); + if (args[0]!=&returnValue) { + if (args[0]==NULL) { + PythonQt::priv()->handleVirtualOverloadReturnError("getFragments", methodInfo, result); + } else { + returnValue = *((QList*)args[0]); + } + } + } + if (result) { Py_DECREF(result); } + Py_DECREF(obj); + return returnValue; + } +} + return srecFile::getFragments(); +} +bool PythonQtShell_srecFile::isopened() +{ +if (_wrapper) { + PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "isopened"); + PyErr_Clear(); + if (obj && !PythonQtSlotFunction_Check(obj)) { + static const char* argumentList[] ={"bool"}; + static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(1, argumentList); + bool returnValue; + void* args[1] = {NULL}; + PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true); + if (result) { + args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue); + if (args[0]!=&returnValue) { + if (args[0]==NULL) { + PythonQt::priv()->handleVirtualOverloadReturnError("isopened", methodInfo, result); + } else { + returnValue = *((bool*)args[0]); + } + } + } + if (result) { Py_DECREF(result); } + Py_DECREF(obj); + return returnValue; + } +} + return srecFile::isopened(); +} +bool PythonQtShell_srecFile::openFile(const QString& File) +{ +if (_wrapper) { + PyObject* obj = PyObject_GetAttrString((PyObject*)_wrapper, "openFile"); + PyErr_Clear(); + if (obj && !PythonQtSlotFunction_Check(obj)) { + static const char* argumentList[] ={"bool" , "const QString&"}; + static const PythonQtMethodInfo* methodInfo = PythonQtMethodInfo::getCachedMethodInfoFromArgumentList(2, argumentList); + bool returnValue; + void* args[2] = {NULL, (void*)&File}; + PyObject* result = PythonQtSignalTarget::call(obj, methodInfo, args, true); + if (result) { + args[0] = PythonQtConv::ConvertPythonToQt(methodInfo->parameters().at(0), result, false, NULL, &returnValue); + if (args[0]!=&returnValue) { + if (args[0]==NULL) { + PythonQt::priv()->handleVirtualOverloadReturnError("openFile", methodInfo, result); + } else { + returnValue = *((bool*)args[0]); + } + } + } + if (result) { Py_DECREF(result); } + Py_DECREF(obj); + return returnValue; + } +} + return srecFile::openFile(File); +} +srecFile* PythonQtWrapper_srecFile::new_srecFile() +{ +return new PythonQtShell_srecFile(); } + +srecFile* PythonQtWrapper_srecFile::new_srecFile(const QString& File) +{ +return new PythonQtShell_srecFile(File); } + +srecFile* PythonQtWrapper_srecFile::new_srecFile(const QStringList& Files) +{ +return new PythonQtShell_srecFile(Files); } + +int PythonQtWrapper_srecFile::closeFile(srecFile* theWrappedObject) +{ + return ( ((PythonQtPublicPromoter_srecFile*)theWrappedObject)->promoted_closeFile()); +} + +QList PythonQtWrapper_srecFile::getFragments(srecFile* theWrappedObject) +{ + return ( ((PythonQtPublicPromoter_srecFile*)theWrappedObject)->promoted_getFragments()); +} + +bool PythonQtWrapper_srecFile::isopened(srecFile* theWrappedObject) +{ + return ( ((PythonQtPublicPromoter_srecFile*)theWrappedObject)->promoted_isopened()); +} + +bool PythonQtWrapper_srecFile::openFile(srecFile* theWrappedObject, const QString& File) +{ + return ( ((PythonQtPublicPromoter_srecFile*)theWrappedObject)->promoted_openFile(File)); +} + +bool PythonQtWrapper_srecFile::openFiles(srecFile* theWrappedObject, const QStringList& Files) +{ + return ( theWrappedObject->openFiles(Files)); +} + + diff --git a/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.h b/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.h --- a/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.h +++ b/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer0.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -48,6 +49,7 @@ #include #include #include +#include #include #include @@ -780,3 +782,47 @@ void delete_elfparser(elfparser* obj) { }; + + + +class PythonQtShell_srecFile : public srecFile +{ +public: + PythonQtShell_srecFile():srecFile(),_wrapper(NULL) {}; + PythonQtShell_srecFile(const QString& File):srecFile(File),_wrapper(NULL) {}; + PythonQtShell_srecFile(const QStringList& Files):srecFile(Files),_wrapper(NULL) {}; + + ~PythonQtShell_srecFile(); + +virtual int closeFile(); +virtual QList getFragments(); +virtual bool isopened(); +virtual bool openFile(const QString& File); + + PythonQtInstanceWrapper* _wrapper; +}; + +class PythonQtPublicPromoter_srecFile : public srecFile +{ public: +inline int promoted_closeFile() { return srecFile::closeFile(); } +inline QList promoted_getFragments() { return srecFile::getFragments(); } +inline bool promoted_isopened() { return srecFile::isopened(); } +inline bool promoted_openFile(const QString& File) { return srecFile::openFile(File); } +}; + +class PythonQtWrapper_srecFile : public QObject +{ Q_OBJECT +public: +public slots: +srecFile* new_srecFile(); +srecFile* new_srecFile(const QString& File); +srecFile* new_srecFile(const QStringList& Files); +void delete_srecFile(srecFile* obj) { delete obj; } + int closeFile(srecFile* theWrappedObject); + QList getFragments(srecFile* theWrappedObject); + bool isopened(srecFile* theWrappedObject); + bool openFile(srecFile* theWrappedObject, const QString& File); + bool openFiles(srecFile* theWrappedObject, const QStringList& Files); +}; + + diff --git a/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer_init.cpp b/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer_init.cpp --- a/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer_init.cpp +++ b/src/common/pythonQtOut/generated_cpp/PySocExplorer/PySocExplorer_init.cpp @@ -16,5 +16,7 @@ PythonQt::priv()->registerCPPClass("code PythonQt::priv()->registerClass(&elfFileWidget::staticMetaObject, "PySocExplorer", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, 0); PythonQt::priv()->registerClass(&elfInfoWdgt::staticMetaObject, "PySocExplorer", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, 0); PythonQt::priv()->registerCPPClass("elfparser", "", "PySocExplorer", PythonQtCreateObject, NULL, module, 0); +PythonQt::priv()->registerClass(&srecFile::staticMetaObject, "PySocExplorer", PythonQtCreateObject, PythonQtSetInstanceWrapperOnShell, module, 0); +PythonQt::self()->addParentClass("srecFile", "abstractExecFile",PythonQtUpcastingOffset()); } diff --git a/src/common/pythonQtgeneratorCfg.txt b/src/common/pythonQtgeneratorCfg.txt --- a/src/common/pythonQtgeneratorCfg.txt +++ b/src/common/pythonQtgeneratorCfg.txt @@ -17,6 +17,7 @@ + diff --git a/src/common/pythongenerator.sh b/src/common/pythongenerator.sh --- a/src/common/pythongenerator.sh +++ b/src/common/pythongenerator.sh @@ -3,4 +3,4 @@ #export QTDIR=/usr/include #export QTDIR=/usr/include/qt5 -pythonqt_generator --include-paths=./elf:/usr/include/qt5:/usr/include/qt5/QtCore:/usr/include/qt5/QtWidgets --output-directory=pythonQtOut PySocExplorer.h pythonQtgeneratorCfg.txt +pythonqt_generator --include-paths=./elf:./srec:/usr/include/qt5:/usr/include/qt5/QtCore:/usr/include/qt5/QtWidgets --output-directory=pythonQtOut PySocExplorer.h pythonQtgeneratorCfg.txt diff --git a/src/common/srec/srecfile.cpp b/src/common/srec/srecfile.cpp new file mode 100644 --- /dev/null +++ b/src/common/srec/srecfile.cpp @@ -0,0 +1,154 @@ +#include "srecfile.h" + +srecFile::srecFile() +{ +} + +srecFile::srecFile(const QString &File) +{ + openFile(File); +} + +srecFile::srecFile(const QStringList &Files) +{ + openFiles(Files); +} + +srecFile::~srecFile() +{ + +} + +bool srecFile::openFile(const QString &File) +{ + openFiles(QStringList()<p_fileNames.clear(); + this->p_fileNames.append(Files); + for(int i=0;ip_files.clear(); + for(int i=0;ip_files.append(new QFile(Files.at(i))); + this->p_files.at(i)->open(QIODevice::ReadOnly); + parseFile(this->p_files.at(i)); + } +} + +bool srecFile::isopened() +{ + bool opened = true; + for(int i=0;ip_files.count();i++) + { + opened &= p_files.at(i)->isOpen(); + } + return opened; +} + +int srecFile::closeFile() +{ + +} + +QList srecFile::getFragments() +{ + return p_fragments; +} + +void srecFile::parseFile(QFile *file) +{ + if(file->isOpen()) + { + file->seek(0); + codeFragment* fragment=NULL; + QByteArray data; + quint32 size=0; + quint32 address=0; + while (!file->atEnd()) + { + QString line = file->readLine(); + if(line.count()>4) + { + if(line.at(0)=='S') + { + bool ok; + int count = line.mid(2,2).toInt(&ok,16); + if(line.at(1)=='0') + { + } + if(line.at(1)=='1') + { + } + if(line.at(1)=='2') + { + + } + if(line.at(1)=='3') + { + int naddress =line.mid(4,8).toInt(&ok,16); + if(address !=naddress) + { + if(fragment!=NULL) + { + fragment->size = data.size(); + fragment->data = (char*)malloc(data.size()); + for(int i =0;idata[i]=data.at(i); + } + data.clear(); + p_fragments.append(fragment); + } + fragment = new codeFragment(); + fragment->address = naddress; + } + address = naddress+count-5; + for(int i=0;i<(count-5);i++) + { + data.append((char)line.mid((2*i)+8,2).toInt(&ok,16)); + } + } + if(line.at(1)=='5') + { + + } + if(line.at(1)=='6') + { + + } + if(line.at(1)=='7') + { + + } + if(line.at(1)=='8') + { + + } + if(line.at(1)=='9') + { + + } + } + } + } + if(data.size()!=0) + { + fragment->size = data.size(); + fragment->data = (char*)malloc(data.size()); + for(int i =0;idata[i]=data.at(i); + } + data.clear(); + p_fragments.append(fragment); + } + + } +} + diff --git a/src/common/srec/srecfile.h b/src/common/srec/srecfile.h new file mode 100644 --- /dev/null +++ b/src/common/srec/srecfile.h @@ -0,0 +1,34 @@ +#ifndef SRECFILE_H +#define SRECFILE_H + +#include +#include +#include +#include + +class srecFile : public abstractExecFile +{ + Q_OBJECT +public: + explicit srecFile(); + srecFile(const QString& File); + srecFile(const QStringList& Files); + ~srecFile(); + bool openFile(const QString& File); + bool openFiles(const QStringList& Files); + bool isopened(); + int closeFile(); + QList getFragments(); + +signals: + +public slots: +private: + void parseFile(QFile* file); + QStringList p_fileNames; + QListp_files; + QList p_fragments; + +}; + +#endif // SRECFILE_H diff --git a/src/src.pro b/src/src.pro --- a/src/src.pro +++ b/src/src.pro @@ -22,6 +22,7 @@ INCLUDEPATH+=$${PWD} \ $${PWD}/common/qhexedit \ $${PWD}/common/QCustomPlot \ $${PWD}/common/elf \ + $${PWD}/common/srec \ SocExplorerEngine/engine \ SocExplorerEngine/pluginloader \ SocExplorerEngine/pluginsInterface \