summaryrefslogtreecommitdiff
path: root/docs/typ
diff options
context:
space:
mode:
Diffstat (limited to 'docs/typ')
-rw-r--r--docs/typ/building.typ20
1 files changed, 18 insertions, 2 deletions
diff --git a/docs/typ/building.typ b/docs/typ/building.typ
index 69468042..9a0bab44 100644
--- a/docs/typ/building.typ
+++ b/docs/typ/building.typ
@@ -226,9 +226,25 @@ manifest does not have fails the configure. The module is
[`memory`, `_initialize`], [its memory, and what a reactor runs once before any other call],
[`reserve(len)`, `release(ptr, len)`], [`len` bytes for the page to write an argument into (at least one, so `reserve(0)` is a pointer too), and their return],
[`highlight(path, path_len, text, len)`], [(a module with a language) a style byte for each byte of `text`: 0 none, 1 keyword, 2 string, 3 number, 4 comment, as pardes colours the file `path` names by its extension; all 0 for a path of another language. The module's until the next `highlight`],
- [`patch(text, len)`], [the diff `text` stacked as the patch view shows it, with no file and no colours: a pointer to a header. The module's until the next `patch`],
+ [`patch(text, len)`], [the diff `text` stacked as the patch view shows it, with no file and no colours: a pointer to a header. The module's until the next `patch` or `patchFile`],
+ [`patchFile(text, len, file, file_len)`], [(a module with a language) `patch` with `file`, the text of the file the diff's first section names, the new one's or the old one's: each hunk is found in it and stacks under the declarations it sits in, from the file's parse (`declaration` rows), as the editor's +Diff does; a hunk the text does not hold, and the diff's other files, stack as with no file. The same header and records as `patch`],
)
+xit writes its hunks' `@@` with nothing after it; with the file's text a
+hunk still gets what it sits in. A page holding a commit's diff of
+`src/lib.rs` and the file's new text calls (`put` copies bytes into a
+`reserve`d buffer and gives the pointer and length):
+
+```
+const [d, dn] = put(diffBytes), [f, fn] = put(fileBytes);
+const header = rust.exports.patchFile(d, dn, f, fn); // as patch's
+```
+
+and reads the rows as it reads `patch`'s. With the new text the labels and
+declarations are numbered as the new file is; with the old text, as the
+old one. Its cost is the file's parse: 18 ms against `patch`'s 4 for a
+28-hunk diff of a 1,100-line Zig file, under node.
+
Each returns 0 when its memory runs out. Pointers and lengths are
wasm32's: unsigned 32-bit; in memory they are little-endian. `patch`'s
header is five u32, 20 bytes:
@@ -242,7 +258,7 @@ header is five u32, 20 bytes:
and a row's record:
#pairs(
- [0 `kind`], [0 other, 1 meta, 2 hunk, 3 declaration (git's words after the `@@`), 4 context, 5 added, 6 removed],
+ [0 `kind`], [0 other, 1 meta, 2 hunk, 3 declaration (git's words after the `@@`; with `patchFile`, a declaration's `path:line`, whose `code_start` is its whole length, and its header's lines), 4 context, 5 added, 6 removed],
[4 `old`, 8 `new`], [its numbers in the old and the new file, from 1; 0 where it has none],
[12 `code_start`], [where its code starts in its text: after a hunk label's `path:line` and stars],
[16 `text_offset`, 20 `text_len`], [its text, without its line end (the `\n`, and a `\r` before it), in the header's `text`],