The module sample
A module of commands that take a record, a handle or a table (property 19). A record is bytes with described fields: the caller and the module read the same layout. A handle is lent for the time of one call, with the rights that the description names and no other right. A table is records of one description in memory of the caller, with a direction: Read, Change or Append. The console calls it with load("sample"), isolate("sample") or connect("sample"): the module has an entry, so the same module also runs as a program that serves its exports. A service holds no export that is wrong on purpose: those are in the module hostile_exports, which no service holds.
| Fact | Value |
|---|---|
| Source | modules/sample |
| Boot image | in the boot image; the image is not built, so its size is not known |
| Imports | none |
| Imported by | none |
Exports
| Export | What it does |
|---|---|
| area(rectangle: Rectangle) -> Integer | gives the width of a rectangle times its height |
| grow(rectangle: Rectangle, by: Integer) -> Rectangle | gives a rectangle with a margin of `by` on each side |
| fill(memory: Handle(Read, Write), value: Integer) -> Integer | writes a value in each byte of a memory object, and gives the count of bytes |
| total(memory: Handle(Read)) -> Integer | adds the bytes of a memory object |
| span_total(span: Span) -> Integer | adds the bytes of a part of a memory object |
| spoil(memory: Handle(Read)) -> Integer | tries to write in a memory object that the caller lent to read |
| readings(count: Integer) -> Table(Reading) | gives a table of `count` readings: sensor n, time n, value 10 * (n + 1) |
| sum_values(readings: Table(Reading, Read)) -> Integer | gives the sum of the values of a table of readings |
| scale_values(readings: Table(Reading, Change), factor: Integer) -> Integer | multiplies the value, the minimum and the maximum of each reading by a factor, in the memory of the caller (the direction Change), and gives the count of readings |
| append_readings(count: Integer, first_value: Integer, readings: Table(Reading, Append)) -> Integer | appends `count` readings after those of the table (the direction Append): sensor n, time n, value first_value + n |
| sum_words(words: Table(Word, Change), text: Bytes(Read)) -> Integer | writes in each word the sum of the bytes of the text that the word names, and gives the sum of all |
| upper_case(text: Bytes(Change)) -> Integer | changes each letter of a range of bytes to upper case, in the memory of the caller (Bytes with the direction Change), and gives the count of letters that it changed |
| scale_values_up_to(readings: Table(Reading, Change), factor: Integer, largest_value: Integer) -> Integer | multiplies the value, the minimum and the maximum of each reading by a factor, in order, in the memory of the caller (the direction Change), while each new value stays at most largest_value, and gives the count of readings |
| entry() |
Read from the source of the module, as the build reads it to describe the exports (tools/kerneltool/describe.odin).
