From 97746b79a9eb2e2829da476bb06d71e916cd2fe2 Mon Sep 17 00:00:00 2001 From: Hana Date: Wed, 13 Mar 2024 13:29:06 +0800 Subject: [PATCH] feat(napi): support to use tuple with either (#1993) `Either` uses `ValidateNapiValue` + `TypeName` to validate and report error on value not being matched. So there's no way to remove these super traits from it. So I implemented these types to `Tuple` types. --- .../src/bindgen_runtime/js_values/array.rs | 32 ++++++++++++++++++ .../__snapshots__/typegen.spec.ts.md | 2 ++ .../__snapshots__/typegen.spec.ts.snap | Bin 4743 -> 4764 bytes .../__snapshots__/values.spec.ts.snap | Bin 380 -> 378 bytes examples/napi/index.cjs | 1 + examples/napi/index.d.cts | 2 ++ examples/napi/src/either.rs | 3 ++ 7 files changed, 40 insertions(+) diff --git a/crates/napi/src/bindgen_runtime/js_values/array.rs b/crates/napi/src/bindgen_runtime/js_values/array.rs index 3fc7baba..d47ae411 100644 --- a/crates/napi/src/bindgen_runtime/js_values/array.rs +++ b/crates/napi/src/bindgen_runtime/js_values/array.rs @@ -335,6 +335,20 @@ macro_rules! tuple_from_napi_value { } } +macro_rules! impl_tuple_validate_napi_value { + ($($ident:ident),+) => { + impl<$($ident: FromNapiValue),*> ValidateNapiValue for ($($ident,)*) {} + impl<$($ident: FromNapiValue),*> TypeName for ($($ident,)*) { + fn type_name() -> &'static str { + concat!("Tuple", "(", $(stringify!($ident), ","),*, ")") + } + fn value_type() -> ValueType { + ValueType::Object + } + } + }; +} + impl FromNapiValue for (T0, T1) where T0: FromNapiValue, @@ -599,3 +613,21 @@ where { tuple_from_napi_value!(16, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); } + +impl_tuple_validate_napi_value!(T0, T1); +impl_tuple_validate_napi_value!(T0, T1, T2); +impl_tuple_validate_napi_value!(T0, T1, T2, T3); +impl_tuple_validate_napi_value!(T0, T1, T2, T3, T4); +impl_tuple_validate_napi_value!(T0, T1, T2, T3, T4, T5); +impl_tuple_validate_napi_value!(T0, T1, T2, T3, T4, T5, T6); +impl_tuple_validate_napi_value!(T0, T1, T2, T3, T4, T5, T6, T7); +impl_tuple_validate_napi_value!(T0, T1, T2, T3, T4, T5, T6, T7, T8); +impl_tuple_validate_napi_value!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9); +impl_tuple_validate_napi_value!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10); +impl_tuple_validate_napi_value!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11); +impl_tuple_validate_napi_value!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12); +impl_tuple_validate_napi_value!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13); +impl_tuple_validate_napi_value!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14); +impl_tuple_validate_napi_value!( + T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15 +); diff --git a/examples/napi/__tests__/__snapshots__/typegen.spec.ts.md b/examples/napi/__tests__/__snapshots__/typegen.spec.ts.md index ab7a246a..d6b71e9a 100644 --- a/examples/napi/__tests__/__snapshots__/typegen.spec.ts.md +++ b/examples/napi/__tests__/__snapshots__/typegen.spec.ts.md @@ -415,6 +415,8 @@ Generated by [AVA](https://avajs.dev). ␊ export function eitherBoolOrFunction(input: boolean | ((...args: any[]) => any)): void␊ ␊ + export function eitherBoolOrTuple(input: boolean | [boolean, string]): void␊ + ␊ export function eitherFromObjects(input: A | B | C): string␊ ␊ export function eitherFromOption(): JsClassForEither | undefined␊ diff --git a/examples/napi/__tests__/__snapshots__/typegen.spec.ts.snap b/examples/napi/__tests__/__snapshots__/typegen.spec.ts.snap index 37b58329a74a460b1933ddbb457e239846b1db9c..ab45356b85d54e6af71ecac0bff07bbc92e13ae8 100644 GIT binary patch literal 4764 zcmV;N5@YQ_RzVShy9m6-zb@Z%-_tB}*PTwj`+A zNd_Kc!X~S`%VM*7SVc)4kAayt*z3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boolean | [boolean, string]): void + export function eitherFromObjects(input: A | B | C): string export function eitherFromOption(): JsClassForEither | undefined diff --git a/examples/napi/src/either.rs b/examples/napi/src/either.rs index 71bbaa9e..4f8902c1 100644 --- a/examples/napi/src/either.rs +++ b/examples/napi/src/either.rs @@ -143,3 +143,6 @@ pub async fn promise_in_either(input: Either>) -> Result } } } + +#[napi] +pub fn either_bool_or_tuple(_input: Either) {}