Skip to content

Commit 0f714d8

Browse files
author
Peter Aronsson
committed
-Added function Error.getNumErrorMessages that returns number of messages in queue with severity 'Error'.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4659 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent e5d74c7 commit 0f714d8

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

Compiler/Error.mo

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,12 @@ algorithm
701701
num := ErrorExt.getNumMessages();
702702
end getNumMessages;
703703

704+
public function getNumErrorMessages "Returns the number of messages with severity 'Error' in the message queue "
705+
output Integer num;
706+
algorithm
707+
num := ErrorExt.getNumErrorMessages();
708+
end getNumErrorMessages;
709+
704710
public function getMessagesStr "Relations for interactive comm. These returns the messages as an array
705711
of strings, suitable for sending to clients like model editor, MDT, etc.
706712

Compiler/ErrorExt.mo

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ public function getNumMessages
9191
external "C";
9292
end getNumMessages;
9393

94+
public function getNumErrorMessages
95+
output Integer num;
96+
97+
external "C";
98+
end getNumErrorMessages;
99+
94100
public function getMessagesStr
95101
output String outString;
96102

Compiler/runtime/errorext.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,22 @@ extern "C"
296296
}
297297
RML_END_LABEL
298298

299+
RML_BEGIN_LABEL(ErrorExt__getNumErrorMessages)
300+
{
301+
int res=0;
302+
303+
stack<ErrorMessage*> queueCopy(errorMessageQueue);
304+
while (!queueCopy.empty()) {
305+
if (queueCopy.top()->getSeverity().compare(std::string("Error")) == 0) {
306+
res++;
307+
}
308+
queueCopy.pop();
309+
}
310+
rmlA0 = mk_icon(res);
311+
RML_TAILCALLK(rmlSC);
312+
}
313+
RML_END_LABEL
314+
299315
RML_BEGIN_LABEL(ErrorExt__printErrorsNoWarning)
300316
{
301317
std::string res("");

0 commit comments

Comments
 (0)