Bug 237875 - [WebGPU] [NSString stringWithCString:encoding:] fails on a null pointer
Summary: [WebGPU] [NSString stringWithCString:encoding:] fails on a null pointer
Status: RESOLVED DUPLICATE of bug 237942
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGPU (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Myles C. Maxfield
URL:
Keywords:
Depends on: 237871
Blocks: 237583 237876
  Show dependency treegraph
 
Reported: 2022-03-14 21:55 PDT by Myles C. Maxfield
Modified: 2022-03-15 22:32 PDT (History)
3 users (show)

See Also:


Attachments
Patch (14.03 KB, patch)
2022-03-14 21:57 PDT, Myles C. Maxfield
kkinnunen: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Myles C. Maxfield 2022-03-14 21:55:33 PDT
.
Comment 1 Myles C. Maxfield 2022-03-14 21:57:32 PDT
Created attachment 454661 [details]
Patch
Comment 2 Kimmo Kinnunen 2022-03-15 08:37:31 PDT
Comment on attachment 454661 [details]
Patch

I think API type conversion should be done ASAP, e.g. a layer below. You wouldn't write "const char*" in WebKit level code, so why WebGPU level code.
For me, overloaded ToAPI, FromAPI functions have been useful. In this case you would have String FromAPI(const char*) or NSString* FromAPI(const char*)
Comment 3 Kimmo Kinnunen 2022-03-15 08:39:00 PDT
and the code would be like

void wgpuBindGroupSetLabel(WGPUBindGroup bindGroup, const char* label)
{
    FromAPI(bindGroup)->setLabel(FromAPI(label));
}
Comment 4 Myles C. Maxfield 2022-03-15 22:32:29 PDT

*** This bug has been marked as a duplicate of bug 237942 ***
Comment 5 Myles C. Maxfield 2022-03-15 22:32:57 PDT
(In reply to Kimmo Kinnunen from comment #2)
> Comment on attachment 454661 [details]
> Patch
> 
> I think API type conversion should be done ASAP, e.g. a layer below. You
> wouldn't write "const char*" in WebKit level code, so why WebGPU level code.
> For me, overloaded ToAPI, FromAPI functions have been useful. In this case
> you would have String FromAPI(const char*) or NSString* FromAPI(const char*)

https://bugs.webkit.org/show_bug.cgi?id=237942 [WebGPU] Use the fromAPI() pattern