Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyosys generator: ignore attributes #4701

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

georgerennie
Copy link
Contributor

@georgerennie georgerennie commented Nov 4, 2024

This allows log_error, log_file_error and log_cmd_error which are all marked [[noreturn]] to be wrapped.

The corresponding diff to the generated c++ is

12653a12654,12671
> 	// WRAPPED from "[[noreturn]] void log_error(const char_p format, ...) YS_ATTRIBUTE(format(printf, 1, 2));" in kernel/log
> 	void log_error(const char * format)
> 	{
> 		::YOSYS_NAMESPACE::log_error("%s", format);
> 	}
> 
> 	// WRAPPED from "[[noreturn]] void log_file_error(const string &filename, int lineno, const char_p format, ...) YS_ATTRIBUTE(format(printf, 3, 4));" in kernel/log
> 	void log_file_error(const string filename, int lineno, const char * format)
> 	{
> 		::YOSYS_NAMESPACE::log_file_error(filename, lineno, "%s", format);
> 	}
> 
> 	// WRAPPED from "[[noreturn]] void log_cmd_error(const char_p format, ...) YS_ATTRIBUTE(format(printf, 1, 2));" in kernel/log
> 	void log_cmd_error(const char * format)
> 	{
> 		::YOSYS_NAMESPACE::log_cmd_error("%s", format);
> 	}
> 
15278a15297,15299
> 		def<void (*)(const char *)>("log_error", YOSYS_PYTHON::log_error);
> 		def<void (*)(const string, int, const char *)>("log_file_error", YOSYS_PYTHON::log_file_error);
> 		def<void (*)(const char *)>("log_cmd_error", YOSYS_PYTHON::log_cmd_error);

Note that although all 3 of these commands are added, log_cmd_error shouldn't be used from python for now as in interactive mode it throws log_cmd_error_exception, expecting the main shell loop to catch it but this exception can't be passed through python so it causes python to throw its own exception. I'm not 100% sure how best to translate this exception so haven't bothered for now

* this allows log_error, log_file_error and log_cmd_error which are all
  marked [[noreturn]] to be supported
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants