Project

General

Profile

Feature #11463

Add constraints to the grammar

Added by Richard Neswold almost 4 years ago. Updated almost 4 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
01/21/2016
Due date:
% Done:

0%

Estimated time:
Duration:

Description

This is a proposal to add constraints to fields of protocol messages. The generated encoders and decoders would make sure the constraints are met.

Just to get a discussion going, one possible syntax would be to follow an item with :: followed by a comma-separated list of constraints. Different types would have different constraints. The optional keyword would be moved into the constraint grammar.

Form Affected Types Comments
optional all Marks the field as optional
# .. # int, double Restricts the range of the integer or double. Only one range can be specified for a field.
string, array, binary Restricts the size of the string/array/binary. The range can be omitted and a single number used to fix the size.

The various integer types would go away and we would only have int (with appropriate constraints to emulate the removed types.) We could add a type keyword to define aliases and then pre-define a few, like:

type int16 = int :: -32768 .. 32767;
type uint16 = int :: 0 .. 65535;

Related issues

Related to Protocol Compiler - Feature #11474: Allow fields to be individually marshalledClosed01/21/2016

History

#1 Updated by Richard Neswold almost 4 years ago

  • Related to Feature #11474: Allow fields to be individually marshalled added

#2 Updated by Richard Neswold almost 4 years ago

Added a link between this issue and #11474. Both of these can be combined into a concept of "field attributes".



Also available in: Atom PDF