Skip to content

Commit

Permalink
- Replaced tab characters with 2 spaces (mostly in C sources since Ec…
Browse files Browse the repository at this point in the history
…lipse/MDT usually manages to avoid using tabs)

$ svn diff Compiler/ | grep ^- | grep -v ^--- | wc -l
4771
$ svn diff c_runtime/ | grep ^- | grep -v ^--- | wc -l
13365
$ svn diff OMNotebook/ | grep ^- | grep -v ^--- | wc -l
17341
$ svn diff OMShell/ | grep ^- | grep -v ^--- | wc -l
582


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7662 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jan 7, 2011
1 parent 1e36f70 commit 526721b
Show file tree
Hide file tree
Showing 9 changed files with 632 additions and 632 deletions.
666 changes: 333 additions & 333 deletions OMShell/commandcompletion.cpp

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions OMShell/commandcompletion.h
Expand Up @@ -54,34 +54,34 @@

namespace IAEX
{
class CommandCompletion : public QObject
{
Q_OBJECT
class CommandCompletion : public QObject
{
Q_OBJECT

public:
static CommandCompletion *instance( const QString &filename );
bool insertCommand( QTextCursor &cursor );
bool nextCommand( QTextCursor &cursor );
QString helpCommand();
bool nextField( QTextCursor &cursor );
public:
static CommandCompletion *instance( const QString &filename );
bool insertCommand( QTextCursor &cursor );
bool nextCommand( QTextCursor &cursor );
QString helpCommand();
bool nextField( QTextCursor &cursor );


private:
void initializeCommands();
void parseCommand(QDomNode node, CommandUnit *item) const;
CommandCompletion( const QString &filename );
private:
void initializeCommands();
void parseCommand(QDomNode node, CommandUnit *item) const;
CommandCompletion( const QString &filename );

static CommandCompletion *instance_;
QDomDocument *doc_;
static CommandCompletion *instance_;
QDomDocument *doc_;

int currentCommand_;
int currentField_;
int commandStartPos_;
int commandEndPos_;
int currentCommand_;
int currentField_;
int commandStartPos_;
int commandEndPos_;

QStringList *currentList_;
QStringList commandList_;
QStringList *currentList_;
QStringList commandList_;
QHash<QString,CommandUnit*> commands_;
};
};
}
#endif
86 changes: 43 additions & 43 deletions OMShell/commandunit.h
Expand Up @@ -47,54 +47,54 @@

namespace IAEX
{
/*!
* \class CommandUnit
* \author Anders Fernström
* \date 2005-12-12
*
* \brief A class that store an omc command
*/
class CommandUnit
{
public:
CommandUnit( QString name ) : name_(name){}
virtual ~CommandUnit(){}
/*!
* \class CommandUnit
* \author Anders Fernström
* \date 2005-12-12
*
* \brief A class that store an omc command
*/
class CommandUnit
{
public:
CommandUnit( QString name ) : name_(name){}
virtual ~CommandUnit(){}

QString name(){ return name_; }
QString fullName()
{
QString tmp = name_;
QHash<QString,QString>::iterator d_iter = datafields_.begin();
while( d_iter != datafields_.end() )
{
tmp.replace( d_iter.key(), d_iter.value() );
++d_iter;
}
QString name(){ return name_; }
QString fullName()
{
QString tmp = name_;
QHash<QString,QString>::iterator d_iter = datafields_.begin();
while( d_iter != datafields_.end() )
{
tmp.replace( d_iter.key(), d_iter.value() );
++d_iter;
}

return tmp;
}
QString helptext(){ return helptext_; }
return tmp;
}
QString helptext(){ return helptext_; }

int numbersField(){ return datafields_.size(); }
QString datafield( QString fieldID )
{
if( datafields_.contains( fieldID ))
return datafields_[fieldID];
else
return QString::null;
}
void addDataField( QString fieldID, QString data )
{
datafields_[fieldID] = data;
}
int numbersField(){ return datafields_.size(); }
QString datafield( QString fieldID )
{
if( datafields_.contains( fieldID ))
return datafields_[fieldID];
else
return QString::null;
}
void addDataField( QString fieldID, QString data )
{
datafields_[fieldID] = data;
}

void setHelptext( QString text ){ helptext_ = text; }
void setHelptext( QString text ){ helptext_ = text; }

private:
QString name_;
QHash<QString,QString> datafields_;
QString helptext_;
};
private:
QString name_;
QHash<QString,QString> datafields_;
QString helptext_;
};
}

#endif
6 changes: 3 additions & 3 deletions OMShell/inputcelldelegate.h
Expand Up @@ -55,9 +55,9 @@ namespace IAEX
public:
virtual QString getResult() = 0;
virtual void evalExpression(QString& expr) = 0;
virtual void closeConnection() = 0; // Added 2006-02-02 AF
virtual void reconnect() = 0; // Added 2006-02-09 AF
virtual bool startDelegate() = 0; // Added 2006-02-09 AF
virtual void closeConnection() = 0; // Added 2006-02-02 AF
virtual void reconnect() = 0; // Added 2006-02-09 AF
virtual bool startDelegate() = 0; // Added 2006-02-09 AF
};

}
Expand Down
4 changes: 2 additions & 2 deletions OMShell/main.cpp
Expand Up @@ -44,8 +44,8 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);

OMS oms;
oms.show();
OMS oms;
oms.show();

return app.exec();
}
164 changes: 82 additions & 82 deletions OMShell/omc_communicator.cpp
Expand Up @@ -78,8 +78,8 @@ OmcCommunicator::~OmcCommunicator()
*/
OmcCommunicator& OmcCommunicator::getInstance()
{
static OmcCommunicator instance;
return instance;
static OmcCommunicator instance;
return instance;
}

