logger: use Logger* instead of Logger& to propagate signature using swig

See the comment in IfcLogger.h explaining this.
This commit is contained in:
Andrej730
2026-07-16 16:21:28 +05:00
parent 9e0c6cf524
commit 2155e3206f
20 changed files with 71 additions and 59 deletions
+1 -1
View File
@@ -447,7 +447,7 @@ public:
};
#ifdef WITH_IFCXML
IFC_PARSE_API IfcFile* parse_ifcxml(const std::string& filename, Logger& logger = Logger::Root());
IFC_PARSE_API IfcFile* parse_ifcxml(const std::string& filename, Logger* logger = nullptr);
#endif
namespace impl {
+7
View File
@@ -142,6 +142,13 @@ class IFC_PARSE_API Logger {
const std::vector<log_message>& log_messages() const { return log_messages_; }
};
// SWIG couldn't represent `Logger::Root()` default value using Python,
// so when translating signature it represents it just as `fn(*args)`, losing information about args.
// Using `Logger * = nullptr` instead of `&Logger = Logger::Root` helps,
// since `nullptr` is convertable Python's `None`.
// `logger_or_root` is just covering the boilerplate for this pattern.
inline Logger& logger_or_root(Logger* logger) { return logger ? *logger : Logger::Root(); }
#define PERF(x) \
\
Logger::Root().Message(Logger::LOG_PERF, "SYS", 1, x); \
+2 -2
View File
@@ -695,10 +695,10 @@ end:
return;
}
IFC_PARSE_API IfcParse::IfcFile* IfcParse::parse_ifcxml(const std::string& filename, Logger& logger) {
IFC_PARSE_API IfcParse::IfcFile* IfcParse::parse_ifcxml(const std::string& filename, Logger* logger) {
throw std::runtime_error("IFC-XML import temporarily disabled");
ifcxml_parse_state state(logger);
ifcxml_parse_state state(logger_or_root(logger));
xmlSAXHandler handler;
memset(&handler, 0, sizeof(xmlSAXHandler));