@@ -5,24 +5,16 @@ 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- function (fww:: FunctionWrappersWrapper{FW, FB} )(args:: Vararg{Any, K} ) where {FW, K, FB}
15- _call (fww. fw, args, fww)
16- end
14+ (fww:: FunctionWrappersWrapper{FW,FB} )(args:: Vararg{Any,K} ) where {FW,K,FB} = _call (fww. fw, args, fww)
1715
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
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)
2618
2719const NO_FUNCTIONWRAPPER_FOUND_MESSAGE = " No matching function wrapper was found!"
2820
@@ -32,20 +24,14 @@ function Base.showerror(io::IO, e::NoFunctionWrapperFoundError)
3224 print (io, NO_FUNCTIONWRAPPER_FOUND_MESSAGE)
3325end
3426
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
27+ _call (:: Tuple{} , arg, fww:: FunctionWrappersWrapper{<:Any,false} ) = throw (NoFunctionWrapperFoundError ())
28+ _call (:: Tuple{} , arg, fww:: FunctionWrappersWrapper{<:Any,true} ) = first (fww. fw). obj[](arg... )
4129
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)
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)
4935end
5036
5137end
0 commit comments