OpenCyphal / pydsdl

Cyphal DSDL processing front end implemented in Python
https://opencyphal.org
MIT License
10 stars 9 forks source link

Add support for strings and byte arrays #97

Open pavel-kirienko opened 1 year ago

pavel-kirienko commented 1 year ago

Implement string and byte array support as described in https://github.com/OpenCyphal/specification/issues/51. The Specification will be updated after this is agreed upon. The grammar has been modified as follows:

At the moment, the following constraints are enforced; they may be lifted in the future:

Both utf8 and byte are concrete instances of UnsignedIntegerType. By virtue of this, existing users of PyDSDL (like Nunavut) will interpret both utf8 and byte as truncated uint8, until explicitly updated to take advantage of the new feature. That is:

utf8[<=10] name  # seen by Nunavut as: truncated uint8[<=10]
utf8[10]   name  # frontend error
utf8       name  # frontend error
byte[<=10] data  # seen by Nunavut as: truncated uint8[<=10]
byte[10]   data  # seen by Nunavut as: truncated uint8[10]
byte       data  # frontend error

Property pydsdl.ArrayType.string_like is now deprecated and should be replaced with an explicit isinstance(array.element_type, pydsdl.UTF8Type).

Some internal refactoring has been done to unify the deprecation consistency checking with the aggregation constraints listed above (e.g., utf8[<=10] is valid but utf8[10] is not).

Closes #96 Relates to https://github.com/OpenCyphal/yakut/issues/65

pavel-kirienko commented 1 year ago

I would like to summon @samcrow for commentary.

samcrow commented 1 year ago

This looks good overall and not very difficult to add to other implementations.

aentinger commented 1 year ago

May I inquire if there's anything keeping this PR from being merged?

pavel-kirienko commented 1 year ago

Blocked on this https://github.com/OpenCyphal/nunavut/issues/301

On Sun, Jul 2, 2023, 20:22 Alexander Entinger @.***> wrote:

May I inquire if there's anything keeping this PR from being merged?

— Reply to this email directly, view it on GitHub https://github.com/OpenCyphal/pydsdl/pull/97#issuecomment-1616740185, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZFIZCHRAXUNTKY5OCVGGLXOGU6FANCNFSM6AAAAAAXTPDSR4 . You are receiving this because you were assigned.Message ID: @.***>