Magic's graphics layer routes every drawing primitive through
function pointers (GrXxxPtr / grXxxPtr) that are bound to a driver
at startup. The original null driver assigned a single 0-arg
nullDoNothing() to every pointer, which works in native builds
because of K&R loose prototype rules but fails in WASM where
call_indirect requires an exact type match between caller and
callee.
This commit:
* Adds typed no-op stubs nullDoNothingI/II/IIII/IIIIIII for
void-returning callbacks of various arities.
* Adds nullReturnFalseI/II/III for bool-returning callbacks and
nullReturnZeroI for int-returning callbacks.
* Casts each pointer assignment in nullSetDisplay() to the K&R
pointer type the public header still uses, while the underlying
function carries the correct WASM signature.
* Fills in window-management and backing-store pointers that the
original null driver left at NULL — many of these are called
unconditionally by WindUpdate paths, and need at least a no-op
to avoid traps.
* Guards the stdin watch in nullSetDisplay() with #ifndef
__EMSCRIPTEN__: WASM has no real stdin file descriptor and
TxAdd1InputDevice() / SigWatchFile() are POSIX-specific.
Native builds are unaffected: the K&R-loose prototype machinery
still accepts the previous and the new code identically.
commit 86b5d591d from 20241004 by me, modified return type of
GrTextSize API in the graphics from 'void' to 'int' to convey
and error scenario to indicate when 'r' was not filled in for
the caller, but this is a multi graphics driver API interface
so requires all downstream graphics engines to also support
the return type change.
This API can error and indicates when 'Rect *r' was
successfully updated.
significant amounts of time even though there is no display to
receive the result. However, the "suspendall" command only works
if a window exists. The obvious solution is to set GrDisplayStatus
to DISPLAY_SUSPEND whenever magic is run with the "-dnull" option.
This should help speed up a lot of scripts, in particular where
designs are large.