Skip to content

Commit 521d58a

Browse files
chore: add setmetadata to exprs while returning
1 parent 3329f26 commit 521d58a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/systems/model_parsing.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ function _model_macro(mod, fullname::Union{Expr, Symbol}, expr, isconnector)
128128

129129
consolidate = get(dict, :consolidate, default_consolidate)
130130
description = get(dict, :description, "")
131+
model_meta = get(dict, :metadata, Dict{Symbol, Any}())
131132

132133
@inline pop_structure_dict!.(
133134
Ref(dict), [:defaults, :kwargs, :structural_parameters])
@@ -146,6 +147,14 @@ function _model_macro(mod, fullname::Union{Expr, Symbol}, expr, isconnector)
146147
isconnector && push!(exprs.args,
147148
:($Setfield.@set!(var"#___sys___".connector_type=$connector_type(var"#___sys___"))))
148149

150+
meta_exprs = quote
151+
for (k, v) in $model_meta
152+
var"#___sys___" = setmetadata(var"#___sys___", $get_var($mod, k), v)
153+
end
154+
end
155+
push!(exprs.args, meta_exprs)
156+
push!(exprs.args, :(var"#___sys___"))
157+
149158
f = if length(where_types) == 0
150159
:($(Symbol(:__, name, :__))(; name, $(kwargs...)) = $exprs)
151160
else

0 commit comments

Comments
 (0)