Skip to content

Commit

Permalink
[WebGPU] Hook up nullability attributes
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=257675
rdar://110202947

Reviewed by NOBODY (OOPS!).

WebGPU.h already has macros to specify nullability. This patch hooks them up to the
appropriate clang attributes.

WebGPU.h's macros don't work out of the box; I opened
webgpu-native/webgpu-headers#190 about fixing the problems
with it.

* Source/WebCore/PAL/Configurations/PAL.xcconfig:
* Source/WebGPU/Configurations/Base.xcconfig:
* Source/WebGPU/Configurations/WebGPU.xcconfig:
* Source/WebGPU/WebGPU/Instance.mm:
(wgpuInstanceRequestAdapter):
* Source/WebGPU/WebGPU/WebGPU.h:
  • Loading branch information
litherum committed Jun 3, 2023
1 parent 728f623 commit 6ed99c2
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 80 deletions.
4 changes: 3 additions & 1 deletion Source/WebCore/PAL/Configurations/PAL.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
#include "../../Configurations/FeatureDefines.xcconfig"
#include "../../../../Configurations/Version.xcconfig"

GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) $(inherited);
WEBGPU_PREPROCESSOR_DEFINITIONS = WGPU_NULLABLE=_Nullable WGPU_NONNULL=_Nonnull WGPU_ASSUME_NONNULL_BEGIN="_Pragma(\"clang assume_nonnull begin\")" WGPU_ASSUME_NONNULL_END="_Pragma(\"clang assume_nonnull end\")";

GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) $(WEBGPU_PREPROCESSOR_DEFINITIONS) $(inherited);

FRAMEWORK_SEARCH_PATHS[sdk=iphone*] = $(FRAMEWORK_SEARCH_PATHS_ios_$(CONFIGURATION));
FRAMEWORK_SEARCH_PATHS_ios_Debug = $(BUILT_PRODUCTS_DIR);
Expand Down
2 changes: 1 addition & 1 deletion Source/WebGPU/Configurations/Base.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ DEAD_CODE_STRIPPING[config=Debug] = NO;
DEBUG_DEFINES = NDEBUG;
DEBUG_DEFINES[config=Debug] = ;

GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) METALCPP_SYMBOL_VISIBILITY_HIDDEN;
GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES);

WK_DEFAULT_GCC_OPTIMIZATION_LEVEL = 3;
WK_DEFAULT_GCC_OPTIMIZATION_LEVEL[config=Debug] = 0;
Expand Down
2 changes: 1 addition & 1 deletion Source/WebGPU/Configurations/WebGPU.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ WEBGPU_FRAMEWORKS_DIR_USE_OVERRIDE_FRAMEWORKS_DIR_YES = $(WK_OVERRIDE_FRAMEWORKS
WEBGPU_FRAMEWORKS_DIR_USE_ALTERNATE_FRAMEWORKS_DIR_NO = $(NORMAL_WEBGPU_FRAMEWORKS_DIR);
WEBGPU_FRAMEWORKS_DIR_USE_ALTERNATE_FRAMEWORKS_DIR_YES = $(WK_ALTERNATE_FRAMEWORKS_DIR)/$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks;

GCC_PREPROCESSOR_DEFINITIONS = WGPU_SHARED_LIBRARY WGPU_IMPLEMENTATION $(inherited);
GCC_PREPROCESSOR_DEFINITIONS = WGPU_SHARED_LIBRARY WGPU_IMPLEMENTATION WGPU_NULLABLE=_Nullable WGPU_NONNULL=_Nonnull WGPU_ASSUME_NONNULL_BEGIN="_Pragma(\"clang assume_nonnull begin\")" WGPU_ASSUME_NONNULL_END="_Pragma(\"clang assume_nonnull end\")" $(inherited);

DEFINES_MODULE = YES;
MODULEMAP_FILE = WebGPU/WebGPU.modulemap;
Expand Down
7 changes: 4 additions & 3 deletions Source/WebGPU/WebGPU/Instance.mm
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,12 @@ void wgpuInstanceProcessEvents(WGPUInstance instance)
WebGPU::fromAPI(instance).processEvents();
}

void wgpuInstanceRequestAdapter(WGPUInstance instance, const WGPURequestAdapterOptions* options, WGPURequestAdapterCallback callback, void* userdata)
void wgpuInstanceRequestAdapter(WGPUInstance apiInstance, const WGPURequestAdapterOptions* options, WGPURequestAdapterCallback callback, void* userdata)
{
WebGPU::fromAPI(instance).requestAdapter(*options, [callback, userdata](WGPURequestAdapterStatus status, Ref<WebGPU::Adapter>&& adapter, String&& message) {
auto& instance = WebGPU::fromAPI(apiInstance);
instance.requestAdapter(*options, [callback, userdata, instance = Ref { instance }](WGPURequestAdapterStatus status, Ref<WebGPU::Adapter>&& adapter, String&& message) {
if (status != WGPURequestAdapterStatus_Success) {
callback(status, nullptr, message.utf8().data(), userdata);
callback(status, WebGPU::releaseToAPI(WebGPU::Adapter::createInvalid(instance)), message.utf8().data(), userdata);
return;
}

Expand Down
Loading

0 comments on commit 6ed99c2

Please sign in to comment.