feat(napi): support build on i686-pc-windows-msvc

This commit is contained in:
LongYinan 2020-11-04 22:52:13 +08:00
parent f9ec712d57
commit 47f5011a8f
13 changed files with 157 additions and 74 deletions

74
.github/workflows/windows-i686.yml vendored Normal file
View file

@ -0,0 +1,74 @@
name: Windows i686
env:
DEBUG: 'napi:*'
on:
push:
branches: [master, develop]
pull_request:
jobs:
build_and_test:
name: stable - windows-latest - i686 - node@14
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install llvm
run: choco install -y llvm
- name: Set llvm path
run: echo "LIBCLANG_PATH=C:\\Program Files\\LLVM\\bin" >> $GITHUB_ENV
shell: bash
- name: Install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Install i686 toolchain
run: rustup target add i686-pc-windows-msvc
- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: generate-lockfile
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: stable-${{ matrix.os }}-node@${{ matrix.node }}-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: stable-${{ matrix.os }}gnu-node@${{ matrix.node }}-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Check build
uses: actions-rs/cargo@v1
with:
command: check
args: --all --bins --examples --tests --target i686-pc-windows-msvc -vvv
- name: Tests
uses: actions-rs/cargo@v1
timeout-minutes: 5
with:
command: test
args: -p napi-sys --lib --target i686-pc-windows-msvc -- --nocapture
- name: Clear the cargo caches
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
cargo-cache

View file

