Skip to content

Commit 883faf2

Browse files
committed
Add PrettifyNames - Notable Decisions section
1 parent 5d18b9e commit 883faf2

1 file changed

Lines changed: 31 additions & 2 deletions

File tree

docs/for-contributors/Generator/name-processing.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,37 @@ var nameProcessors = new INameProcessor[]
9090

9191
For specifics on how these processors and other steps work, it is best to refer to the `PrettifyNames` source code.
9292

93+
## PrettifyNames - Notable Decisions
94+
95+
Note: It may be helpful to come back to this section after reading about the rest of the name processing pipeline.
96+
97+
### Strip/Reapply Affixes Scope
98+
99+
Affixes are stripped and reapplied to create a "scope" where only the base name is visible.
100+
101+
For example, in the execution order above, `PrettifyProcessor` only affects the base name, but
102+
`PrefixIfStartsWithNumberProcessor` works on the full name with affixes applied.
103+
104+
Currently, this distinction is not as prevalent as it was when shared prefix trimming was done during `PrettifyNames`.
105+
106+
Originally, this was implemented so that prefix identification ignores any affixes that have been declared. This
107+
notably affects cases like the `I-` prefix in the Microsoft bindings (the C-style namespace prefix is after the `I-`)
108+
and the vendor suffixes in the Khronos bindings (removing the suffixes before identifying shared prefixes prevents
109+
problematic cases where prefix trimming trims everything except for the vendor suffix, since the vendor suffix was the
110+
only non-shared part of the name; see `OcclusionQueryParameterNameNV` in OpenGL for example).
111+
112+
Shared prefix identification is now handled by `IdentifySharedPrefixes` by handling affix stripping/reapplication using
113+
the utility methods provided by `NameAffixer`. `PrettifyNames` can be then configured to remove these shared prefixes,
114+
thus matching the original behavior.
115+
116+
### Strip/Reapply Affixes Configuration
117+
118+
To keep things simple, only affix reapplication is configurable. This is because the user is expected to configure the
119+
generator output, while mods are expected to handle the process of affix identification.
120+
121+
Affix reapplication is when common transformations to affixes are applied, such as removing them, reordering them, and
122+
prettifying them.
123+
93124
## Name Splitting
94125

95126
Name splitting involves splitting an identifier into separate "tokens" and is handled by the `NameSplitter` class. These
@@ -234,8 +265,6 @@ Furthermore, because each category of affix can be identified by different mods,
234265
identification process localized to the mod that specializes in that area. For example, C-style namespace prefixes
235266
are handled by `IdentifySharedPrefixes`.
236267

237-
(TODO: Explain the motivation behind this system. Explain that users configure how name affixes are processed while mods identify affixes (separation of concerns).)
238-
239268
### Referenced Affixes
240269

241270
(TODO: Explain why referenced affixes exist (compound names and types that are the logical extensions of other types) and when these are used in the generator. Explain how these are processed.)

0 commit comments

Comments
 (0)