Skip to content

Commit

Permalink
Merge pull request #86 from ArnoStrouwen/formatter
Browse files Browse the repository at this point in the history
reapply formatter
  • Loading branch information
ChrisRackauckas authored Feb 22, 2024
2 parents 33271f4 + cf2b432 commit fef902d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 44 deletions.
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 @@ struct RuntimeGeneratedFunction{argnames, cache_tag, context_tag, id, B} <: Func

# 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 @@ function _check_rgf_initialized(mods...)
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 @@ macro RuntimeGeneratedFunction(context_module, code, opaque_closures = true)
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 @@ function init(mod)
# 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(
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 @@ end
# 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 @@ function Serialization.serialize(s::AbstractSerializer,
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

0 comments on commit fef902d

Please sign in to comment.