• R/O
  • SSH

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2


Commit MetaInfo

Révision1fe9416066c5c173e52d00091e5e5bb77e701309 (tree)
l'heure2023-09-25 23:27:00
AuteurAlbert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Message de Log

RPY: added ProtocolDataStructures (test&code&template)

Change Summary

Modification

diff -r 253881064ed7 -r 1fe9416066c5 castle/writers/RPy/templates/EventIndexes.jinja2
--- a/castle/writers/RPy/templates/EventIndexes.jinja2 Sun Sep 24 00:48:56 2023 +0200
+++ b/castle/writers/RPy/templates/EventIndexes.jinja2 Mon Sep 25 16:27:00 2023 +0200
@@ -4,8 +4,8 @@
44 ##
55 ## EventIndexes (All {{events|length}} events of {{protocol.name}})
66 ##
7-{% block EventIndexes %}
8- {% for e in events %}
9- {{- m.EventIndexName(protocol.name, e.name) }} = {{e.indexNo}}
10- {% endfor %}
11-{% endblock %}
7+
8+{% for e in events %}
9+ {{- m.EventIndexName(protocol.name, e.name) }} = {{e.indexNo}}
10+{% endfor %}
11+
diff -r 253881064ed7 -r 1fe9416066c5 castle/writers/RPy/templates/ProtocolDataStructures.jinja2
--- a/castle/writers/RPy/templates/ProtocolDataStructures.jinja2 Sun Sep 24 00:48:56 2023 +0200
+++ b/castle/writers/RPy/templates/ProtocolDataStructures.jinja2 Mon Sep 25 16:27:00 2023 +0200
@@ -2,21 +2,21 @@
22
33 {% import "CastleMacros.jinja2" as m %}
44
5-{#GAM Note: do not put {% block ... inside the loop - does not work#}
6-{% block ProtocolDataStructures %}
7- {% for p in protocols %}
5+{#GAM Note: do not put {% block ... inside the loop - does not work#}
86
9-{{- m.ProtocolName(p.name) -}} = buildin.CC_B_Protocol(name="{{ p.name }}",
10- kind=buildin.{{p.kind}},
11- inherit_from=<ToDo>,
12- events = [])
13- {% for e in p.events %}
14-{{m.ProtocolName(p.name) }}.events.append(
15- buildin.CC_B_P_EventID(name="{{- e.name -}}",
16- seqNo={{- m.EventIndexName(p.name, e.name) }},
17- part_of={{ m.ProtocolName(p.name) }} ))
18- {% endfor %} {# event #}
19- {% endfor %} {# protocols #}
20-{% endblock %} {# ProtocolDataStructures #}
7+{% for p in protocols %}
8+ {{- m.ProtocolName(p.name) }} = buildin.CC_B_Protocol(name="{{ p.name }}",
9+ kind=buildin.{{p.kind}},
10+ inherit_from={{m.ProtocolName(p.based_on.name)}}
11+ events = []) {#- filled in below -- see design notes // limitation #}
12+
13+ {% for e in p.events %}
14+ {{- m.ProtocolName(p.name) }}.events.append(buildin.CC_B_P_EventID(name="{{- e.name -}}",
15+ seqNo={{- m.EventIndexName(p.name, e.name) }},
16+ part_of={{ m.ProtocolName(p.name) }} ))
17+ {% endfor %} {#- event #}
18+
19+{% endfor %} {# protocols #}
2120
2221
22+
diff -r 253881064ed7 -r 1fe9416066c5 castle/writers/RPy/templates/protocol.jinja2
--- a/castle/writers/RPy/templates/protocol.jinja2 Sun Sep 24 00:48:56 2023 +0200
+++ b/castle/writers/RPy/templates/protocol.jinja2 Mon Sep 25 16:27:00 2023 +0200
@@ -20,6 +20,10 @@
2020 #Put the Castle/generated imports here
2121 {% endblock %}
2222
23+{% block EventIndexes %}
2324 {% include 'EventIndexes.jinja2' %}
25+{% endblock %}
2426
27+{% block ProtocolDataStructures %}
2528 {% include 'ProtocolDataStructures.jinja2' %}
29+{% endblock %}
diff -r 253881064ed7 -r 1fe9416066c5 pytst/writers/RPy/test_2_ProtocolDataStructures.py
--- a/pytst/writers/RPy/test_2_ProtocolDataStructures.py Sun Sep 24 00:48:56 2023 +0200
+++ b/pytst/writers/RPy/test_2_ProtocolDataStructures.py Mon Sep 25 16:27:00 2023 +0200
@@ -11,14 +11,41 @@
1111 from . import T_Protocol
1212 from . import assert_marker
1313
14+protoData_PreFix = "cc_P_" #Keep in sync with implementation
15+
1416 @pytest.mark.skip("XXX ToDo:: The MockProtocol should go")
1517 def test_ToDo(): pass
1618
19+@pytest.fixture
20+def p_1e():
21+ "Protocol with 1 event"
22+ p = EventProtocol(name="P1", events=(MockEvent(name="e1", indexNo=101),))
23+ logger.debug("%s", p)
24+ return p
1725
18-def test_0(T_ProtocolDataStructures):
19- p1=EventProtocol(name="DEMO", events=(MockEvent(name="e1", indexNo=101), MockEvent(name="e2", indexNo=102)))
20- logger.debug(p1)
26+@pytest.fixture
27+def p_2e_1i(p_1e):
28+ "Protocol with 2 events, and 1 inherited; so 3 in total"
29+ p = EventProtocol(name="P2", events=(MockEvent(name="e2", indexNo=102), MockEvent(name="e3", indexNo=103)), based_on=p_1e)
30+ logger.debug("%s", p)
31+ return p
2132
22- out = T_ProtocolDataStructures.render(protocols=[p1])
23- logger.info("\n---------- out:: ------------------------\n%s\n--------------------------------", out)
24- assert False, out
33+##
34+## assert_marker(.. `need`) CALCULATION
35+## 1*p (protocol dataclasses assignment
36+## 2*e (each event: 1 [ <P-name>...append ] + 1 part_of=<P-name>
37+## The inherited events dont' count
38+
39+def test_0(T_ProtocolDataStructures, p_1e):
40+ out = T_ProtocolDataStructures.render(protocols=[p_1e])
41+ logger.debug("\n---------- out:: ------------------------\n%s\n--------------------------------", out)
42+
43+ assert_marker(protoData_PreFix + 'P1', out, 1+2*1)
44+
45+
46+def test_0n(T_ProtocolDataStructures, p_1e, p_2e_1i):
47+ out = T_ProtocolDataStructures.render(protocols=[p_1e, p_2e_1i])
48+ logger.debug("\n---------- out:: ------------------------\n%s\n--------------------------------", out)
49+
50+ assert_marker(protoData_PreFix + 'P2', out, 1+2*2)
51+