Skip to content

Apply PR #7: Parse #define constants and fix array type bindings (with code standards improvements)#8

Merged
jcant0n merged 2 commits intomainfrom
copilot/review-pr-7-code-standards
Mar 12, 2026
Merged

Apply PR #7: Parse #define constants and fix array type bindings (with code standards improvements)#8
jcant0n merged 2 commits intomainfrom
copilot/review-pr-7-code-standards

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 12, 2026

PR #7 introduced parsing of #define entries from the Khronos registry and fixed struct members whose array sizes are defined by symbolic constants (e.g., XrUuid.data, XrApiLayerCreateInfo.settings_file_location). This applies those changes with modularity and maintainability improvements.

Generator fixes

  • StructureDefinition.cs — Regex now uses Regex.Escape() on member name, named capture groups, match.Success instead of match.Captures.Count > 0, and correctly sets m.ConstantValue when the array bound is a symbolic name rather than a literal integer
  • OpenXRSpecification.cs — Added Defines dictionary populated by parsing <type category="define"> entries via regex; used downstream to resolve array sizes
  • Program.cs — Replaced duplicated constant-resolution branches with a single TryResolveArrayCount helper that searches API Constants → enum values → #define entries in order; added null-safety + InvalidOperationException with context when resolution fails
private static bool TryResolveArrayCount(
    string constantName, OpenXRVersion openXRVersion, OpenXRSpecification openXRSpec, out int count)
{
    // API Constants → enum values → #define entries
    ...
}
  • Helpers.cs — Moved TryParseDefineIntValue here (was inlined in Program); handles decimal, hex (0x), sign, and numeric suffixes; rejects compound expressions including subtraction
  • ConstantDefinition.cs — Fixed NormalizeValue return type from object to string

Generated output (Structs.cs)

Three struct members corrected by the above fixes:

Struct Member Before After
XrUuid data byte data fixed byte data[(int)OpenXRNative.XR_UUID_SIZE]
XrApiLayerCreateInfo settings_file_location byte settings_file_location fixed byte settings_file_location[512]
XrEyeGazesFB gaze XrEyeGazeFB gaze XrEyeGazeFB gaze_0; XrEyeGazeFB gaze_1
Original prompt

Review code changes in PR #7 to ensure compliance with coding standards and identify opportunities for optimization or improvement. Specifically prioritize modularity, readability, and maintainability.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Could you check if the code in this PR could be improved?

Assistant: I've initiated an analysis of the code in PR #7 to identify potential improvements. I'll update you once a review is complete.

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: jcant0n <1783366+jcant0n@users.noreply.github.com>
Copilot AI changed the title [WIP] Review code changes in PR #7 for compliance and improvements Apply PR #7: Parse #define constants and fix array type bindings (with code standards improvements) Mar 12, 2026
@jcant0n jcant0n marked this pull request as ready for review March 12, 2026 08:53
@jcant0n jcant0n merged commit 279c08b into main Mar 12, 2026
1 check passed
@jcant0n jcant0n deleted the copilot/review-pr-7-code-standards branch March 12, 2026 08:56
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