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

Moving values into scopes #317

Closed
gabrielschulhof opened this issue Apr 28, 2018 · 2 comments
Closed

Moving values into scopes #317

gabrielschulhof opened this issue Apr 28, 2018 · 2 comments

Comments

@gabrielschulhof
Copy link
Collaborator

Sometimes you might want to return a value that is not scoped and then to
delete the reference to it at the same time. In order to do this, it may
be useful to add the value to the scope so that it can be returned.

N-API might automatically do this; the documentation isn't quite clear. If
N-API does already do this, it should be explained, and the stuff in this
section need not be implemented.

Another alternative would be to provide another function to return values
from a native code rather than returning it directly.

Another possibility may be to create an array and add the value into that
array to prevent it from getting lost, and the array is automatically lost
when the function returns, but that seems a bit klugy to me.

Re: nodejs/node#14256

@mhdawson
Copy link
Member

@zzo38 can you clarify this a bit more?

When you return from a native function everything (JavaScript Objects) allocated in the Scope for the native method are no longer held alive unless a reference to them has been passed to JavaScript (for example by calling a JavaScript function and passing as a parametr), stored in a Reference or returned by the native function.

I think that likely covers the case you were thinking of but I'm not 100% sure from your description.

@mhdawson
Copy link
Member

Since there was no response for a number of years and the answer was that the case was likely covered closing. Please let us know if you think that was not the right thing to do.

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

No branches or pull requests

2 participants