Skip to content

Commit

Permalink
Deal with the final unbound wpgu_native function
Browse files Browse the repository at this point in the history
  • Loading branch information
PyryM committed Jan 19, 2024
1 parent 2c6ee5f commit c5e8424
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
19 changes: 9 additions & 10 deletions codegen/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
import { docs } from "./extract_docs";
import {
PATCHED_FUNCTIONS,
BAD_FUNCTIONS,
FORCE_NULLABLE_ARGS,
} from "./patches";

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 = "";
Expand Down
7 changes: 1 addition & 6 deletions codegen/patches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ export const FORCE_NULLABLE_ARGS: Set<string> = new Set([

export const PATCHED_FUNCTIONS: Map<string, string[]> = new Map([
["wgpuAdapterEnumerateFeatures", listFeatures("Adapter")],
["wgpuDeviceEnumerateFeatures", listFeatures("Device")],
["wgpuDeviceEnumerateFeatures", listFeatures("Device")]
]);

export const BAD_FUNCTIONS: Map<string, string> = new Map([
["wgpuAdapterEnumerateFeatures", "This is unsafe. Use hasFeature."],
["wgpuDeviceEnumerateFeatures", "This is unsafe. Use hasFeature."],
["wgpuGetProcAddress", "Untyped function pointer return."],
]);

0 comments on commit c5e8424

Please sign in to comment.