nomen-lang 0.2.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/NOMEN_AGENTS.md +7 -1
  2. package/core/System/Arena.nm +166 -0
  3. package/core/System/Array.nm +30 -161
  4. package/core/System/BigInt.nm +36 -57
  5. package/core/System/Buffer.nm +197 -279
  6. package/core/System/ClassBuffer.nm +120 -130
  7. package/core/System/Console.nm +4 -2
  8. package/core/System/Controls/Button.nm +4 -4
  9. package/core/System/Controls/CheckBox.nm +1 -1
  10. package/core/System/Controls/LayoutParams.nm +1 -1
  11. package/core/System/Controls/Text.nm +2 -2
  12. package/core/System/Controls/TextBox.nm +6 -6
  13. package/core/System/Controls/Window.nm +2 -2
  14. package/core/System/Graph.nm +4 -4
  15. package/core/System/LinkedList.nm +4 -4
  16. package/core/System/List.nm +6 -6
  17. package/core/System/Map.nm +33 -30
  18. package/core/System/Set.nm +24 -24
  19. package/core/System/Stream/Directory.nm +4 -4
  20. package/core/System/Stream/File.nm +19 -12
  21. package/core/System/String.nm +300 -34
  22. package/core/System/StringBuilder.nm +53 -117
  23. package/core/System/Text/CharIndex.nm +144 -0
  24. package/core/System/Text/Chars.nm +32 -0
  25. package/core/System/Text/JsonTree.nm +48 -96
  26. package/core/System/Text/Regex.nm +726 -40
  27. package/core/System/Text/Utf8.nm +163 -0
  28. package/core/System/bool.nm +2 -1
  29. package/core/System/char.nm +27 -1
  30. package/core/System/float.nm +2 -1
  31. package/core/System/float32.nm +2 -1
  32. package/core/System/float64.nm +2 -1
  33. package/core/System/int.nm +4 -2
  34. package/core/System/int16.nm +2 -1
  35. package/core/System/int32.nm +2 -1
  36. package/core/System/int64.nm +2 -1
  37. package/core/System/int8.nm +2 -1
  38. package/core/System/ufloat.nm +2 -1
  39. package/core/System/ufloat32.nm +2 -1
  40. package/core/System/ufloat64.nm +2 -1
  41. package/core/System/uint.nm +2 -1
  42. package/core/System/uint16.nm +2 -1
  43. package/core/System/uint32.nm +2 -1
  44. package/core/System/uint64.nm +2 -1
  45. package/core/System/uint8.nm +2 -1
  46. package/core/docs/System/BigInt.md +0 -1
  47. package/dist/index.mjs +5273 -1339
  48. package/package.json +1 -1
  49. package/src/index.ts +58 -7
@@ -8,76 +8,43 @@
8
8
  * A flat buffer of owned class pointers of type T — the backing store for collections of classes
9
9
  **/
