[oden-js] Functions up to 8 args
This commit is contained in:
parent
fd7e19e529
commit
af12dccd5d
1 changed files with 120 additions and 10 deletions
|
|
@ -48,11 +48,11 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R, A, F> RustFunction<PhantomData<(&R, &A, &F)>> for F
|
impl<R, A, FN> RustFunction<PhantomData<(&R, &A, &FN)>> for FN
|
||||||
where
|
where
|
||||||
R: IntoRustFunctionResult,
|
R: IntoRustFunctionResult,
|
||||||
A: TryFromValue,
|
A: TryFromValue,
|
||||||
F: Fn(&ContextRef, A) -> R + Sized,
|
FN: Fn(&ContextRef, A) -> R + Sized,
|
||||||
{
|
{
|
||||||
fn argument_count() -> usize {
|
fn argument_count() -> usize {
|
||||||
1
|
1
|
||||||
|
|
@ -72,12 +72,12 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R, A, B, F> RustFunction<PhantomData<(&R, &A, &B, &F)>> for F
|
impl<R, A, B, FN> RustFunction<PhantomData<(&R, &A, &B, &FN)>> for FN
|
||||||
where
|
where
|
||||||
R: IntoRustFunctionResult,
|
R: IntoRustFunctionResult,
|
||||||
A: TryFromValue,
|
A: TryFromValue,
|
||||||
B: TryFromValue,
|
B: TryFromValue,
|
||||||
F: Fn(&ContextRef, A, B) -> R + Sized,
|
FN: Fn(&ContextRef, A, B) -> R + Sized,
|
||||||
{
|
{
|
||||||
fn argument_count() -> usize {
|
fn argument_count() -> usize {
|
||||||
2
|
2
|
||||||
|
|
@ -98,13 +98,13 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R, A, B, C, F> RustFunction<PhantomData<(&R, &A, &B, &C, &F)>> for F
|
impl<R, A, B, C, FN> RustFunction<PhantomData<(&R, &A, &B, &C, &FN)>> for FN
|
||||||
where
|
where
|
||||||
R: IntoRustFunctionResult,
|
R: IntoRustFunctionResult,
|
||||||
A: TryFromValue,
|
A: TryFromValue,
|
||||||
B: TryFromValue,
|
B: TryFromValue,
|
||||||
C: TryFromValue,
|
C: TryFromValue,
|
||||||
F: Fn(&ContextRef, A, B, C) -> R + Sized,
|
FN: Fn(&ContextRef, A, B, C) -> R + Sized,
|
||||||
{
|
{
|
||||||
fn argument_count() -> usize {
|
fn argument_count() -> usize {
|
||||||
3
|
3
|
||||||
|
|
@ -126,14 +126,14 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R, A, B, C, D, F> RustFunction<PhantomData<(&R, &A, &B, &C, &D, &F)>> for F
|
impl<R, A, B, C, D, FN> RustFunction<PhantomData<(&R, &A, &B, &C, &D, &FN)>> for FN
|
||||||
where
|
where
|
||||||
R: IntoRustFunctionResult,
|
R: IntoRustFunctionResult,
|
||||||
A: TryFromValue,
|
A: TryFromValue,
|
||||||
B: TryFromValue,
|
B: TryFromValue,
|
||||||
C: TryFromValue,
|
C: TryFromValue,
|
||||||
D: TryFromValue,
|
D: TryFromValue,
|
||||||
F: Fn(&ContextRef, A, B, C, D) -> R + Sized,
|
FN: Fn(&ContextRef, A, B, C, D) -> R + Sized,
|
||||||
{
|
{
|
||||||
fn argument_count() -> usize {
|
fn argument_count() -> usize {
|
||||||
4
|
4
|
||||||
|
|
@ -156,7 +156,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R, A, B, C, D, E, F> RustFunction<PhantomData<(&R, &A, &B, &C, &D, &E, &F)>> for F
|
impl<R, A, B, C, D, E, FN> RustFunction<PhantomData<(&R, &A, &B, &C, &D, &E, &FN)>> for FN
|
||||||
where
|
where
|
||||||
R: IntoRustFunctionResult,
|
R: IntoRustFunctionResult,
|
||||||
A: TryFromValue,
|
A: TryFromValue,
|
||||||
|
|
@ -164,7 +164,7 @@ where
|
||||||
C: TryFromValue,
|
C: TryFromValue,
|
||||||
D: TryFromValue,
|
D: TryFromValue,
|
||||||
E: TryFromValue,
|
E: TryFromValue,
|
||||||
F: Fn(&ContextRef, A, B, C, D, E) -> R + Sized,
|
FN: Fn(&ContextRef, A, B, C, D, E) -> R + Sized,
|
||||||
{
|
{
|
||||||
fn argument_count() -> usize {
|
fn argument_count() -> usize {
|
||||||
5
|
5
|
||||||
|
|
@ -187,3 +187,113 @@ where
|
||||||
res.into_res(context)
|
res.into_res(context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<R, A, B, C, D, E, F, FN> RustFunction<PhantomData<(&R, &A, &B, &C, &D, &E, &F, &FN)>> for FN
|
||||||
|
where
|
||||||
|
R: IntoRustFunctionResult,
|
||||||
|
A: TryFromValue,
|
||||||
|
B: TryFromValue,
|
||||||
|
C: TryFromValue,
|
||||||
|
D: TryFromValue,
|
||||||
|
E: TryFromValue,
|
||||||
|
F: TryFromValue,
|
||||||
|
FN: Fn(&ContextRef, A, B, C, D, E, F) -> R + Sized,
|
||||||
|
{
|
||||||
|
fn argument_count() -> usize {
|
||||||
|
6
|
||||||
|
}
|
||||||
|
|
||||||
|
fn call(&self, context: &ContextRef, args: &[&ValueRef]) -> ValueResult {
|
||||||
|
if args.len() != Self::argument_count() {
|
||||||
|
return Err(Error::ArgumentCountMismatch {
|
||||||
|
expected: Self::argument_count(),
|
||||||
|
received: args.len(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let va = A::try_from_value(args[0], &context)?;
|
||||||
|
let vb = B::try_from_value(args[1], &context)?;
|
||||||
|
let vc = C::try_from_value(args[2], &context)?;
|
||||||
|
let vd = D::try_from_value(args[3], &context)?;
|
||||||
|
let ve = E::try_from_value(args[4], &context)?;
|
||||||
|
let vf = F::try_from_value(args[4], &context)?;
|
||||||
|
let res = self(context, va, vb, vc, vd, ve, vf);
|
||||||
|
res.into_res(context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<R, A, B, C, D, E, F, G, FN> RustFunction<PhantomData<(&R, &A, &B, &C, &D, &E, &F, &G, &FN)>>
|
||||||
|
for FN
|
||||||
|
where
|
||||||
|
R: IntoRustFunctionResult,
|
||||||
|
A: TryFromValue,
|
||||||
|
B: TryFromValue,
|
||||||
|
C: TryFromValue,
|
||||||
|
D: TryFromValue,
|
||||||
|
E: TryFromValue,
|
||||||
|
F: TryFromValue,
|
||||||
|
G: TryFromValue,
|
||||||
|
FN: Fn(&ContextRef, A, B, C, D, E, F, G) -> R + Sized,
|
||||||
|
{
|
||||||
|
fn argument_count() -> usize {
|
||||||
|
7
|
||||||
|
}
|
||||||
|
|
||||||
|
fn call(&self, context: &ContextRef, args: &[&ValueRef]) -> ValueResult {
|
||||||
|
if args.len() != Self::argument_count() {
|
||||||
|
return Err(Error::ArgumentCountMismatch {
|
||||||
|
expected: Self::argument_count(),
|
||||||
|
received: args.len(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let va = A::try_from_value(args[0], &context)?;
|
||||||
|
let vb = B::try_from_value(args[1], &context)?;
|
||||||
|
let vc = C::try_from_value(args[2], &context)?;
|
||||||
|
let vd = D::try_from_value(args[3], &context)?;
|
||||||
|
let ve = E::try_from_value(args[4], &context)?;
|
||||||
|
let vf = F::try_from_value(args[4], &context)?;
|
||||||
|
let vg = G::try_from_value(args[4], &context)?;
|
||||||
|
let res = self(context, va, vb, vc, vd, ve, vf, vg);
|
||||||
|
res.into_res(context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<R, A, B, C, D, E, F, G, H, FN>
|
||||||
|
RustFunction<PhantomData<(&R, &A, &B, &C, &D, &E, &F, &G, &H, &FN)>> for FN
|
||||||
|
where
|
||||||
|
R: IntoRustFunctionResult,
|
||||||
|
A: TryFromValue,
|
||||||
|
B: TryFromValue,
|
||||||
|
C: TryFromValue,
|
||||||
|
D: TryFromValue,
|
||||||
|
E: TryFromValue,
|
||||||
|
F: TryFromValue,
|
||||||
|
G: TryFromValue,
|
||||||
|
H: TryFromValue,
|
||||||
|
FN: Fn(&ContextRef, A, B, C, D, E, F, G, H) -> R + Sized,
|
||||||
|
{
|
||||||
|
fn argument_count() -> usize {
|
||||||
|
8
|
||||||
|
}
|
||||||
|
|
||||||
|
fn call(&self, context: &ContextRef, args: &[&ValueRef]) -> ValueResult {
|
||||||
|
if args.len() != Self::argument_count() {
|
||||||
|
return Err(Error::ArgumentCountMismatch {
|
||||||
|
expected: Self::argument_count(),
|
||||||
|
received: args.len(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let va = A::try_from_value(args[0], &context)?;
|
||||||
|
let vb = B::try_from_value(args[1], &context)?;
|
||||||
|
let vc = C::try_from_value(args[2], &context)?;
|
||||||
|
let vd = D::try_from_value(args[3], &context)?;
|
||||||
|
let ve = E::try_from_value(args[4], &context)?;
|
||||||
|
let vf = F::try_from_value(args[4], &context)?;
|
||||||
|
let vg = G::try_from_value(args[4], &context)?;
|
||||||
|
let vh = H::try_from_value(args[4], &context)?;
|
||||||
|
let res = self(context, va, vb, vc, vd, ve, vf, vg, vh);
|
||||||
|
res.into_res(context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue