(view, offset, arg, index)
| 159 | // Returns true on fast-path success, false when the caller must fall back |
| 160 | // to the slow path (strings, Buffers, ArrayBuffers, ArrayBufferViews). |
| 161 | function writePointerArg(view, offset, arg, index) { |
| 162 | if (typeof arg === 'bigint') { |
| 163 | // Bound by `uintptrMax` (not `U64_MAX`) to mirror the slow path: on |
| 164 | // 32-bit platforms a BigInt that doesn't fit in `uintptr_t` would be |
| 165 | // silently truncated by `ReadFFIArgFromBuffer`'s |
| 166 | // `memcpy(..., type->size, ...)`. |
| 167 | if (arg < 0n || arg > uintptrMax) { |
| 168 | throwFFIArgError( |
| 169 | `Argument ${index} must be a non-negative pointer bigint`); |
| 170 | } |
| 171 | sU64(view, offset, arg, true); |
| 172 | return true; |
| 173 | } |
| 174 | if (arg === null || arg === undefined) { |
| 175 | sU64(view, offset, 0n, true); |
| 176 | return true; |
| 177 | } |
| 178 | return false; |
| 179 | } |
| 180 | |
| 181 | // The `pointer` descriptor mirrors the raw function's so user code that |
| 182 | // reassigns `.pointer` keeps working through the wrapper. |
no test coverage detected
searching dependent graphs…