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

[P4Testgen] Introduce the option to produce lowercase hex for the formatting library. #4340

Merged
merged 2 commits into from
Jan 24, 2024

Conversation

fruffy-g
Copy link
Contributor

Also add an options structure to the library

Copy link
Member

@smolkaj smolkaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice :)

bool useSep = false;
bool pad = true;
bool usePrefix = true;
bool writeUpperCaseHex = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: any reason why we say "write" here, but "use" for some of the other options? If not, shall we be consistent?

@@ -58,7 +58,7 @@ const Expression *Expression::evaluate(const Model &model, bool doComplete) cons

void Expression::print(std::ostream &os) const {
Generic::print(os);
os << ": " << formatHexExpr(value, true);
os << ": " << formatHexExpr(value, {true});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{true}: This isn't great for code readability, use designated initializers instead?

{.useSep = true}

It is technically a C++20 feature, so may not be supported?

Ditto a couple of more times, throughout.

Copy link
Contributor Author

@fruffy-g fruffy-g Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the compiler still uses C++17. :/ But I do not think there is any reason why we can't move to C++20. Would unlock some nice things. Let me start a discussion on this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main concern is if this requires bumping the minimal required version of GCC. If so, that could be problematic for downstream tools, or even for users of p4c directly. Not much of C++20 is supported in GCC 9. Designated initializers are, because they were GNU extension for a long time... But this should be probably discussed elsewhere.

@fruffy fruffy merged commit 25f4648 into p4lang:main Jan 24, 2024
16 checks passed
@fruffy-g fruffy-g deleted the fruffy/format_hex_lowercase branch February 8, 2024 14:34
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.

4 participants