@@ -55,7 +55,8 @@ function _model_macro(mod, fullname::Union{Expr, Symbol}, expr, isconnector)
5555 dict = Dict {Symbol, Any} (
5656 :defaults => Dict {Symbol, Any} (),
5757 :kwargs => Dict {Symbol, Dict} (),
58- :structural_parameters => Dict {Symbol, Dict} ()
58+ :structural_parameters => Dict {Symbol, Dict} (),
59+ :metadata => Dict {Symbol, Any} ()
5960 )
6061 comps = Union{Symbol, Expr}[]
6162 ext = []
@@ -678,6 +679,8 @@ function parse_model!(exprs, comps, ext, eqs, icon, vs, ps, sps, c_evts, d_evts,
678679 parse_costs! (costs, dict, body)
679680 elseif mname == Symbol (" @consolidate" )
680681 parse_consolidate! (body, dict)
682+ elseif mname == Symbol (" @metadata" )
683+ parse_metadata_block! (body, dict, mod)
681684 else
682685 error (" $mname is not handled." )
683686 end
@@ -1254,6 +1257,24 @@ function parse_description!(body, dict)
12541257 end
12551258end
12561259
1260+ function parse_metadata_block! (body, dict, mod)
1261+ Base. remove_linenums! (body)
1262+ for arg in body. args
1263+ MLStyle. @match arg begin
1264+ Expr (:(= ), a, b) => begin
1265+ @show esc (b)
1266+ # dict[:metadata][a] = get_var(mod, b)
1267+ dict[:metadata ][a] = Core. eval (mod, b)
1268+ end
1269+ Expr (:call , :(=> ), a, b) => begin
1270+ # dict[:metadata][a] = get_var(mod, b)
1271+ dict[:metadata ][a] = Core. eval (mod, b)
1272+ end
1273+ _ => error (" Invalid metadata entry: $arg . Expected key = value or key => value format." )
1274+ end
1275+ end
1276+ end
1277+
12571278# ## Parsing Components:
12581279
12591280function component_args! (a, b, varexpr, kwargs; index_name = nothing )
0 commit comments