Skip to content

Commit f0b2633

Browse files
[ci-skip] Revert "Apply JuliaFormatter to fix code formatting"
This reverts commit 82e45fa. Reverting JuliaFormatter changes due to formatting issues being addressed in JuliaFormatter.jl PR#933.
1 parent f89b217 commit f0b2633

5 files changed

Lines changed: 37 additions & 53 deletions

File tree

.JuliaFormatter.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
[![Build Status](https://github.com/chriselrod/FunctionWrappersWrappers.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/chriselrod/FunctionWrappersWrappers.jl/actions/workflows/CI.yml?query=branch%3Amain)
44
[![Coverage](https://codecov.io/gh/chriselrod/FunctionWrappersWrappers.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/chriselrod/FunctionWrappersWrappers.jl)
55

6+
67
If wrapping your functions once makes them better, why not try wrapping them twice?
8+

docs/make.jl

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
using FunctionWrappersWrappers
22
using Documenter
33

4-
DocMeta.setdocmeta!(FunctionWrappersWrappers, :DocTestSetup,
5-
:(using FunctionWrappersWrappers); recursive = true)
4+
DocMeta.setdocmeta!(FunctionWrappersWrappers, :DocTestSetup, :(using FunctionWrappersWrappers); recursive=true)
65

76
makedocs(;
8-
modules = [FunctionWrappersWrappers],
9-
authors = "Chris Elrod <elrodc@gmail.com> and contributors",
10-
repo = "https://github.com/chriselrod/FunctionWrappersWrappers.jl/blob/{commit}{path}#{line}",
11-
sitename = "FunctionWrappersWrappers.jl",
12-
format = Documenter.HTML(;
13-
prettyurls = get(ENV, "CI", "false") == "true",
14-
canonical = "https://chriselrod.github.io/FunctionWrappersWrappers.jl",
15-
assets = String[]
7+
modules=[FunctionWrappersWrappers],
8+
authors="Chris Elrod <elrodc@gmail.com> and contributors",
9+
repo="https://github.com/chriselrod/FunctionWrappersWrappers.jl/blob/{commit}{path}#{line}",
10+
sitename="FunctionWrappersWrappers.jl",
11+
format=Documenter.HTML(;
12+
prettyurls=get(ENV, "CI", "false") == "true",
13+
canonical="https://chriselrod.github.io/FunctionWrappersWrappers.jl",
14+
assets=String[],
1615
),
17-
pages = [
18-
"Home" => "index.md"
19-
]
16+
pages=[
17+
"Home" => "index.md",
18+
],
2019
)
2120

2221
deploydocs(;
23-
repo = "github.com/chriselrod/FunctionWrappersWrappers.jl",
24-
devbranch = "main"
22+
repo="github.com/chriselrod/FunctionWrappersWrappers.jl",
23+
devbranch="main",
2524
)

src/FunctionWrappersWrappers.jl

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,16 @@ import TruncatedStacktraces
55

66
export FunctionWrappersWrapper
77

8-
struct FunctionWrappersWrapper{FW, FB}
9-
fw::FW
8+
struct FunctionWrappersWrapper{FW,FB}
9+
fw::FW
1010
end
1111

1212
TruncatedStacktraces.@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

2719
const 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)
3325
end
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)
4935
end
5036

5137
end

test/runtests.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ using FunctionWrappersWrappers
22
using Test
33

44
@testset "FunctionWrappersWrappers.jl" begin
5-
fwplus = FunctionWrappersWrapper(
6-
+, (Tuple{Float64, Float64}, Tuple{Int, Int}), (Float64, Int))
7-
@test fwplus(4.0, 8.0) === 12.0
8-
@test fwplus(4, 8) === 12
5+
6+
fwplus = FunctionWrappersWrapper(+, (Tuple{Float64,Float64}, Tuple{Int,Int}), (Float64,Int));
7+
@test fwplus(4.0, 8.0) === 12.0
8+
@test fwplus(4, 8) === 12
9+
10+
fwexp2 = FunctionWrappersWrapper(exp2, (Tuple{Float64}, Tuple{Float32}, Tuple{Int}), (Float64,Float32,Float64));
11+
@test fwexp2(4.0) === 16.0
12+
@test fwexp2(4f0) === 16f0
13+
@test fwexp2(4) === 16.0
914

10-
fwexp2 = FunctionWrappersWrapper(
11-
exp2, (Tuple{Float64}, Tuple{Float32}, Tuple{Int}), (Float64, Float32, Float64))
12-
@test fwexp2(4.0) === 16.0
13-
@test fwexp2(4.0f0) === 16.0f0
14-
@test fwexp2(4) === 16.0
1515
end

0 commit comments

Comments
 (0)