Skip to content

Mechanical witx naming convention changes#137

Merged
pchickey merged 11 commits into
masterfrom
pch/witx_formatting_changes
Nov 12, 2019
Merged

Mechanical witx naming convention changes#137
pchickey merged 11 commits into
masterfrom
pch/witx_formatting_changes

Conversation

@pchickey
Copy link
Copy Markdown
Contributor

@pchickey pchickey commented Nov 4, 2019

Witx files started out encoding the types directly from the wasi/core.h header, including the C rules around identifier capitalization and namespacing.

This PR drops those conventions that are specific to the C language. We do so uniformly in each witx file, meaning we change both the current unstable and the contents of phases/old, so that code generators that know about these new conventions can still support all witx files in this repo.

I performed the following changes, mechanically when possible (leaving the sed script in the commit message):

  • Drop trailing _t from all typenames.
  • Change all $SHOUTY_SNAKE_CASE identifiers to $snake_case.
  • Remove repeated prefixes from flag and enum variants: e.g. drop right_ prefix on all $rights
    • Most cases of the above was removing the thistypename_ prefix, with underscore to make it obvious. These were done by sed where possible.
    • Special cases: All $errno enum cases had the leading e dropped, all $signal enum cases had the leading sig dropped.

@pchickey pchickey requested a review from sunfishcode November 4, 2019 23:31
Comment thread phases/ephemeral/witx/typenames.witx Outdated
Comment thread phases/ephemeral/witx/typenames.witx Outdated
Comment thread phases/ephemeral/witx/typenames.witx Outdated
@pchickey pchickey force-pushed the pch/witx_formatting_changes branch from 07d88a8 to 371eec1 Compare November 6, 2019 19:05
@pchickey
Copy link
Copy Markdown
Contributor Author

pchickey commented Nov 6, 2019

Review feedback and merge conflicts are fixed

@pchickey pchickey requested a review from sunfishcode November 6, 2019 19:17
@sunfishcode sunfishcode force-pushed the pch/witx_formatting_changes branch from 371eec1 to 0817768 Compare November 7, 2019 13:19
@pchickey pchickey force-pushed the pch/witx_formatting_changes branch 2 times, most recently from ea38d22 to b350928 Compare November 12, 2019 00:49
@pchickey
Copy link
Copy Markdown
Contributor Author

Rebased on #140. There were more conflicts than were worth resolving by hand, so I re-ran the sed commands and then re-applied the fixups.

@pchickey pchickey closed this Nov 12, 2019
@pchickey pchickey reopened this Nov 12, 2019
Pat Hickey added 9 commits November 11, 2019 16:56
this suffix is not appropriate for all languages that may need to
generate code from witx, so this change removes it from all witx files
and leaves the code generator in charge of putting the appropriate
suffix onto any type names it produces.

sed -i -E 's/\$([a-z_]+)_t([)\n\r ])?/\$\1\2/g' **/*.witx
Change all $SHOUTY_SNAKE_CASE identifers to $snake_case.

It is the responsibility of a code generator backend to select the
right case and style of these identifiers for the target language.
In witx, we should standardize on snake case (lowercase with a
single underscore as a word separator)

sed -i -E 's/\$([A-Z0-9_]+)([)\n\r ])?/\$\L\1\2/g' **/*.witx
once again, the code translation tool is responsible for putting the
right prefix in the generated code. languages with proper namespacing
facilities don't need the identifiers themselves to be namespaced.
otherwise, you can derive the namespacing prefix from the type name.

sed -i -E 's/\$(clock_|right_|whence_|filetype_|advice_|fdflag_|filestat_set_|lookup_|o_|st_|sock_|shut_|preopentype_)/\$/g' **/*.witx
doing so by regexp would delete various other valid event_ prefixes
this one could have been mechanical, but i left it out of the regexp
@pchickey pchickey force-pushed the pch/witx_formatting_changes branch from b350928 to 5479984 Compare November 12, 2019 00:56
Copy link
Copy Markdown
Member

@sunfishcode sunfishcode left a comment

Choose a reason for hiding this comment

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

Looks good! This will help reduce the C-specific feel of the overall API :-).

@pchickey pchickey merged commit 17f33a5 into master Nov 12, 2019
@pchickey pchickey deleted the pch/witx_formatting_changes branch November 12, 2019 01:16
yoshuawuyts pushed a commit to yoshuawuyts/WASI that referenced this pull request Nov 25, 2025
* witx: drop trailing `_t` from all typenames

this suffix is not appropriate for all languages that may need to
generate code from witx, so this change removes it from all witx files
and leaves the code generator in charge of putting the appropriate
suffix onto any type names it produces.

sed -i -E 's/\$([a-z_]+)_t([)\n\r ])?/\$\1\2/g' **/*.witx

* witx: change identifiers to snake case

Change all $SHOUTY_SNAKE_CASE identifers to $snake_case.

It is the responsibility of a code generator backend to select the
right case and style of these identifiers for the target language.
In witx, we should standardize on snake case (lowercase with a
single underscore as a word separator)

sed -i -E 's/\$([A-Z0-9_]+)([)\n\r ])?/\$\L\1\2/g' **/*.witx

* witx: mechanically remove repeated prefixes from flags, enums

once again, the code translation tool is responsible for putting the
right prefix in the generated code. languages with proper namespacing
facilities don't need the identifiers themselves to be namespaced.
otherwise, you can derive the namespacing prefix from the type name.

sed -i -E 's/\$(clock_|right_|whence_|filetype_|advice_|fdflag_|filestat_set_|lookup_|o_|st_|sock_|shut_|preopentype_)/\$/g' **/*.witx

