diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 362667c..b4b5585 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -25,7 +25,7 @@ jobs: uses: actions/checkout@v4 with: repository: cogu/cfile - ref: v0.3.1 + ref: v0.3.2 path: cfile_0.3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 diff --git a/README.md b/README.md index 9b34dd9..12b6343 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ For currently supported XML elements, see the [CHANGELOG](CHANGELOG.md) file. * Python 3.10+ * lxml -* [cfile](https://github.com/cogu/cfile) v0.3.1+ +* [cfile](https://github.com/cogu/cfile) v0.3.2+ ## Installation @@ -73,7 +73,7 @@ python -m pip install --upgrade pip python -m pip install --upgrade setuptools git clone https://github.com/cogu/cfile.git cfile_0.3 cd cfile_0.3 -git checkout v0.3.1 +git checkout v0.3.2 cd .. python -m pip install cfile_0.3 ``` diff --git a/examples/generator/data_types/gen_type_defs_array.py b/examples/generator/data_types/gen_type_defs_array.py index 07897ac..bf66d8a 100644 --- a/examples/generator/data_types/gen_type_defs_array.py +++ b/examples/generator/data_types/gen_type_defs_array.py @@ -1,6 +1,6 @@ """ Example generation of RTE type header - Array type -Requires cfile v0.3.1 +Requires cfile v0.3.2 """ import autosar import autosar.xml.element as ar_element diff --git a/examples/generator/data_types/gen_type_defs_record.py b/examples/generator/data_types/gen_type_defs_record.py index 74376d4..491b46c 100644 --- a/examples/generator/data_types/gen_type_defs_record.py +++ b/examples/generator/data_types/gen_type_defs_record.py @@ -1,6 +1,6 @@ """ Example generation of RTE type header - Record type -Requires cfile v0.3.1 +Requires cfile v0.3.2 """ import autosar import autosar.xml.element as ar_element diff --git a/examples/generator/data_types/gen_type_defs_scalar.py b/examples/generator/data_types/gen_type_defs_scalar.py index be56971..29a5fc7 100644 --- a/examples/generator/data_types/gen_type_defs_scalar.py +++ b/examples/generator/data_types/gen_type_defs_scalar.py @@ -1,6 +1,6 @@ """ Example generation of RTE type header - Scalar type -Requires cfile v0.3.1 +Requires cfile v0.3.2 """ import autosar import autosar.xml.element as ar_element diff --git a/src/autosar/generator/type_generator.py b/src/autosar/generator/type_generator.py index 5e85ae3..8ecb9d0 100644 --- a/src/autosar/generator/type_generator.py +++ b/src/autosar/generator/type_generator.py @@ -1,6 +1,6 @@ """ RTE type generator -Requires cfile v0.3.1 +Requires cfile v0.3.2 """ import os from typing import Iterator @@ -104,11 +104,11 @@ def _gen_type_defs(self, data_types: Iterator[rte_element.Element]) -> cfile.cor code = C.sequence() for data_type in data_types: if isinstance(data_type, rte_element.BaseType): - code.append(C.statement(C.typedef(data_type.name, data_type.native_declaration))) + code.append(C.statement(C.declaration(C.typedef(data_type.name, data_type.native_declaration)))) elif isinstance(data_type, rte_element.ScalarType): - code.append(C.statement(C.typedef(data_type.name, data_type.base_type.name))) + code.append(C.statement(C.declaration(C.typedef(data_type.name, data_type.base_type.name)))) elif isinstance(data_type, rte_element.RefType): - code.append(C.statement(C.typedef(data_type.name, data_type.impl_type.name))) + code.append(C.statement(C.declaration(C.typedef(data_type.name, data_type.impl_type.name)))) elif isinstance(data_type, rte_element.ArrayType): code.append(self._gen_array_type_def(data_type)) elif isinstance(data_type, rte_element.RecordType): @@ -129,7 +129,7 @@ def _gen_array_type_def(self, data_type: rte_element.ArrayType) -> cfile.core.St target_type = C.type(last_element.data_type.impl_type.name) else: raise NotImplementedError(str(type(last_element.data_type))) - return C.statement(C.typedef(data_type.name, target_type, array=last_element.array_size)) + return C.statement(C.declaration(C.typedef(data_type.name, target_type, array=last_element.array_size))) def _gen_record_type_def(self, data_type: rte_element.RecordType) -> cfile.core.Statement: members = [] @@ -147,6 +147,7 @@ def _gen_record_type_def(self, data_type: rte_element.RecordType) -> cfile.core. members.append(C.struct_member(element.name, target_type)) struct_name = "Rte_struct_" + data_type.name code = C.sequence() - code.append(C.statement(C.struct(struct_name, members))) - code.append(C.statement(C.typedef(data_type.name, C.struct_ref(struct_name)))) + struct = C.struct(struct_name, members) + code.append(C.statement(C.declaration(struct))) + code.append(C.statement(C.declaration(C.typedef(data_type.name, struct)))) return code