@zerodds/wire 0.0.0-stage → 1.0.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -2
- package/dist/branded.d.ts +98 -0
- package/dist/branded.js +64 -0
- package/dist/dds_any.d.ts +47 -0
- package/dist/dds_any.js +41 -0
- package/dist/endianness.d.ts +22 -0
- package/dist/endianness.js +35 -0
- package/dist/equal.d.ts +46 -0
- package/dist/equal.js +273 -0
- package/dist/error.d.ts +52 -0
- package/dist/error.js +78 -0
- package/dist/float128.d.ts +15 -0
- package/dist/float128.js +181 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +33 -0
- package/dist/operations.d.ts +180 -0
- package/dist/operations.js +74 -0
- package/dist/policy.d.ts +133 -0
- package/dist/policy.js +184 -0
- package/dist/reader.d.ts +605 -0
- package/dist/reader.js +1345 -0
- package/dist/registry.d.ts +84 -0
- package/dist/registry.js +166 -0
- package/dist/test_backend.d.ts +9 -0
- package/dist/test_backend.js +173 -0
- package/dist/types.d.ts +246 -0
- package/dist/types.js +3 -0
- package/dist/wasm.d.ts +203 -0
- package/dist/wasm.js +194 -0
- package/dist/writer.d.ts +662 -0
- package/dist/writer.js +1333 -0
- package/package.json +27 -4
package/dist/policy.d.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wire policies a layout plan cannot answer.
|
|
3
|
+
*
|
|
4
|
+
* Every one of these is a place where measured implementations differ
|
|
5
|
+
* and the clause leaves room, so the generated codec names the policy
|
|
6
|
+
* and the runtime carries it out. The names are
|
|
7
|
+
* `crates/ast-layout/src/key.rs`'s axes, in TypeScript's spelling; the
|
|
8
|
+
* measurements and the arguments are there.
|
|
9
|
+
*
|
|
10
|
+
* A member per value and no catch-all anywhere that reads one: a
|
|
11
|
+
* policy this column has not implemented has to be a compile error and
|
|
12
|
+
* not a value that looks plausible.
|
|
13
|
+
*/
|
|
14
|
+
/** How many octets one `wchar` takes. */
|
|
15
|
+
export declare enum WcharWidth {
|
|
16
|
+
/** Two, which is Table 31 and seven of the nine measured columns. */
|
|
17
|
+
Octets2 = 2,
|
|
18
|
+
/** Four, which is RTI's XCDR1, TAO, and rosidl's type support. */
|
|
19
|
+
Octets4 = 4
|
|
20
|
+
}
|
|
21
|
+
/** What shape a `wchar` goes out in. */
|
|
22
|
+
export declare enum WcharFraming {
|
|
23
|
+
/** The code unit alone, at its width. */
|
|
24
|
+
Fixed = "fixed",
|
|
25
|
+
/**
|
|
26
|
+
* CORBA 3.3 part 2 §9.3.1.6's GIOP 1.2 form: an octet count first,
|
|
27
|
+
* then the code unit's octets, all aligned to one.
|
|
28
|
+
*/
|
|
29
|
+
GiopLengthPrefixed = "giop-length-prefixed"
|
|
30
|
+
}
|
|
31
|
+
/** In what order a `wstring`'s code units land. */
|
|
32
|
+
export declare enum WstringUnitOrder {
|
|
33
|
+
/** The stream's, which the encapsulation identifier announced. */
|
|
34
|
+
Stream = "stream",
|
|
35
|
+
/** Big-endian whatever the stream says. */
|
|
36
|
+
BigEndianAlways = "big-endian-always",
|
|
37
|
+
/** Preceded by a byte order mark. */
|
|
38
|
+
ByteOrderMark = "byte-order-mark",
|
|
39
|
+
/** The host's, unswapped, which is what Fast CDR writes. */
|
|
40
|
+
HostUnswapped = "host-unswapped"
|
|
41
|
+
}
|
|
42
|
+
/** What a `wstring`'s length field counts, and in what units. */
|
|
43
|
+
export declare enum WstringLengthPolicy {
|
|
44
|
+
/** §7.4.1.1.2: an octet count over UTF-16 units, no terminator. */
|
|
45
|
+
Specification = "specification",
|
|
46
|
+
/** A character count over two-octet units. */
|
|
47
|
+
CharacterCount = "character-count",
|
|
48
|
+
/** The same, with a terminator counted. */
|
|
49
|
+
CharacterCountTerminated = "character-count-terminated",
|
|
50
|
+
/** An octet count over four-octet units. */
|
|
51
|
+
SpecificationWideUnits = "specification-wide-units",
|
|
52
|
+
/** What `rosidl_typesupport_fastrtps` writes. */
|
|
53
|
+
RosTypeSupport = "ros-type-support",
|
|
54
|
+
/** An octet count with a two-octet terminator counted. */
|
|
55
|
+
OctetsTerminated2 = "octets-terminated-2",
|
|
56
|
+
/** The same with a four-octet one. */
|
|
57
|
+
OctetsTerminated4 = "octets-terminated-4",
|
|
58
|
+
/** A character count with a two-octet terminator counted. */
|
|
59
|
+
CharactersTerminated2 = "characters-terminated-2"
|
|
60
|
+
}
|
|
61
|
+
/** What a `fixed`'s digit count is taken from. */
|
|
62
|
+
export declare enum FixedDigitCount {
|
|
63
|
+
/** The IDL's `fixed<D, S>`. */
|
|
64
|
+
Declared = "declared",
|
|
65
|
+
/** The value's own precision (JacORB 3.9). */
|
|
66
|
+
ValuePrecision = "value-precision",
|
|
67
|
+
/**
|
|
68
|
+
* The integer digits of the decimal as written, leading zeros
|
|
69
|
+
* included, plus the S fraction digits, made odd by one leading zero: ACE/TAO 2.5.24's
|
|
70
|
+
* `ACE_CDR::Fixed::from_string` through its own CDR operator (OpenDDS writes the declared count). `0.12345` under
|
|
71
|
+
* `fixed<5,5>` is `0012345c`; past 31 digits it is refused. Read like
|
|
72
|
+
* `ValuePrecision`.
|
|
73
|
+
*/
|
|
74
|
+
ValueStringDigits = "value-string-digits"
|
|
75
|
+
}
|
|
76
|
+
/** What a PL_CDR1 parameter frames. */
|
|
77
|
+
export declare enum ParameterRole {
|
|
78
|
+
/** A member of the type. */
|
|
79
|
+
Member = "member",
|
|
80
|
+
/** An `@optional` member outside a `@mutable` type. */
|
|
81
|
+
Optional = "optional"
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* What §7.2.2.7 says to do with a member the stream cannot give.
|
|
85
|
+
*
|
|
86
|
+
* The reader's, and named here because the generated decoder passes it
|
|
87
|
+
* down as a parameter.
|
|
88
|
+
*/
|
|
89
|
+
export declare enum TryConstruct {
|
|
90
|
+
/** Discard the whole sample. */
|
|
91
|
+
Discard = "discard",
|
|
92
|
+
/** Take Table 9's value. */
|
|
93
|
+
UseDefault = "use-default",
|
|
94
|
+
/** Keep what fits. §7.3.1.2.1.12.3. */
|
|
95
|
+
Trim = "trim"
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* C1 of {@link WstringLengthPolicy} — whether the length prefix counts
|
|
99
|
+
* characters and not octets.
|
|
100
|
+
*
|
|
101
|
+
* A function per axis rather than three fields on an object, because a
|
|
102
|
+
* TypeScript string enum is a name and a value and carries nothing
|
|
103
|
+
* else; Java hangs the three on the enum constant and C on a table.
|
|
104
|
+
* Which axis a cell sits on is the same in all three, and
|
|
105
|
+
* `crates/ast-layout/src/key.rs` is where the measurements are.
|
|
106
|
+
*/
|
|
107
|
+
export declare function wstringCountsCharacters(policy: WstringLengthPolicy): boolean;
|
|
108
|
+
/** C2 — whether a terminating NUL code unit is written and counted. */
|
|
109
|
+
export declare function wstringIsTerminated(policy: WstringLengthPolicy): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* C3 — how many octets one of a `wstring`'s code units takes.
|
|
112
|
+
*
|
|
113
|
+
* **Not** the width of a scalar `wchar`, which is {@link WcharWidth}:
|
|
114
|
+
* `rmw_cyclonedds_cpp` 1.3.4 writes two octets for a `wchar` member and
|
|
115
|
+
* four for a `wstring`'s units, which is why the two are separate axes.
|
|
116
|
+
*/
|
|
117
|
+
export declare function wstringUnitWidth(policy: WstringLengthPolicy): 2 | 4;
|
|
118
|
+
/**
|
|
119
|
+
* Whether the units go out little-endian whatever the stream says.
|
|
120
|
+
*
|
|
121
|
+
* True for the byte-order-mark form, whose mark omniORB writes
|
|
122
|
+
* little-endian, and for the host-unswapped one. The one thing the unit
|
|
123
|
+
* writers ask of this axis besides `BigEndianAlways`.
|
|
124
|
+
*/
|
|
125
|
+
export declare function wstringOrderIsFixedLittle(order: WstringUnitOrder): boolean;
|
|
126
|
+
/** Why a reader stopped. */
|
|
127
|
+
export declare enum Status {
|
|
128
|
+
Ok = "ok",
|
|
129
|
+
Truncated = "truncated",
|
|
130
|
+
ImpossibleLength = "impossible-length",
|
|
131
|
+
OutOfRange = "out-of-range",
|
|
132
|
+
Discarded = "discarded"
|
|
133
|
+
}
|
package/dist/policy.js
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright 2026 ZeroDDS Contributors
|
|
3
|
+
/**
|
|
4
|
+
* The wire policies a layout plan cannot answer.
|
|
5
|
+
*
|
|
6
|
+
* Every one of these is a place where measured implementations differ
|
|
7
|
+
* and the clause leaves room, so the generated codec names the policy
|
|
8
|
+
* and the runtime carries it out. The names are
|
|
9
|
+
* `crates/ast-layout/src/key.rs`'s axes, in TypeScript's spelling; the
|
|
10
|
+
* measurements and the arguments are there.
|
|
11
|
+
*
|
|
12
|
+
* A member per value and no catch-all anywhere that reads one: a
|
|
13
|
+
* policy this column has not implemented has to be a compile error and
|
|
14
|
+
* not a value that looks plausible.
|
|
15
|
+
*/
|
|
16
|
+
/** How many octets one `wchar` takes. */
|
|
17
|
+
export var WcharWidth;
|
|
18
|
+
(function (WcharWidth) {
|
|
19
|
+
/** Two, which is Table 31 and seven of the nine measured columns. */
|
|
20
|
+
WcharWidth[WcharWidth["Octets2"] = 2] = "Octets2";
|
|
21
|
+
/** Four, which is RTI's XCDR1, TAO, and rosidl's type support. */
|
|
22
|
+
WcharWidth[WcharWidth["Octets4"] = 4] = "Octets4";
|
|
23
|
+
})(WcharWidth || (WcharWidth = {}));
|
|
24
|
+
/** What shape a `wchar` goes out in. */
|
|
25
|
+
export var WcharFraming;
|
|
26
|
+
(function (WcharFraming) {
|
|
27
|
+
/** The code unit alone, at its width. */
|
|
28
|
+
WcharFraming["Fixed"] = "fixed";
|
|
29
|
+
/**
|
|
30
|
+
* CORBA 3.3 part 2 §9.3.1.6's GIOP 1.2 form: an octet count first,
|
|
31
|
+
* then the code unit's octets, all aligned to one.
|
|
32
|
+
*/
|
|
33
|
+
WcharFraming["GiopLengthPrefixed"] = "giop-length-prefixed";
|
|
34
|
+
})(WcharFraming || (WcharFraming = {}));
|
|
35
|
+
/** In what order a `wstring`'s code units land. */
|
|
36
|
+
export var WstringUnitOrder;
|
|
37
|
+
(function (WstringUnitOrder) {
|
|
38
|
+
/** The stream's, which the encapsulation identifier announced. */
|
|
39
|
+
WstringUnitOrder["Stream"] = "stream";
|
|
40
|
+
/** Big-endian whatever the stream says. */
|
|
41
|
+
WstringUnitOrder["BigEndianAlways"] = "big-endian-always";
|
|
42
|
+
/** Preceded by a byte order mark. */
|
|
43
|
+
WstringUnitOrder["ByteOrderMark"] = "byte-order-mark";
|
|
44
|
+
/** The host's, unswapped, which is what Fast CDR writes. */
|
|
45
|
+
WstringUnitOrder["HostUnswapped"] = "host-unswapped";
|
|
46
|
+
})(WstringUnitOrder || (WstringUnitOrder = {}));
|
|
47
|
+
/** What a `wstring`'s length field counts, and in what units. */
|
|
48
|
+
export var WstringLengthPolicy;
|
|
49
|
+
(function (WstringLengthPolicy) {
|
|
50
|
+
/** §7.4.1.1.2: an octet count over UTF-16 units, no terminator. */
|
|
51
|
+
WstringLengthPolicy["Specification"] = "specification";
|
|
52
|
+
/** A character count over two-octet units. */
|
|
53
|
+
WstringLengthPolicy["CharacterCount"] = "character-count";
|
|
54
|
+
/** The same, with a terminator counted. */
|
|
55
|
+
WstringLengthPolicy["CharacterCountTerminated"] = "character-count-terminated";
|
|
56
|
+
/** An octet count over four-octet units. */
|
|
57
|
+
WstringLengthPolicy["SpecificationWideUnits"] = "specification-wide-units";
|
|
58
|
+
/** What `rosidl_typesupport_fastrtps` writes. */
|
|
59
|
+
WstringLengthPolicy["RosTypeSupport"] = "ros-type-support";
|
|
60
|
+
/** An octet count with a two-octet terminator counted. */
|
|
61
|
+
WstringLengthPolicy["OctetsTerminated2"] = "octets-terminated-2";
|
|
62
|
+
/** The same with a four-octet one. */
|
|
63
|
+
WstringLengthPolicy["OctetsTerminated4"] = "octets-terminated-4";
|
|
64
|
+
/** A character count with a two-octet terminator counted. */
|
|
65
|
+
WstringLengthPolicy["CharactersTerminated2"] = "characters-terminated-2";
|
|
66
|
+
})(WstringLengthPolicy || (WstringLengthPolicy = {}));
|
|
67
|
+
/** What a `fixed`'s digit count is taken from. */
|
|
68
|
+
export var FixedDigitCount;
|
|
69
|
+
(function (FixedDigitCount) {
|
|
70
|
+
/** The IDL's `fixed<D, S>`. */
|
|
71
|
+
FixedDigitCount["Declared"] = "declared";
|
|
72
|
+
/** The value's own precision (JacORB 3.9). */
|
|
73
|
+
FixedDigitCount["ValuePrecision"] = "value-precision";
|
|
74
|
+
/**
|
|
75
|
+
* The integer digits of the decimal as written, leading zeros
|
|
76
|
+
* included, plus the S fraction digits, made odd by one leading zero: ACE/TAO 2.5.24's
|
|
77
|
+
* `ACE_CDR::Fixed::from_string` through its own CDR operator (OpenDDS writes the declared count). `0.12345` under
|
|
78
|
+
* `fixed<5,5>` is `0012345c`; past 31 digits it is refused. Read like
|
|
79
|
+
* `ValuePrecision`.
|
|
80
|
+
*/
|
|
81
|
+
FixedDigitCount["ValueStringDigits"] = "value-string-digits";
|
|
82
|
+
})(FixedDigitCount || (FixedDigitCount = {}));
|
|
83
|
+
/** What a PL_CDR1 parameter frames. */
|
|
84
|
+
export var ParameterRole;
|
|
85
|
+
(function (ParameterRole) {
|
|
86
|
+
/** A member of the type. */
|
|
87
|
+
ParameterRole["Member"] = "member";
|
|
88
|
+
/** An `@optional` member outside a `@mutable` type. */
|
|
89
|
+
ParameterRole["Optional"] = "optional";
|
|
90
|
+
})(ParameterRole || (ParameterRole = {}));
|
|
91
|
+
/**
|
|
92
|
+
* What §7.2.2.7 says to do with a member the stream cannot give.
|
|
93
|
+
*
|
|
94
|
+
* The reader's, and named here because the generated decoder passes it
|
|
95
|
+
* down as a parameter.
|
|
96
|
+
*/
|
|
97
|
+
export var TryConstruct;
|
|
98
|
+
(function (TryConstruct) {
|
|
99
|
+
/** Discard the whole sample. */
|
|
100
|
+
TryConstruct["Discard"] = "discard";
|
|
101
|
+
/** Take Table 9's value. */
|
|
102
|
+
TryConstruct["UseDefault"] = "use-default";
|
|
103
|
+
/** Keep what fits. §7.3.1.2.1.12.3. */
|
|
104
|
+
TryConstruct["Trim"] = "trim";
|
|
105
|
+
})(TryConstruct || (TryConstruct = {}));
|
|
106
|
+
/**
|
|
107
|
+
* C1 of {@link WstringLengthPolicy} — whether the length prefix counts
|
|
108
|
+
* characters and not octets.
|
|
109
|
+
*
|
|
110
|
+
* A function per axis rather than three fields on an object, because a
|
|
111
|
+
* TypeScript string enum is a name and a value and carries nothing
|
|
112
|
+
* else; Java hangs the three on the enum constant and C on a table.
|
|
113
|
+
* Which axis a cell sits on is the same in all three, and
|
|
114
|
+
* `crates/ast-layout/src/key.rs` is where the measurements are.
|
|
115
|
+
*/
|
|
116
|
+
export function wstringCountsCharacters(policy) {
|
|
117
|
+
switch (policy) {
|
|
118
|
+
case WstringLengthPolicy.CharacterCount:
|
|
119
|
+
case WstringLengthPolicy.CharacterCountTerminated:
|
|
120
|
+
case WstringLengthPolicy.RosTypeSupport:
|
|
121
|
+
case WstringLengthPolicy.CharactersTerminated2:
|
|
122
|
+
return true;
|
|
123
|
+
case WstringLengthPolicy.Specification:
|
|
124
|
+
case WstringLengthPolicy.SpecificationWideUnits:
|
|
125
|
+
case WstringLengthPolicy.OctetsTerminated2:
|
|
126
|
+
case WstringLengthPolicy.OctetsTerminated4:
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/** C2 — whether a terminating NUL code unit is written and counted. */
|
|
131
|
+
export function wstringIsTerminated(policy) {
|
|
132
|
+
switch (policy) {
|
|
133
|
+
case WstringLengthPolicy.CharacterCountTerminated:
|
|
134
|
+
case WstringLengthPolicy.OctetsTerminated2:
|
|
135
|
+
case WstringLengthPolicy.OctetsTerminated4:
|
|
136
|
+
case WstringLengthPolicy.CharactersTerminated2:
|
|
137
|
+
return true;
|
|
138
|
+
case WstringLengthPolicy.Specification:
|
|
139
|
+
case WstringLengthPolicy.CharacterCount:
|
|
140
|
+
case WstringLengthPolicy.SpecificationWideUnits:
|
|
141
|
+
case WstringLengthPolicy.RosTypeSupport:
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* C3 — how many octets one of a `wstring`'s code units takes.
|
|
147
|
+
*
|
|
148
|
+
* **Not** the width of a scalar `wchar`, which is {@link WcharWidth}:
|
|
149
|
+
* `rmw_cyclonedds_cpp` 1.3.4 writes two octets for a `wchar` member and
|
|
150
|
+
* four for a `wstring`'s units, which is why the two are separate axes.
|
|
151
|
+
*/
|
|
152
|
+
export function wstringUnitWidth(policy) {
|
|
153
|
+
switch (policy) {
|
|
154
|
+
case WstringLengthPolicy.Specification:
|
|
155
|
+
case WstringLengthPolicy.CharacterCount:
|
|
156
|
+
case WstringLengthPolicy.OctetsTerminated2:
|
|
157
|
+
case WstringLengthPolicy.CharactersTerminated2:
|
|
158
|
+
return 2;
|
|
159
|
+
case WstringLengthPolicy.CharacterCountTerminated:
|
|
160
|
+
case WstringLengthPolicy.SpecificationWideUnits:
|
|
161
|
+
case WstringLengthPolicy.RosTypeSupport:
|
|
162
|
+
case WstringLengthPolicy.OctetsTerminated4:
|
|
163
|
+
return 4;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Whether the units go out little-endian whatever the stream says.
|
|
168
|
+
*
|
|
169
|
+
* True for the byte-order-mark form, whose mark omniORB writes
|
|
170
|
+
* little-endian, and for the host-unswapped one. The one thing the unit
|
|
171
|
+
* writers ask of this axis besides `BigEndianAlways`.
|
|
172
|
+
*/
|
|
173
|
+
export function wstringOrderIsFixedLittle(order) {
|
|
174
|
+
return order === WstringUnitOrder.ByteOrderMark || order === WstringUnitOrder.HostUnswapped;
|
|
175
|
+
}
|
|
176
|
+
/** Why a reader stopped. */
|
|
177
|
+
export var Status;
|
|
178
|
+
(function (Status) {
|
|
179
|
+
Status["Ok"] = "ok";
|
|
180
|
+
Status["Truncated"] = "truncated";
|
|
181
|
+
Status["ImpossibleLength"] = "impossible-length";
|
|
182
|
+
Status["OutOfRange"] = "out-of-range";
|
|
183
|
+
Status["Discarded"] = "discarded";
|
|
184
|
+
})(Status || (Status = {}));
|