-
Notifications
You must be signed in to change notification settings - Fork 749
export_native_api.md: partially revert "Relax the ground rule" #1588
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
Conversation
This partially revert 1c89a37. The need of pointer conversions is actually more than a recommendation.
| - Never pass any structure/class object pointer to native (do data serialization instead) | ||
| - Do the pointer address conversion in the native API if "$\*" is not used for the pointer in the function signature | ||
| - Never pass a function pointer to the native |
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.
maybe add, "if you plan to call it, from native side, as a C/C++ callback. In that case, you must use wasm_runtime_call_indirect or any other variant provided by WAMR.".
What do you think?
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 understand what you mean. what's a "regular" callback? is there a "non-regular" callback?
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.
Edited for better description!
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 think this doc is basically about what the author recommends. i feel it's a bit awkward to explain more about what's discouraged here.
anyway, i added some clarifications.
| C function pointers are usually represented as table indexes which | ||
| the native API can call with wasm_runtime_call_indirect() or similar. | ||
| However, in this document, we don't recommend to implement your native | ||
| API that way unless necessary because it needs extra carefulness. |
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.
"because it needs extra carefulness" is just my guess of the intention of this document.
…odealliance#1588) And add some clarifications
This partially revert 1c89a37.
The need of pointer conversions is actually more than a recommendation.