Skip to content

Commit 734a901

Browse files
Extend cpp model with node type and small int types (#58)
1 parent 84c3107 commit 734a901

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

NOTICE-3RD-PARTY-CONTENT.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,21 @@
66
|anytree|2.12.1|Apache 2.0|
77
|cfgv|3.4.0|MIT|
88
|deprecation|2.1.0|Apache 2.0|
9-
|distlib|0.3.8|Python Software Foundation License|
10-
|filelock|3.14.0|The Unlicense (Unlicense)|
11-
|graphql-core|3.2.3|MIT|
12-
|identify|2.5.36|MIT|
13-
|mypy|1.10.0|MIT|
9+
|distlib|0.3.9|Python Software Foundation License|
10+
|filelock|3.16.1|The Unlicense (Unlicense)|
11+
|graphql-core|3.2.5|MIT|
12+
|identify|2.6.2|MIT|
13+
|mypy|1.13.0|MIT|
1414
|mypy-extensions|1.0.0|MIT|
15-
|nodeenv|1.8.0|BSD|
16-
|packaging|24.0|Apache 2.0<br/>BSD|
17-
|platformdirs|4.2.2|MIT|
18-
|pre-commit|3.7.1|MIT|
19-
|PyYAML|6.0.1|MIT|
20-
|setuptools|58.1.0|MIT|
15+
|nodeenv|1.9.1|BSD|
16+
|packaging|24.2|Apache 2.0<br/>BSD|
17+
|platformdirs|4.3.6|MIT|
18+
|pre-commit|4.0.1|MIT|
19+
|PyYAML|6.0.2|MIT|
2120
|six|1.16.0|MIT|
22-
|tomli|2.0.1|MIT|
23-
|typing-extensions|4.11.0|Python Software Foundation License|
24-
|virtualenv|20.26.2|MIT|
21+
|tomli|2.1.0|MIT|
22+
|typing-extensions|4.12.2|Python Software Foundation License|
23+
|virtualenv|20.27.1|MIT|
2524
|vss-tools|4.0|Mozilla Public License 2.0|
2625
## Workflows
2726
| Dependency | Version | License |

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ This generator creates a vehicle model from the given vspec specification for th
1010
* Python 3
1111
* C++
1212

13+
**HINT**: C++ model generated by model generator versions >= 0.8.0 require C++ SDK versions >= 0.5.5 !
14+
1315
## Supported VSS versions
14-
* 3.0
15-
* 3.1
16-
* 3.1.1
17-
* 4.0
16+
* 3.x
17+
* 4.x
1818

1919
## Usage
2020

src/velocitas/model_generator/cpp/cpp_generator.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def __gen_model_docstring(self, node: VSSNode):
172172
def __document_member(self, node: VSSNode):
173173
self.ctx_header.write("/**\n")
174174
if node.type.value == "attribute":
175+
assert node.datatype is not None
175176
self.ctx_header.write(
176177
f"* {node.name}: {node.type.value} ({node.datatype.value})\n"
177178
)
@@ -378,7 +379,10 @@ def __gen_model(self, node: VSSNode, namespace_list: List[str], is_root=False):
378379
header_public.write(
379380
f"velocitas::DataPoint{data_type} {child.name};\n\n"
380381
)
381-
member += ",\n\t\t" + f'{child.name}("{child.name}", this)'
382+
member += (
383+
",\n\t\t"
384+
+ f'{child.name}("{child.name}", Type::{child.type.value.upper()}, this)'
385+
)
382386

383387
if child.type == VSSType.BRANCH:
384388
if child.instances:
@@ -410,6 +414,7 @@ def __gen_model(self, node: VSSNode, namespace_list: List[str], is_root=False):
410414
self.ctx_header.reset()
411415

412416
def __gen_instances(self, node: VSSNode) -> list[tuple[str, list]]:
417+
assert node.instances is not None
413418
instances = node.instances
414419

415420
reg_ex = r"\w+\[\d+,(\d+)\]"
@@ -448,8 +453,6 @@ def __parse_instances(self, reg_ex, i) -> tuple[str, list]:
448453
raise ValueError("", "", f"is of type {type(i)} which is unsupported")
449454

450455
def __get_data_type(self, data_type: str) -> str:
451-
# there are no 8bit or 16bit types in grpc...
452-
data_type = data_type.replace("8", "32").replace("16", "32")
453456
if data_type[-1] == "]":
454457
return data_type[0].upper() + data_type[1:-2] + "Array"
455458
return data_type[0].upper() + data_type[1:]

src/velocitas/model_generator/python/vss_collection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def __init__(self, node: VSSNode):
5858

5959
def __gen_collection(self, node: VSSNode):
6060
print(f"- {self.name:30}{node.instances}")
61+
assert node.instances is not None
6162
self.ctx.write(self.ctx.line_break)
6263
self.ctx.write(f"class {self.name}(Model):\n")
6364
with self.ctx as def_ctx:

0 commit comments

Comments
 (0)