/**
Expand All @@ -91,56 +91,56 @@ OmcCommunicator& OmcCommunicator::getInstance()
*/
bool OmcCommunicator::establishConnection()
{
if (omc_)
{
return true;
}
if (omc_)
{
return true;
}

// ORB initialization.
int argc(0); char* argv = new char[1];
CORBA::ORB_var orb = CORBA::ORB_init(argc, &argv);
// ORB initialization.
int argc(0); char* argv = new char[1];
CORBA::ORB_var orb = CORBA::ORB_init(argc, &argv);

QFile objectRefFile;
QFile objectRefFile;

#ifdef WIN32

char tempDirectory[1024];
GetTempPath(1024, tempDirectory);
objectRefFile.setFileName(*(new QString(tempDirectory)) + "openmodelica.objid");
char tempDirectory[1024];
GetTempPath(1024, tempDirectory);
objectRefFile.setFileName(*(new QString(tempDirectory)) + "openmodelica.objid");

#else // UNIX environment
#else // UNIX environment

char *user = getenv("USER");
if (!user) { user = "nobody"; }
char *user = getenv("USER");
if (!user) { user = "nobody"; }

objectRefFile.setFileName(QString(QDir::tempPath()) + "/openmodelica." + *(new QString(user)) + ".objid");
objectRefFile.setFileName(QString(QDir::tempPath()) + "/openmodelica." + *(new QString(user)) + ".objid");

#endif

if (!objectRefFile.exists())
return false;
if (!objectRefFile.exists())
return false;

objectRefFile.open(QIODevice::ReadOnly);
objectRefFile.open(QIODevice::ReadOnly);

char buf[1024];
objectRefFile.readLine( buf, sizeof(buf) );
QString uri( (const char*)buf );
char buf[1024];
objectRefFile.readLine( buf, sizeof(buf) );
QString uri( (const char*)buf );

CORBA::Object_var obj = orb->string_to_object( uri.trimmed().toLatin1() );
CORBA::Object_var obj = orb->string_to_object( uri.trimmed().toLatin1() );

omc_ = OmcCommunication::_narrow(obj);
omc_ = OmcCommunication::_narrow(obj);


// Test if we have a connection.
try {
omc_->sendExpression("getClassNames()");
}
catch (CORBA::Exception&) {
omc_ = 0;
return false;
}
// Test if we have a connection.
try {
omc_->sendExpression("getClassNames()");
}
catch (CORBA::Exception&) {
omc_ = 0;
return false;
}

return true;
return true;
}

/**
Expand All @@ -149,7 +149,7 @@ bool OmcCommunicator::establishConnection()
*/
bool OmcCommunicator::isConnected() const
{
return omc_ != 0;
return omc_ != 0;
}

/**
Expand All @@ -158,8 +158,8 @@ bool OmcCommunicator::isConnected() const
*/
void OmcCommunicator::closeConnection()
{
// 2006-02-02 AF, added this code:
omc_ = 0;
// 2006-02-02 AF, added this code:
omc_ = 0;
}


Expand All @@ -172,51 +172,51 @@ void OmcCommunicator::closeConnection()
*/
QString OmcCommunicator::callOmc(const QString& fnCall)
{
if (!omc_) {
//throw OmcError(fnCall);

// 2006-02-02 AF, Added throw exception
string msg = string("OMC-ERROR in function call: ") + fnCall.toStdString();
throw runtime_error( msg.c_str() );
}

QString returnString;
while (true) {
try {
returnString = omc_->sendExpression( fnCall.toLatin1() );
break;
}
catch (CORBA::Exception&)
{
if( fnCall != "quit()" && fnCall != "quit();" )
{
throw runtime_error("NOT RESPONDING");
}
else
break;
}
}

// PORT >> returnString = returnString.stripWhiteSpace();
returnString = returnString.trimmed();
if (fnCall.startsWith("list(")) {
//emit omcOutput("...");
// qDebug("...");
} else {
//emit omcOutput(returnString);
//qDebug(QString(returnString).replace("%"," "));
}

if (returnString == "-1") {
string tmp = "[Internal Error] OmcCommunicator::callOmc():\nOmc call \""
+ fnCall.toStdString() + "\" failed!\n\n";

qWarning( tmp.c_str() );
//throw OmcError(fnCall, returnString);
cerr << "OmcError(" << fnCall.toStdString() << ", " << returnString.toStdString() << ")" << endl;
}

return returnString;
if (!omc_) {
//throw OmcError(fnCall);

// 2006-02-02 AF, Added throw exception
string msg = string("OMC-ERROR in function call: ") + fnCall.toStdString();
throw runtime_error( msg.c_str() );
}

QString returnString;
while (true) {
try {
returnString = omc_->sendExpression( fnCall.toLatin1() );
break;
}
catch (CORBA::Exception&)
{
if( fnCall != "quit()" && fnCall != "quit();" )
{
throw runtime_error("NOT RESPONDING");
}
else
break;
}
}

// PORT >> returnString = returnString.stripWhiteSpace();
returnString = returnString.trimmed();
if (fnCall.startsWith("list(")) {
//emit omcOutput("...");
// qDebug("...");
} else {
//emit omcOutput(returnString);
//qDebug(QString(returnString).replace("%"," "));
}

if (returnString == "-1") {
string tmp = "[Internal Error] OmcCommunicator::callOmc():\nOmc call \""
+ fnCall.toStdString() + "\" failed!\n\n";

qWarning( tmp.c_str() );
//throw OmcError(fnCall, returnString);
cerr << "OmcError(" << fnCall.toStdString() << ", " << returnString.toStdString() << ")" << endl;
}

return returnString;
}


Expand Down

0 comments on commit 526721b

Please sign in to comment.