Skip to content

Commit 6a2a045

Browse files
authored
Merge pull request #98 from AlgebraicJulia/export-generic-acset
Export generic acset name from InterType module
2 parents 85cf61d + da324ba commit 6a2a045

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

src/intertypes/InterTypes.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ end
8282
NamedACSetType(typespec::ACSetTypeSpec)
8383
end
8484

85+
exports(::InterTypeDecl) = Symbol[]
86+
87+
function exports(acset_type::NamedACSetType)
88+
if !isnothing(acset_type.typespec.genericname)
89+
[acset_type.typespec.genericname]
90+
else
91+
[]
92+
end
93+
end
94+
8595
function hashdecls end
8696

8797
struct InterTypeModule
@@ -98,6 +108,15 @@ struct InterTypeModule
98108
end
99109
end
100110

111+
function exports(mod::InterTypeModule)
112+
export_list = Symbol[]
113+
for (name, decl) in pairs(mod.declarations)
114+
push!(export_list, name)
115+
append!(export_list, exports(decl))
116+
end
117+
export_list
118+
end
119+
101120
function intertype end
102121

103122
abstract type ExportTarget end

src/intertypes/julia.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ function include_intertypes(into::Module, file::String, imports::AbstractVector)
313313
into.include(as_intertypes(mod), file)
314314
# recompute the hash
315315
mod = InterTypeModule(name, mod.imports, mod.declarations)
316-
into.eval(Expr(:export, keys(mod.declarations)...))
316+
into.eval(Expr(:export, exports(mod)...))
317317
mod
318318
end
319319

test/intertypes/InterTypes.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ g = EDWeightedGraph()
6969
add_parts!(g, :V, 2)
7070
add_part!(g, :E, src=1, tgt=2, weight=EdgeData(:mass_ave, 42))
7171

72-
@test testjson(m)
72+
@test testjson(g)
73+
74+
sg = WeightedGraph{Symbol}()
75+
76+
add_parts!(sg, :V, 2)
77+
add_part!(sg, :E, src=1, tgt=2, weight=:mass_ave)
78+
79+
@test testjson(sg)
7380

7481
generate_module(wgraph, JSONTarget)
7582

0 commit comments

Comments
 (0)