-
Notifications
You must be signed in to change notification settings - Fork 286
Function calls #507
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
Merged
Merged
Function calls #507
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
1ac73a6
Add `env` parameter to `invoke()` API
goto-bus-stop 6d5c32a
Make CallbackInfo wrap a pointer.
goto-bus-stop cfc8940
Unwrap v8::External pointer in C++
goto-bus-stop 98462ae
Start work on exporting n-api functions
goto-bus-stop f61b739
napi: Implement receiving call arguments on the Rust side.
goto-bus-stop a0ec71b
napi: implement return value
goto-bus-stop dfebfc6
Start porting function tests from nan to n-api runtime.
goto-bus-stop 8d00d71
Start porting object test to n-api runtime.
goto-bus-stop 546f2ce
Implement runtime::fun::call.
goto-bus-stop 440e5f9
Implement runtime::fun::construct.
goto-bus-stop 1835acf
Implement `is_object` tag check.
goto-bus-stop 10495c4
Implement runtime::fun::this().
goto-bus-stop f4adc5b
Enable other passing `this` tests.
goto-bus-stop 0738432
Remove outdated comments.
goto-bus-stop b7e52e1
Add test for get_own_property_names.
goto-bus-stop 3b4de37
Check that `get_own_property_names` does not return Symbols
goto-bus-stop d9e3324
Remove possibly-incorrect handling of Rust panics in callback
goto-bus-stop d25fe61
Add a lifetime parameter to `CallbackInfo`
goto-bus-stop a488204
kick ci
goto-bus-stop 5281247
Remove unnecessary `argc` value from `neon_runtime::call::data()`.
goto-bus-stop e31c16c
try to explain why we unwrap the external
goto-bus-stop 7213332
do a capitalisation
goto-bus-stop 0a40f6a
reference TODO issue
goto-bus-stop File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,44 @@ | ||
| use std::os::raw::c_void; | ||
| //! Facilities for working with JS functions. | ||
|
|
||
| use call::CCallback; | ||
| use raw::{Env, Local}; | ||
| use std::os::raw::c_void; | ||
| use std::mem::MaybeUninit; | ||
| use std::ptr::{null, null_mut}; | ||
|
|
||
| use nodejs_sys as napi; | ||
|
|
||
| /// Mutates the `out` argument provided to refer to a newly created `v8::Function`. Returns | ||
| /// `false` if the value couldn't be created. | ||
| pub unsafe extern "C" fn new(out: &mut Local, env: Env, callback: CCallback) -> bool { | ||
| let status = napi::napi_create_function( | ||
| env, | ||
| null(), | ||
| 0, | ||
| Some(std::mem::transmute(callback.static_callback)), | ||
| callback.dynamic_callback, | ||
| out as *mut Local, | ||
| ); | ||
|
|
||
| status == napi::napi_status::napi_ok | ||
| } | ||
|
|
||
| pub unsafe extern "C" fn new_template(_out: &mut Local, _env: Env, _callback: CCallback) -> bool { | ||
| unimplemented!() | ||
| } | ||
|
|
||
| pub unsafe extern "C" fn new(_out: &mut Local, _env: Env, _callback: CCallback) -> bool { unimplemented!() } | ||
| pub unsafe extern "C" fn get_dynamic_callback(env: Env, data: *mut c_void) -> *mut c_void { | ||
| data | ||
| } | ||
|
|
||
| pub unsafe extern "C" fn new_template(_out: &mut Local, _env: Env, _callback: CCallback) -> bool { unimplemented!() } | ||
| pub unsafe extern "C" fn call(out: &mut Local, env: Env, fun: Local, this: Local, argc: i32, argv: *mut c_void) -> bool { | ||
| let status = napi::napi_call_function(env, this, fun, argc as usize, argv as *const _, out as *mut _); | ||
|
|
||
| pub unsafe extern "C" fn get_dynamic_callback(_obj: Local) -> *mut c_void { unimplemented!() } | ||
| status == napi::napi_status::napi_ok | ||
| } | ||
|
|
||
| pub unsafe extern "C" fn call(_out: &mut Local, _env: Env, _fun: Local, _this: Local, _argc: i32, _argv: *mut c_void) -> bool { unimplemented!() } | ||
| pub unsafe extern "C" fn construct(out: &mut Local, env: Env, fun: Local, argc: i32, argv: *mut c_void) -> bool { | ||
| let status = napi::napi_new_instance(env, fun, argc as usize, argv as *const _, out as *mut _); | ||
|
|
||
| pub unsafe extern "C" fn construct(_out: &mut Local, _env: Env, _fun: Local, _argc: i32, _argv: *mut c_void) -> bool { unimplemented!() } | ||
| status == napi::napi_status::napi_ok | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.