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

vmodtool: Add option to specify c names of arguments and avoid "bool" #4240

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nigoroll
Copy link
Member

@nigoroll nigoroll commented Dec 3, 2024

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:

vclname:cname

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.

@nigoroll nigoroll marked this pull request as draft December 4, 2024 08:12
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.
@nigoroll nigoroll force-pushed the vmodtool_argument_cname branch from 2c73ff9 to 7265024 Compare December 4, 2024 14:21
@nigoroll nigoroll marked this pull request as ready for review December 4, 2024 14:22
Copy link
Member

@dridi dridi left a 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.

Comment on lines 159 to 160
if (a->valid_bool)
return (a->bool ? 1 : 0);
if (a->valid_boola)
return (a->boola ? 1 : 0);
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah... walid_boolean ;)

@nigoroll
Copy link
Member Author

nigoroll commented Dec 9, 2024

bugwash:
see how a generic "prefix for all c names" would look like

@nigoroll nigoroll self-assigned this Dec 9, 2024
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