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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user