-
Notifications
You must be signed in to change notification settings - Fork 100
/
zproto_dot.gsl
98 lines (78 loc) · 3.01 KB
/
zproto_dot.gsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
.template 0
# Generate dot diagram from a protocol specification
#
# This is a code generator built using the iMatix GSL code generation
# language. See https://github.com/imatix/gsl for details.
#
# Copyright (c) the Contributors as noted in the AUTHORS file.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
function generate_event (event, inherited)
label = "<<table border=\"0\" cellborder=\"0\" cellpadding=\"3\" bgcolor=\"white\"><tr><td bgcolor=\"black\" align=\"center\" colspan=\"2\"><font color=\"white\">$(event.name)</font></td></tr>"
for event.action as action
label = label + "<tr><td align=\"left\" port=\"r3\">$(action.name)$(defined(action.message) ?? " (" + action.message + ")")</td></tr>"
endfor
label = label + "</table>>"
if my.inherited = 1
style = "dashed"
else
style = "solid"
endif
> "$(state.name) $(event.name)" [shape = "Mrecord" style = $(style:) label = $(label)];
> "$(state.name)" -> "$(state.name) $(event.name)";
if defined (event.next)
> "$(state.name) $(event.name)" -> "$(event.next)";
else
> "$(state.name) $(event.name)" -> "$(state.name)";
endif
endfunction
function generate_dot
output "$(class.name).dot"
>## Automatically generated from $(class.name).xml by gsl
>digraph "$(class.name)" {
# Mark super-states (those, which are inherited by some other state)
for class.state as state where defined (inherit)
> "$(state.name)" -> "$(state.inherit)" [style=dotted,arrowhead=empty]
endfor
for class.state
>
> "$(name)" [shape = "doublecircle"];
for event
generate_event (event, 0)
endfor
endfor
>}
endfunction
function generate_dot_old
output "$(class.name)_old.dot"
>## Automatically generated from $(class.name).xml by gsl
>digraph "$(class.name)" {
# Mark super-states (those, which are inherited by some other state)
for class.state where defined (inherit)
for class.state as superstate where name = state.inherit
superstate.superstate = 1
endfor
endfor
# GO through all classes except superstates, which does not have
# an entry point and are merged with their descendants
for class.state where ! defined (superstate)
>
> "$(name)" [shape = "doublecircle"];
if defined (inherit)
for class.state as superstate where name = state.inherit
for event where count (state.event, name = -1.name) = 0
generate_event (event, 1)
endfor
else
echo "E: superstate $(inherit) isn't defined"
endfor
endif
for event
generate_event (event, 0)
endfor
endfor
>}
endfunction
.endtemplate