docs(rag): note two-way type conversion + sysinfo multi-type example

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
CharlesKWON
2026-06-15 21:42:01 +09:00
parent ffafdc8fa5
commit c50a2b61fc

View File

@@ -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:<name>(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 <pkg>`; 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.