Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reapply formatter #86

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
style = "sciml"
format_markdown = true
format_markdown = true
format_docstrings = true
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ makedocs(sitename = "RuntimeGeneratedFunctions.jl",
canonical = "https://docs.sciml.ai/RuntimeGeneratedFunctions/stable/"),
pages = [
"RuntimeGeneratedFunctions.jl: Efficient Staged Compilation" => "index.md",
"API" => "api.md",
"API" => "api.md"
])

deploydocs(;
Expand Down
83 changes: 42 additions & 41 deletions src/RuntimeGeneratedFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,27 @@

# For internal use in deserialize() - doesen't check whether the body is in the cache!
function RuntimeGeneratedFunction{
argnames,
cache_tag,
context_tag,
id,
argnames,
cache_tag,
context_tag,
id
}(body) where {
argnames,
cache_tag,
context_tag,
id,
argnames,
cache_tag,
context_tag,
id
}
new{argnames, cache_tag, context_tag, id, typeof(body)}(body)
end
end

function drop_expr(::RuntimeGeneratedFunction{
a,
cache_tag,
c,
id,
a,
cache_tag,
c,
id
}) where {a, cache_tag, c,
id}
id}
# When dropping the reference to the body from an RGF, we need to upgrade
# from a weak to a strong reference in the cache to prevent the body being
# GC'd.
Expand All @@ -111,7 +111,7 @@
end

function RuntimeGeneratedFunction(cache_module::Module, context_module::Module, code;
opaque_closures = true)
opaque_closures = true)
_check_rgf_initialized(cache_module, context_module)
RuntimeGeneratedFunction(getfield(cache_module, _tagname),
getfield(context_module, _tagname),
Expand All @@ -133,11 +133,11 @@
end

function Base.show(io::IO, ::MIME"text/plain",
f::RuntimeGeneratedFunction{argnames, cache_tag, context_tag, id}) where {
argnames,
cache_tag,
context_tag,
id,
f::RuntimeGeneratedFunction{argnames, cache_tag, context_tag, id}) where {
argnames,
cache_tag,
context_tag,
id
}
cache_mod = parentmodule(cache_tag)
context_mod = parentmodule(context_tag)
Expand Down Expand Up @@ -250,16 +250,17 @@
# or so. See:
# https://github.com/JuliaLang/julia/pull/32902
# https://github.com/NHDaly/StagedFunctions.jl/blob/master/src/StagedFunctions.jl#L30
@inline @generated function $RuntimeGeneratedFunctions.generated_callfunc(f::$RuntimeGeneratedFunctions.RuntimeGeneratedFunction{
@inline @generated function $RuntimeGeneratedFunctions.generated_callfunc(

Check warning on line 253 in src/RuntimeGeneratedFunctions.jl

View check run for this annotation

Codecov / codecov/patch

src/RuntimeGeneratedFunctions.jl#L253

Added line #L253 was not covered by tests
f::$RuntimeGeneratedFunctions.RuntimeGeneratedFunction{
argnames,
cache_tag,
$_tagname,
id
},
__args...) where {
argnames,
cache_tag,
$_tagname,
id,
},
__args...) where {
argnames,
cache_tag,
id,
id
}
$RuntimeGeneratedFunctions.generated_callfunc_body(argnames,
cache_tag,
Expand Down Expand Up @@ -334,13 +335,13 @@
# the body on a remote node when using Serialization.jl (in Distributed.jl
# and elsewhere)
function Serialization.serialize(s::AbstractSerializer,
rgf::RuntimeGeneratedFunction{argnames, cache_tag,
context_tag, id, B}) where {
argnames,
cache_tag,
context_tag,
id,
B,
rgf::RuntimeGeneratedFunction{argnames, cache_tag,
context_tag, id, B}) where {
argnames,
cache_tag,
context_tag,
id,
B
}
body = _lookup_body(cache_tag, id)
Serialization.serialize_type(s,
Expand All @@ -350,14 +351,14 @@
end

function Serialization.deserialize(s::AbstractSerializer,
::Type{
<:RuntimeGeneratedFunction{argnames, cache_tag,
::Type{
<:RuntimeGeneratedFunction{argnames, cache_tag,
context_tag, id, B}}) where {
argnames,
cache_tag,
context_tag,
id,
B,
argnames,
cache_tag,
context_tag,
id,
B
}
body = deserialize(s)
cached_body = _cache_body(cache_tag, id, body)
Expand Down
1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ using RuntimeGeneratedFunctions
f = @RuntimeGeneratedFunction(:(x -> x + y))
end)


ex = :(x -> (y -> x + y))
@test @RuntimeGeneratedFunction(ex)(2)(3) === 5

Expand Down
Loading