From 8403883b9d703f1bee5cf63ef3095a8e0006b9ea Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Thu, 8 Jan 2026 21:00:56 -0600 Subject: [PATCH] blob w32 --- source/quickjs.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/source/quickjs.c b/source/quickjs.c index 2269d2bf..6d08f27b 100644 --- a/source/quickjs.c +++ b/source/quickjs.c @@ -38880,6 +38880,26 @@ static JSValue js_blob_w16(JSContext *ctx, JSValueConst this_val, return JS_NULL; } +/* blob.w32(value) - write 32-bit value */ +static JSValue js_blob_w32(JSContext *ctx, JSValueConst this_val, + int argc, JSValueConst *argv) +{ + if (argc < 1) + return JS_ThrowTypeError(ctx, "w32(value) requires 1 argument"); + + blob *bd = js_get_blob(ctx, this_val); + if (!bd) + return JS_ThrowTypeError(ctx, "w32: not called on a blob"); + + int32_t value; + if (JS_ToInt32(ctx, &value, argv[0]) < 0) return JS_EXCEPTION; + + if (blob_write_bytes(bd, &value, sizeof(int32_t)) < 0) + return JS_ThrowTypeError(ctx, "w32: cannot write"); + + return JS_NULL; +} + /* blob.wf(value) - write float */ static JSValue js_blob_wf(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { @@ -39080,6 +39100,7 @@ static const JSCFunctionListEntry js_blob_proto_funcs[] = { JS_CFUNC_DEF("write_pad", 1, js_blob_write_pad), JS_CFUNC_DEF("wf", 1, js_blob_wf), JS_CFUNC_DEF("w16", 1, js_blob_w16), + JS_CFUNC_DEF("w32", 1, js_blob_w32), /* Read methods */ JS_CFUNC_DEF("read_logical", 1, js_blob_read_logical),