Skip to content

Commit 7b82136

Browse files
committed
Use globalref for component type
1 parent b32de83 commit 7b82136

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/systems/abstractsystem.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
const SYSTEM_COUNT = Threads.Atomic{UInt}(0)
22

3+
get_component_type(x::AbstractSystem) = get_gui_metadata(x).type
34
struct GUIMetadata
4-
type::Symbol
5+
type::GlobalRef
56
layout::Any
67
end
78

@@ -1137,7 +1138,7 @@ function component_post_processing(expr, isconnector)
11371138
if $isconnector
11381139
$Setfield.@set!(res.connector_type=$connector_type(res))
11391140
end
1140-
$Setfield.@set!(res.gui_metadata=$GUIMetadata(name))
1141+
$Setfield.@set!(res.gui_metadata=$GUIMetadata($GlobalRef(@__MODULE__, name)))
11411142
else
11421143
res
11431144
end

test/components.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Test
22
using ModelingToolkit, OrdinaryDiffEq
3-
using ModelingToolkit: get_gui_metadata
3+
using ModelingToolkit: get_component_type
44
using ModelingToolkit.BipartiteGraphs
55
using ModelingToolkit.StructuralTransformations
66
include("../examples/rc_model.jl")
@@ -35,8 +35,8 @@ function check_rc_sol(sol)
3535
end
3636

3737
@named pin = Pin()
38-
@test get_gui_metadata(pin).type == :Pin
39-
@test get_gui_metadata(rc_model.resistor).type == :Resistor
38+
@test get_component_type(pin).name == :Pin
39+
@test get_component_type(rc_model.resistor).name == :Resistor
4040

4141
completed_rc_model = complete(rc_model)
4242
@test isequal(completed_rc_model.resistor.n.i, resistor.n.i)

0 commit comments

Comments
 (0)