-
Notifications
You must be signed in to change notification settings - Fork 288
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
N-API Initial Patterns #458
Conversation
$crate::macro_internal::initialize_module( | ||
// FIXME: Can we do without these? | ||
std::mem::transmute(env), | ||
std::mem::transmute(m), |
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'm not as confident in this one, but I believe that this is simply an explicit version of the implicit type conversion happening in this definition:
register_func: Option<extern "C" fn(
$crate::handle::Handle<$crate::types::JsObject>, *mut u8, *mut u8)>,
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.
Awesome work, this will really help the N-API transition.
[napi_get_value_string_utf8](https://nodejs.org/api/n-api.html#n_api_napi_get_value_string_utf8) wants to write a NULL terminator at the end, and truncates the string if it doesn't fit in the provided buffer. So we need to have an extra byte beyond the length of the string, so it can write the full thing.
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.
Looks great! Totally fine deferring some of the feedback to future issues.
ensure enough space for n-api to write a null terminator
No description provided.