From c5e8424a3e2751ab62b947f40518dd5dcba9e467 Mon Sep 17 00:00:00 2001 From: PyryM Date: Thu, 18 Jan 2024 21:40:55 -0500 Subject: [PATCH] Deal with the final unbound wpgu_native function --- codegen/generate.ts | 19 +++++++++---------- codegen/patches.ts | 7 +------ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/codegen/generate.ts b/codegen/generate.ts index 5fd75a0..9817951 100644 --- a/codegen/generate.ts +++ b/codegen/generate.ts @@ -14,7 +14,6 @@ import { import { docs } from "./extract_docs"; import { PATCHED_FUNCTIONS, - BAD_FUNCTIONS, FORCE_NULLABLE_ARGS, } from "./patches"; @@ -376,6 +375,15 @@ class ApiInfo { }, }); + this.types.set("WGPUProc", { + cName: "WGPUProc", + pyName: "VoidPtr", + kind: "primitive", + pyAnnotation: () => "VoidPtr", + wrap: (v) => `VoidPtr(${v})`, + unwrap: (v) => `${v}._ptr` + }); + // C `char *` is treated specially as Python `str` this.types.set("char", { cName: "char", @@ -974,15 +982,6 @@ function emitFuncDef( return patched; } - const badReason = BAD_FUNCTIONS.get(func.name); - if (badReason) { - return [ - `# ${func.name} is marked as a MISBEHAVED FUNCTION:`, - `# ${badReason}`, - ``, - ]; - } - const { pyArgs, callArgs, staging } = api.prepFuncCall(func, isMemberFunc); let retval = ""; diff --git a/codegen/patches.ts b/codegen/patches.ts index fac66f7..0e17c1e 100644 --- a/codegen/patches.ts +++ b/codegen/patches.ts @@ -16,11 +16,6 @@ export const FORCE_NULLABLE_ARGS: Set = new Set([ export const PATCHED_FUNCTIONS: Map = new Map([ ["wgpuAdapterEnumerateFeatures", listFeatures("Adapter")], - ["wgpuDeviceEnumerateFeatures", listFeatures("Device")], + ["wgpuDeviceEnumerateFeatures", listFeatures("Device")] ]); -export const BAD_FUNCTIONS: Map = new Map([ - ["wgpuAdapterEnumerateFeatures", "This is unsafe. Use hasFeature."], - ["wgpuDeviceEnumerateFeatures", "This is unsafe. Use hasFeature."], - ["wgpuGetProcAddress", "Untyped function pointer return."], -]);