-
Notifications
You must be signed in to change notification settings - Fork 380
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
vmodtool: Add option to specify c names of arguments and avoid "bool" #4240
base: master
Are you sure you want to change the base?
Conversation
I tried gcc version 15.0.0 20241203 and even without -std=c23, it would reserve "bool": In file included from vcc_std_if.c:10: vcc_std_if.h:78:33: error: two or more data types in declaration specifiers 78 | VCL_BOOL bool; | ^~~~ (and more) So this patch adds the option to specify the c name of arguments to vmod functions/methods by separating it with a colon in the spec in the VCC file. vclname:cname We use this facility to rename the "bool" argument to vmod_std functions to "boola". Implementation -------------- The cname needs to be specified by the VMOD author because it is also used in the vmod implementation. Obviously, VCC needs to know that name, too, to generate argument structs, so we need to transport it from the VMOD to VCC via the JSON spec. A logical place for cname is next to the name, because the other attributes following in the argument spec array are optional. So this changes the JSON spec format, and, consequently, we need to increase the version number. So, ultimately, this is a breaking change with respect to vmodtool: One can not import vmods built before this change. We could add compatibility for this case, but as we have a tradition of forcing rebuilds with each release by bumping the VRT major number anyway, I did not see my time well spent on implementing backwards compatibility.
2c73ff9
to
7265024
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent idea. I didn't look further than the diff.
vmod/vmod_std_conversions.c
Outdated
if (a->valid_bool) | ||
return (a->bool ? 1 : 0); | ||
if (a->valid_boola) | ||
return (a->boola ? 1 : 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not fond of "boola" here, why not "boolean" instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah... walid_boolean
;)
bugwash: |
I tried gcc version 15.0.0 20241203 and even without -std=c23, it would reserve "bool":
(and more)
So this patch adds the option to specify the c name of arguments to vmod functions/methods by separating it with a colon:
We use this facility to rename the "bool" argument to vmod_std functions to "boola".
Implementation
cname needs to be specified by the VMOD author because it is also used in the vmod implementation.
Obviously, VCC needs to know that name, too, to generate argument structs, so we need to transport it from the VMOD to VCC via the JSON spec. A logical place for is next to the name, because the other attributes following in the argument spec array are optional. So this changes the JSON spec format, and, consequently, we need to increase the version number.
So, ultimately, this is a breaking change with respect to vmodtool: One can not import vmods built before this change. We could add compatibility for this case, but as we have a tradition of forcing rebuilds with each release by bumping the VRT major number anyway, I did not see my time well spent on implementing backwards compatibility.