@@ -55,7 +55,8 @@ function _model_macro(mod, fullname::Union{Expr, Symbol}, expr, isconnector)
55
55
dict = Dict {Symbol, Any} (
56
56
:defaults => Dict {Symbol, Any} (),
57
57
:kwargs => Dict {Symbol, Dict} (),
58
- :structural_parameters => Dict {Symbol, Dict} ()
58
+ :structural_parameters => Dict {Symbol, Dict} (),
59
+ :metadata => Dict {Symbol, Any} ()
59
60
)
60
61
comps = Union{Symbol, Expr}[]
61
62
ext = []
@@ -678,6 +679,8 @@ function parse_model!(exprs, comps, ext, eqs, icon, vs, ps, sps, c_evts, d_evts,
678
679
parse_costs! (costs, dict, body)
679
680
elseif mname == Symbol (" @consolidate" )
680
681
parse_consolidate! (body, dict)
682
+ elseif mname == Symbol (" @metadata" )
683
+ parse_metadata_block! (body, dict, mod)
681
684
else
682
685
error (" $mname is not handled." )
683
686
end
@@ -1254,6 +1257,24 @@ function parse_description!(body, dict)
1254
1257
end
1255
1258
end
1256
1259
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
+
1257
1278
# ## Parsing Components:
1258
1279
1259
1280
function component_args! (a, b, varexpr, kwargs; index_name = nothing )
0 commit comments