Open
Description
I had to make quite a bit of changes to make the nullability attributes actually compile. I eventually got them to work in https://github.com/WebKit/WebKit/pull/14652/files#diff-1a3f28db146a69a5330a62cca964426d2794d35086c2d2e9f9a23e493a54d433
- The attribute is in the wrong place. Right:
char const * WGPU_NULLABLE label;
Wrong:WGPU_NULLABLE char const * label;
- You probably want to add a place to stick
_Pragma("clang assume_nonnull begin")
and_Pragma("clang assume_nonnull end")
so you don't have to annotate literally everything - Even when using
assume_nonnull
, there are still some places that need an explicitWGPU_NONNULL
. I don't quite understand why. The docs say "More complex pointer types ... must be explicitly annotated." -
wgpuAdapterEnumerateFeatures()
andwgpuDeviceEnumerateFeatures()
need to have their argument be nullable. These functions are designed to be called twice: once to let the caller know how much storage to allocate, and then a second time with the actual store. That first call needs to support nullptr.
On the upside, though, after getting these attributes to compile, they found 2 real bugs in our implementation!
Original issue: #119
EDIT(kainino0x): adding onto that list from #182 (review) and others:
- ChainedStruct pointers should be nullable
- Typedef'd pointer types (like callback types) should be annotated
- Objects types (which are opaque pointers) should be annotated
- Return types should be annotated (like
wgpuCreateInstance()
)