[3.0] Improve handling of nested struct names and affixes#2555
Draft
Exanite wants to merge 36 commits intodotnet:develop/3.0from
Draft
[3.0] Improve handling of nested struct names and affixes#2555Exanite wants to merge 36 commits intodotnet:develop/3.0from
Exanite wants to merge 36 commits intodotnet:develop/3.0from
Conversation
…ld used by other bindings The default acronym threshold was changed during #29, which was merged as part of dotnet#2503.
Considering we decided to follow Microsoft's Framework Design Guidelines (acronym threshold of 2) for the bindings and rest of the API, might as well be consistent here.
… separation hack (no longer necessary)
…mbers are normalized
This lets us handle prefixing and prettification separately, which notably is important if we add prefixes after prettification. We want to prefix the final name, not the intermediate name in this case.
…igured (cherry picked from commit bc94260)
…ous that it is not the last trimmer
This no longer makes sense to keep and enabling features by baseline version seems fiddly. If we need to toggle features for newer versions, we can explicitly add a boolean config option.
2693e05 to
adf4eee
Compare
…essor and ReapplyAffixesNameProcessor
Kinda a cop out decision, but it keeps thing simple (and thus maintainable) and implementing it fully seems overkill for what we need.
… for function pointer types are named
This is because we no longer output the separating underscore in ExtractNestedTyping
… of INameTrimmer registrations
…ed-struct-name-affixes
…nvention Note that the goal is to eventually remove the name overrides for the `EFXEAXREVERBPROPERTIESflLateReverbPan` and `-Delegate` cases entirely. This is because these are theoretically possible to handle automatically and the reason it doesn't work is due to an edge case interaction with the name override system. See the "Tasks" section here for more info: dotnet#2555
This covers cases where there are multiple levels of nested structs, such as in SDL: GamepadBinding contains GamepadBindingInput which contains GamepadBindingInputAxis
…t fully fulfilled
This is just to hint that these structs come from SDL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the PR
I also call this the "referenced affix" PR due to the system introduced to the problem below.
The problem
Nested struct names are an edge case in the name affix system because they have the following format:
Currently, nested struct names are generated by directly combining the full parent type name with the full field name.
This leads to issues where the ParentSuffix is not handled correctly.
For example,
PerformanceCounterDescriptionArmNameshould bePerformanceCounterDescriptionARMName.The solution
This PR adds a "referenced affix" system where name affixes can reference the names of other symbols.
This is based on the observation that these names are compound names where part of the name makes use of a name of another symbol.
For example,
PerformanceCounterDescriptionARMNameis annotated as the following:This allows PrettifyNames to use the final value of the referenced name (
PerformanceCounterDescriptionARM) as the final value for the affix. This means all changes are automatically synchronized between the two names (caveat: name overrides currently do not work due to an edge case interaction; I plan to rework the system to cleanly handle this case).Related issues, Discord discussions, or proposals
Original discussion: https://discord.com/channels/521092042781229087/587346162802229298/1460017726813900975
Further Comments
Tasks
PerformanceCounterDescriptionArmNameshould bePerformanceCounterDescriptionARMNameExtractNestedTypingandTransformHandlesinto a new set ofExtract-mods.ExtractNestedTyping, but forTransformHandlesit is useful forAddApiProfilesto be executed after all types are extracted, but not yet transformed.TransformHandlesintoTransformHandlesandExtractHandlesExtractNestedTypingINameTrimmer.Order/Versionissue (we don't want magic numbers) and consider removingINameTrimmerentirely.INameTrimmertoINameProcessorand update names where relevantUpdate OpenAL name overridesALBUFFERCALLBACKTYPESOFTDelegateuses the native name ofBufferCallbackSOFT(native nameALBUFFERCALLBACKTYPESOFT) as a prefix. This should allowPrettifyNamesto replaceALBUFFERCALLBACKTYPESOFTinALBUFFERCALLBACKTYPESOFTDelegatewithBufferCallbackSOFT, thus resulting inBufferCallbackSOFTDelegate. However, this is not currently the case because the name lookup fails.