Skip to content

Eliminate functionPointerFixups.json via auto-discovery heuristics#2246

Closed
jevansaks wants to merge 1 commit into
mainfrom
user/jevansa/fn-ptr-fixups
Closed

Eliminate functionPointerFixups.json via auto-discovery heuristics#2246
jevansaks wants to merge 1 commit into
mainfrom
user/jevansa/fn-ptr-fixups

Conversation

@jevansaks
Copy link
Copy Markdown
Member

Summary

Eliminates functionPointerFixups.json entirely by extending the scraper's auto-discovery heuristics in RemapDiscovery.cs to handle all 27 remaining entries.

New heuristic passes

Pass 3 — Same-level aliases (10 entries): For already-pointer function typedefs with exactly one same-level typedef alias (e.g., typedef DWORD (*PTHREAD_START_ROUTINE)(...); typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;), generates --remap and --exclude (no --reducePointerLevel since no extra indirection).

Pass 4 — Struct field callbacks (12 entries): Scans RecordDecl fields for pointers to bare function typedefs (e.g., QUERYFORCONNECTION *QueryForConnection; in LDAP structs, UCharIteratorGetIndex *getIndex; in ICU iterators). Generates --reducePointerLevel for the typedef name.

Header inclusion gaps (4 entries): LSA_GET_EXTENDED_CALL_FLAGS and _WHEA_ERROR_SOURCE_* follow patterns the existing heuristic already handles — the JSON entries were masking auto-discovery.

Deleted

  • generation/WinSDK/functionPointerFixups.json — all 27 manual entries
  • sources/GeneratorSdk/MetadataTasks/PrepSettingsForFunctionPointerFixups.cs — MSBuild task
  • scripts/CreateRspsForFunctionPointerFixups.ps1 — PowerShell helper
  • sources/GeneratorSdk/samples/.../functionPointerFixups.json — sample copy
  • All build wiring in sdk.props, sdk.targets, and ScrapeHeaders.cs

Tests

52 unit tests pass (44 existing + 8 new). New tests cover same-level alias resolution, struct field scanning, edge cases (multiple aliases, exclude disambiguation, OldFontEnum pattern).

Risk

The 4 non-alreadyPointer JSON entries (PBMCALLBACKFN, PTOP_LEVEL_EXCEPTION_FILTER, LPFNADDPROPSHEETPAGE, PFIBER_START_ROUTINE) previously generated --reducePointerLevel via the JSON path. The new heuristic correctly omits it (they are same-level aliases, not pointer-adding). If the baseline winmd relied on that incorrect reducePointerLevel, CI will surface it.

Add two new passes to RemapDiscovery.ResolveFunctionPointerFixups:
- Pass 3: already-pointer typedefs with same-level aliases (10 entries)
- Pass 4: bare function typedefs used as struct field pointers (12 entries)

The remaining 4 header-inclusion-gap entries are already auto-discovered
by partitions that include the relevant headers.

Delete functionPointerFixups.json, PrepSettingsForFunctionPointerFixups,
CreateRspsForFunctionPointerFixups.ps1, and all build wiring. Update docs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jevansaks jevansaks force-pushed the user/jevansa/fn-ptr-fixups branch from 5ebccd4 to dc80312 Compare April 21, 2026 16:26
@jevansaks jevansaks closed this May 5, 2026
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.

1 participant