OLD | NEW |
1 # C bindings guide | 1 # C bindings guide |
2 | 2 |
3 The Mojo C bindings are a way to talk the Mojom protocol, the canonical protocol | 3 The Mojo C bindings are a way to talk the Mojom protocol, the canonical protocol |
4 for communication between Mojo programs. The library under `bindings/` provides | 4 for communication between Mojo programs. The library under `bindings/` provides |
5 functionality for encoding, decoding and other computation, so it needs to be | 5 functionality for encoding, decoding and other computation, so it needs to be |
6 linked together with C code generated from .mojom files. These C bindings are | 6 linked together with C code generated from .mojom files. These C bindings are |
7 lower-level than the C++ bindings (or any other language, for that matter), | 7 lower-level than the C++ bindings (or any other language, for that matter), |
8 are more error-prone, and require some knowledge of the C Mojo API and the | 8 are more error-prone, and require some knowledge of the C Mojo API and the |
9 mojom encoding format. This document assumes the reader knows about (or knows | 9 mojom encoding format. This document assumes the reader knows about (or knows |
10 how to look up) this relevant information. Consequently, C bindings can also | 10 how to look up) this relevant information. Consequently, C bindings can also |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 as the number of bytes (minus the header). By convention, mojom strings are not | 361 as the number of bytes (minus the header). By convention, mojom strings are not |
362 null-terminated. | 362 null-terminated. |
363 | 363 |
364 ## Maps | 364 ## Maps |
365 | 365 |
366 Maps on the wire are mojom structs with two arrays; one for the keys, and one | 366 Maps on the wire are mojom structs with two arrays; one for the keys, and one |
367 for the values. The `i`th element in the keys array corresponds to the `i`th | 367 for the values. The `i`th element in the keys array corresponds to the `i`th |
368 element in the values array. As such, both arrays must have the same number | 368 element in the values array. As such, both arrays must have the same number |
369 of elements, and neither may be null. | 369 of elements, and neither may be null. |
370 | 370 |
371 # Numbers on generated bindings. | 371 # Additional Readings |
372 | 372 * [Internals of the generated bindings](INTERNALS.md) |
373 TODO(vardhan): Probably as a separate doc? | |
OLD | NEW |