Skip to content

Commit

Permalink
Merge pull request #98 from AlgebraicJulia/export-generic-acset
Browse files Browse the repository at this point in the history
Export generic acset name from InterType module
  • Loading branch information
olynch authored Jan 10, 2024
2 parents 85cf61d + da324ba commit 6a2a045
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/intertypes/InterTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ end
NamedACSetType(typespec::ACSetTypeSpec)
end

exports(::InterTypeDecl) = Symbol[]

function exports(acset_type::NamedACSetType)
if !isnothing(acset_type.typespec.genericname)
[acset_type.typespec.genericname]
else
[]
end
end

function hashdecls end

struct InterTypeModule
Expand All @@ -98,6 +108,15 @@ struct InterTypeModule
end
end

function exports(mod::InterTypeModule)
export_list = Symbol[]
for (name, decl) in pairs(mod.declarations)
push!(export_list, name)
append!(export_list, exports(decl))
end
export_list
end

function intertype end

abstract type ExportTarget end
Expand Down
2 changes: 1 addition & 1 deletion src/intertypes/julia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ function include_intertypes(into::Module, file::String, imports::AbstractVector)
into.include(as_intertypes(mod), file)
# recompute the hash
mod = InterTypeModule(name, mod.imports, mod.declarations)
into.eval(Expr(:export, keys(mod.declarations)...))
into.eval(Expr(:export, exports(mod)...))
mod
end

Expand Down
9 changes: 8 additions & 1 deletion test/intertypes/InterTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,14 @@ g = EDWeightedGraph()
add_parts!(g, :V, 2)
add_part!(g, :E, src=1, tgt=2, weight=EdgeData(:mass_ave, 42))

@test testjson(m)
@test testjson(g)

sg = WeightedGraph{Symbol}()

add_parts!(sg, :V, 2)
add_part!(sg, :E, src=1, tgt=2, weight=:mass_ave)

@test testjson(sg)

generate_module(wgraph, JSONTarget)

Expand Down

0 comments on commit 6a2a045

Please sign in to comment.