From 1fa5ceee8c57347b9a834ecd3f4a80cf343f91fa Mon Sep 17 00:00:00 2001 From: Mohamed Gaber Date: Mon, 15 Sep 2025 17:02:11 +0300 Subject: [PATCH] pyosys: restore remaining log functions Co-authored-by: George Rennie <19538554+georgerennie@users.noreply.github.com> --- kernel/log.h | 5 +++++ misc/py_wrap_generator.py | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/kernel/log.h b/kernel/log.h index 78b202159..bd5788758 100644 --- a/kernel/log.h +++ b/kernel/log.h @@ -153,6 +153,11 @@ inline void log_warning(FmtString...> fmt, const Args &... ar { log_formatted_warning("Warning: ", fmt.format(args...)); } + +inline void log_formatted_warning_noprefix(std::string str) +{ + log_formatted_warning("", str); +} template inline void log_warning_noprefix(FmtString...> fmt, const Args &... args) { diff --git a/misc/py_wrap_generator.py b/misc/py_wrap_generator.py index e695d1ef0..aa1406f9b 100644 --- a/misc/py_wrap_generator.py +++ b/misc/py_wrap_generator.py @@ -632,12 +632,17 @@ class Attribute: arg.wtype.attr_type = attr_types.amp arg.varname = arg.varname[1:] - # special exception: format strings + # handle string views if arg.wtype.name in ["std::string_view", "string_view"]: - if arg.varname == "format": + if arg.varname == "format" and owner_fn_name.startswith("log_"): + # coerce format strings to "%s" (not bridgable) arg.coerce_arg = '"%s"' elif arg.varname == "prefix" and "warning" in owner_fn_name: + # coerce warning prefix to "warning:" arg.coerce_arg = '"Warning: "' + else: + # boost::python can't bridge string views, so just copy them + arg.wtype.name = "string" return arg