@@ -5,16 +5,24 @@ import TruncatedStacktraces
55
66export FunctionWrappersWrapper
77
8- struct FunctionWrappersWrapper{FW,FB}
9- fw:: FW
8+ struct FunctionWrappersWrapper{FW, FB}
9+ fw:: FW
1010end
1111
1212TruncatedStacktraces. @truncate_stacktrace FunctionWrappersWrapper
1313
14- (fww:: FunctionWrappersWrapper{FW,FB} )(args:: Vararg{Any,K} ) where {FW,K,FB} = _call (fww. fw, args, fww)
14+ function (fww:: FunctionWrappersWrapper{FW, FB} )(args:: Vararg{Any, K} ) where {FW, K, FB}
15+ _call (fww. fw, args, fww)
16+ end
1517
16- _call (fw:: Tuple{FunctionWrappers.FunctionWrapper{R,A},Vararg} , arg:: A , fww:: FunctionWrappersWrapper ) where {R,A} = first (fw)(arg... )
17- _call (fw:: Tuple{FunctionWrappers.FunctionWrapper{R,A1},Vararg} , arg:: A2 , fww:: FunctionWrappersWrapper ) where {R,A1,A2} = _call (Base. tail (fw), arg, fww)
18+ function _call (fw:: Tuple{FunctionWrappers.FunctionWrapper{R, A}, Vararg} ,
19+ arg:: A , fww:: FunctionWrappersWrapper ) where {R, A}
20+ first (fw)(arg... )
21+ end
22+ function _call (fw:: Tuple{FunctionWrappers.FunctionWrapper{R, A1}, Vararg} ,
23+ arg:: A2 , fww:: FunctionWrappersWrapper ) where {R, A1, A2}
24+ _call (Base. tail (fw), arg, fww)
25+ end
1826
1927const NO_FUNCTIONWRAPPER_FOUND_MESSAGE = " No matching function wrapper was found!"
2028
@@ -24,14 +32,20 @@ function Base.showerror(io::IO, e::NoFunctionWrapperFoundError)
2432 print (io, NO_FUNCTIONWRAPPER_FOUND_MESSAGE)
2533end
2634
27- _call (:: Tuple{} , arg, fww:: FunctionWrappersWrapper{<:Any,false} ) = throw (NoFunctionWrapperFoundError ())
28- _call (:: Tuple{} , arg, fww:: FunctionWrappersWrapper{<:Any,true} ) = first (fww. fw). obj[](arg... )
35+ function _call (:: Tuple{} , arg, fww:: FunctionWrappersWrapper{<:Any, false} )
36+ throw (NoFunctionWrapperFoundError ())
37+ end
38+ function _call (:: Tuple{} , arg, fww:: FunctionWrappersWrapper{<:Any, true} )
39+ first (fww. fw). obj[](arg... )
40+ end
2941
30- function FunctionWrappersWrapper (f:: F , argtypes:: Tuple{Vararg{Any,K}} , rettypes:: Tuple{Vararg{DataType,K}} , fallback:: Val{FB} = Val {false} ()) where {F,K,FB}
31- fwt = map (argtypes, rettypes) do A, R
32- FunctionWrappers. FunctionWrapper {R,A} (f)
33- end
34- FunctionWrappersWrapper {typeof(fwt),FB} (fwt)
42+ function FunctionWrappersWrapper (
43+ f:: F , argtypes:: Tuple{Vararg{Any, K}} , rettypes:: Tuple{Vararg{DataType, K}} ,
44+ fallback:: Val{FB} = Val {false} ()) where {F, K, FB}
45+ fwt = map (argtypes, rettypes) do A, R
46+ FunctionWrappers. FunctionWrapper {R, A} (f)
47+ end
48+ FunctionWrappersWrapper {typeof(fwt), FB} (fwt)
3549end
3650
3751end
0 commit comments