-
-
Notifications
You must be signed in to change notification settings - Fork 11
Add support for strings and byte arrays #97
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
Conversation
|
I would like to summon @samcrow for commentary. |
|
This looks good overall and not very difficult to add to other implementations. |
|
May I inquire if there's anything keeping this PR from being merged? |
|
Blocked on this OpenCyphal/nunavut#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
<#97 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZFIZCHRAXUNTKY5OCVGGLXOGU6FANCNFSM6AAAAAAXTPDSR4>
.
You are receiving this because you were assigned.Message ID:
***@***.***>
|
|
@thirtytwobits I suggest we merge this |
| assert isinstance(major, _expression.Rational) and isinstance(minor, _expression.Rational) | ||
| return _serializable.Version(major=major.as_native_integer(), minor=minor.as_native_integer()) | ||
|
|
||
| def visit_type_primitive_boolean(self, _n: _Node, _c: _Children) -> _serializable.PrimitiveType: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that these types are not part of the current standard, should we add an "allow experimental" or, inversely, "strict" mode to ensure we can enforce 1.0 compatibility when using pydsdl?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a new strict mode option. In the future we should extract all options into a single Options dataclass. Right now we can't do it properly without breaking API compatibility.
…s into a single Options dataclass.
|
Would there ever be a case where we'd want to send individual characters as bytes or utf8? Certainly one could 'byte[1]' but this seems heavy. |
|
I couldn't come up with a use case where this would be needed instead of We can always remove these restrictions in the future if needed. It makes sense to start with a restricted feature set to allow more choices in the future without breaking backward compatibility. |
Closes #51 See OpenCyphal/pydsdl#97 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Implement string and byte array support as described in OpenCyphal/specification#51. The Specification will be updated after this is agreed upon. The grammar has been modified as follows:
utf8primitive.byteprimitive.saturated bool, which was shorthand forbool, for regularity. From now on, only unqualifiedboolis allowed. The expected impact is zero since the long form was never seen in the wild. Note thattruncated boolwas never legal.At the moment, the following constraints are enforced; they may be lifted in the future:
utf8can only be used as an element type of a variable-length array:bytecan only be used as an element type of an array:Both
utf8andbyteare concrete instances ofUnsignedIntegerType. By virtue of this, existing users of PyDSDL (like Nunavut) will interpret bothutf8andbyteastruncated uint8, until explicitly updated to take advantage of the new feature. That is:Property
pydsdl.ArrayType.string_likeis now deprecated and should be replaced with an explicitisinstance(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 bututf8[10]is not).Closes #96
Relates to OpenCyphal/yakut#65