Skip to content

Commit

Permalink
Add fundamental types to model + docs
Browse files Browse the repository at this point in the history
Signed-off-by: Gunnar Andersson <gunnar_dev@[email protected]>
  • Loading branch information
Gunnar Andersson authored and gunnar-mb committed Jun 18, 2024
1 parent 07faaf9 commit 1b110af
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/generate_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- name: Join docs into one specification
run: |
git status
docs/generate-types-doc.py >docs/generated-types.md
markup docs/def-specification.stage1.m.md >docs/generated-specification.stage1.md
docs/create-toc.py < docs/generated-specification.stage1.md >docs/generated-toc.md
markup docs/def-specification.stage2.m.md >docs/ifex-specification.md
Expand Down
2 changes: 1 addition & 1 deletion docs/create-toc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/env python

import sys, os, re

Expand Down
8 changes: 7 additions & 1 deletion docs/def-specification.stage1.m.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
!INCLUDE "static-general-description.md"

<!-- Types, constraints/ranges, type resolution in namespaces. -->
!INCLUDE "static-types.md"
----

# FUNDAMENTAL TYPES

These are the supported fundamental (primitive) types, as generated from the source code model. These primitive types are identical to the types used in the VSS (Vehicle Signal Specification) model, and of course they should easily match typical datatypes in other interface description systems.

!INCLUDE "generated-types.md"

<!-- Layers concept, IFEX File Syntax, semantics and structure -->
!INCLUDE "static-files-and-layers.md"
Expand Down
11 changes: 11 additions & 0 deletions docs/generate-types-doc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python

# SPDX-FileCopyrightText: Copyright (c) 2023 Novaspring AB
# SPDX-License-Identifier: MPL-2.0

from ifex.model.ifex_ast import FundamentalTypes

print("|Name|Description|Min value|Max value|")
print("|----|-----------|---------|---------|")
for line in [f"|{t[0]} | {t[1]} | {t[2]} | {t[3]}|" for t in FundamentalTypes.ptypes]:
print(line)
26 changes: 26 additions & 0 deletions ifex/model/ifex_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,3 +644,29 @@ class AST():
minor_version: Optional[int] = None # ------ " ------
includes: Optional[List[Include]] = field(default_factory=EmptyList)
namespaces: Optional[List[Namespace]] = field(default_factory=EmptyList)

class FundamentalTypes:
# Fundamental types are the same as for VSS (Vehicle Signal Specification)
# This table copied from VSS documentation:
ptypes = [
# name, description, min value, max value
["uint8", "unsigned 8-bit integer", 0, 255],
["int8", "signed 8-bit integer", -128, 127],
["uint16", "unsigned 16-bit integer", 0, 65535],
["int16", "signed 16-bit integer", -32768, 32767],
["uint32", "unsigned 32-bit integer", 0, 4294967295],
["int32", "signed 32-bit integer", -2147483648, 2147483647],
["uint64", "unsigned 64-bit integer", 0, "2^64 - 1"],
["int64", "signed 64-bit integer", "-2^63", "2^63 - 1"],
["boolean", "boolean value", False, True],
["float", "floating point number", "-3.4e -38", "3.4e 38"],
["double", "double precision floating point number", "-1.7e -300", "1.7e 300"],
["string", "character string", "N/A","N/A"]
]

ctypes = [
# name, description, min value, max value
["set", "A set of fundamental unsigned 8-bit integer", "N/A", "N/A"],
["map", "A key-value mapping type", "N/A", "N/A"],
["opaque", "Indicates a complex type which is not explicitly defined in this context.", "N/A","N/A"]
]

0 comments on commit 1b110af

Please sign in to comment.