@ -17,12 +17,13 @@ A minimal library for building compiled `NodeJS` add-ons in `Rust`.
![Linux musl](https://github.com/napi-rs/napi-rs/workflows/Linux%20musl/badge.svg) ![Linux musl](https://github.com/napi-rs/napi-rs/workflows/Linux%20musl/badge.svg)
![macOS/Windows/Linux x64](https://github.com/napi-rs/napi-rs/workflows/macOS/Windows/Linux%20x64/badge.svg) ![macOS/Windows/Linux x64](https://github.com/napi-rs/napi-rs/workflows/macOS/Windows/Linux%20x64/badge.svg)
![Linux-aarch64](https://github.com/napi-rs/napi-rs/workflows/Linux-aarch64/badge.svg) ![Linux-aarch64](https://github.com/napi-rs/napi-rs/workflows/Linux-aarch64/badge.svg)
![Windows i686](https://github.com/napi-rs/napi-rs/workflows/Windows%20i686/badge.svg)
[![FreeBSD](https://api.cirrus-ci.com/github/napi-rs/napi-rs.svg)](https://cirrus-ci.com/github/napi-rs/napi-rs?branch=master) [![FreeBSD](https://api.cirrus-ci.com/github/napi-rs/napi-rs.svg)](https://cirrus-ci.com/github/napi-rs/napi-rs?branch=master)
## Operating Systems ## Operating Systems
| Linux | macOS | Windows x64 MSVC | FreeBSD | | Linux | macOS | Windows MSVC | FreeBSD |
| ----- | ----- | ---------------- | ------- | | ----- | ----- | ------------ | ------- |
| ✓ | ✓ | ✓ | ✓ | | ✓ | ✓ | ✓ | ✓ |
## NodeJS ## NodeJS

View file

@ -110,7 +110,7 @@ pub fn js_function(attr: TokenStream, input: TokenStream) -> TokenStream {
let status = napi::sys::napi_get_cb_info( let status = napi::sys::napi_get_cb_info(
raw_env, raw_env,
cb_info, cb_info,
&mut argc as *mut usize as *mut u64, &mut argc as *mut usize as *mut _,
raw_args.as_mut_ptr(), raw_args.as_mut_ptr(),
&mut raw_this, &mut raw_this,
ptr::null_mut(), ptr::null_mut(),

View file

@ -44,7 +44,7 @@ pub fn run<'env, T: Task>(env: &'env Env, task: T) -> Result<AsyncWorkPromise<'e
sys::napi_create_string_utf8( sys::napi_create_string_utf8(
env.0, env.0,
s.as_ptr() as *const c_char, s.as_ptr() as *const c_char,
s.len() as u64, s.len() as _,
&mut raw_name, &mut raw_name,
) )
})?; })?;

View file

@ -137,7 +137,7 @@ impl Env {
true => 1, true => 1,
false => 0, false => 0,
}, },
len as u64, len as _,
words.as_ptr(), words.as_ptr(),
&mut raw_value, &mut raw_value,
) )
@ -146,31 +146,33 @@ impl Env {
} }
pub fn create_string(&self, s: &str) -> Result<JsString> { pub fn create_string(&self, s: &str) -> Result<JsString> {
self.create_string_from_chars(s.as_ptr() as *const c_char, s.len() as u64) self.create_string_from_chars(s.as_ptr() as *const c_char, s.len())
} }
pub fn create_string_from_std(&self, s: String) -> Result<JsString> { pub fn create_string_from_std(&self, s: String) -> Result<JsString> {
self.create_string_from_chars(s.as_ptr() as *const c_char, s.len() as u64) self.create_string_from_chars(s.as_ptr() as *const c_char, s.len())
} }
pub fn create_string_from_vec_u8(&self, bytes: Vec<u8>) -> Result<JsString> { pub fn create_string_from_vec_u8(&self, bytes: Vec<u8>) -> Result<JsString> {
self.create_string_from_chars(bytes.as_ptr() as *const c_char, bytes.len() as u64) self.create_string_from_chars(bytes.as_ptr() as *const c_char, bytes.len())
} }
pub fn create_string_from_vec_i8(&self, bytes: Vec<i8>) -> Result<JsString> { pub fn create_string_from_vec_i8(&self, bytes: Vec<i8>) -> Result<JsString> {
self.create_string_from_chars(bytes.as_ptr() as *const c_char, bytes.len() as u64) self.create_string_from_chars(bytes.as_ptr() as *const c_char, bytes.len())
} }
fn create_string_from_chars(&self, data_ptr: *const c_char, len: u64) -> Result<JsString> { fn create_string_from_chars(&self, data_ptr: *const c_char, len: usize) -> Result<JsString> {
let mut raw_value = ptr::null_mut(); let mut raw_value = ptr::null_mut();
check_status(unsafe { sys::napi_create_string_utf8(self.0, data_ptr, len, &mut raw_value) })?; check_status(unsafe {
sys::napi_create_string_utf8(self.0, data_ptr, len as _, &mut raw_value)
})?;
Ok(JsString::from_raw_unchecked(self.0, raw_value)) Ok(JsString::from_raw_unchecked(self.0, raw_value))
} }
pub fn create_string_utf16(&self, chars: &[u16]) -> Result<JsString> { pub fn create_string_utf16(&self, chars: &[u16]) -> Result<JsString> {
let mut raw_value = ptr::null_mut(); let mut raw_value = ptr::null_mut();
check_status(unsafe { check_status(unsafe {
sys::napi_create_string_utf16(self.0, chars.as_ptr(), chars.len() as u64, &mut raw_value) sys::napi_create_string_utf16(self.0, chars.as_ptr(), chars.len() as _, &mut raw_value)
})?; })?;
Ok(JsString::from_raw_unchecked(self.0, raw_value)) Ok(JsString::from_raw_unchecked(self.0, raw_value))
} }
@ -181,7 +183,7 @@ impl Env {
sys::napi_create_string_latin1( sys::napi_create_string_latin1(
self.0, self.0,
chars.as_ptr() as *const _, chars.as_ptr() as *const _,
chars.len() as u64, chars.len() as _,
&mut raw_value, &mut raw_value,
) )
})?; })?;
@ -224,17 +226,17 @@ impl Env {
pub fn create_array_with_length(&self, length: usize) -> Result<JsObject> { pub fn create_array_with_length(&self, length: usize) -> Result<JsObject> {
let mut raw_value = ptr::null_mut(); let mut raw_value = ptr::null_mut();
check_status(unsafe { check_status(unsafe {
sys::napi_create_array_with_length(self.0, length as u64, &mut raw_value) sys::napi_create_array_with_length(self.0, length as _, &mut raw_value)
})?; })?;
Ok(JsObject::from_raw_unchecked(self.0, raw_value)) Ok(JsObject::from_raw_unchecked(self.0, raw_value))
} }
pub fn create_buffer(&self, length: u64) -> Result<JsBufferValue> { pub fn create_buffer(&self, length: usize) -> Result<JsBufferValue> {
let mut raw_value = ptr::null_mut(); let mut raw_value = ptr::null_mut();
let mut data: Vec<u8> = Vec::with_capacity(length as usize); let mut data: Vec<u8> = Vec::with_capacity(length);
let mut data_ptr = data.as_mut_ptr() as *mut c_void; let mut data_ptr = data.as_mut_ptr() as *mut c_void;
check_status(unsafe { check_status(unsafe {
sys::napi_create_buffer(self.0, length, &mut data_ptr, &mut raw_value) sys::napi_create_buffer(self.0, length as _, &mut data_ptr, &mut raw_value)
})?; })?;
Ok(JsBufferValue::new( Ok(JsBufferValue::new(
@ -248,16 +250,16 @@ impl Env {
} }
pub fn create_buffer_with_data(&self, mut data: Vec<u8>) -> Result<JsBufferValue> { pub fn create_buffer_with_data(&self, mut data: Vec<u8>) -> Result<JsBufferValue> {
let mut length = data.len() as u64; let mut length = data.len();
let mut raw_value = ptr::null_mut(); let mut raw_value = ptr::null_mut();
let data_ptr = data.as_mut_ptr(); let data_ptr = data.as_mut_ptr();
check_status(unsafe { check_status(unsafe {
sys::napi_create_external_buffer( sys::napi_create_external_buffer(
self.0, self.0,
length, length as _,
data_ptr as *mut c_void, data_ptr as *mut c_void,
Some(drop_buffer), Some(drop_buffer),
&mut length as *mut u64 as *mut _, &mut length as *mut usize as *mut _,
&mut raw_value, &mut raw_value,
) )
})?; })?;
@ -284,7 +286,7 @@ impl Env {
check_status(unsafe { check_status(unsafe {
sys::napi_create_buffer_copy( sys::napi_create_buffer_copy(
self.0, self.0,
length as u64, length as _,
data_ptr as *mut c_void, data_ptr as *mut c_void,
&mut copy_data, &mut copy_data,
&mut raw_value, &mut raw_value,
@ -300,12 +302,12 @@ impl Env {
)) ))
} }
pub fn create_arraybuffer(&self, length: u64) -> Result<JsArrayBufferValue> { pub fn create_arraybuffer(&self, length: usize) -> Result<JsArrayBufferValue> {
let mut raw_value = ptr::null_mut(); let mut raw_value = ptr::null_mut();
let mut data: Vec<u8> = Vec::with_capacity(length as usize); let mut data: Vec<u8> = Vec::with_capacity(length as usize);
let mut data_ptr = data.as_mut_ptr() as *mut c_void; let mut data_ptr = data.as_mut_ptr() as *mut c_void;
check_status(unsafe { check_status(unsafe {
sys::napi_create_arraybuffer(self.0, length, &mut data_ptr, &mut raw_value) sys::napi_create_arraybuffer(self.0, length as _, &mut data_ptr, &mut raw_value)
})?; })?;
Ok(JsArrayBufferValue::new( Ok(JsArrayBufferValue::new(
@ -315,16 +317,16 @@ impl Env {
} }
pub fn create_arraybuffer_with_data(&self, data: Vec<u8>) -> Result<JsArrayBufferValue> { pub fn create_arraybuffer_with_data(&self, data: Vec<u8>) -> Result<JsArrayBufferValue> {
let mut length = data.len() as u64; let mut length = data.len();
let mut raw_value = ptr::null_mut(); let mut raw_value = ptr::null_mut();
let data_ptr = data.as_ptr(); let data_ptr = data.as_ptr();
check_status(unsafe { check_status(unsafe {
sys::napi_create_external_arraybuffer( sys::napi_create_external_arraybuffer(
self.0, self.0,
data_ptr as *mut c_void, data_ptr as *mut c_void,
length, length as _,
Some(drop_buffer), Some(drop_buffer),
&mut length as *mut u64 as *mut c_void, &mut length as *mut usize as *mut c_void,
&mut raw_value, &mut raw_value,
) )
})?; })?;
@ -347,7 +349,7 @@ impl Env {
sys::napi_create_function( sys::napi_create_function(
self.0, self.0,
name.as_ptr() as *const c_char, name.as_ptr() as *const c_char,
name.len() as u64, name.len() as _,
Some(callback), Some(callback),
callback as *mut c_void, callback as *mut c_void,
&mut raw_result, &mut raw_result,
@ -389,10 +391,10 @@ impl Env {
sys::napi_define_class( sys::napi_define_class(
self.0, self.0,
name.as_ptr() as *const c_char, name.as_ptr() as *const c_char,
name.len() as u64, name.len() as _,
Some(constructor_cb), Some(constructor_cb),
ptr::null_mut(), ptr::null_mut(),
raw_properties.len() as u64, raw_properties.len() as _,
raw_properties.as_ptr(), raw_properties.as_ptr(),
&mut raw_result, &mut raw_result,
) )
@ -597,7 +599,7 @@ impl Env {
>( >(
&self, &self,
func: JsFunction, func: JsFunction,
max_queue_size: u64, max_queue_size: usize,
callback: R, callback: R,
) -> Result<ThreadsafeFunction<T>> { ) -> Result<ThreadsafeFunction<T>> {
ThreadsafeFunction::create(self.0, func, max_queue_size, callback) ThreadsafeFunction::create(self.0, func, max_queue_size, callback)

View file

@ -68,7 +68,7 @@ impl Error {
let status = sys::napi_create_string_utf8( let status = sys::napi_create_string_utf8(
env, env,
s.as_ptr() as *const c_char, s.as_ptr() as *const c_char,
s.len() as u64, s.len() as _,
&mut err_reason, &mut err_reason,
); );
debug_assert!( debug_assert!(

View file

@ -121,14 +121,17 @@ impl JsArrayBuffer {
pub fn into_value(self) -> Result<JsArrayBufferValue> { pub fn into_value(self) -> Result<JsArrayBufferValue> {
let mut data = ptr::null_mut(); let mut data = ptr::null_mut();
let mut len: u64 = 0; let mut len: usize = 0;
check_status(unsafe { check_status(unsafe {
sys::napi_get_arraybuffer_info(self.0.env, self.0.value, &mut data, &mut len) sys::napi_get_arraybuffer_info(
self.0.env,
self.0.value,
&mut data,
&mut len as *mut usize as *mut _,
)
})?; })?;
Ok(JsArrayBufferValue { Ok(JsArrayBufferValue {
data: mem::ManuallyDrop::new(unsafe { data: mem::ManuallyDrop::new(unsafe { Vec::from_raw_parts(data as *mut _, len, len) }),
Vec::from_raw_parts(data as *mut _, len as usize, len as usize)
}),
value: self, value: self,
}) })
} }
@ -144,9 +147,9 @@ impl JsArrayBuffer {
sys::napi_create_typedarray( sys::napi_create_typedarray(
self.0.env, self.0.env,
typedarray_type.into(), typedarray_type.into(),
length, length as _,
self.0.value, self.0.value,
byte_offset, byte_offset as _,
&mut typedarray_value, &mut typedarray_value,
) )
})?; })?;
@ -162,9 +165,9 @@ impl JsArrayBuffer {
check_status(unsafe { check_status(unsafe {
sys::napi_create_dataview( sys::napi_create_dataview(
self.0.env, self.0.env,
length, length as _,
self.0.value, self.0.value,
byte_offset, byte_offset as _,
&mut dataview_value, &mut dataview_value,
) )
})?; })?;
@ -228,10 +231,10 @@ impl JsTypedArray {
self.0.env, self.0.env,
self.0.value, self.0.value,
&mut typedarray_type, &mut typedarray_type,
&mut len, &mut len as *mut u64 as *mut _,
&mut data, &mut data,
&mut arraybuffer_value, &mut arraybuffer_value,
&mut byte_offset, &mut byte_offset as *mut u64 as *mut _,
) )
})?; })?;
@ -256,10 +259,10 @@ impl JsDataView {
sys::napi_get_dataview_info( sys::napi_get_dataview_info(
self.0.env, self.0.env,
self.0.value, self.0.value,
&mut length, &mut length as *mut u64 as *mut _,
&mut data, &mut data,
&mut arraybuffer_value, &mut arraybuffer_value,
&mut byte_offset, &mut byte_offset as *mut u64 as *mut _,
) )
})?; })?;
Ok(JsDataViewValue { Ok(JsDataViewValue {

View file

@ -135,7 +135,7 @@ impl NapiValue for JsBigint {
env, env,
value, value,
ptr::null_mut(), ptr::null_mut(),
&mut word_count, &mut word_count as *mut u64 as *mut _,
ptr::null_mut(), ptr::null_mut(),
) )
})?; })?;
@ -156,7 +156,7 @@ impl NapiValue for JsBigint {
env, env,
value, value,
ptr::null_mut(), ptr::null_mut(),
&mut word_count, &mut word_count as *mut u64 as *mut _,
ptr::null_mut(), ptr::null_mut(),
) )
}; };
@ -205,7 +205,7 @@ impl JsBigint {
self.raw.env, self.raw.env,
self.raw.value, self.raw.value,
&mut sign_bit, &mut sign_bit,
word_count, word_count as *mut u64 as *mut _,
words.as_mut_ptr(), words.as_mut_ptr(),
) )
})?; })?;

View file

@ -21,14 +21,17 @@ pub struct JsBufferValue {
impl JsBuffer { impl JsBuffer {
pub fn into_value(self) -> Result<JsBufferValue> { pub fn into_value(self) -> Result<JsBufferValue> {
let mut data = ptr::null_mut(); let mut data = ptr::null_mut();
let mut len: u64 = 0; let mut len: usize = 0;
check_status(unsafe { check_status(unsafe {
sys::napi_get_buffer_info(self.0.env, self.0.value, &mut data, &mut len) sys::napi_get_buffer_info(
self.0.env,
self.0.value,
&mut data,
&mut len as *mut usize as *mut _,
)
})?; })?;
Ok(JsBufferValue { Ok(JsBufferValue {
data: mem::ManuallyDrop::new(unsafe { data: mem::ManuallyDrop::new(unsafe { Vec::from_raw_parts(data as *mut _, len, len) }),
Vec::from_raw_parts(data as *mut _, len as usize, len as usize)
}),
value: self, value: self,
}) })
} }
@ -43,17 +46,17 @@ impl JsBufferValue {
#[cfg(feature = "serde-json")] #[cfg(feature = "serde-json")]
pub(crate) fn from_raw(env: sys::napi_env, value: sys::napi_value) -> Result<Self> { pub(crate) fn from_raw(env: sys::napi_env, value: sys::napi_value) -> Result<Self> {
let mut data = ptr::null_mut(); let mut data = ptr::null_mut();
let mut len: u64 = 0; let mut len = 0usize;
check_status(unsafe { sys::napi_get_buffer_info(env, value, &mut data, &mut len) })?; check_status(unsafe {
sys::napi_get_buffer_info(env, value, &mut data, &mut len as *mut usize as *mut _)
})?;
Ok(Self { Ok(Self {
value: JsBuffer(Value { value: JsBuffer(Value {
env, env,
value, value,
value_type: ValueType::Object, value_type: ValueType::Object,
}), }),
data: mem::ManuallyDrop::new(unsafe { data: mem::ManuallyDrop::new(unsafe { Vec::from_raw_parts(data as *mut _, len, len) }),
Vec::from_raw_parts(data as *mut _, len as usize, len as usize)
}),
}) })
} }

View file

@ -47,7 +47,7 @@ impl JsFunction {
self.0.env, self.0.env,
raw_this, raw_this,
self.0.value, self.0.value,
args.len() as u64, args.len() as _,
raw_args.as_ptr(), raw_args.as_ptr(),
&mut return_value, &mut return_value,
) )
@ -63,7 +63,7 @@ impl JsFunction {
V: NapiValue, V: NapiValue,
{ {
let mut js_instance = ptr::null_mut(); let mut js_instance = ptr::null_mut();
let length = args.len() as u64; let length = args.len();
let raw_args = args let raw_args = args
.iter() .iter()
.map(|arg| arg.raw()) .map(|arg| arg.raw())
@ -72,7 +72,7 @@ impl JsFunction {
sys::napi_new_instance( sys::napi_new_instance(
self.0.env, self.0.env,
self.0.value, self.0.value,
length, length as _,
raw_args.as_ptr(), raw_args.as_ptr(),
&mut js_instance, &mut js_instance,
) )

View file

@ -43,7 +43,7 @@ impl JsString {
} }
pub fn into_utf8(self) -> Result<JsStringUtf8> { pub fn into_utf8(self) -> Result<JsStringUtf8> {
let mut written_char_count: u64 = 0; let mut written_char_count = 0;
let len = self.utf8_len()? + 1; let len = self.utf8_len()? + 1;
let mut result = Vec::with_capacity(len); let mut result = Vec::with_capacity(len);
let buf_ptr = result.as_mut_ptr(); let buf_ptr = result.as_mut_ptr();
@ -52,7 +52,7 @@ impl JsString {
self.0.env, self.0.env,
self.0.value, self.0.value,
buf_ptr, buf_ptr,
len as u64, len as _,
&mut written_char_count, &mut written_char_count,
) )
})?; })?;
@ -76,7 +76,7 @@ impl JsString {
} }
pub fn into_utf16(self) -> Result<JsStringUtf16> { pub fn into_utf16(self) -> Result<JsStringUtf16> {
let mut written_char_count: u64 = 0; let mut written_char_count = 0;
let len = self.utf16_len()? + 1; let len = self.utf16_len()? + 1;
let mut result = Vec::with_capacity(len); let mut result = Vec::with_capacity(len);
let buf_ptr = result.as_mut_ptr(); let buf_ptr = result.as_mut_ptr();
@ -85,7 +85,7 @@ impl JsString {
self.0.env, self.0.env,
self.0.value, self.0.value,
buf_ptr, buf_ptr,
len as u64, len as _,
&mut written_char_count, &mut written_char_count,
) )
})?; })?;
@ -113,8 +113,8 @@ impl JsString {
self.0.env, self.0.env,
self.0.value, self.0.value,
buf_ptr, buf_ptr,
len as u64, len as _,
&mut written_char_count, &mut written_char_count as *mut u64 as *mut _,
) )
})?; })?;

View file

@ -27,7 +27,7 @@ impl<T, V: NapiValue> FuturePromise<T, V> {
sys::napi_create_string_utf8( sys::napi_create_string_utf8(
env, env,
s.as_ptr() as *const c_char, s.as_ptr() as *const c_char,
s.len() as u64, s.len() as _,
&mut async_resource_name, &mut async_resource_name,
) )
})?; })?;
@ -44,7 +44,7 @@ impl<T, V: NapiValue> FuturePromise<T, V> {
pub(crate) fn start(self) -> Result<TSFNValue> { pub(crate) fn start(self) -> Result<TSFNValue> {
let mut tsfn_value = ptr::null_mut(); let mut tsfn_value = ptr::null_mut();
let async_resource_name = self.async_resource_name; let async_resource_name = self.async_resource_name;
let initial_thread_count: u64 = 1; let initial_thread_count = 1;
let env = self.env; let env = self.env;
let self_ref = Box::leak(Box::from(self)); let self_ref = Box::leak(Box::from(self));
check_status(unsafe { check_status(unsafe {
@ -54,7 +54,7 @@ impl<T, V: NapiValue> FuturePromise<T, V> {
ptr::null_mut(), ptr::null_mut(),
async_resource_name, async_resource_name,
0, 0,
initial_thread_count, initial_thread_count as _,
ptr::null_mut(), ptr::null_mut(),
None, None,
self_ref as *mut _ as *mut c_void, self_ref as *mut _ as *mut c_void,

View file

@ -119,7 +119,7 @@ impl<T: 'static> ThreadsafeFunction<T> {
>( >(
env: sys::napi_env, env: sys::napi_env,
func: JsFunction, func: JsFunction,
max_queue_size: u64, max_queue_size: usize,
callback: R, callback: R,
) -> Result<Self> { ) -> Result<Self> {
let mut async_resource_name = ptr::null_mut(); let mut async_resource_name = ptr::null_mut();
@ -128,12 +128,12 @@ impl<T: 'static> ThreadsafeFunction<T> {
sys::napi_create_string_utf8( sys::napi_create_string_utf8(
env, env,
s.as_ptr() as *const c_char, s.as_ptr() as *const c_char,
s.len() as u64, s.len() as _,
&mut async_resource_name, &mut async_resource_name,
) )
})?; })?;
let initial_thread_count: u64 = 1; let initial_thread_count = 1;
let mut raw_tsfn = ptr::null_mut(); let mut raw_tsfn = ptr::null_mut();
let context = ThreadSafeContext(Box::from(callback)); let context = ThreadSafeContext(Box::from(callback));
let ptr = Box::into_raw(Box::new(context)) as *mut _; let ptr = Box::into_raw(Box::new(context)) as *mut _;
@ -143,7 +143,7 @@ impl<T: 'static> ThreadsafeFunction<T> {
func.0.value, func.0.value,
ptr::null_mut(), ptr::null_mut(),
async_resource_name, async_resource_name,
max_queue_size, max_queue_size as _,
initial_thread_count, initial_thread_count,
ptr, ptr,
Some(thread_finalize_cb::<T, V>), Some(thread_finalize_cb::<T, V>),