fix(napi): add missing NoExternalBuffersAllowed (#1457)

This commit is contained in:
LongYinan 2023-01-28 14:53:31 +08:00 committed by GitHub
parent 134eb8e19b
commit adb2508fdf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,6 +29,7 @@ pub enum Status {
ArrayBufferExpected,
DetachableArraybufferExpected,
WouldDeadlock,
NoExternalBuffersAllowed,
Unknown = 1024, // unknown status. for example, using napi3 module in napi7 Node.js, and generate an invalid napi3 status
}
@ -64,6 +65,7 @@ impl From<i32> for Status {
sys::Status::napi_arraybuffer_expected => Status::ArrayBufferExpected,
sys::Status::napi_detachable_arraybuffer_expected => Status::DetachableArraybufferExpected,
sys::Status::napi_would_deadlock => Status::WouldDeadlock,
sys::Status::napi_no_external_buffers_allowed => Status::NoExternalBuffersAllowed,
_ => Status::Unknown,
}
}
@ -94,6 +96,7 @@ impl From<Status> for i32 {
Status::ArrayBufferExpected => sys::Status::napi_arraybuffer_expected,
Status::DetachableArraybufferExpected => sys::Status::napi_detachable_arraybuffer_expected,
Status::WouldDeadlock => sys::Status::napi_would_deadlock,
Status::NoExternalBuffersAllowed => sys::Status::napi_no_external_buffers_allowed,
Status::Unknown => sys::Status::napi_generic_failure,
}
}