-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
26 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
use std::mem::MaybeUninit; | ||
use nodejs_sys as napi; | ||
use raw::{Env, Local}; | ||
|
||
pub unsafe extern "C" fn new_date(env: Env, out: *mut Local, value: f64) { | ||
let status = napi::napi_create_date(env, value, out); | ||
pub unsafe extern "C" fn new_date(env: Env, value: f64) -> Local { | ||
let mut local = MaybeUninit::zeroed(); | ||
let status = napi::napi_create_date(env, value, local.as_mut_ptr()); | ||
assert_eq!(status, napi::napi_status::napi_ok); | ||
local.assume_init() | ||
} | ||
|
||
pub unsafe extern "C" fn value(env: Env, p: Local) -> f64 { | ||
let mut value = 0.0; | ||
let status = napi::napi_get_date_value(env, p, &mut value as *mut f64); | ||
let status = napi::napi_get_date_value(env, p, &mut value as *mut _); | ||
assert_eq!(status, napi::napi_status::napi_ok); | ||
return value; | ||
} |
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