File indexing completed on 2024-04-21 05:43:46
0001 /*************************************************************************** 0002 * Copyright (C) 2005 by David Saxton * 0003 * david@bluehaze.org * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 ***************************************************************************/ 0010 0011 #include "gplib.h" 0012 #include "languagemanager.h" 0013 #include "logview.h" 0014 0015 #include <KLocalizedString> 0016 #include <KMessageBox> 0017 #include <KProcess> 0018 0019 Gplib::Gplib(ProcessChain *processChain) 0020 : ExternalLanguage(processChain, "Gpasm") 0021 { 0022 m_successfulMessage = i18n("*** Archiving successful ***"); 0023 m_failedMessage = i18n("*** Archiving failed ***"); 0024 } 0025 0026 Gplib::~Gplib() 0027 { 0028 } 0029 0030 void Gplib::processInput(ProcessOptions options) 0031 { 0032 resetLanguageProcess(); 0033 m_processOptions = options; 0034 0035 *m_languageProcess << ("gplib"); 0036 *m_languageProcess << ("--create"); 0037 0038 *m_languageProcess << (options.intermediaryOutput()); 0039 0040 const QStringList inputFiles = options.inputFiles(); 0041 QStringList::const_iterator end = inputFiles.end(); 0042 for (QStringList::const_iterator it = inputFiles.begin(); it != end; ++it) 0043 *m_languageProcess << (*it); 0044 0045 if (!start()) { 0046 KMessageBox::error(LanguageManager::self()->logView(), i18n("Linking failed. Please check you have gputils installed.")); 0047 processInitFailed(); 0048 return; 0049 } 0050 } 0051 0052 bool Gplib::isError(const QString &message) const 0053 { 0054 return message.contains("Error", Qt::CaseInsensitive); 0055 } 0056 0057 bool Gplib::isWarning(const QString &message) const 0058 { 0059 return message.contains("Warning", Qt::CaseInsensitive); 0060 } 0061 0062 MessageInfo Gplib::extractMessageInfo(const QString &text) 0063 { 0064 if (text.length() < 5 || !text.startsWith("/")) 0065 return MessageInfo(); 0066 #if 0 0067 const int index = text.indexOf( ".asm", 0, Qt::CaseInsensitive )+4; 0068 if ( index == -1+4 ) 0069 return MessageInfo(); 0070 const QString fileName = text.left(index); 0071 0072 // Extra line number 0073 const QString message = text.right(text.length()-index); 0074 const int linePos = message.indexOf( QRegExp(":[\\d]+") ); 0075 int line = -1; 0076 if ( linePos != -1 ) 0077 { 0078 const int linePosEnd = message.indexOf( ':', linePos+1 ); 0079 if ( linePosEnd != -1 ) 0080 { 0081 const QString number = message.mid( linePos+1, linePosEnd-linePos-1 ).trimmed(); 0082 bool ok; 0083 line = number.toInt(&ok)-1; 0084 if (!ok) line = -1; 0085 } 0086 } 0087 return MessageInfo( fileName, line ); 0088 #endif 0089 return MessageInfo(); 0090 } 0091 0092 ProcessOptions::ProcessPath::Path Gplib::outputPath(ProcessOptions::ProcessPath::Path inputPath) const 0093 { 0094 switch (inputPath) { 0095 case ProcessOptions::ProcessPath::Object_Library: 0096 return ProcessOptions::ProcessPath::None; 0097 0098 case ProcessOptions::ProcessPath::AssemblyAbsolute_PIC: 0099 case ProcessOptions::ProcessPath::AssemblyAbsolute_Program: 0100 case ProcessOptions::ProcessPath::AssemblyRelocatable_Library: 0101 case ProcessOptions::ProcessPath::AssemblyRelocatable_Object: 0102 case ProcessOptions::ProcessPath::AssemblyRelocatable_PIC: 0103 case ProcessOptions::ProcessPath::AssemblyRelocatable_Program: 0104 case ProcessOptions::ProcessPath::C_AssemblyRelocatable: 0105 case ProcessOptions::ProcessPath::C_Library: 0106 case ProcessOptions::ProcessPath::C_Object: 0107 case ProcessOptions::ProcessPath::C_PIC: 0108 case ProcessOptions::ProcessPath::C_Program: 0109 case ProcessOptions::ProcessPath::FlowCode_AssemblyAbsolute: 0110 case ProcessOptions::ProcessPath::FlowCode_Microbe: 0111 case ProcessOptions::ProcessPath::FlowCode_PIC: 0112 case ProcessOptions::ProcessPath::FlowCode_Program: 0113 case ProcessOptions::ProcessPath::Microbe_AssemblyAbsolute: 0114 case ProcessOptions::ProcessPath::Microbe_PIC: 0115 case ProcessOptions::ProcessPath::Microbe_Program: 0116 case ProcessOptions::ProcessPath::Object_Disassembly: 0117 case ProcessOptions::ProcessPath::Object_PIC: 0118 case ProcessOptions::ProcessPath::Object_Program: 0119 case ProcessOptions::ProcessPath::PIC_AssemblyAbsolute: 0120 case ProcessOptions::ProcessPath::Program_Disassembly: 0121 case ProcessOptions::ProcessPath::Program_PIC: 0122 case ProcessOptions::ProcessPath::Invalid: 0123 case ProcessOptions::ProcessPath::None: 0124 return ProcessOptions::ProcessPath::Invalid; 0125 } 0126 0127 return ProcessOptions::ProcessPath::Invalid; 0128 }