Skip to content
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

Implement dynamic string size. #110

Merged
merged 2 commits into from
Dec 23, 2020
Merged

Conversation

mattcollier
Copy link
Contributor

Allows for strings of variable lengths to be passed in.

Since I didn't see any existing in-line comments, I did not add any.

I'm not sure what the safety implications are for using Box in this manner. Here's a recent discussion that seems relevant: rust-lang/unsafe-code-guidelines#157

Passing NULL into napi_get_value_string_utf8 will return the size of the string.

https://nodejs.org/api/n-api.html#n_api_napi_get_value_string_utf8

Adapted from example provided here: https://github.com/nodejs/node-addon-examples/pull/107/files#diff-8252f94e35e4da5136727f8d25a119308698c527d26c04f4dc71ce90ca8fc85b

That PR is in connection with this issue: nodejs/node-addon-examples#83 (comment)

@sehz
Copy link
Collaborator

sehz commented Dec 23, 2020

This looks good.

Can you add test cases for in examples/function? as well as bump up version for crate.

Thanks!

Copy link
Collaborator

@sehz sehz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please provide test case in examples/function

Copy link
Collaborator

@sehz sehz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job on tests

@sehz sehz merged commit b44b981 into infinyon:master Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants