diff options
author | snek <snek@deno.com> | 2024-07-22 11:41:59 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-22 11:41:59 -0700 |
commit | 92abdb7669d81b656ae0505cf923fca3b7feea01 (patch) | |
tree | 51b69d12fc67351f979246d86fc9cfdf369dde48 /ext/napi/sym/README.md | |
parent | a459b43d59d2f8f055f3ecda30d1cf0fed2e181f (diff) |
chore: move all node-api impl to ext (#24662)
these symbols are re-exported from runtime/cli using `build.rs`, so we
don't need them in the same crate.
Diffstat (limited to 'ext/napi/sym/README.md')
-rw-r--r-- | ext/napi/sym/README.md | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ext/napi/sym/README.md b/ext/napi/sym/README.md new file mode 100644 index 000000000..de08a8e17 --- /dev/null +++ b/ext/napi/sym/README.md @@ -0,0 +1,37 @@ +# napi_sym + +A proc_macro for Deno's Node-API implementation. It does the following things: + +- Marks the symbol as `#[no_mangle]` and rewrites it as `pub extern "C" $name`. +- Asserts that the function symbol is present in + [`symbol_exports.json`](./symbol_exports.json). +- Maps `deno_napi::Result` to raw `napi_result`. + +```rust +use deno_napi::napi_value; +use deno_napi::Env; +use deno_napi::Error; +use deno_napi::Result; + +#[napi_sym::napi_sym] +fn napi_get_boolean( + env: *mut Env, + value: bool, + result: *mut napi_value, +) -> Result { + let _env: &mut Env = env.as_mut().ok_or(Error::InvalidArg)?; + // *result = ... + Ok(()) +} +``` + +### `symbol_exports.json` + +A file containing the symbols that need to be put into the executable's dynamic +symbol table at link-time. + +This is done using `/DEF:` on Windows, `-exported_symbol,_` on macOS and +`--export-dynamic-symbol=` on Linux. See [`cli/build.rs`](../build.rs). + +On Windows, you need to generate the `.def` file by running +[`tools/napi/generate_symbols_lists.js`](../../tools/napi/generate_symbols_lists.js). |