You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: component-model/src/advanced/canonical-abi.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -4,4 +4,4 @@ An ABI is an **application binary interface** - an agreement on how to pass data
4
4
5
5
The component model defines a **canonical ABI** - an ABI to which all [components](../design/components.md) adhere. This guarantees that components can talk to each other without confusion, even if they are built in different languages. Internally, a C component might represent strings in a quite different way from a Rust component, but the canonical ABI provides a format for them to pass strings across the boundary between them.
6
6
7
-
> ⓘ For a more formal definition of what the Canonical ABI is, take a look at the [Canonical ABI explainer](https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md).
7
+
> For a more formal definition of what the Canonical ABI is, take a look at the [Canonical ABI explainer](https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md).
Copy file name to clipboardExpand all lines: component-model/src/design/components.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -6,4 +6,4 @@
6
6
7
7
The external interface of a component - its imports and exports - corresponds to a [world](./worlds.md). The component, however, internally defines how that world is implemented.
8
8
9
-
> ⓘ For a more formal definition of what a component is, take a look at the [Component Model specification](https://github.com/WebAssembly/component-model).
9
+
> For a more formal definition of what a component is, take a look at the [Component Model specification](https://github.com/WebAssembly/component-model).
Copy file name to clipboardExpand all lines: component-model/src/design/interfaces.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -7,4 +7,4 @@ An **interface** describes a single-focus, composable contract, through which co
7
7
8
8
Interfaces are defined using [the WIT language](./wit.md).
9
9
10
-
> ⓘ For a more formal definition of what an interface is, take a look at the [WIT specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md).
10
+
> For a more formal definition of what an interface is, take a look at the [WIT specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md).
Copy file name to clipboardExpand all lines: component-model/src/design/packages.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -6,4 +6,4 @@ A WIT package is not a [world](./worlds.md). It's a way of grouping related inte
6
6
7
7
* The WebAssembly System Interface (WASI) defines a number of packages, including one named `wasi:clocks`. Our HTTP proxy world could import the `wall-clock` interface from the `wasi:clocks` package, rather than having to define a custom clock interface.
8
8
9
-
> ⓘ For a more formal definition of what a WIT package is, take a look at the [WIT specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md).
9
+
> For a more formal definition of what a WIT package is, take a look at the [WIT specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md).
Copy file name to clipboardExpand all lines: component-model/src/design/why-component-model.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -16,4 +16,4 @@ Moreover, a component interacts with a runtime or other components _only_ by cal
16
16
17
17
Now that you have a better idea about how the component model can help you, take a look at [how to build components](../language-support.md) in your favorite language!
18
18
19
-
> ⓘ For more background on why the component model was created, take a look at the specification's [goals](https://github.com/WebAssembly/component-model/blob/main/design/high-level/Goals.md), [use cases](https://github.com/WebAssembly/component-model/blob/main/design/high-level/UseCases.md) and [design choices](https://github.com/WebAssembly/component-model/blob/main/design/high-level/Choices.md).
19
+
> For more background on why the component model was created, take a look at the specification's [goals](https://github.com/WebAssembly/component-model/blob/main/design/high-level/Goals.md), [use cases](https://github.com/WebAssembly/component-model/blob/main/design/high-level/UseCases.md) and [design choices](https://github.com/WebAssembly/component-model/blob/main/design/high-level/Choices.md).
Copy file name to clipboardExpand all lines: component-model/src/design/wit.md
+32-30Lines changed: 32 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -91,29 +91,29 @@ WIT defines the following primitive types:
91
91
92
92
| Identifier | Description |
93
93
|----------------------------|-------------|
94
-
|`bool`| Boolean value - true or false. |
95
-
|`s8`, `s16`, `s32`, `s64`| Signed integers of the appropriate width. For example, `s32` is a 32-bit integer. |
96
-
|`u8`, `u16`, `u32`, `u64`| Unsigned integers of the appropriate width. For example, `u32` is a 32-bit integer. |
97
-
|`f32`, `f64`| Floating-point numbers of the appropriate width. For example, `f64` is a 64-bit (double precision) floating-point number. See the note on NaNs below. |
94
+
|`bool`| Boolean value `true` or `false`. |
95
+
|`s8`, `s16`, `s32`, `s64`| Signed integers of the appropriate width. For example, `s32` is a signed 32-bit integer. |
96
+
|`u8`, `u16`, `u32`, `u64`| Unsigned integers of the appropriate width. For example, `u32` is an unsigned 32-bit integer. |
97
+
|`f32`, `f64`| Floating-point numbers of the appropriate width. For example, `f64` is a 64-bit (double precision) floating-point number. See the note on `NaN`s below. |
98
98
|`char`| Unicode character. (Specifically, a [Unicode scalar value](https://unicode.org/glossary/#unicode_scalar_value).) |
99
99
|`string`| A Unicode string - that is, a finite sequence of characters. |
100
100
101
-
The `f32` and `f64` types support the usual set of IEEE 754 single and double-precision values, except that they logically only have a single NaN value. The exact bit-level representation of a NaN is not guaranteed to be preserved when values pass through WIT interfaces.
101
+
> The `f32` and `f64` types support the usual set of IEEE 754 single and double-precision values, except that they logically only have a single `nan` value. The exact bit-level representation of an IEEE 754 `NaN` is not guaranteed to be preserved when values pass through WIT interfaces as the singular WIT `nan` value.
102
102
103
103
### Lists
104
104
105
-
`list<T>` for any type T denotes an ordered sequence of values of type T. T can be any type, built-in or user-defined:
105
+
`list<T>` for any type `T` denotes an ordered sequence of values of type `T`. `T` can be any type, built-in or user-defined:
106
106
107
107
```wit
108
-
list<u8> // byte buffer
109
-
list<customer> // a list of customers
108
+
list<u8> // byte buffer
109
+
list<customer> // a list of customers
110
110
```
111
111
112
112
This is similar to Rust `Vec`, or Java `List`.
113
113
114
114
### Options
115
115
116
-
`option<T>` for any type T may contain a value of type T, or may contain no value. T can be any type, built-in or user-defined. For example, a lookup function might return an option, allowing for the possibility that the lookup key wasn't found:
116
+
`option<T>` for any type `T` may contain a value of type `T`, or may contain no value. `T` can be any type, built-in or user-defined. For example, a lookup function might return an option, allowing for the possibility that the lookup key wasn't found:
117
117
118
118
```wit
119
119
option<customer>
@@ -125,7 +125,7 @@ This is similar to Rust `Option`, C++ `std::optional`, or Haskell `Maybe`.
125
125
126
126
### Results
127
127
128
-
`result<T, E>` for any types T and E may contain a value of type T_or_ a value of type E (but not both). This is typically used for "value or error" situations; for example, a HTTP request function might return a result, with the success case (the T type) representing a HTTP response, and the error case (the E type) representing the various kinds of error that might occur:
128
+
`result<T, E>` for any types `T` and `E `may contain a value of type `T`_or_ a value of type `E` (but not both). This is typically used for "value or error" situations; for example, a HTTP request function might return a result, with the success case (the `T` type) representing a HTTP response, and the error case (the `E` type) representing the various kinds of error that might occur:
129
129
130
130
```wit
131
131
result<http-response, http-error>
@@ -145,11 +145,11 @@ result // no data associated with either case
145
145
146
146
### Tuples
147
147
148
-
A tuple type is an ordered _fixed length_ sequence of values of specified types. It is similar to a [_record_](#records), except that the fields are identified by their order instead of by names.
148
+
A `tuple` type is an ordered _fixed length_ sequence of values of specified types. It is similar to a [_record_](#records), except that the fields are identified by their order instead of by names.
149
149
150
150
```wit
151
-
tuple<u64, string> // An integer and a string
152
-
tuple<u64, string, u64> // An integer, then a string, then an integer
151
+
tuple<u64, string> // An integer and a string
152
+
tuple<u64, string, u64> // An integer, then a string, then an integer
153
153
```
154
154
155
155
This is similar to tuples in Rust or OCaml.
@@ -160,7 +160,7 @@ You can define your own types within an `interface` or `world`. WIT offers sever
160
160
161
161
### Records
162
162
163
-
A record type declares a set of named fields, each of the form `name: type`, separated by commas. A record instance contains a value for every field. Field types can be built-in or user-defined. The syntax is as follows:
163
+
A `record` type declares a set of named fields, each of the form `name: type`, separated by commas. A record instance contains a value for every field. Field types can be built-in or user-defined. The syntax is as follows:
164
164
165
165
```wit
166
166
record customer {
@@ -177,7 +177,7 @@ Records are similar to C or Rust `struct`s.
177
177
178
178
### Variants
179
179
180
-
A variant type declares one or more cases. Each case has a name and, optionally, a type of data associated with that case. A variant instance contains exactly one case. Cases are separated by commas. The syntax is as follows:
180
+
A `variant` type declares one or more cases. Each case has a name and, optionally, a type of data associated with that case. A variant instance contains exactly one case. Cases are separated by commas. The syntax is as follows:
181
181
182
182
```wit
183
183
variant allowed-destinations {
@@ -193,7 +193,7 @@ Variants are similar to Rust `enum`s or OCaml discriminated unions. The closest
193
193
194
194
### Enums
195
195
196
-
An enum type is a variant type where none of the cases have associated data:
196
+
An `enum` type is a variant type where none of the cases have associated data:
197
197
198
198
```wit
199
199
enum color {
@@ -203,7 +203,7 @@ enum color {
203
203
}
204
204
```
205
205
206
-
This can provide a simpler representation in languages without discriminated unions. For example, a WIT enum can translate directly to a C++ `enum`.
206
+
This can provide a simpler representation in languages without discriminated unions. For example, a WIT `enum` can translate directly to a C++ `enum`.
> More precisely, these are borrowed or owned `handles` of the resource. Learn more about `handles` in the [upstream component model specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#handles).
259
257
260
258
### Flags
261
259
262
-
A flags type is a set of named booleans. In an instance of the type, each flag will be either true or false.
260
+
A `flags` type is a set of named booleans. In an instance of the type, each flag will be either `true` or `false`.
263
261
264
262
```wit
265
263
flags allowed-methods {
@@ -270,7 +268,7 @@ flags allowed-methods {
270
268
}
271
269
```
272
270
273
-
> A flags type is logically equivalent to a record type where each field is of type `bool`, but it is represented more efficiently (as a bitfield) at the binary level.
271
+
> A `flags` type is logically equivalent to a record type where each field is of type `bool`, but it is represented more efficiently (as a bitfield) at the binary level.
274
272
275
273
### Type aliases
276
274
@@ -292,10 +290,10 @@ do-nothing: func();
292
290
The function type is the word `func`, followed by a parenthesised, comma-separated list of parameters (names and types). If the function returns a value, this is expressed as an arrow symbol (`->`) followed by the return type:
/// The component implements the `printer` interface
366
+
// The component implements the `printer` interface
369
367
export printer;
370
-
/// The component implements the `scan` function
368
+
369
+
// The component implements the `scan` function
371
370
export scan: func() -> list<u8>;
372
-
/// The component needs to be supplied with an `error-reporter`
371
+
372
+
// The component needs to be supplied with an `error-reporter`
373
373
import error-reporter;
374
374
}
375
375
```
@@ -407,8 +407,10 @@ You can `include` another world. This causes your world to export all that world
407
407
408
408
```wit
409
409
world glow-in-the-dark-multi-function-device {
410
-
// The component provides all the same exports, and depends on all the same imports, as a `multi-function-device`...
410
+
// The component provides all the same exports, and depends on
411
+
// all the same imports, as a `multi-function-device`...
411
412
include multi-function-device;
413
+
412
414
// ...but also exports a function to make it glow in the dark
413
415
export glow: func(brightness: u8);
414
416
}
@@ -455,4 +457,4 @@ world proxy {
455
457
}
456
458
```
457
459
458
-
> ⓘ For a more formal definition of the WIT language, take a look at the [WIT specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md).
460
+
> For a more formal definition of the WIT language, take a look at the [WIT specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md).
Copy file name to clipboardExpand all lines: component-model/src/design/worlds.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -17,4 +17,4 @@ For a component to run, its imports must be fulfilled, by a host or by other com
17
17
* A (trivial) "HTTP proxy" world would export a "handle HTTP requests" interface, and import a "send HTTP requests" interface. A host, or another component, would call the exported "handle" interface, passing an HTTP request; the component would forward it on via the imported "send" interface. To be a _useful_ proxy, the component may also need to import interfaces such as I/O and clock time - without those imports the component could not perform, for example, on-disk caching.
18
18
* A "regex parser" world would export a "parse regex" function, and would import nothing. This declares not only that the component implementing this world can parse regular expressions, but also that it calls no other APIs. A user of such a parser could know, without looking at the implementation, that is does not access the file system, or send the user's regexes to a network service.
19
19
20
-
> ⓘ For a more formal definition of what a WIT world is, take a look at the [WIT world specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#wit-worlds).
20
+
> For a more formal definition of what a WIT world is, take a look at the [WIT world specification](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#wit-worlds).
> ⓘ This documentation is aimed at _users_ of the component model: developers of libraries and applications. _Compiler and Wasm runtime developers_ can take a look at the [Component Model specification](https://github.com/WebAssembly/component-model) to see how to add support for the component model to their project.
28
+
> This documentation is aimed at _users_ of the component model: developers of libraries and applications. _Compiler and Wasm runtime developers_ can take a look at the [Component Model specification](https://github.com/WebAssembly/component-model) to see how to add support for the component model to their project.
Copy file name to clipboardExpand all lines: component-model/src/language-support.md
+7-3Lines changed: 7 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,10 @@
3
3
WebAssembly can be targeted by the majority of top programming
4
4
languages; however, the level of
5
5
support varies. This document details the subset of languages that target WASI and support
6
-
components. This is a living document, so if you are aware of advancements in a toolchain, please do
7
-
not hesitate to [contribute documentation](https://github.com/bytecodealliance/component-docs/blob/main/CONTRIBUTING.md). You can find more information about the development of support for specific languages [here](https://github.com/bytecodealliance/governance/blob/main/SIGs/SIG-guest-languages/proposal.md). Each section covers how to build and
8
-
run components for a given toolchain.
6
+
components.
7
+
8
+
> This is a living document, so if you are aware of advancements in a toolchain, please do
9
+
not hesitate to [contribute documentation](https://github.com/bytecodealliance/component-docs/blob/main/CONTRIBUTING.md). You can find more information about the development of support for specific languages in the [Guest Languages Special Interest Group Proposal](https://github.com/bytecodealliance/governance/blob/main/SIGs/SIG-guest-languages/proposal.md) document.
9
10
10
11
One of the benefits of components is their portability across host runtimes. The runtime only needs
11
12
to know what world the component is targeting in order to import or execute the component. This
@@ -16,6 +17,9 @@ toolchain section walks through creating a component of this world, which can be
16
17
example host or from an application of that toolchain. This aims to provide a full story for using
0 commit comments