-
Notifications
You must be signed in to change notification settings - Fork 35
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
Simplify the C API #183
Comments
Those changes would help as well with the Node.js binding I'm working on. I have ~400 lines (probably badly written) only to handle config. |
Side node: |
That’s not what it does. It really resets the entirety of uarch. Including RAM and all other registers. |
So documentation should be fixed. machine-emulator/src/machine-c-api.h Line 1845 in 77fb173
|
@mpernambuco can you take a look? |
|
I wanted to relate our experience on creating Rust binding.
I was initially confused me about the machine config. I think it's because there are instances of it created and managed by us (like in the create function), and there are instances of it created and managed by the emulator. It was easy to deal with the one created and managed by the emulator. I had no problem accessing the fields. No problem freeing memory either, we just need to wrap it in another Rust object and implement On using json for machine config. For creating a machine, I think that may help a lot. For querying the machine about the initial config, I think it would not be super ergonomic, but it would be easy, and it may be the best solution I have a feeling most users will be after the same few fields in the machine config (like the address and length of the tx/rx buffer). Maybe dedicated methods to read commonly needed fields could help? Or maybe specific functions for common operations, like clearing rx/tx buffer. Or writing an input (setting all the correct registers and buffers). Or reading an input (parsing all the correct registers). I was copying these operations from |
Context
Our C API is currently being used to create machine bindings in Lua, Rust, Go and TypeScript languages. Since this, we noticed there are some pain points when creating C bindings in those languages, we could make a refactor to improve it, make it smaller and simpler.
Subtasks
uint64
into a single write/read method shared for all registers and CSRs, and use a new enumeration.cm_get_last_error_message(machine)
.cm_delete_*
methods, for examplecm_delete_semantic_version
could be removed by making it always static allocated.cm_merkle_tree_proof
we could removecm_delete_merkle_tree_proof
. Similar we could maybe removecm_delete_memory_range_config
andcm_delete_memory_range_descr_array
.The text was updated successfully, but these errors were encountered: