-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #507 from goto-bus-stop/functions
Function calls
- Loading branch information
Showing
20 changed files
with
775 additions
and
103 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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.