10
10
  pub struct ClassBuffer<T> {
11
- var uint64 data = 0
12
- var cap = 0
11
+ internal var uint64 data = 0
12
+ // Publicly readable; grown only by ClassBuffer's own methods (`readonly`).
13
+ readonly cap = 0
13
14
 
14
- func alloc_int = (ref self, int size, out int: out >= size) {
15
- ```
16
- #arch: c
17
- self->cap = size;
18
- self->data = (unsigned long long)(long*)calloc(size, sizeof(long));
19
- return self->cap;
20
- ```
21
- ```
22
- #arch: aarch64
23
- str x1, [x19, #16]
24
- mov x0, x1
25
- mov x1, #8
26
- bl _calloc
27
- str x0, [x19, #8]
28
- ldr x0, [x19, #16]
29
- ```
15
+ internal func alloc_int = (ref self, int size, out int: out >= size) {
16
+ self.cap = size
17
+ self.data = calloc(size, 8)
18
+ return self.cap
30
19
  }
31
20
 
32
- func grow_int = (ref self, int needed, out int: out >= needed) {
33
- ```
34
- #arch: c
35
- if (self->cap >= needed) return self->cap;
36
- int new_cap = self->cap;
37
- if (new_cap == 0) new_cap = 4;
38
- while (new_cap < needed) new_cap *= 2;
39
- self->data = (unsigned long long)(long*)realloc((long*)(unsigned long long)self->data, new_cap * sizeof(long));
40
- memset((long*)(unsigned long long)self->data + self->cap, 0, (new_cap - self->cap) * sizeof(long));
41
- self->cap = new_cap;
42
- return self->cap;
43
- ```
44
- ```
45
- #arch: aarch64
46
- ldr x2, [x19, #16]
47
- cmp x2, x1
48
- b.ge .Lcb_grow_end
49
- mov x3, #4
50
- cmp x2, #0
51
- csel x3, x3, x2, eq
52
- cmp x3, x1
53
- b.ge .Lcb_grow_got
54
- .Lcb_grow_loop:
55
- lsl x3, x3, #1
56
- cmp x3, x1
57
- b.lt .Lcb_grow_loop
58
- .Lcb_grow_got:
59
- sub sp, sp, #16
60
- str x2, [sp, #0]
61
- str x3, [sp, #8]
62
- ldr x0, [x19, #8]
63
- lsl x1, x3, #3
64
- bl _realloc
65
- str x0, [x19, #8]
66
- ldr x2, [sp, #0]
67
- ldr x3, [sp, #8]
68
- add sp, sp, #16
69
- str x3, [x19, #16]
70
- add x0, x0, x2, lsl #3
71
- mov x1, #0
72
- sub x2, x3, x2
73
- lsl x2, x2, #3
74
- bl _memset
75
- .Lcb_grow_end:
76
- ldr x0, [x19, #16]
77
- ```
21
+ // Semantic parity with Buffer<T>.alloc: generic code (e.g. Map#init's
22
+ // `self.values.alloc(N)`) forwards to either Buffer — where alloc is
23
+ // T_SIZE-aware (string slots are 16 bytes) — or this ClassBuffer, whose
24
+ // slots are always one pointer wide. The compiler routes value-struct
25
+ // element types to Buffer and class/trait elements to ClassBuffer
26
+ // (monomorphize's field rewrite), so a call arriving HERE is always
27
+ // pointer-sized: delegate to alloc_int.
28
+ func alloc = (ref self, int size, out int: out >= size) {
29
+ return self.alloc_int(size)
30
+ }
31
+
32
+ internal func grow_int = (ref self, int needed, out int: out >= needed) {
33
+ if self.cap >= needed {
34
+ return self.cap
35
+ }
36
+ var int new_cap = self.cap
37
+ if new_cap == 0 {
38
+ new_cap = 4
39
+ }
40
+ while new_cap < needed; new_cap *= 2 {}
41
+ self.data = realloc(self.data, new_cap * 8)
42
+ memset(self.data + self.cap * 8, 0, (new_cap - self.cap) * 8)
43
+ self.cap = new_cap
44
+ return self.cap
78
45
  }
79
46
 
80
- inline func load_int = (self, int i: i >= 0 && i < self.cap, out int) {
47
+ internal inline func load_int = (self, int i: i >= 0 && i < self.cap, out int) {
81
48
  ```
82
49
  #arch: c
83
50
  return ((long*)(unsigned long long)self->data)[i];
@@ -91,62 +58,29 @@ pub struct ClassBuffer<T> {
91
58
  ```
92
59
  }
93
60
 
94
- // T_SIZE-aware aliases of the _int primitives. ClassBuffer only ever holds
95
- // 8-byte class pointers (T_SIZE is 8), so these are behaviorally identical
96
- // to their _int counterparts — they exist so List<T> can call a single
97
- // uniform `_T` API whether T is a value struct (Buffer) or a class
98
- // (ClassBuffer, after the Buffer<T> field is rewritten). Bodies use 8-byte
99
- // slots, matching _int.
61
+ // Generic (T-typed) counterparts of the _int primitives. ClassBuffer only
62
+ // ever holds 8-byte class pointers (T_SIZE is 8), so these are
63
+ // behaviorally identical to their _int counterparts — they exist so
64
+ // List<T> can call a single uniform API whether T is a value struct
65
+ // (Buffer) or a class (ClassBuffer, after the Buffer<T> field is
66
+ // rewritten). Bodies use 8-byte slots, matching _int.
100
67
 
101
- func grow_T = (ref self, int needed, out int: out >= needed) {
102
- ```
103
- #arch: c
104
- if (self->cap >= needed) return self->cap;
105
- int new_cap = self->cap;
106
- if (new_cap == 0) new_cap = 4;
107
- while (new_cap < needed) new_cap *= 2;
108
- self->data = (unsigned long long)(long*)realloc((long*)(unsigned long long)self->data, new_cap * sizeof(long));
109
- memset((long*)(unsigned long long)self->data + self->cap, 0, (new_cap - self->cap) * sizeof(long));
110
- self->cap = new_cap;
111
- return self->cap;
112
- ```
113
- ```
114
- #arch: aarch64
115
- ldr x2, [x19, #16]
116
- cmp x2, x1
117
- b.ge .Lcb_grow_T_end
118
- mov x3, #4
119
- cmp x2, #0
120
- csel x3, x3, x2, eq
121
- cmp x3, x1
122
- b.ge .Lcb_grow_T_got
123
- .Lcb_grow_T_loop:
124
- lsl x3, x3, #1
125
- cmp x3, x1
126
- b.lt .Lcb_grow_T_loop
127
- .Lcb_grow_T_got:
128
- sub sp, sp, #16
129
- str x2, [sp, #0]
130
- str x3, [sp, #8]
131
- ldr x0, [x19, #8]
132
- lsl x1, x3, #3
133
- bl _realloc
134
- str x0, [x19, #8]
135
- ldr x2, [sp, #0]
136
- ldr x3, [sp, #8]
137
- add sp, sp, #16
138
- str x3, [x19, #16]
139
- add x0, x0, x2, lsl #3
140
- mov x1, #0
141
- sub x2, x3, x2
142
- lsl x2, x2, #3
143
- bl _memset
144
- .Lcb_grow_T_end:
145
- ldr x0, [x19, #16]
146
- ```
68
+ func grow = (ref self, int needed, out int: out >= needed) {
69
+ if self.cap >= needed {
70
+ return self.cap
71
+ }
72
+ var int new_cap = self.cap
73
+ if new_cap == 0 {
74
+ new_cap = 4
75
+ }
76
+ while new_cap < needed; new_cap *= 2 {}
77
+ self.data = realloc(self.data, new_cap * 8)
78
+ memset(self.data + self.cap * 8, 0, (new_cap - self.cap) * 8)
79
+ self.cap = new_cap
80
+ return self.cap
147
81
  }
148
82
 
149
- inline func load_T = (self, int i: i >= 0 && i < self.cap, out T) {
83
+ inline func load = (self, int i: i >= 0 && i < self.cap, out T) {
150
84
  ```
151
85
  #arch: c
152
86
  return (void*)((long*)(unsigned long long)self->data)[i];
@@ -160,7 +94,16 @@ pub struct ClassBuffer<T> {
160
94
  ```
161
95
  }
162
96
 
163
- inline func store_T = (ref self, int i: i >= 0 && i < self.cap, T val: val != 0) {
97
+ // Store the owned class pointer `val` into slot `i`, which MUST be fresh
98
+ // (calloc'd, or zeroed by move/move_int). Takes OWNERSHIP of `val`
99
+ // (`move`): the slot's #destroy reclaims the instance, so the caller must
100
+ // not free its copy — a fresh constructor result transfers here directly,
101
+ // and a local must be moved (its own cleanup is suppressed at the call
102
+ // site). This is a plain pointer store — it does NOT destroy/free the
103
+ // slot's previous occupant, so a second `store` at an occupied index
104
+ // leaks that instance. Use replace (or replace_int) to overwrite a live
105
+ // slot.
106
+ internal inline func store = (ref self, int i: i >= 0 && i < self.cap, move T val: val != 0) {
164
107
  ```
165
108
  #arch: c
166
109
  ((long*)(unsigned long long)self->data)[i] = (long)val;
@@ -178,11 +121,11 @@ pub struct ClassBuffer<T> {
178
121
  // buffer no longer references it. Declared `move out T` so the borrow
179
122
  // checker treats the result as OWNED — the slot is relinquished, so the
180
123
  // caller is the sole remaining owner. This is the owning-extract primitive
181
- // (parallel to List.pop); use it (not load_T) when transferring ownership
124
+ // (parallel to List.pop); use it (not load) when transferring ownership
182
125
  // out of a ClassBuffer slot, or moving a value into a fresh owning
183
- // container — load_T returns a BORROW (the slot is unchanged) and storing
126
+ // container — load returns a BORROW (the slot is unchanged) and storing
184
127
  // it elsewhere would create shared ownership (double-free at destroy).
185
- inline func move_T = (ref self, int i: i >= 0 && i < self.cap, move out T) {
128
+ inline func move = (ref self, int i: i >= 0 && i < self.cap, move out T) {
186
129
  ```
187
130
  #arch: c
188
131
  long *slots = (long*)(unsigned long long)self->data;
@@ -200,7 +143,52 @@ pub struct ClassBuffer<T> {
200
143
  ```
201
144
  }
202
145
 
203
- inline func store_int = (ref self, int i: i >= 0 && i < self.cap, int val: val != 0) {
146
+ // Apply `f` to slot `i` in place — the owning-counterpart of Buffer's
147
+ // modify for class elements. `f` receives the current instance pointer
148
+ // as a borrow and returns the replacement instance (fresh, or the same
149
+ // pointer); the primitive frees the displaced instance (destroy + free)
150
+ // unless `f` returned it. Storing the returned instance raw is sound:
151
+ // the slot takes sole ownership and `f`'s return is not retained
152
+ // elsewhere. NOT `inline`: the body calls through the fn pointer.
153
+ func modify = (ref self, int i: i >= 0 && i < self.cap, func (T, out T) f) {
154
+ ```
155
+ #arch: c
156
+ long *slots = (long*)(unsigned long long)self->data;
157
+ void *old = (void*)slots[i];
158
+ void *new_value = (void*)f(old);
159
+ slots[i] = (long)new_value;
160
+ if (old != new_value) {
161
+ T_destroy(old);
162
+ free(old);
163
+ }
164
+ ```
165
+ ```
166
+ #arch: aarch64
167
+ // x19 = self, x1 = i, x2 = f. Class slots are one pointer wide.
168
+ stp x20, x21, [sp, #-16]!
169
+ stp x22, x23, [sp, #-16]!
170
+ mov x22, x2
171
+ ldr x9, [x19, #8]
172
+ lsl x3, x1, #3
173
+ add x20, x9, x3
174
+ ldr x0, [x20]
175
+ blr x22
176
+ mov x23, x0
177
+ ldr x9, [x20]
178
+ str x23, [x20]
179
+ cmp x9, x23
180
+ b.eq .Lcb_modify_T_done
181
+ mov x0, x9
182
+ bl T_destroy
183
+ mov x0, x9
184
+ bl _free
185
+ .Lcb_modify_T_done:
186
+ ldp x22, x23, [sp], #16
187
+ ldp x20, x21, [sp], #16
188
+ ```
189
+ }
190
+
191
+ internal inline func store_int = (ref self, int i: i >= 0 && i < self.cap, int val: val != 0) {
204
192
  ```
205
193
  #arch: c
206
194
  ((long*)(unsigned long long)self->data)[i] = val;
@@ -214,7 +202,7 @@ pub struct ClassBuffer<T> {
214
202
  ```
215
203
  }
216
204
 
217
- inline func move_int = (ref self, int i: i >= 0 && i < self.cap, out int) {
205
+ internal inline func move_int = (ref self, int i: i >= 0 && i < self.cap, out int) {
218
206
  ```
219
207
  #arch: c
220
208
  long *slots = (long*)(unsigned long long)self->data;
@@ -234,7 +222,7 @@ pub struct ClassBuffer<T> {
234
222
 
235
223
  // Store into a slot, freeing the previous value (it is an owned class
236
224
  // pointer): run its destroy then free it before overwriting.
237
- func replace_int = (ref self, int i: i >= 0 && i < self.cap, int val: val != 0) {
225
+ internal func replace_int = (ref self, int i: i >= 0 && i < self.cap, int val: val != 0) {
238
226
  ```
239
227
  #arch: c
240
228
  long *slots = (long*)(unsigned long long)self->data;
@@ -266,9 +254,11 @@ pub struct ClassBuffer<T> {
266
254
  }
267
255
 
268
256
  // T-typed alias of replace_int: free the outgoing class pointer (destroy +
269
- // free) then store the new one. Used by List.set so the uniform `_T` API
257
+ // free) then store the new one. Used by List.set so the uniform API
270
258
  // preserves ownership for class elements.
271
- func replace_T = (ref self, int i: i >= 0 && i < self.cap, T val: val != 0) {
259
+ // Overwrite a live slot: destroy + free the displaced instance, then take
260
+ // OWNERSHIP of `val` (`move`) — same transfer rule as store.
261
+ func replace = (ref self, int i: i >= 0 && i < self.cap, move T val: val != 0) {
272
262
  ```
273
263
  #arch: c
274
264
  long *slots = (long*)(unsigned long long)self->data;
@@ -301,10 +291,10 @@ pub struct ClassBuffer<T> {
301
291
 
302
292
  // Move slot src into slot dst: reclaim dst's previous instance (destroy +
303
293
  // free), take over src's pointer, and zero src — exactly one slot owns the
304
- // instance afterwards. The class-buffer counterpart of Buffer.shift_T,
294
+ // instance afterwards. The class-buffer counterpart of Buffer.shift,
305
295
  // used by Map/Set.remove's backward-shift so shifting entries neither
306
296
  // duplicates nor orphans owned instances.
307
- func shift_T = (ref self, int dst: dst >= 0 && dst < self.cap, int src: src >= 0 && src < self.cap) {
297
+ func shift = (ref self, int dst: dst >= 0 && dst < self.cap, int src: src >= 0 && src < self.cap) {
308
298
  ```
309
299
  #arch: c
310
300
  long *slots = (long*)(unsigned long long)self->data;
@@ -348,7 +338,7 @@ pub struct ClassBuffer<T> {
348
338
  // pointers, returned as a `view T` (T is a class, so each element is an
349
339
  // 8-byte pointer). Borrows from self — invalidated on reassignment. Mirrors
350
340
  // Buffer.slice; ClassBuffer stores 8-byte slots, so the element width is 8.
351
- func slice = (self, int start: start >= 0, int end: end >= start, out view T) {
341
+ func slice = (self, int start: start >= 0, int end: end >= start && end <= self.cap, out view T) {
352
342
  ```
353
343
  #arch: c
354
344
  nomen_view _r;
@@ -5,7 +5,9 @@ pub struct Console {
5
5
  pub func write = (string line) {
6
6
  ```
7
7
  #arch: c
8
- printf("%s", line);
8
+ // Fat-string ABI: strings pass their ptr half. printf %s stops at
9
+ // the first embedded NUL on both backends (known display limit).
10
+ printf("%s", line.ptr);
9
11
  ```
10
12
  ```
11
13
  #arch: aarch64
@@ -25,7 +27,7 @@ pub struct Console {
25
27
  pub func write_line = (string line) {
26
28
  ```
27
29
  #arch: c
28
- printf("%s\n", line);
30
+ printf("%s\n", line.ptr);
29
31
  ```
30
32
  ```
31
33
  #arch: aarch64
@@ -17,7 +17,7 @@ pub class Button : Control {
17
17
  ((void(*)(id, SEL, id))objc_msgSend)(
18
18
  btn, sel_registerName("setTitle:"),
19
19
  ((id(*)(id, SEL, const char*))objc_msgSend)(
20
- (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title));
20
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
21
21
  id contentView = ((id(*)(id, SEL))objc_msgSend)(
22
22
  (id)window->handle, sel_registerName("contentView"));
23
23
  ((void(*)(id, SEL, id))objc_msgSend)(
@@ -53,7 +53,7 @@ pub class Button : Control {
53
53
  ((void(*)(id, SEL, unsigned long, id, id))objc_msgSend)(
54
54
  btn, sel_registerName("setTitle:forState:"),
55
55
  ((id(*)(id, SEL, const char*))objc_msgSend)(
56
- (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title),
56
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr),
57
57
  0); // UIControlStateNormal = 0
58
58
  id parentView = ((id(*)(id, SEL))objc_msgSend)(
59
59
  ((id(*)(id, SEL))objc_msgSend)(
@@ -123,7 +123,7 @@ pub class Button : Control {
123
123
  ((void(*)(id, SEL, id))objc_msgSend)(
124
124
  (id)self->handle, sel_registerName("setTitle:"),
125
125
  ((id(*)(id, SEL, const char*))objc_msgSend)(
126
- (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title));
126
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
127
127
  ```
128
128
  ```
129
129
  #arch: aarch64_use_c
@@ -139,7 +139,7 @@ pub class Button : Control {
139
139
  ((void(*)(id, SEL, unsigned long, id, id))objc_msgSend)(
140
140
  (id)self->handle, sel_registerName("setTitle:forState:"),
141
141
  ((id(*)(id, SEL, const char*))objc_msgSend)(
142
- (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title),
142
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr),
143
143
  0); // UIControlStateNormal = 0
144
144
  ```
145
145
  ```
@@ -109,7 +109,7 @@ pub class CheckBox : Control {
109
109
  ((void(*)(id, SEL, id))objc_msgSend)(
110
110
  (id)self->handle, sel_registerName("setTitle:"),
111
111
  ((id(*)(id, SEL, const char*))objc_msgSend)(
112
- (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title));
112
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
113
113
  ```
114
114
  ```
115
115
  #arch: aarch64_use_c
@@ -41,7 +41,7 @@ pub struct LayoutParams {
41
41
  }
42
42
 
43
43
  // Sensible defaults so most children just work
44
- const LayoutParams DEFAULT_PARAMS = LayoutParams() + [
44
+ const LayoutParams DEFAULT_PARAMS = [ .. LayoutParams(),
45
45
  width = .auto,
46
46
  height = .auto,
47
47
  grow = 0,
@@ -100,7 +100,7 @@ pub class Text: Control {
100
100
  ((void(*)(id, SEL, id))objc_msgSend)(
101
101
  (id)self->handle, sel_registerName("setStringValue:"),
102
102
  ((id(*)(id, SEL, const char*))objc_msgSend)(
103
- (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text));
103
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
104
104
  ```
105
105
  ```
106
106
  #arch: aarch64_use_c
@@ -116,7 +116,7 @@ pub class Text: Control {
116
116
  ((void(*)(id, SEL, id))objc_msgSend)(
117
117
  (id)self->handle, sel_registerName("setText:"),
118
118
  ((id(*)(id, SEL, const char*))objc_msgSend)(
119
- (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text));
119
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
120
120
  ```
121
121
  ```
122
122
  #arch: aarch64_use_c
@@ -133,7 +133,7 @@ pub class TextBox : Control {
133
133
  ((void(*)(id, SEL, id))objc_msgSend)(
134
134
  (id)self->handle, sel_registerName("setStringValue:"),
135
135
  ((id(*)(id, SEL, const char*))objc_msgSend)(
136
- (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text));
136
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
137
137
  ```
138
138
  ```
139
139
  #arch: aarch64_use_c
@@ -149,7 +149,7 @@ pub class TextBox : Control {
149
149
  ((void(*)(id, SEL, id))objc_msgSend)(
150
150
  (id)self->handle, sel_registerName("setText:"),
151
151
  ((id(*)(id, SEL, const char*))objc_msgSend)(
152
- (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text));
152
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), text.ptr));
153
153
  ```
154
154
  ```
155
155
  #arch: aarch64_use_c
@@ -169,7 +169,7 @@ pub class TextBox : Control {
169
169
  (id)self->handle, sel_registerName("stringValue"));
170
170
  const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
171
171
  str, sel_registerName("UTF8String"));
172
- return strdup(cstr);
172
+ return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
173
173
  ```
174
174
  ```
175
175
  #arch: aarch64_use_c
@@ -178,7 +178,7 @@ pub class TextBox : Control {
178
178
  (id)self->handle, sel_registerName("stringValue"));
179
179
  const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
180
180
  str, sel_registerName("UTF8String"));
181
- return strdup(cstr);
181
+ return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
182
182
  ```
183
183
  ```
184
184
  #arch: c
@@ -187,7 +187,7 @@ pub class TextBox : Control {
187
187
  (id)self->handle, sel_registerName("text"));
188
188
  const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
189
189
  str, sel_registerName("UTF8String"));
190
- return strdup(cstr);
190
+ return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
191
191
  ```
192
192
  ```
193
193
  #arch: aarch64_use_c
@@ -196,7 +196,7 @@ pub class TextBox : Control {
196
196
  (id)self->handle, sel_registerName("text.ptr"));
197
197
  const char *cstr = ((const char*(*)(id, SEL))objc_msgSend)(
198
198
  str, sel_registerName("UTF8String"));
199
- return strdup(cstr);
199
+ return (nomen_string){ strdup(cstr), (long)strlen(cstr) };
200
200
  ```
201
201
  }
202
202
 
@@ -22,7 +22,7 @@ pub class Window: Control {
22
22
  ((id(*)(id, SEL, id))objc_msgSend)(
23
23
  win, sel_registerName("setTitle:"),
24
24
  ((id(*)(id, SEL, const char*))objc_msgSend)(
25
- (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title));
25
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
26
26
  ((void(*)(id, SEL, double, double))objc_msgSend)(
27
27
  win, sel_registerName("setFrameTopLeftPoint:"), 100.0, 100.0);
28
28
  ((void(*)(id, SEL, id))objc_msgSend)(win, sel_registerName("makeKeyAndOrderFront:"), (id)0);
@@ -115,7 +115,7 @@ pub class Window: Control {
115
115
  ((id(*)(id, SEL, id))objc_msgSend)(
116
116
  (id)self->handle, sel_registerName("setTitle:"),
117
117
  ((id(*)(id, SEL, const char*))objc_msgSend)(
118
- (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title));
118
+ (id)objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), title.ptr));
119
119
  ```
120
120
  ```
121
121
  #arch: aarch64_use_c
@@ -16,8 +16,8 @@ pub struct Graph<T>: Enumerable {
16
16
 
17
17
  pub func add_node = (ref self, move T value) {
18
18
  var int idx = self.node_count
19
- self.values.grow_T(idx + 1)
20
- self.values.store_T(idx, value)
19
+ self.values.grow(idx + 1)
20
+ self.values.store(idx, value)
21
21
  self.head_edge.grow_int(idx + 1)
22
22
  self.head_edge.store_int(idx, -1)
23
23
  self.node_count = self.node_count + 1
@@ -50,11 +50,11 @@ pub struct Graph<T>: Enumerable {
50
50
  }
51
51
 
52
52
  pub func first = (self: self.node_count > 0, out T) {
53
- return self.values.load_T(0)
53
+ return self.values.load(0)
54
54
  }
55
55
 
56
56
  pub func at = (self, int idx: idx >= 0 && idx < self.node_count, out T) {
57
- return self.values.load_T(idx)
57
+ return self.values.load(idx)
58
58
  }
59
59
 
60
60
  pub func node_length = (self, out int) {
@@ -15,8 +15,8 @@ pub struct LinkedList<T>: Enumerable {
15
15
 
16
16
  pub func add = (ref self, move T value) {
17
17
  var int idx = self.count
18
- self.values.grow_T(idx + 1)
19
- self.values.store_T(idx, value)
18
+ self.values.grow(idx + 1)
19
+ self.values.store(idx, value)
20
20
  self.nexts.grow_int(idx + 1)
21
21
  self.nexts.store_int(idx, -1)
22
22
  self.prevs.grow_int(idx + 1)
@@ -50,11 +50,11 @@ pub struct LinkedList<T>: Enumerable {
50
50
  }
51
51
 
52
52
  pub func first = (self: self.count > 0, out T) {
53
- return self.values.load_T(0)
53
+ return self.values.load(0)
54
54
  }
55
55
 
56
56
  pub func at = (self, int idx: idx >= 0 && idx < self.count, out T) {
57
- return self.values.load_T(idx)
57
+ return self.values.load(idx)
58
58
  }
59
59
 
60
60
  // Bounds-checked access: `fallback` when idx is outside [0, self.count).
@@ -12,23 +12,23 @@ pub struct List<T>: Viewable {
12
12
  if old_cap >= 4 {
13
13
  new_cap = old_cap * 2
14
14
  }
15
- self.items.grow_T(new_cap)
15
+ self.items.grow(new_cap)
16
16
  }
17
- self.items.store_T(self.length, value)
17
+ self.items.store(self.length, value)
18
18
  self.length += 1
19
19
  }
20
20
 
21
21
  pub func pop = (ref self, move out T) {
22
22
  if self.length <= 0 {
23
- return self.items.move_T(0)
23
+ return self.items.move(0)
24
24
  }
25
25
  var int idx = self.length - 1
26
26
  self.length = idx
27
- return self.items.move_T(idx)
27
+ return self.items.move(idx)
28
28
  }
29
29
 
30
30
  pub inline func at = (self, int i: i >= 0 && i < self.length, out T) {
31
- return self.items.load_T(i)
31
+ return self.items.load(i)
32
32
  }
33
33
 
34
34
  // Bounds-checked access: `fallback` when i is outside [0, self.length) —
@@ -58,7 +58,7 @@ pub struct List<T>: Viewable {
58
58
  }
59
59
 
60
60
  pub func set = (ref self, int i: i >= 0 && i < self.length, move T value) {
61
- self.items.replace_T(i, value)
61
+ self.items.replace(i, value)
62
62
  }
63
63
 
64
64
  // A deep copy: a fresh List<T> with an independent copy of every element.