|
| 1 | +# C Base Code |
| 2 | + |
| 3 | +This directory (`base`) and its sibling |
| 4 | +([`auxiliary`](/internal/cgen/auxiliary)) contain C and C++ code respectively. |
| 5 | +This C/C++ code combines with the transpiled-to-C/C++ form of the Wuffs code in |
| 6 | +the top-level [`std`](/std) directory to create the "single file C/C++ library" |
| 7 | +form of the Wuffs standard library. |
| 8 | + |
| 9 | +- From Wuffs-the-language's point of view, this directory contains |
| 10 | + implementations of the built-in `base` package types, such as [I/O |
| 11 | + buffers](/doc/note/io-input-output.md), [ranges and |
| 12 | + rects](/doc/note/ranges-and-rects.md) and [statuses](/doc/note/statuses.md). |
| 13 | +- From application code's point of view (Wuffs is for writing libraries not |
| 14 | + applications), this directory also contains helper functions for working with |
| 15 | + those `base` types, such as constructing an I/O buffer from a pointer and a |
| 16 | + length, that aren't relevant to Wuffs-the-language code. |
| 17 | +- This directory also contains some functionality (e.g. pixel conversion and |
| 18 | + string conversion) that, in the future, could possibly be Wuffs packages |
| 19 | + under `std`. For optimal performance, they sometimes require programming |
| 20 | + language features (e.g. function-pointer typed variables, SIMD acceleration) |
| 21 | + that are not yet available in Wuffs-the-language (or were not available at |
| 22 | + the time they were added). In the short term, it was more practical to |
| 23 | + implement them in carefully hand-written C/C++, in this directory. In the |
| 24 | + long term, they could migrate out of `base` to be under `std`, but any `base` |
| 25 | + API removal would require a Wuffs version number bump. |
| 26 | + |
| 27 | + |
| 28 | +## Making Changes |
| 29 | + |
| 30 | +After editing source code in this directory, to see those changes when |
| 31 | +generating the C/C++ form of Wuffs' standard library: |
| 32 | + |
| 33 | + go install github.com/google/wuffs/cmd/wuffs-c && wuffs gen base |
| 34 | + |
| 35 | +This should modify the |
| 36 | +[`wuffs-unsupported-snapshot.c`](/release/c/wuffs-unsupported-snapshot.c) file. |
0 commit comments