mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
logger: use Logger* instead of Logger& to propagate signature using swig
See the comment in IfcLogger.h explaining this.
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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); \
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user