Skip to content

UXPathComp

UXPathComp is one segment of a UXPath: a single directory or file name, with no separators.

#use <UXKit> // or #import "UXPath.xc"
class UXPathComp : Object {
u8* s; // the name, NUL-terminated, no '/'
}

The class has one field.

UXPath keeps its components in an Array, and an Array holds Objects, so a bare u8* cannot go in one. UXPathComp is the box that lets a C string live in a collection.

UXStrItem and UXKVEntry exist for the same reason. Boxing is explicit, so the wrapper appears in the type and not only in the implementation.

You rarely name it directly: UXPath.component(i) unwraps it and returns the u8*.

for (i32 i = 0; i < p.count(); i = i + 1) {
Stdio.printf(" %s\n", p.component(i)); // no UXPathComp in sight
}

It matters for the breadcrumb bar. A path bar shows a normalized path’s components, one control per box, and each crumb needs something with identity to hang a target/action on.

u8* s

s is not owned in any managed sense. It is a raw pointer, and whoever allocated it decides who frees it. In practice UXPath always gives it bytes it allocated itself (parse and appendingComponent both copy), so the component owns its name for as long as the path lives.

The exception is UXPath.copy, which makes new boxes that share the original’s buffers. Nothing in the toolkit writes through a component pointer, so the sharing is invisible. Do not write through one yourself.

init sets s to "" instead of null, so a new component is safe to print before it is filled in.

u8* s

The component name. No separators, never null after init.

  • UXPath: the path these make up
  • UXStrItem: the same boxing for a general string list