From c50a2b61fca4a4669f65dc134dc5ab98d3dbe2a6 Mon Sep 17 00:00:00 2001 From: CharlesKWON Date: Mon, 15 Jun 2026 21:42:01 +0900 Subject: [PATCH] docs(rag): note two-way type conversion + sysinfo multi-type example Co-Authored-By: Claude Opus 4.8 (1M context) --- rag/04-idioms.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rag/04-idioms.md b/rag/04-idioms.md index c2f302a..ee28d55 100644 --- a/rag/04-idioms.md +++ b/rag/04-idioms.md @@ -237,9 +237,12 @@ oQR:__end__() // release the handle ``` How it works: at `FN_REQUIRE` the bridge enumerates the module's method names and registers each as a class method whose closure proxies `oObj:(args)` to Node -(mirrors the C++ `TFNModule` `hb_clsAdd(clsH, NAME, DISPATCH)`). Args are native PRG -values (string/number/hash/array → JS); the result comes back as string/number/ -boolean/buffer(base64)/json. `__end__()` frees the node-side handle. +(mirrors the C++ `TFNModule` `hb_clsAdd(clsH, NAME, DISPATCH)`). Type conversion is +two-way: PRG args (string/number/logical/hash/array) → JS; JS results → +string/number/boolean/buffer(base64), and **JS arrays/objects decode to native PRG +arrays/hashes** (recursively) — so `Len(oOs:cpus())`, `aCpus[1]`, `hb_HGetDef(h,"k")` +all work. `__end__()` frees the node-side handle. Multi-type example: +solmade `app/api/sysinfo.prg` (`os.hostname/uptime/cpus/loadavg/userInfo`). - Setup: a `node/` dir with `package.json` + `npm install `; the bridge points `NODE_PATH` there (default via env `SOLMADE_NODE_DIR`). - One persistent `node` per process; calls serialized; pure Go, node spawned on first use.