-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update docs for plugins #832
Conversation
Wasm module. Then you need to run | ||
|
||
``` | ||
javy init-plugin <path_to_plugin> -o <path_to_initialized_module>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
docs/docs-using-extending.md
Outdated
The Wasm API the Javy CLI expects Javy plugins to expose is the following: | ||
- Exported `initialize_runtime() -> ()` function. This will initialize a mutable | ||
global containing the Javy runtime for use by `compile_src` and `invoke`. | ||
- Exported | ||
`canonical_abi_realloc(orig_ptr: i32, orig_len: i32, new_ptr: i32, new_len: i32) -> ptr: i32` | ||
function. This is used to allocate memory in the plugin module. | ||
- Exported `compile_src(src_ptr: i32, src_len: i32) -> bytecode_wide_ptr: i32` | ||
function. This is used to compile JavaScript source code to QuickJS bytecode. | ||
The return pointer points to a tuple of | ||
`(bytecode_ptr: i32, bytecode_len: i32)` in the plugin instance's linear | ||
memory. | ||
- Exported | ||
`invoke(bytecode_ptr: i32, bytecode_len: i32, fn_name_ptr: i32, fn_name_len: i32) -> ()` | ||
function. This is used to evaluate the JavaScript code and optionally to | ||
call an exported JS function if `fn_name_ptr` is not `0`. | ||
- Custom section named `import_namespace` containing a UTF-8 encoded string. | ||
This is used to determine the namespace that will be used for the Wasm | ||
imports in dynamically linked modules built with this plugin. | ||
|
||
The `javy-plugin-api` crate will export implementations of all required exported | ||
functions except `initialize_runtime`. `import_namespace!` will define the | ||
`import_namespace` custom section. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit: what do you think of putting this information inside a table to improve readability? It'll for sure be less readable in markdown format, but potentially more readable when rendered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think a table would help make it more readable. The explanation text would just be super squished. Maybe headers instead? That's how most documentation sites would render methods/functions.
Description of the change
Updates documentation with new project architecture and how to extend Javy with plugins.
Why am I making this change?
Part of #768. The documentation was a bit out-of-date.
Checklist
javy-cli
andjavy-plugin
do not require updating CHANGELOG files.