diff options
Diffstat (limited to 'src/systemc/utils')
-rw-r--r-- | src/systemc/utils/report.cc | 37 | ||||
-rw-r--r-- | src/systemc/utils/report.hh | 9 |
2 files changed, 44 insertions, 2 deletions
diff --git a/src/systemc/utils/report.cc b/src/systemc/utils/report.cc index 755542fd6..87671f181 100644 --- a/src/systemc/utils/report.cc +++ b/src/systemc/utils/report.cc @@ -29,6 +29,8 @@ #include "systemc/utils/report.hh" +#include "systemc/core/python.hh" + namespace sc_gem5 { @@ -63,11 +65,42 @@ std::unique_ptr<sc_core::sc_report> globalReportCache; bool reportWarningsAsErrors = false; -DefaultReportMessages::DefaultReportMessages( - std::initializer_list<std::pair<int, const char *>> msgs) +DefaultReportMessages *& +DefaultReportMessages::top() +{ + static DefaultReportMessages *top_ptr = nullptr; + return top_ptr; +} + +void +DefaultReportMessages::install() { for (auto &p: msgs) sc_core::sc_report::register_id(p.first, p.second); } +DefaultReportMessages::DefaultReportMessages( + std::initializer_list<std::pair<int, const char *>> msgs) : + next(top()), msgs(msgs) +{ + top() = this; +} + +void +DefaultReportMessages::installAll() +{ + for (DefaultReportMessages *ptr = top(); ptr; ptr = ptr->next) + ptr->install(); +} + +namespace +{ + +struct InstallDefaultReportMessages : public PythonReadyFunc +{ + void run() override { DefaultReportMessages::installAll(); } +} messageInstaller; + +} // anonymous namespace + } // namespace sc_gem5 diff --git a/src/systemc/utils/report.hh b/src/systemc/utils/report.hh index ddbf62fa5..a0840c65b 100644 --- a/src/systemc/utils/report.hh +++ b/src/systemc/utils/report.hh @@ -110,8 +110,17 @@ extern bool reportWarningsAsErrors; struct DefaultReportMessages { + protected: + static DefaultReportMessages *&top(); + DefaultReportMessages *next; + + std::initializer_list<std::pair<int, const char *>> msgs; + void install(); + public: DefaultReportMessages(std::initializer_list<std::pair<int, const char *>>); + + static void installAll(); }; } // namespace sc_gem5 |