Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate C++ #91

Open
2 of 5 tasks
thirtytwobits opened this issue Oct 24, 2019 · 3 comments
Open
2 of 5 tasks

Generate C++ #91

thirtytwobits opened this issue Oct 24, 2019 · 3 comments
Assignees
Labels
feature New feature or request

Comments

@thirtytwobits
Copy link
Member

thirtytwobits commented Oct 24, 2019

That's it. Just generate C++. Easy right?

TODO:

  • variant support
  • default static allocator for variable-length array type
  • serialization
  • deserialization
  • documentation
@thirtytwobits thirtytwobits self-assigned this Oct 24, 2019
@thirtytwobits thirtytwobits added the feature New feature or request label Oct 24, 2019
thirtytwobits added a commit to thirtytwobits/nunavut that referenced this issue Oct 29, 2019
thirtytwobits added a commit to thirtytwobits/nunavut that referenced this issue Nov 3, 2019
thirtytwobits added a commit to thirtytwobits/nunavut that referenced this issue Nov 6, 2019
thirtytwobits added a commit to thirtytwobits/nunavut that referenced this issue Nov 6, 2019
thirtytwobits added a commit to thirtytwobits/nunavut that referenced this issue Nov 6, 2019
1) Fixing a problem with unique identifier generation (Issue OpenCyphal#88)
2) Generating C++ data structures (Issue OpenCyphal#91)

Still TODO for Issue OpenCyphal#91 is serialization for types.
thirtytwobits pushed a commit that referenced this issue Nov 11, 2019
Disabling the Jinja cache results in the unique name generator state disappearing from the global Jinja context:

    >       return _UniqueNameGenerator.ensure_generator_in_globals(env.globals)('c', adj_base_token, '_', '_')
    E       TypeError: 'NoneType' object is not callable
    .tox/py35-test/lib/python3.5/site-packages/nunavut/lang/c.py:527: TypeError

This issue affects all languages. The following test modification indicates that the state gets replaced with None:

    ------------------------- src/nunavut/lang/__init__.py -------------------------
    index bd6524c..135a29a 100644
    @@ -226,7 +226,7 @@ class _UniqueNameGenerator:
        def ensure_generator_in_globals(cls, environment_globals: typing.Dict[str, typing.Any]) -> '_UniqueNameGenerator':
            from .. import TypeLocalGlobalKey

    -        if TypeLocalGlobalKey not in environment_globals:
    +        if environment_globals.get(TypeLocalGlobalKey) is None:
                environment_globals[TypeLocalGlobalKey] = cls()
            return typing.cast('_UniqueNameGenerator', environment_globals[TypeLocalGlobalKey])

Am stuck.

Progress on #91

1) Fixing a problem with unique identifier generation (Issue #88)
2) Generating C++ data structures (Issue #91)

Still TODO for Issue #91 is serialization for types.
thirtytwobits added a commit that referenced this issue Nov 16, 2019
* Combining additional #88 test with #88 fix and #91

Disabling the Jinja cache results in the unique name generator state disappearing from the global Jinja context:

    >       return _UniqueNameGenerator.ensure_generator_in_globals(env.globals)('c', adj_base_token, '_', '_')
    E       TypeError: 'NoneType' object is not callable
    .tox/py35-test/lib/python3.5/site-packages/nunavut/lang/c.py:527: TypeError

This issue affects all languages. The following test modification indicates that the state gets replaced with None:

    ------------------------- src/nunavut/lang/__init__.py -------------------------
    index bd6524c..135a29a 100644
    @@ -226,7 +226,7 @@ class _UniqueNameGenerator:
        def ensure_generator_in_globals(cls, environment_globals: typing.Dict[str, typing.Any]) -> '_UniqueNameGenerator':
            from .. import TypeLocalGlobalKey

    -        if TypeLocalGlobalKey not in environment_globals:
    +        if environment_globals.get(TypeLocalGlobalKey) is None:
                environment_globals[TypeLocalGlobalKey] = cls()
            return typing.cast('_UniqueNameGenerator', environment_globals[TypeLocalGlobalKey])

Am stuck.

Progress on #91

1) Fixing a problem with unique identifier generation (Issue #88)
2) Generating C++ data structures (Issue #91)

Still TODO for Issue #91 is serialization for types.

* A new way to generate unique ids in a template
thirtytwobits added a commit to thirtytwobits/nunavut that referenced this issue Nov 26, 2019
Major refactor of language context to drive filter options from
configuration. The ability to modify things like stropping and
encoding were fundamentally broken before this change.

This work was done in support of adding named types as a concept to
languages. This will allow generation of serialization code that is more
configurable and will avoid fixing decisions like the use of size_t into
templates instead moving these decisions into user-overridable
configuration.
thirtytwobits added a commit to thirtytwobits/nunavut that referenced this issue Nov 26, 2019
Major refactor of language context to drive filter options from
configuration. The ability to modify things like stropping and
encoding were fundamentally broken before this change.

This work was done in support of adding named types as a concept to
languages. This will allow generation of serialization code that is more
configurable and will avoid fixing decisions like the use of size_t into
templates instead moving these decisions into user-overridable
configuration.
thirtytwobits added a commit to thirtytwobits/nunavut that referenced this issue Nov 26, 2019
Major refactor of language context to drive filter options from
configuration. The ability to modify things like stropping and
encoding were fundamentally broken before this change.

This work was done in support of adding named types as a concept to
languages. This will allow generation of serialization code that is more
configurable and will avoid fixing decisions like the use of size_t into
templates instead moving these decisions into user-overridable
configuration.
thirtytwobits added a commit to thirtytwobits/nunavut that referenced this issue Nov 26, 2019
Major refactor of language context to drive filter options from
configuration. The ability to modify things like stropping and
encoding were fundamentally broken before this change.

This work was done in support of adding named types as a concept to
languages. This will allow generation of serialization code that is more
configurable and will avoid fixing decisions like the use of size_t into
templates instead moving these decisions into user-overridable
configuration.
thirtytwobits added a commit to thirtytwobits/nunavut that referenced this issue Nov 26, 2019
Major refactor of language context to drive filter options from
configuration. The ability to modify things like stropping and
encoding were fundamentally broken before this change.

This work was done in support of adding named types as a concept to
languages. This will allow generation of serialization code that is more
configurable and will avoid fixing decisions like the use of size_t into
templates instead moving these decisions into user-overridable
configuration.
thirtytwobits added a commit to thirtytwobits/nunavut that referenced this issue Nov 27, 2019
Major refactor of language context to drive filter options from
configuration. The ability to modify things like stropping and
encoding were fundamentally broken before this change.

This work was done in support of adding named types as a concept to
languages. This will allow generation of serialization code that is more
configurable and will avoid fixing decisions like the use of size_t into
templates instead moving these decisions into user-overridable
configuration.
thirtytwobits added a commit to thirtytwobits/nunavut that referenced this issue Nov 27, 2019
Major refactor of language context to drive filter options from
configuration. The ability to modify things like stropping and
encoding were fundamentally broken before this change.

This work was done in support of adding named types as a concept to
languages. This will allow generation of serialization code that is more
configurable and will avoid fixing decisions like the use of size_t into
templates instead moving these decisions into user-overridable
configuration.
thirtytwobits added a commit that referenced this issue Dec 13, 2019
* Issue #94 and progress on Issue #91

Major refactor of language context to drive filter options from
configuration. The ability to modify things like stropping and
encoding were fundamentally broken before this change.

This work was done in support of adding named types as a concept to
languages. This will allow generation of serialization code that is more
configurable and will avoid fixing decisions like the use of size_t into
templates instead moving these decisions into user-overridable
configuration.

* updates per PR review comments
thirtytwobits added a commit to thirtytwobits/nunavut that referenced this issue Jan 15, 2020
1. refactor to support embedding support code in nunavut distribution.
2. refactor to support optional inclusion of serialization support and
routines. Retaining ability to generate POD types.
3. Simplification of some CMake stuff to deduplicate what TOX does for
us.
4. Unification of test fixtures between Sybil and our regular unit
tests.
thirtytwobits added a commit to thirtytwobits/nunavut that referenced this issue Jan 15, 2020
1. refactor to support embedding support code in nunavut distribution.
2. refactor to support optional inclusion of serialization support and
routines. Retaining ability to generate POD types.
3. Simplification of some CMake stuff to deduplicate what TOX does for
us.
4. Unification of test fixtures between Sybil and our regular unit
tests.
thirtytwobits added a commit to thirtytwobits/nunavut that referenced this issue Jan 16, 2020
1. refactor to support embedding support code in nunavut distribution.
2. refactor to support optional inclusion of serialization support and
routines. Retaining ability to generate POD types.
3. Simplification of some CMake stuff to deduplicate what TOX does for
us.
4. Unification of test fixtures between Sybil and our regular unit
tests.
thirtytwobits added a commit that referenced this issue Jan 16, 2020
1. refactor to support embedding support code in nunavut distribution.
2. refactor to support optional inclusion of serialization support and
routines. Retaining ability to generate POD types.
3. Simplification of some CMake stuff to deduplicate what TOX does for
us.
4. Unification of test fixtures between Sybil and our regular unit
tests.
thirtytwobits added a commit that referenced this issue Jun 7, 2021
* A lot of stuff in this one:

1. Fixed support generator to properly use specified file and line
   post-processors.
2. General progress on the variable length array.
3. Added "no-cov" to cmake build so it doesn't get in the way during
   development. This was a constant problem on OSX.

Still left is to get all the noexcept guarentees to be correct and to
figure out how to verify them.

* adding array type override

* version bump

* disabling coverage for now

* Fixing GCC 9 and earlier syntax

* parallelizing python builds

* increasing host parallelism

* fixing concurrency issues with native build
@asmfreak
Copy link
Contributor

asmfreak commented Mar 5, 2022

The #236 PR added basic support for (de)serialization. More work should be done, of course, but current version is a quite bit useable. Maybe not yet on embedded uCs, but on bigger computers.

And by more work I want to point out the following tasks:

  • Add optimizations
    • Use VLA implementation with allocators and sizes (not C-style VLA, but a separate type, implemented in the support library).
    • Implement a packed bit array (this should be a type in the support library, calling bitspan::get/setBit().
    • Various optimizations on zero-cost conversion of types (see C templates for examples).
  • Make copy-pasted tests more maintainable (using C implementation as golden standard).

@emrainey
Copy link

emrainey commented Jun 3, 2022

Can't wait for variant support (C++17)

@thirtytwobits
Copy link
Member Author

variant support is already available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants