Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2
Revision | d9b4832da639a1d0560cec33fdf6a8476440d9da (tree) |
---|---|
Time | 2023-11-21 05:28:20 |
Author | Albert Mietus < albert AT mietus DOT nl > |
Commiter | Albert Mietus < albert AT mietus DOT nl > |
Is it a hack? Should it be in RenderNS (ToDo), or ... -- Found a solution to render Slowstart_1 correctly
@@ -6,8 +6,8 @@ | ||
6 | 6 | |
7 | 7 | ''NOTE: Old RTD/plantuml.1.2020.2.jar syntax! |
8 | 8 | |
9 | -'!procedure $comp($name) | |
10 | -!function $comp($name) | |
9 | +!procedure $comp($name) | |
10 | +''!function $comp($name) | |
11 | 11 | !$in = $name + "in" |
12 | 12 | !$out = $name + "out" |
13 | 13 |
@@ -17,8 +17,8 @@ | ||
17 | 17 | |
18 | 18 | $in )-- $name |
19 | 19 | $name --( $out |
20 | -'!endprocedure | |
21 | -!endfunction | |
20 | +!endprocedure | |
21 | +''!endfunction | |
22 | 22 | |
23 | 23 | |
24 | 24 | frame "CCastle Compiler" as CCC #c0c0c0 { |
@@ -1,32 +1,30 @@ | ||
1 | 1 | AIGR/SIEVE Namespace analyse |
2 | 2 | ============================ |
3 | 3 | |
4 | -.. UML:: | |
4 | +.. uml:: | |
5 | 5 | |
6 | 6 | @startuml |
7 | 7 | skin rose |
8 | - skinparam style strictuml | |
9 | - | |
8 | + 'skinparam style strictuml | |
10 | 9 | skinparam sequenceMessageAlign left |
11 | 10 | |
12 | - | |
13 | 11 | actor Dev |
14 | - | |
12 | + entity T_Protocol | |
13 | + boundary "CastleMacros.jinja2" as m | |
15 | 14 | |
16 | 15 | !procedure $register($ns, $n, $details=0) |
17 | 16 | Dev -> $ns : register($n) |
18 | - $ns o--\o $n : ""$ns._dict[$n]=$n"" | |
17 | + $ns o--\o $n : ""$ns._dict[$n] := $n"" | |
19 | 18 | activate $ns |
20 | 19 | |
21 | 20 | !if $details |
22 | 21 | group details |
23 | 22 | $ns -> $ns : _register_2ways() |
24 | 23 | $ns-> $n : register_in_NS() |
25 | - $n o--\o $ns :""$n._ns=$ns"" | |
26 | 24 | end |
25 | + $n o--\o $ns :""$n._ns := $ns"" | |
27 | 26 | !else |
28 | - $ns-> $n : register_in_NS() | |
29 | - $n o--\o $ns :""$n._ns=$ns"" | |
27 | + $n o--\o $ns :""$n._ns := $ns"" | |
30 | 28 | !endif |
31 | 29 | deactivate $ns |
32 | 30 | !endprocedure |
@@ -34,13 +32,73 @@ | ||
34 | 32 | |
35 | 33 | participant "simple_sieve :NS" as simple_sieve #LightSkyBlue |
36 | 34 | participant "slow_start :NS" as slow_start #LightSkyBlue |
35 | + participant "SimpleSieve:P" as SimpleSieve | |
37 | 36 | participant "SlowStart_1:P" as SlowStart_1 |
38 | - participant "SimpleSieve:P" as SimpleSieve | |
39 | 37 | participant "SlowStart:P" as SlowStart |
40 | 38 | |
39 | + == TestDoubles/AIGR/sieve/namespaces.py == | |
40 | + | |
41 | + $register(simple_sieve, slow_start,1) | |
42 | + alt "old AIGR" | |
43 | + $register(simple_sieve, SlowStart_1) | |
44 | + else "deleted 'simple_sieve.register(protocols.SlowStart_1)'" | |
45 | + note over simple_sieve, SlowStart1 #aqua: Is it a hack? Should it be in RenderNS (ToDo), or ... | |
46 | + end | |
47 | + $register(simple_sieve, SimpleSieve) | |
48 | + $register(slow_start, SlowStart) | |
49 | + | |
50 | + == pytst/writers/RPy/test_3_SieveProtocols.py== | |
51 | + | |
41 | 52 | |
53 | + [-> T_Protocol: render((sieve.SlowStart_1, sieve.SimpleSieve)) | |
54 | + note left: ""inherit_from={{proto.based_on.ns.name}}.{{m.ProtocolName(proto.based_on)}}"" | |
42 | 55 | |
43 | - $register(simple_sieve, slow_start,1) | |
44 | - $register(simple_sieve, SlowStart_1) | |
45 | - $register(simple_sieve, SimpleSieve) | |
56 | + ... sieve.SlowStart_1 ... | |
57 | + T_Protocol -> SlowStart_1: based_on() | |
58 | + SlowStart_1 o/--x SlowStart: "".based_on"" | |
59 | + T_Protocol <-- SlowStart_1: SlowStart | |
60 | + | |
61 | + T_Protocol -> SlowStart: ns() | |
62 | + T_Protocol <-- SlowStart: slow_start | |
63 | + | |
64 | + opt "obj 2 str" | |
65 | + T_Protocol -> slow_start :name | |
66 | + T_Protocol <-- slow_start : "slow_start" | |
67 | + end | |
68 | + | |
69 | + T_Protocol -> m: ProtocolName(SlowStart) | |
70 | + T_Protocol <--m: ""cc_P_Slowstart"" | |
71 | + note right: cc_P_{{Proto.name}} | |
72 | + note left of T_Protocol: inherit_from=slow_start.cc_P_SlowStart | |
73 | + | |
74 | + ... sieve.SimpleSieve ... | |
75 | + T_Protocol -> SimpleSieve: based_on() | |
76 | + SimpleSieve o/--x SlowStart_1: "".based_on"" | |
77 | + T_Protocol <-- SimpleSieve: SlowStart_1 | |
78 | + | |
79 | + T_Protocol -> SlowStart_1: ns() | |
80 | + alt "old AIGR" | |
81 | + T_Protocol <-- SlowStart_1: simple_sieve | |
82 | + note left: Note: ‘simple_sieve’ is (also) is the current namespace\n\tSo, it should be named | |
83 | + | |
84 | + opt "obj 2 str" | |
85 | + T_Protocol -> simple_sieve : name | |
86 | + T_Protocol <-- simple_sieve : "<color:red>simple_sieve</color>" | |
87 | + end | |
88 | + | |
89 | + T_Protocol -> m: ProtocolName(SimpleSieve) | |
90 | + T_Protocol <--m: ""cc_P_SimpleSieve"" | |
91 | + note right: cc_P_{{Proto.name}} | |
92 | + | |
93 | + note left of T_Protocol #orangered: <color:yellow>inherit_from=<color:white>simple_sieve.<color:yellow>cc_P_SimpleSieve | |
94 | + else "deteled 'simple_sieve.register(protocols.SlowStart_1)'" | |
95 | + T_Protocol <-- SlowStart_1: <NIL> | |
96 | + | |
97 | + T_Protocol -> m: ProtocolName(SimpleSieve) | |
98 | + T_Protocol <--m: ""cc_P_SimpleSieve"" | |
99 | + | |
100 | + note left of T_Protocol #lime: <color:white>inherit_from=cc_P_SimpleSieve</color> | |
101 | + end | |
102 | + | |
46 | 103 | @enduml |
104 | + |
@@ -14,7 +14,7 @@ | ||
14 | 14 | start_sieve.register(protocols.StartSieve) |
15 | 15 | slow_start.register(protocols.SlowStart) |
16 | 16 | simple_sieve.register(slow_start) # Import/use, to be able to refer slow_start.SlowStart |
17 | -simple_sieve.register(protocols.SlowStart_1) | |
17 | +#simple_sieve.register(protocols.SlowStart_1) | |
18 | 18 | simple_sieve.register(protocols.SimpleSieve) |
19 | 19 | |
20 | 20 |
@@ -8,8 +8,6 @@ | ||
8 | 8 | #Put the Castle/generated imports here |
9 | 9 | from CC import base |
10 | 10 | from CC import slow_start |
11 | -from CC import base #XXX# twice is not needed, but allowed | |
12 | -from CC import slow_start #XXX# twice is not needed, but allowed | |
13 | 11 | |
14 | 12 | |
15 | 13 |
@@ -3,7 +3,7 @@ | ||
3 | 3 | {# See:: http://docideas.mietus.nl/en/default/CCastle/3.Design/B.Workshop/rPY/8.RPY_Jinja.html #} |
4 | 4 | |
5 | 5 | |
6 | -{%macro ProtocolName(Proto) -%} cc_P_{{Proto.name}} {%- endmacro %} | |
6 | +{%macro ProtocolName(Proto) -%} cc_P_{{Proto.name}} {%- endmacro %} | |
7 | 7 | {%macro EventIndexName(Proto, Event) -%} CC_P_{{Proto.name}}_{{Event.name}} {%- endmacro %} |
8 | 8 | {%macro comp_interface_Name(Comp) -%} cc_CI_{{Comp.name}} {%- endmacro %} |
9 | 9 | {%macro comp_component_Name(Comp) -%} CC_{{Comp.name}} {%- endmacro %} |
@@ -13,6 +13,17 @@ | ||
13 | 13 | {%- endif -%} |
14 | 14 | {%- endmacro -%} |
15 | 15 | |
16 | + | |
17 | +{%- macro DotOrNot(opt_namespace, id) -%} | |
18 | + {%- if opt_namespace|length -%} | |
19 | + {{ opt_namespace }}.{{ id }} | |
20 | + {%- else -%} | |
21 | + {{ id }} | |
22 | + {%- endif -%} | |
23 | +{%- endmacro -%} | |
24 | + | |
25 | + | |
26 | + | |
16 | 27 | {%- for proto in protocols %} |
17 | 28 | ## |
18 | 29 | ## The protocol Data Definitions for {{proto.name}} -- with {{proto.events|length}} events |
@@ -28,7 +39,8 @@ | ||
28 | 39 | |
29 | 40 | {% endif %} |
30 | 41 | kind=buildin.{{proto.kind}}, |
31 | - inherit_from={{proto.based_on.ns.name}}.{{m.ProtocolName(proto.based_on)}}, #XXX# NSa & NSb | |
42 | + inherit_from= | |
43 | + {{- DotOrNot( proto.based_on.ns.name , m.ProtocolName(proto.based_on) ) -}}, #XXX# NSa & NSb | |
32 | 44 | {# |
33 | 45 | * NSa: Need cleanup |
34 | 46 | * NSb: (Prio) Inserts "own" NS, which is wrong |
@@ -4,6 +4,7 @@ | ||
4 | 4 | See file:///Users/albert/work/DocIdeas,hg/__result/html/CCastle/HACK/DocParts/Design/231016_NS.html |
5 | 5 | (not published yet -- see .../DocParts/Design/231016_NS.rst for source)""" |
6 | 6 | |
7 | +import logging; logger = logging.getLogger(__name__) | |
7 | 8 | import pytest |
8 | 9 | |
9 | 10 | import castle.aigr as aigr |
@@ -32,7 +33,8 @@ | ||
32 | 33 | |
33 | 34 | def test_simple_sieve_has_SimpleSieve_and_SpecialiseGeneric(): |
34 | 35 | ns = namespaces.simple_sieve |
35 | - verify_NS(ns, "simple_sieve", ["SlowStart_1", "SimpleSieve"]) | |
36 | + #verify_NS(ns, "simple_sieve", ["SlowStart_1", "SimpleSieve"]) | |
37 | + verify_NS(ns, "simple_sieve", ["SimpleSieve"]) | |
36 | 38 | |
37 | 39 | |
38 | 40 | def test_top(): |
@@ -9,8 +9,8 @@ | ||
9 | 9 | """ |
10 | 10 | |
11 | 11 | import logging; logger = logging.getLogger(__name__) |
12 | +import pytest | |
12 | 13 | |
13 | -import pytest | |
14 | 14 | from TestDoubles.AIGR import sieve |
15 | 15 | from . import TstDoubles, generatedProtocol_verifier |
16 | 16 | ##Note: T_* are used in **_verifier; but need to be in this scope (or pytest can't find it) |
@@ -24,7 +24,6 @@ | ||
24 | 24 | def test_02_SlowStart(generatedProtocol_verifier): |
25 | 25 | generatedProtocol_verifier(aigr_mocks=sieve.SlowStart, td=TstDoubles('protocols/slow_start'), strip_remarker=True) |
26 | 26 | |
27 | -@pytest.mark.xfail(reason="ToDo BUSY") | |
28 | 27 | def test_03_SimpleSieve_withGeneric(generatedProtocol_verifier): |
29 | 28 | """``SimpleSieve`` depend on the instantiated generic ``SlowStart_1``. |
30 | 29 | They are in the same namespace and (so) need to be rendered in the same file. |