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.