Skip to content

[breaking, wrapper] Improve distinct handle and location type decls #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2025

Conversation

hazeycode
Copy link
Member

Includes fix to UniformLocation underlying type. -1 (invalid location) can be passed to some uniform procs per the spec.

@hazeycode hazeycode added the bug Something isn't working label Jun 24, 2025
@hazeycode hazeycode requested a review from Copilot June 24, 2025 23:20
@hazeycode hazeycode added breaking and removed bug Something isn't working labels Jun 24, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the handle and location type declarations for the wrapper by replacing plain extern structs with enums that include explicit invalid values, in accordance with spec allowances (e.g. UniformLocation accepts –1 as valid for special cases).

  • Replaces several extern struct declarations with enums for stronger type safety.
  • Updates many API calls by converting enum values consistently via @intFromEnum and adding appropriate assertions.
  • Improves error detection by asserting against invalid enum states before calling underlying binding functions.
Comments suppressed due to low confidence (3)

src/wrapper.zig:3312

  • The original code passed 'buffer.name' and now uses @intFromEnum(buffer), implying that the enum encapsulates the underlying value. Please confirm that this conversion correctly represents the intended value and update documentation if needed.
            bindings.bindBufferRange(@intFromEnum(target), index, @intFromEnum(buffer), offset, size);

src/wrapper.zig:2735

  • The assert ensuring 'name.len > 0' implies empty names are not allowed. Please verify that this behavior aligns with the expected API usage and document the rationale if empty names might occur.
            assert(name.len > 0);

src/wrapper.zig:2556

  • Switching from bitCast-based conversions to using @intFromEnum is a good move, but please double-check that the semantics—especially for handles with possible negative values like UniformLocation—are preserved throughout all similar functions.
            assert(program != Program.invalid);

@hazeycode hazeycode changed the title Wrapper: Improve distinct handle and location type decls [breaking, wrapper] Improve distinct handle and location type decls Jun 24, 2025
@hazeycode hazeycode merged commit 964f72e into main Jun 24, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant