Skip to content
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

nullable annotations would be useful #119

Closed
litherum opened this issue Nov 16, 2021 · 8 comments
Closed

nullable annotations would be useful #119

litherum opened this issue Nov 16, 2021 · 8 comments

Comments

@litherum
Copy link

It would help implementations know what's allowed to be null and what isn't.

https://clang.llvm.org/docs/analyzer/developer-docs/nullability.html

@litherum
Copy link
Author

Bump. It's unclear if a create method fails due to a validation failure, if it should return nullptr or an invalid object.

@Kangz
Copy link
Collaborator

Kangz commented May 23, 2022

See #157 for arguments to the API.

In general return values that are object are never null, and instead are invalid objects, like the JS API.

@Kangz Kangz closed this as completed May 23, 2022
@litherum
Copy link
Author

litherum commented May 23, 2022

I was thinking of __nullable from https://clang.llvm.org/docs/analyzer/developer-docs/nullability.html ...

@kainino0x kainino0x reopened this May 23, 2022
@Kangz
Copy link
Collaborator

Kangz commented May 24, 2022

Erhm, that's non-standard and just an LLVM thing. That header also needs to be compatible with other C compilers like GCC or MSVC. At best we could do a WGPU_NULLABLE define that default to being an empty list of tokens but can be overriden.

@kainino0x
Copy link
Collaborator

for future reference: __nullable isn't the correct syntax, that appears to be some internal thing. Actual names are _Nullable and _Nonnull. Here's the reference page:
https://clang.llvm.org/docs/AttributeReference.html#nullability-attributes

@litherum
Copy link
Author

WGPU_NULLABLE sounds like the perfect solution.

Kangz added a commit to Kangz/webgpu-headers that referenced this issue May 22, 2023
 - Also adds WGPU_NULLABLE instead of the /* nullable */ comments
 - Also adds WGPUFeatureName_Float32Filterable
 - Also adds struct forward declarations and move funtion pointers
   typedefs before the struct definitions, so that struct can contain
   function pointers.

Fixes webgpu-native#179
Fixes webgpu-native#119
kainino0x pushed a commit to Kangz/webgpu-headers that referenced this issue May 24, 2023
 - Also adds WGPU_NULLABLE instead of the /* nullable */ comments
 - Also adds WGPUFeatureName_Float32Filterable
 - Also adds struct forward declarations and move funtion pointers
   typedefs before the struct definitions, so that struct can contain
   function pointers.

Fixes webgpu-native#179
Fixes webgpu-native#119
kainino0x pushed a commit that referenced this issue May 24, 2023
- Also adds WGPU_NULLABLE instead of the /* nullable */ comments
 - Also adds WGPUFeatureName_Float32Filterable
 - Also adds struct forward declarations and move funtion pointers
   typedefs before the struct definitions, so that struct can contain
   function pointers.

Fixes #179
Partially addresses #119
@kainino0x
Copy link
Collaborator

Partially addressed in #182, but there were some open follow-up questions:
#182 (review)

@kainino0x
Copy link
Collaborator

Added the important item from there to #190. Closing this issue, so we can track there.

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

No branches or pull requests

3 participants