diff --git a/.github/workflows/generate_docs.yml b/.github/workflows/generate_docs.yml index 38ea696..f98caf4 100644 --- a/.github/workflows/generate_docs.yml +++ b/.github/workflows/generate_docs.yml @@ -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 diff --git a/docs/create-toc.py b/docs/create-toc.py index 638581b..af7d216 100755 --- a/docs/create-toc.py +++ b/docs/create-toc.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python import sys, os, re diff --git a/docs/def-specification.stage1.m.md b/docs/def-specification.stage1.m.md index ad781c0..c19e27c 100644 --- a/docs/def-specification.stage1.m.md +++ b/docs/def-specification.stage1.m.md @@ -2,7 +2,13 @@ !INCLUDE "static-general-description.md" -!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" !INCLUDE "static-files-and-layers.md" diff --git a/docs/generate-types-doc.py b/docs/generate-types-doc.py new file mode 100755 index 0000000..b5938bd --- /dev/null +++ b/docs/generate-types-doc.py @@ -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) diff --git a/ifex/model/ifex_ast.py b/ifex/model/ifex_ast.py index 1582291..a6d8a31 100644 --- a/ifex/model/ifex_ast.py +++ b/ifex/model/ifex_ast.py @@ -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"] + ]