@@ -14,49 +14,9 @@ found here](https://github.com/WebAssembly/interface-types/blob/master/proposals
1414The endian-ness of these types are ** little endian** , as _ all_ types in the WebAssembly
1515type system are little endian. [ See here for more information] ( https://github.com/WebAssembly/design/issues/786#issuecomment-244548105 ) .
1616
17- # Enum(T)
17+ # Record
1818
19- An ` Enum(T) ` is simply is a ` T ` . However, the value of T can only be one of the
20- specific variants of the enum. This type lends itself to describing when
21- something can only be one of the enumerations in the group (for example, in a
22- group of Dogs and Cats, you may have an enum representing either a Dog or a
23- Cat).
24-
25- ```
26- errno: Enum(u32)
27- +------+------+------+------+
28- | 0x00 | 0x00 | 0x00 | 0x15 |
29- +------+------+------+------+
30- ^ fault
31- ```
32-
33- (` clockid ` despite only representing 4 values is an ` Enum(u32) ` . This is
34- primarily for ABI compatibility, and future-proofing.)
35-
36- # Flags(T)
37-
38- A ` Flags(T) ` datatype takes up exactly a ` T ` in memory, similar to ` Enum(T) ` .
39- However, each variant of a ` Flags(T) ` will take up exactly one bit in the data.
40- This allows the usage of bitwise AND, bitwise OR, and bitwise NOT operators to
41- combine, check, or exclude specific values in the flag very easily. This type
42- lends itself to describing capabilities.
43-
44- ```
45- oflags: Flags(u16)
46-
47- +-----------------+-----------------+
48- | 0 1 1 0 0 0 0 0 | 0 0 0 0 0 0 0 0 |
49- +-----------------+-----------------+
50- ^ ^ ^ ^
51- | | | trunc
52- | | excl
53- | directory
54- creat
55- ```
56-
57- # Struct
58-
59- A ` Struct ` is a type that takes up some contiguous amount of memory, with each
19+ A ` Record ` is a type that takes up some contiguous amount of memory, with each
6020field taking up a specific amount of reserved bytes. Interpreting the bytes as
6121one of the types in Witx will yield a usable value.
6222
@@ -72,26 +32,36 @@ buf_len: size @ offset 4
7232^buf ^buf_len
7333```
7434
75- The ` Size ` of a ` Struct ` refers to how many contiguous bytes it takes up in
35+ The ` Size ` of a ` Record ` refers to how many contiguous bytes it takes up in
7636memory.
7737
78- The ` Alignment ` of a ` Struct ` refers to <X >.
38+ The ` Alignment ` of a ` Record ` refers to the byte boundary that the record must
39+ be on in memory. For example, the above ` iovec ` could only ever get allocated
40+ to a memory address that is divisible by 4, because the alignment is 4.
7941
80- # Union
42+ # Variant
8143
82- A ` Union ` is a type which uses ` tag_size ` bytes to determine which variant of
83- the union the data will be. The data is simply inserted as is with whatever
44+ A ` Variant ` is a type which uses some bits to determine which variant of
45+ the variant the data will be. The data is simply inserted as is with whatever
8446type it may be.
8547
48+ ```
49+ errno: Variant
50+ +------+------+------+------+
51+ | 0x00 | 0x00 | 0x00 | 0x15 |
52+ +------+------+------+------+
53+ ^ fault
54+ ```
55+
8656```
8757subscription_u
8858
8959+------+------+------+------+------+------+------+------+
9060| 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 |
9161+------+------+------+------+------+------+------+------+
92- ^ padding due to the alignment of the union ^tag_size
62+ ^ padding due to the alignment of the variant ^tag_size
9363
94- cont. 32 bytes for the union 's data
64+ cont. 32 bytes for the variant 's data
9565+------+------+------+------+------+------+------+------+
9666| 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 |
9767+------+------+------+------+------+------+------+------+
@@ -101,9 +71,9 @@ cont. 32 bytes for the union's data
10171+------+------+------+------+------+------+------+------+
10272```
10373
104- # Pointer<T > and Array <T >
74+ # Pointer<T > and List <T >
10575
106- A ` Pointer<T> ` and ` Array <T>` are both just ` Pointer<T> ` s. A ` Pointer<T> ` 's
76+ A ` Pointer<T> ` and ` List <T>` are both just ` Pointer<T> ` s. A ` Pointer<T> ` 's
10777size is guaranteed to be 8 bytes, but if on a 32 bit architecture it will only
10878use 4 of the 8 bytes. The pointers themselves are 32 bit, as wasm32 is the only
10979ABI currently implemented. In the future when the specification for wasm64 is
@@ -114,8 +84,8 @@ at that location will be an unknown contiguous amount of `T`s.
11484```
11585Pointer<u8>
11686
117- +------+------+------+------+------+------+------+------+
118- | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 |
119- +------+------+------+------+------+------+------+------+
87+ +------+------+------+------+
88+ | 0x00 | 0x00 | 0x00 | 0x00 |
89+ +------+------+------+------+
12090^ a number, that represents another position in RAM that leads to the data.
12191```
0 commit comments