• R/O
  • SSH

Commit

Tags
No Tags

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

Revisão8e783da5dab406b5190f8be2618d001491965a13 (tree)
Hora2023-02-13 07:23:54
AutorAlbert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Mensagem de Log

(asis) fstring is gone; it just a str(ing)

Mudança Sumário

Diff

diff -r 42ac70b0a6b1 -r 8e783da5dab4 Makefile
--- a/Makefile Sun Feb 12 23:09:01 2023 +0100
+++ b/Makefile Sun Feb 12 23:23:54 2023 +0100
@@ -92,6 +92,9 @@
9292 XXX:
9393 grep XXX `find . -type f -name \*.py`
9494
95+WC:
96+ wc -l `find . -type f -name \*.py`
97+
9598
9699 PYREVERSE_DIR=pyreversed/
97100 PYREVERSE_FORMAT=svg
diff -r 42ac70b0a6b1 -r 8e783da5dab4 castle/writers/CC2Cpy/CCbase.py
--- a/castle/writers/CC2Cpy/CCbase.py Sun Feb 12 23:09:01 2023 +0100
+++ b/castle/writers/CC2Cpy/CCbase.py Sun Feb 12 23:23:54 2023 +0100
@@ -1,16 +1,77 @@
11 # (C) Albert Mietus, 2022, 2023. Part of Castle/CCastle project
22
3+
34 from typing import TypeAlias, ClassVar, Optional
45 from dataclasses import dataclass, field as dc_field, KW_ONLY
56 from collections.abc import Sequence # Use for typing
67
8+from castle.auxiliary.abcd import ABCD
79
8-fstring: TypeAlias=str # a Fix (sized) string. May be inplemented as a C-string, a Pascal-string, or ...
10+from enum import Enum
11+
912
1013 class CC_Base: pass
1114
1215 @dataclass
1316 class CC_TypedParameter(CC_Base):
1417 """This is many a helper class/struct to combine a parameter: a name and an type"""
15- name: fstring
18+ name: str
1619 type: type
20+
21+class CC_PortDirection(Enum):
22+ CC_B_PortDirectionIs_UNKNOWN = Unknown = 0
23+ CC_B_PortDirectionIs_in = In = 1
24+ CC_B_PortDirectionIs_out = Out = 2
25+ CC_B_PortDirectionIs_bidirect = BiDir = 3 # Not supported yet
26+ CC_B_PortDirectionIs_master = Master = 4 # Not supported yet
27+ CC_B_PortDirectionIs_slave = Slave = 5 # Not supported yet
28+
29+ def portray_name(self): ### CC_B_PortDirectionIs_{self.name}'
30+ return f'{self.name}'
31+
32+@dataclass
33+class CC_Port(CC_Base):
34+ name: str
35+ _ : KW_ONLY
36+ direction: CC_PortDirection = CC_PortDirection.Unknown
37+ type: type
38+
39+ def portray_name(self) ->str: ### <port name>
40+ return f'{self.name}'
41+
42+ def portray_typePtr(self) ->str: ### <port type> e.g a protocol
43+ if isinstance(self.type, CC_Base):
44+ return f'&{self.type.portray_name()}'
45+ elif self.type is None:
46+ return "NULL"
47+ else:
48+ from warnings import warn
49+ tn = self.type if isinstance(self.type, str) else self.type.__name__
50+ warn(f"Using string (or other non CC_Base types) port.types (for >>{tn}<<) is not wise", DeprecationWarning, stacklevel=2)
51+ return f'&cc_P_{tn}'
52+
53+
54+
55+@dataclass
56+class CC_Function(ABCD, CC_Base): # ABC
57+ name: str
58+ _ : KW_ONLY
59+ type: type # the return type of the callable
60+ body=None; # XXX Add the (AST of the) body LATER
61+
62+
63+@dataclass
64+class CC_Handler(CC_Function): # ABC Can be an event of data/stream -- with or without paramters
65+ _ : KW_ONLY
66+ portID: CC_Port
67+
68+@dataclass
69+class CC_EventHandler(CC_Handler):
70+ _ : KW_ONLY
71+ parameterTuple: "ToBeDone"
72+
73+@dataclass
74+class CC_Method(CC_Function): pass
75+class CC_ClassMethod(CC_Method): pass
76+class CC_ElementMethod(CC_Method): pass #Or CC InstanceMethod??
77+
diff -r 42ac70b0a6b1 -r 8e783da5dab4 castle/writers/CC2Cpy/Component.py
--- a/castle/writers/CC2Cpy/Component.py Sun Feb 12 23:09:01 2023 +0100
+++ b/castle/writers/CC2Cpy/Component.py Sun Feb 12 23:23:54 2023 +0100
@@ -2,46 +2,12 @@
22
33 __all__ = ['CC_B_ComponentInterface', 'CC_Port', 'CC_PortDirection', 'CC_B_ComponentClass']
44
5-from enum import Enum
65
76 from .CCbase import *
87 from castle.auxiliary.pack import mk_tuple
9-from castle.auxiliary.abcd import ABCD
108
119 CC_Component: TypeAlias = 'CC_Component' # Forward ref # pragma: no mutate
1210
13-class CC_PortDirection(Enum):
14- CC_B_PortDirectionIs_UNKNOWN = Unknown = 0
15- CC_B_PortDirectionIs_in = In = 1
16- CC_B_PortDirectionIs_out = Out = 2
17- CC_B_PortDirectionIs_bidirect = BiDir = 3 # Not supported yet
18- CC_B_PortDirectionIs_master = Master = 4 # Not supported yet
19- CC_B_PortDirectionIs_slave = Slave = 5 # Not supported yet
20-
21- def portray_name(self): ### CC_B_PortDirectionIs_{self.name}'
22- return f'{self.name}'
23-
24-@dataclass
25-class CC_Port(CC_Base):
26- name: str
27- _ : KW_ONLY
28- direction: CC_PortDirection = CC_PortDirection.Unknown
29- type: type
30-
31- def portray_name(self) ->str: ### <port name>
32- return f'{self.name}'
33-
34- def portray_typePtr(self) ->str: ### <port type> e.g a protocol
35- if isinstance(self.type, CC_Base):
36- return f'&{self.type.portray_name()}'
37- elif self.type is None:
38- return "NULL"
39- else:
40- from warnings import warn
41- tn = self.type if isinstance(self.type, str) else self.type.__name__
42- warn(f"Using string (or other non CC_Base types) port.types (for >>{tn}<<) is not wise", DeprecationWarning, stacklevel=2)
43- return f'&cc_P_{tn}'
44-
4511
4612 @dataclass
4713 class CC_B_ComponentInterface(CC_Base):
@@ -95,31 +61,6 @@
9561
9662
9763
98-
99-@dataclass
100-class CC_Function(ABCD, CC_Base): # ABC
101- name: str
102- _ : KW_ONLY
103- type: type # the return type of the callable
104- body=None; # XXX Add the (AST of the) body LATER
105-
106-
107-@dataclass
108-class CC_Handler(CC_Function): # ABC Can be an event of data/stream -- with or without paramters
109- _ : KW_ONLY
110- portID: CC_Port
111-
112-@dataclass
113-class CC_EventHandler(CC_Handler):
114- _ : KW_ONLY
115- parameterTuple: "ToBeDone"
116-
117-@dataclass
118-class CC_Method(CC_Function): pass
119-class CC_ClassMethod(CC_Method): pass
120-class CC_ElementMethod(CC_Method): pass #Or CC InstanceMethod??
121-
122-
12364 @dataclass
12465 class CC_B_ComponentClass(CC_Base):
12566 metaclass="NULL" # //NULL for now, later: meta-class
diff -r 42ac70b0a6b1 -r 8e783da5dab4 castle/writers/CC2Cpy/Event.py
--- a/castle/writers/CC2Cpy/Event.py Sun Feb 12 23:09:01 2023 +0100
+++ b/castle/writers/CC2Cpy/Event.py Sun Feb 12 23:23:54 2023 +0100
@@ -10,7 +10,7 @@
1010
1111 It has a name, a return-type (can be void), and a sequence of typed parameters."""
1212
13- name: fstring
13+ name: str
1414 _: KW_ONLY # The field below must be passed as keywords, when initialising
1515 return_type: type=None
1616 typedParameters: Sequence[CC_TypedParameter]=() ## A tuple `()` is inmutable
diff -r 42ac70b0a6b1 -r 8e783da5dab4 castle/writers/CC2Cpy/Protocol.py
--- a/castle/writers/CC2Cpy/Protocol.py Sun Feb 12 23:09:01 2023 +0100
+++ b/castle/writers/CC2Cpy/Protocol.py Sun Feb 12 23:23:54 2023 +0100
@@ -34,7 +34,7 @@
3434 """
3535 _BASE: ClassVar=None # pragma: no mutate
3636
37- name: fstring
37+ name: str
3838 kind: CC_ProtocolKind
3939 based_on: Optional[CC_B_Protocol]=dc_field(default_factory= lambda :CC_B_Protocol._BASE)
4040
diff -r 42ac70b0a6b1 -r 8e783da5dab4 pytst/writers/CC2Cpy/test_0.py
--- a/pytst/writers/CC2Cpy/test_0.py Sun Feb 12 23:09:01 2023 +0100
+++ b/pytst/writers/CC2Cpy/test_0.py Sun Feb 12 23:23:54 2023 +0100
@@ -30,5 +30,3 @@
3030 """Test some trivial (type-hints) types; mostly by just using them"""
3131
3232 assert CC_TypedParameter('test', int).type is int
33- assert fstring is str
34- assert fstring("foo") == "foo"