@@ -14,49 +14,9 @@ found here](https://github.com/WebAssembly/interface-types/blob/master/proposals
14
14
The endian-ness of these types are ** little endian** , as _ all_ types in the WebAssembly
15
15
type system are little endian. [ See here for more information] ( https://github.com/WebAssembly/design/issues/786#issuecomment-244548105 ) .
16
16
17
- # Enum(T)
17
+ # Record
18
18
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
60
20
field taking up a specific amount of reserved bytes. Interpreting the bytes as
61
21
one of the types in Witx will yield a usable value.
62
22
@@ -72,26 +32,36 @@ buf_len: size @ offset 4
72
32
^buf ^buf_len
73
33
```
74
34
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
76
36
memory.
77
37
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.
79
41
80
- # Union
42
+ # Variant
81
43
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
84
46
type it may be.
85
47
48
+ ```
49
+ errno: Variant
50
+ +------+------+------+------+
51
+ | 0x00 | 0x00 | 0x00 | 0x15 |
52
+ +------+------+------+------+
53
+ ^ fault
54
+ ```
55
+
86
56
```
87
57
subscription_u
88
58
89
59
+------+------+------+------+------+------+------+------+
90
60
| 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 |
91
61
+------+------+------+------+------+------+------+------+
92
- ^ padding due to the alignment of the union ^tag_size
62
+ ^ padding due to the alignment of the variant ^tag_size
93
63
94
- cont. 32 bytes for the union 's data
64
+ cont. 32 bytes for the variant 's data
95
65
+------+------+------+------+------+------+------+------+
96
66
| 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 |
97
67
+------+------+------+------+------+------+------+------+
@@ -101,9 +71,9 @@ cont. 32 bytes for the union's data
101
71
+------+------+------+------+------+------+------+------+
102
72
```
103
73
104
- # Pointer<T > and Array <T >
74
+ # Pointer<T > and List <T >
105
75
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
107
77
size is guaranteed to be 8 bytes, but if on a 32 bit architecture it will only
108
78
use 4 of the 8 bytes. The pointers themselves are 32 bit, as wasm32 is the only
109
79
ABI currently implemented. In the future when the specification for wasm64 is
0 commit comments