* restore fields named pr_type and d_type

* remove $event_ prefix from eventrwflags member

doing so by regexp would delete various other valid event_ prefixes

* remove eventtype_ prefix from enum fields

this one could have been mechanical, but i left it out of the regexp

* restore oflags, fdflags argument names in path_open

* witx: delete leading `sig` from each $signal enum variant

* witx: delete leading `e` from each $errno enum variant

* fixup test

* witx: fix up old style names in comments
yoshuawuyts pushed a commit to yoshuawuyts/WASI that referenced this pull request Nov 25, 2025
* witx: drop trailing `_t` from all typenames

this suffix is not appropriate for all languages that may need to
generate code from witx, so this change removes it from all witx files
and leaves the code generator in charge of putting the appropriate
suffix onto any type names it produces.

sed -i -E 's/\$([a-z_]+)_t([)\n\r ])?/\$\1\2/g' **/*.witx

* witx: change identifiers to snake case

Change all $SHOUTY_SNAKE_CASE identifers to $snake_case.

It is the responsibility of a code generator backend to select the
right case and style of these identifiers for the target language.
In witx, we should standardize on snake case (lowercase with a
single underscore as a word separator)

sed -i -E 's/\$([A-Z0-9_]+)([)\n\r ])?/\$\L\1\2/g' **/*.witx

* witx: mechanically remove repeated prefixes from flags, enums

once again, the code translation tool is responsible for putting the
right prefix in the generated code. languages with proper namespacing
facilities don't need the identifiers themselves to be namespaced.
otherwise, you can derive the namespacing prefix from the type name.

sed -i -E 's/\$(clock_|right_|whence_|filetype_|advice_|fdflag_|filestat_set_|lookup_|o_|st_|sock_|shut_|preopentype_)/\$/g' **/*.witx

* restore fields named pr_type and d_type

* remove $event_ prefix from eventrwflags member

doing so by regexp would delete various other valid event_ prefixes

* remove eventtype_ prefix from enum fields

this one could have been mechanical, but i left it out of the regexp

* restore oflags, fdflags argument names in path_open

* witx: delete leading `sig` from each $signal enum variant

* witx: delete leading `e` from each $errno enum variant

* fixup test

* witx: fix up old style names in comments
yoshuawuyts pushed a commit to yoshuawuyts/WASI that referenced this pull request Nov 25, 2025
…ly#137)

* wit-deps update to latest io streams.wit, which exposes `error`

* add `filesystem-error-code`, for elaborating `stream.error`

* generate markdown
yoshuawuyts pushed a commit to yoshuawuyts/WASI that referenced this pull request Nov 25, 2025
…yntax

Enclose URLs in documentation with angle brakcets.
yoshuawuyts pushed a commit to yoshuawuyts/WASI that referenced this pull request Nov 25, 2025
* witx: drop trailing `_t` from all typenames

this suffix is not appropriate for all languages that may need to
generate code from witx, so this change removes it from all witx files
and leaves the code generator in charge of putting the appropriate
suffix onto any type names it produces.

sed -i -E 's/\$([a-z_]+)_t([)\n\r ])?/\$\1\2/g' **/*.witx

* witx: change identifiers to snake case

Change all $SHOUTY_SNAKE_CASE identifers to $snake_case.

It is the responsibility of a code generator backend to select the
right case and style of these identifiers for the target language.
In witx, we should standardize on snake case (lowercase with a
single underscore as a word separator)

sed -i -E 's/\$([A-Z0-9_]+)([)\n\r ])?/\$\L\1\2/g' **/*.witx

* witx: mechanically remove repeated prefixes from flags, enums

once again, the code translation tool is responsible for putting the
right prefix in the generated code. languages with proper namespacing
facilities don't need the identifiers themselves to be namespaced.
otherwise, you can derive the namespacing prefix from the type name.

sed -i -E 's/\$(clock_|right_|whence_|filetype_|advice_|fdflag_|filestat_set_|lookup_|o_|st_|sock_|shut_|preopentype_)/\$/g' **/*.witx

* restore fields named pr_type and d_type

* remove $event_ prefix from eventrwflags member

doing so by regexp would delete various other valid event_ prefixes

* remove eventtype_ prefix from enum fields

this one could have been mechanical, but i left it out of the regexp

* restore oflags, fdflags argument names in path_open

* witx: delete leading `sig` from each $signal enum variant

* witx: delete leading `e` from each $errno enum variant

* fixup test

* witx: fix up old style names in comments
yoshuawuyts pushed a commit to yoshuawuyts/WASI that referenced this pull request Nov 25, 2025
…rc-2025-09-16

Update 0.3.0 WIT definitions to 0.3.0-rc-2025-09-16
alexcrichton added a commit to alexcrichton/WASI that referenced this pull request Jan 29, 2026
* Update WIT vendoring source and wit-bindgen

This commit updates how WITs are vendored here to use `wkg` the same way
that bytecodealliance/wasmtime#12327 does. This then updated to use the
latest `wit-bindgen` to be able to process the WITs which had a few
extra artifacts in them that made it necessary.

Generated bindings are changing here, but it's just things moving
around.

* Update wit-bindgen

* Update other CI tools

* Update MSRV to 1.87.0

* Update/pin more tools
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