nomen-lang 0.8.0 → 0.10.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.
- package/audit_runtime.c +12 -2
- package/core/System/Arena.nm +14 -5
- package/core/System/Array.nm +1 -1
- package/core/System/Atomic.nm +3 -3
- package/core/System/BigInt.nm +182 -23
- package/core/System/Buffer.nm +392 -33
- package/core/System/ClassBuffer.nm +145 -13
- package/core/System/Controls/Alert.nm +3 -3
- package/core/System/Controls/App.nm +17 -17
- package/core/System/Controls/Button.nm +2 -2
- package/core/System/Controls/CheckBox.nm +3 -3
- package/core/System/Controls/ColorPicker.nm +2 -2
- package/core/System/Controls/ComboBox.nm +2 -2
- package/core/System/Controls/Container.nm +39 -33
- package/core/System/Controls/DatePicker.nm +1 -1
- package/core/System/Controls/Form.nm +2 -2
- package/core/System/Controls/GroupBox.nm +2 -2
- package/core/System/Controls/ImageView.nm +2 -2
- package/core/System/Controls/Layout.nm +5 -5
- package/core/System/Controls/LevelIndicator.nm +2 -2
- package/core/System/Controls/ListView.nm +2 -2
- package/core/System/Controls/Menu.nm +2 -2
- package/core/System/Controls/NumberInput.nm +3 -3
- package/core/System/Controls/OtpInput.nm +2 -2
- package/core/System/Controls/OutlineView.nm +2 -2
- package/core/System/Controls/Pagination.nm +14 -14
- package/core/System/Controls/Popover.nm +2 -2
- package/core/System/Controls/Progress.nm +2 -2
- package/core/System/Controls/Radio.nm +3 -3
- package/core/System/Controls/Scrollable.nm +1 -1
- package/core/System/Controls/SearchField.nm +2 -2
- package/core/System/Controls/SecureField.nm +2 -2
- package/core/System/Controls/Segmented.nm +2 -2
- package/core/System/Controls/Select.nm +2 -2
- package/core/System/Controls/Separator.nm +2 -2
- package/core/System/Controls/Sheet.nm +2 -2
- package/core/System/Controls/Slider.nm +2 -2
- package/core/System/Controls/Spinner.nm +5 -5
- package/core/System/Controls/SplitView.nm +3 -3
- package/core/System/Controls/Stepper.nm +2 -2
- package/core/System/Controls/Switch.nm +2 -2
- package/core/System/Controls/Table.nm +2 -2
- package/core/System/Controls/Tabs.nm +2 -2
- package/core/System/Controls/Text.nm +2 -2
- package/core/System/Controls/TextBox.nm +3 -3
- package/core/System/Controls/TextView.nm +2 -2
- package/core/System/Controls/Toggle.nm +3 -3
- package/core/System/Controls/Toolbar.nm +2 -2
- package/core/System/Controls/Window.nm +12 -5
- package/core/System/Fiber.nm +16 -3
- package/core/System/Graph.nm +2 -2
- package/core/System/LinkedList.nm +13 -4
- package/core/System/List.nm +76 -17
- package/core/System/Map.nm +179 -21
- package/core/System/Mutex.nm +4 -4
- package/core/System/Random.nm +6 -7
- package/core/System/Set.nm +99 -23
- package/core/System/StableList.nm +371 -0
- package/core/System/Stream/Directory.nm +2 -2
- package/core/System/Stream/File.nm +18 -18
- package/core/System/Stream/Http.nm +5 -5
- package/core/System/Stream/Tcp.nm +5 -5
- package/core/System/String.nm +10 -5
- package/core/System/StringBuilder.nm +223 -12
- package/core/System/Task.nm +56 -64
- package/core/System/Test.nm +18 -18
- package/core/System/Text/CharIndex.nm +9 -9
- package/core/System/Text/Chars.nm +1 -1
- package/core/System/Text/Json.nm +72 -58
- package/core/System/Text/JsonTree.nm +126 -98
- package/core/System/Text/Regex.nm +43 -38
- package/core/System/Text/Utf8.nm +5 -5
- package/core/System/Thread.nm +26 -3
- package/core/System/Tree.nm +19 -3
- package/core/System/float.nm +36 -22
- package/core/System/int.nm +80 -28
- package/core/System/int16.nm +11 -0
- package/core/System/int32.nm +11 -0
- package/core/System/int64.nm +11 -0
- package/core/System/int8.nm +11 -0
- package/core/System/uint.nm +11 -0
- package/core/System/uint16.nm +11 -0
- package/core/System/uint32.nm +11 -0
- package/core/System/uint64.nm +11 -0
- package/core/System/uint8.nm +11 -0
- package/core/docs/System/StringBuilder.md +6 -0
- package/core/docs/System/Text/JsonTree.md +3 -2
- package/dist/index.mjs +37622 -30603
- package/package.json +1 -1
- package/src/bench_loop.nm +9 -9
|
@@ -12,7 +12,7 @@ pub struct ClassBuffer<T> {
|
|
|
12
12
|
// Publicly readable; grown only by ClassBuffer's own methods (`readonly`).
|
|
13
13
|
readonly cap = 0
|
|
14
14
|
|
|
15
|
-
internal func alloc_int = (ref self, int size, out int: out >= size) {
|
|
15
|
+
internal func alloc_int = (ref self {}, int size, out int: out >= size) {
|
|
16
16
|
self.cap = size
|
|
17
17
|
self.data = calloc(size, 8)
|
|
18
18
|
return self.cap
|
|
@@ -25,11 +25,11 @@ pub struct ClassBuffer<T> {
|
|
|
25
25
|
// element types to Buffer and class/trait elements to ClassBuffer
|
|
26
26
|
// (monomorphize's field rewrite), so a call arriving HERE is always
|
|
27
27
|
// pointer-sized: delegate to alloc_int.
|
|
28
|
-
func alloc = (ref self, int size, out int: out >= size) {
|
|
28
|
+
func alloc = (ref self {}, int size, out int: out >= size) {
|
|
29
29
|
return self.alloc_int(size)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
internal func grow_int = (ref self, int needed, out int: out >= needed) {
|
|
32
|
+
internal func grow_int = (ref self {}, int needed, out int: out >= needed) {
|
|
33
33
|
if self.cap >= needed {
|
|
34
34
|
return self.cap
|
|
35
35
|
}
|
|
@@ -65,7 +65,7 @@ pub struct ClassBuffer<T> {
|
|
|
65
65
|
// handles, so the slot's CONTENT is the instance pointer: return the
|
|
66
66
|
// stored word, not the slot's address. Library-internal: bounds are the
|
|
67
67
|
// caller's obligation (the List wrapper constrains them).
|
|
68
|
-
|
|
68
|
+
internal func slot_ptr = (ref self {}, int i, out ptr T) {
|
|
69
69
|
```
|
|
70
70
|
#arch: c
|
|
71
71
|
// The slot's address: through the alias, reads and writes hit the
|
|
@@ -89,7 +89,7 @@ pub struct ClassBuffer<T> {
|
|
|
89
89
|
// (Buffer) or a class (ClassBuffer, after the Buffer<T> field is
|
|
90
90
|
// rewritten). Bodies use 8-byte slots, matching _int.
|
|
91
91
|
|
|
92
|
-
func grow = (ref self, int needed, out int: out >= needed) {
|
|
92
|
+
func grow = (ref self {}, int needed, out int: out >= needed) {
|
|
93
93
|
if self.cap >= needed {
|
|
94
94
|
return self.cap
|
|
95
95
|
}
|
|
@@ -118,6 +118,15 @@ pub struct ClassBuffer<T> {
|
|
|
118
118
|
```
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
+
// Labeled delegation point for raw-body callers in other containers
|
|
122
|
+
// (StableList's chunked storage calls this): `load` is `inline` — spliced
|
|
123
|
+
// at Nomen call sites, so no label exists for a raw C call or `bl` to
|
|
124
|
+
// target. Mirror of Buffer.load_from (class slots are pointer words —
|
|
125
|
+
// the pointer load IS the borrow form).
|
|
126
|
+
internal func load_from = (self, int i: i >= 0 && i < self.cap, out T) {
|
|
127
|
+
return self.load(i)
|
|
128
|
+
}
|
|
129
|
+
|
|
121
130
|
// Store the owned class pointer `val` into slot `i`, which MUST be fresh
|
|
122
131
|
// (calloc'd, or zeroed by mv/move_int). Takes OWNERSHIP of `val`
|
|
123
132
|
// (`mv`): the slot's #destroy reclaims the instance, so the caller must
|
|
@@ -127,7 +136,7 @@ pub struct ClassBuffer<T> {
|
|
|
127
136
|
// slot's previous occupant, so a second `store` at an occupied index
|
|
128
137
|
// leaks that instance. Use replace (or replace_int) to overwrite a live
|
|
129
138
|
// slot.
|
|
130
|
-
internal inline func store = (ref self, int i: i >= 0 && i < self.cap, mv T val: val != 0) {
|
|
139
|
+
internal inline func store = (ref self {}, int i: i >= 0 && i < self.cap, mv T val: val != 0) {
|
|
131
140
|
```
|
|
132
141
|
#arch: c
|
|
133
142
|
((long*)(unsigned long long)self->data)[i] = (long)val;
|
|
@@ -141,6 +150,42 @@ pub struct ClassBuffer<T> {
|
|
|
141
150
|
```
|
|
142
151
|
}
|
|
143
152
|
|
|
153
|
+
// Initialize this buffer as a VIEW over a foreign slab (INTERNAL — the
|
|
154
|
+
// chunked-container primitive): `data` becomes `slab` and `cap` becomes
|
|
155
|
+
// `fill`, and the buffer owns NOTHING — the slab keeps its real owner
|
|
156
|
+
// (never grown, never freed by the view). Mirror of Buffer.init_view;
|
|
157
|
+
// class slots are pointer words.
|
|
158
|
+
internal func init_view = (ref self {}, uint64 slab, int fill: fill >= 0) {
|
|
159
|
+
self.data = slab
|
|
160
|
+
self.cap = fill
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Clear a view initialized by init_view (see Buffer.clear_view): the
|
|
164
|
+
// holder's own field destroy then reclaims nothing.
|
|
165
|
+
internal func clear_view = (ref self {}) {
|
|
166
|
+
self.data = 0
|
|
167
|
+
self.cap = 0
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Store the owned class pointer `val` into slot `slot` of a foreign slab
|
|
171
|
+
// at `slab` (fill `fill`) through this buffer as a transient view —
|
|
172
|
+
// INTERNAL (StableList's directory chunks, class elements): init the
|
|
173
|
+
// view, run the typed `store` (the ownership-transferring slot store),
|
|
174
|
+
// then clear the view so the holder's teardown reclaims nothing. The
|
|
175
|
+
// holder passes a ClassBuffer FIELD, never a local (a local owning buffer
|
|
176
|
+
// is auto-destroyed at scope exit and would free the borrowed slab).
|
|
177
|
+
internal func store_in_slab = (
|
|
178
|
+
ref self {},
|
|
179
|
+
uint64 slab,
|
|
180
|
+
int fill: fill >= 0,
|
|
181
|
+
int slot: slot >= 0,
|
|
182
|
+
mv T val
|
|
183
|
+
) {
|
|
184
|
+
self.init_view(slab, fill)
|
|
185
|
+
self.store(slot, val)
|
|
186
|
+
self.clear_view()
|
|
187
|
+
}
|
|
188
|
+
|
|
144
189
|
// Move a class pointer out of a slot: return it and zero the slot so the
|
|
145
190
|
// buffer no longer references it. Declared `mv out T` so the borrow
|
|
146
191
|
// checker treats the result as OWNED — the slot is relinquished, so the
|
|
@@ -149,7 +194,7 @@ pub struct ClassBuffer<T> {
|
|
|
149
194
|
// out of a ClassBuffer slot, or moving a value into a fresh mv
|
|
150
195
|
// container — load returns a BORROW (the slot is unchanged) and storing
|
|
151
196
|
// it elsewhere would create shared ownership (double-free at destroy).
|
|
152
|
-
inline func move = (ref self, int i: i >= 0 && i < self.cap, mv out T) {
|
|
197
|
+
inline func move = (ref self {}, int i: i >= 0 && i < self.cap, mv out T) {
|
|
153
198
|
```
|
|
154
199
|
#arch: c
|
|
155
200
|
long *slots = (long*)(unsigned long long)self->data;
|
|
@@ -180,7 +225,7 @@ pub struct ClassBuffer<T> {
|
|
|
180
225
|
// free). Storing the returned instance raw is sound: the slot takes
|
|
181
226
|
// sole ownership and `f`'s return is not retained elsewhere. NOT
|
|
182
227
|
// `inline`: the body calls through the fn pointer.
|
|
183
|
-
func modify = (ref self, int i: i >= 0 && i < self.cap, func(T, out T) f) {
|
|
228
|
+
func modify = (ref self {}, int i: i >= 0 && i < self.cap, func(T, out T) f) {
|
|
184
229
|
```
|
|
185
230
|
#arch: c
|
|
186
231
|
long *slots = (long*)(unsigned long long)self->data;
|
|
@@ -213,7 +258,7 @@ pub struct ClassBuffer<T> {
|
|
|
213
258
|
```
|
|
214
259
|
}
|
|
215
260
|
|
|
216
|
-
internal inline func store_int = (ref self, int i: i >= 0 && i < self.cap, int val: val != 0) {
|
|
261
|
+
internal inline func store_int = (ref self {}, int i: i >= 0 && i < self.cap, int val: val != 0) {
|
|
217
262
|
```
|
|
218
263
|
#arch: c
|
|
219
264
|
((long*)(unsigned long long)self->data)[i] = val;
|
|
@@ -227,7 +272,7 @@ pub struct ClassBuffer<T> {
|
|
|
227
272
|
```
|
|
228
273
|
}
|
|
229
274
|
|
|
230
|
-
internal inline func move_int = (ref self, int i: i >= 0 && i < self.cap, out int) {
|
|
275
|
+
internal inline func move_int = (ref self {}, int i: i >= 0 && i < self.cap, out int) {
|
|
231
276
|
```
|
|
232
277
|
#arch: c
|
|
233
278
|
long *slots = (long*)(unsigned long long)self->data;
|
|
@@ -247,7 +292,7 @@ pub struct ClassBuffer<T> {
|
|
|
247
292
|
|
|
248
293
|
// Store into a slot, freeing the previous value (it is an owned class
|
|
249
294
|
// pointer): run its destroy then free it before overwriting.
|
|
250
|
-
internal func replace_int = (ref self, int i: i >= 0 && i < self.cap, int val: val != 0) {
|
|
295
|
+
internal func replace_int = (ref self {}, int i: i >= 0 && i < self.cap, int val: val != 0) {
|
|
251
296
|
```
|
|
252
297
|
#arch: c
|
|
253
298
|
long *slots = (long*)(unsigned long long)self->data;
|
|
@@ -278,12 +323,46 @@ pub struct ClassBuffer<T> {
|
|
|
278
323
|
```
|
|
279
324
|
}
|
|
280
325
|
|
|
326
|
+
// Reclaim slot i's owned class pointer (destroy + free) WITHOUT writing
|
|
327
|
+
// the slot — the destroy half of replace_int, without the store, zeroing
|
|
328
|
+
// the handle so a re-destroy is a no-op. The caller (Map.set_slot_ptr's
|
|
329
|
+
// replace path — the value-side sibling of `values.replace`) overwrites
|
|
330
|
+
// the slot immediately afterwards. Contract: the slot must be
|
|
331
|
+
// overwritten before it is read or destroyed again.
|
|
332
|
+
internal func destroy_at = (ref self {}, int i: i >= 0 && i < self.cap) {
|
|
333
|
+
```
|
|
334
|
+
#arch: c
|
|
335
|
+
long *slots = (long*)(unsigned long long)self->data;
|
|
336
|
+
if (slots[i]) {
|
|
337
|
+
T_destroy((void*)slots[i]);
|
|
338
|
+
free((void*)slots[i]);
|
|
339
|
+
slots[i] = 0;
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
```
|
|
343
|
+
#arch: aarch64
|
|
344
|
+
stp x20, x21, [sp, #-16]!
|
|
345
|
+
ldr x20, [x19, #8]
|
|
346
|
+
lsl x3, x1, #3
|
|
347
|
+
add x20, x20, x3
|
|
348
|
+
ldr x0, [x20]
|
|
349
|
+
cbz x0, .Lcb_destroy_at_done
|
|
350
|
+
mov x21, x0
|
|
351
|
+
bl T_destroy
|
|
352
|
+
mov x0, x21
|
|
353
|
+
bl _free
|
|
354
|
+
str xzr, [x20]
|
|
355
|
+
.Lcb_destroy_at_done:
|
|
356
|
+
ldp x20, x21, [sp], #16
|
|
357
|
+
```
|
|
358
|
+
}
|
|
359
|
+
|
|
281
360
|
// T-typed alias of replace_int: free the outgoing class pointer (destroy +
|
|
282
361
|
// free) then store the new one. Used by List.set so the uniform API
|
|
283
362
|
// preserves ownership for class elements.
|
|
284
363
|
// Overwrite a live slot: destroy + free the displaced instance, then take
|
|
285
364
|
// OWNERSHIP of `val` (`mv`) — same transfer rule as store.
|
|
286
|
-
func replace = (ref self, int i: i >= 0 && i < self.cap, mv T val: val != 0) {
|
|
365
|
+
func replace = (ref self {}, int i: i >= 0 && i < self.cap, mv T val: val != 0) {
|
|
287
366
|
```
|
|
288
367
|
#arch: c
|
|
289
368
|
long *slots = (long*)(unsigned long long)self->data;
|
|
@@ -320,7 +399,7 @@ pub struct ClassBuffer<T> {
|
|
|
320
399
|
// used by Map/Set.remove's backward-shift so shifting entries neither
|
|
321
400
|
// duplicates nor orphans owned instances.
|
|
322
401
|
func shift = (
|
|
323
|
-
ref self,
|
|
402
|
+
ref self {},
|
|
324
403
|
int dst: dst >= 0 && dst < self.cap,
|
|
325
404
|
int src: src >= 0 && src < self.cap
|
|
326
405
|
) {
|
|
@@ -363,6 +442,59 @@ pub struct ClassBuffer<T> {
|
|
|
363
442
|
```
|
|
364
443
|
}
|
|
365
444
|
|
|
445
|
+
// Bulk transfer for backward-shift deletion — the ClassBuffer
|
|
446
|
+
// counterpart of Buffer.move_range (same contract: every slot in
|
|
447
|
+
// [dst, dst + count) must be DEAD — zeroed by a move-out or otherwise
|
|
448
|
+
// unowned — because the block move overwrites without reclaiming; the
|
|
449
|
+
// deletion algorithms zero and relocate in lockstep). Slots are 8-byte
|
|
450
|
+
// instance pointers, so the block is one memmove + one memset of the
|
|
451
|
+
// source slots the destination never covers — List.remove_at_or_panic's
|
|
452
|
+
// whole-tail shift instead of per-element `shift` calls.
|
|
453
|
+
internal inline func move_range = (
|
|
454
|
+
ref self {},
|
|
455
|
+
int dst: dst >= 0,
|
|
456
|
+
int src: src >= dst,
|
|
457
|
+
int count: count >= 0 && src + count <= self.cap
|
|
458
|
+
) {
|
|
459
|
+
```
|
|
460
|
+
#arch: c
|
|
461
|
+
if (count > 0) {
|
|
462
|
+
long *slots = (long*)(unsigned long long)self->data;
|
|
463
|
+
memmove((void*)&slots[dst], (void*)&slots[src],
|
|
464
|
+
(unsigned long long)count * sizeof(long));
|
|
465
|
+
memset((void*)&slots[dst + count], 0,
|
|
466
|
+
(unsigned long long)(src - dst) * sizeof(long));
|
|
467
|
+
}
|
|
468
|
+
```
|
|
469
|
+
```
|
|
470
|
+
#arch: aarch64
|
|
471
|
+
// x19 = self, x1 = dst, x2 = src, x3 = count. x0-x18 die across the
|
|
472
|
+
// bl calls, so the block math parks on the stack around _memmove.
|
|
473
|
+
cbz x3, .Lcb_move_range_T_end
|
|
474
|
+
ldr x4, [x19, #8]
|
|
475
|
+
lsl x5, x1, #3
|
|
476
|
+
add x6, x4, x5
|
|
477
|
+
lsl x5, x2, #3
|
|
478
|
+
add x7, x4, x5
|
|
479
|
+
lsl x9, x3, #3
|
|
480
|
+
sub x10, x2, x1
|
|
481
|
+
lsl x10, x10, #3
|
|
482
|
+
stp x6, x9, [sp, #-16]!
|
|
483
|
+
str x10, [sp, #-16]!
|
|
484
|
+
mov x0, x6
|
|
485
|
+
mov x1, x7
|
|
486
|
+
mov x2, x9
|
|
487
|
+
bl _memmove
|
|
488
|
+
ldr x10, [sp], #16
|
|
489
|
+
ldp x6, x9, [sp], #16
|
|
490
|
+
add x0, x6, x9
|
|
491
|
+
mov x1, #0
|
|
492
|
+
mov x2, x10
|
|
493
|
+
bl _memset
|
|
494
|
+
.Lcb_move_range_T_end:
|
|
495
|
+
```
|
|
496
|
+
}
|
|
497
|
+
|
|
366
498
|
// A non-mv (ptr, len) slice [start, end) over this buffer's class
|
|
367
499
|
// pointers, returned as a `view T` (T is a class, so each element is an
|
|
368
500
|
// 8-byte pointer). Borrows from self — invalidated on reassignment. Mirrors
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
* UIAlertController needs a presenting view controller (TODO stubs; see
|
|
13
13
|
* GUI_PLAN Tier 1 #19).
|
|
14
14
|
**/
|
|
15
|
-
pub mv struct Alert
|
|
15
|
+
pub mv struct Alert: Control {
|
|
16
16
|
var uint64 handle = 0
|
|
17
17
|
|
|
18
18
|
// The `#handle` hook synthesizes `NameHandle` — a copyable, non-owning
|
|
19
19
|
// twin (same public bare-self methods, no destroy) so closures can
|
|
20
20
|
// capture this control without moving it. See GUI.md, "Handles".
|
|
21
|
-
#handle = () {}
|
|
21
|
+
#handle = () { }
|
|
22
22
|
|
|
23
23
|
pub func #init = (self) {
|
|
24
24
|
```
|
|
@@ -281,7 +281,7 @@ pub mv struct Alert : Control {
|
|
|
281
281
|
// An alert is a modal, not an in-window view: it measures to nothing and
|
|
282
282
|
// the layout engine never frames it. The conformance exists so an Alert
|
|
283
283
|
// can sit in a Control-typed slot without special-casing.
|
|
284
|
-
pub func set_frame = (ref self, int x, int y, int width, int height) {
|
|
284
|
+
pub func set_frame = (ref self {}, int x, int y, int width, int height) {
|
|
285
285
|
// No-op: modals are positioned by the window server.
|
|
286
286
|
}
|
|
287
287
|
|
|
@@ -51,11 +51,11 @@
|
|
|
51
51
|
pub trait App {
|
|
52
52
|
// Called once before the window is shown, after the app is in its
|
|
53
53
|
// final storage. Register layout roots here.
|
|
54
|
-
func start = (ref self, ref Window win) {
|
|
54
|
+
func start = (ref self, ref Window win {}) {
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// Called every frame until the window closes.
|
|
58
|
-
func frame = (ref self, ref Window win, FrameEvents ev) {
|
|
58
|
+
func frame = (ref self, ref Window win {}, FrameEvents ev) {
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// The per-frame event pump: drains every registered control event —
|
|
@@ -67,7 +67,7 @@ pub trait App {
|
|
|
67
67
|
// in this one slot — the App contract never grows with the event
|
|
68
68
|
// catalog. Conformers without registrations inherit this empty default
|
|
69
69
|
// (trait defaults have precedent: `Enumerable.length`).
|
|
70
|
-
func handle_events = (ref self, ref Window win) {
|
|
70
|
+
func handle_events = (ref self, ref Window win {}) {
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
// The up-call protocol (docs/HANDLERS.md Stage 3): a composite the app
|
|
@@ -76,7 +76,7 @@ pub trait App {
|
|
|
76
76
|
// synthesized override, whose arms dispatch the id to the app's handler.
|
|
77
77
|
// The borrow flows down per call; nothing outlives it. Default-empty,
|
|
78
78
|
// like `handle_events`.
|
|
79
|
-
func run_handler = (ref self, int id, ref Window win) {
|
|
79
|
+
func run_handler = (ref self, int id, ref Window win {}) {
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// Close interception (the unsaved-changes pattern): run consults this
|
|
@@ -86,7 +86,7 @@ pub trait App {
|
|
|
86
86
|
// close request consults again. Programmatic `win.close()` is FORCED
|
|
87
87
|
// and bypasses this — handlers closing their own window never trip the
|
|
88
88
|
// interception. Default: allow.
|
|
89
|
-
func close_requested = (ref self, ref Window win, out bool) {
|
|
89
|
+
func close_requested = (ref self, ref Window win {}, out bool) {
|
|
90
90
|
return true
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -102,7 +102,7 @@ pub trait App {
|
|
|
102
102
|
pub mv struct FrameEvents {
|
|
103
103
|
// 0 = no mouse-down this frame, 1 = left, 2 = right (edge-triggered:
|
|
104
104
|
// only the frame that pumped the event reports it).
|
|
105
|
-
pub var
|
|
105
|
+
pub var click = 0
|
|
106
106
|
pub var int click_x = -1
|
|
107
107
|
pub var int click_y = -1
|
|
108
108
|
// The full mouse record for this frame (0 = no mouse-down): the 1-based
|
|
@@ -112,14 +112,14 @@ pub mv struct FrameEvents {
|
|
|
112
112
|
// 0x40000, Shift = 0x20000). The same values the `win.mouse_button()` /
|
|
113
113
|
// `mouse_click_count()` / `mouse_modifiers()` getters report to
|
|
114
114
|
// `on_mouse_down` handlers. `click` remains the left/right compat view.
|
|
115
|
-
pub var
|
|
116
|
-
pub var
|
|
117
|
-
pub var
|
|
115
|
+
pub var mouse_button = 0
|
|
116
|
+
pub var mouse_click_count = 0
|
|
117
|
+
pub var mouse_modifiers = 0
|
|
118
118
|
// This frame's accumulated scroll-wheel deltas (dy positive scrolling
|
|
119
119
|
// up/away, dx positive right; trackpad frames sum every small event).
|
|
120
120
|
// `Scrollable.on_scroll` is the registered-handler form.
|
|
121
|
-
pub var
|
|
122
|
-
pub var
|
|
121
|
+
pub var scroll_dx = 0
|
|
122
|
+
pub var scroll_dy = 0
|
|
123
123
|
// The keyboard record for this frame (-1 = no key this frame): the
|
|
124
124
|
// hardware keycode of the last key-down (Space = 49, Return = 36,
|
|
125
125
|
// arrows = 123–126, letters a…z = 0–25), the modifiers at key-down,
|
|
@@ -127,8 +127,8 @@ pub mv struct FrameEvents {
|
|
|
127
127
|
// `on_key_down` / `on_key_up` are the registered-handler forms; text
|
|
128
128
|
// ENTRY flows through `on_input` (the field editor), not here.
|
|
129
129
|
pub var int key_code = -1
|
|
130
|
-
pub var
|
|
131
|
-
pub var
|
|
130
|
+
pub var key_modifiers = 0
|
|
131
|
+
pub var key_repeat = false
|
|
132
132
|
pub var int key_up_code = -1
|
|
133
133
|
// The pointer-MOVE record for this frame (-1 = no movement): the
|
|
134
134
|
// current pointer position. `on_mouse_move` is the registered-handler
|
|
@@ -137,11 +137,11 @@ pub mv struct FrameEvents {
|
|
|
137
137
|
pub var int mouse_y = -1
|
|
138
138
|
// Milliseconds since the previous frame (0 on the first) — the
|
|
139
139
|
// animation clock. `win.dt()` reports the same value.
|
|
140
|
-
pub var
|
|
140
|
+
pub var dt = 0
|
|
141
141
|
// True when the window's content rect changed since the last frame —
|
|
142
142
|
// the framework has already re-laid-out the registered roots; re-layout
|
|
143
143
|
// App-owned panes (tab pages, split panes) here.
|
|
144
|
-
pub var
|
|
145
|
-
pub var
|
|
146
|
-
pub var
|
|
144
|
+
pub var resized = false
|
|
145
|
+
pub var width = 0
|
|
146
|
+
pub var height = 0
|
|
147
147
|
}
|
|
@@ -12,7 +12,7 @@ pub mv struct Button: Control {
|
|
|
12
12
|
// The `#handle` hook synthesizes `NameHandle` — a copyable, non-owning
|
|
13
13
|
// twin (same public bare-self methods, no destroy) so closures can
|
|
14
14
|
// capture this control without moving it. See GUI.md, "Handles".
|
|
15
|
-
#handle = () {}
|
|
15
|
+
#handle = () { }
|
|
16
16
|
|
|
17
17
|
pub func #init = (self, Window window, string title) {
|
|
18
18
|
```
|
|
@@ -99,7 +99,7 @@ pub mv struct Button: Control {
|
|
|
99
99
|
```
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
pub func set_frame = (ref self, int x, int y, int width, int height) {
|
|
102
|
+
pub func set_frame = (ref self {}, int x, int y, int width, int height) {
|
|
103
103
|
```
|
|
104
104
|
#arch: c
|
|
105
105
|
#platform: macos
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
* `#destroy` releases what the handle names. The constructor's `self` is
|
|
7
7
|
* the inline instance (the `.` accessor); methods keep the pointer form.
|
|
8
8
|
**/
|
|
9
|
-
pub mv struct CheckBox
|
|
9
|
+
pub mv struct CheckBox: Control {
|
|
10
10
|
var uint64 handle = 0
|
|
11
11
|
|
|
12
12
|
// The `#handle` hook synthesizes `NameHandle` — a copyable, non-owning
|
|
13
13
|
// twin (same public bare-self methods, no destroy) so closures can
|
|
14
14
|
// capture this control without moving it. See GUI.md, "Handles".
|
|
15
|
-
#handle = () {}
|
|
15
|
+
#handle = () { }
|
|
16
16
|
|
|
17
17
|
pub func #init = (self, Window window) {
|
|
18
18
|
```
|
|
@@ -85,7 +85,7 @@ pub mv struct CheckBox : Control {
|
|
|
85
85
|
```
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
pub func set_frame = (ref self, int x, int y, int width, int height) {
|
|
88
|
+
pub func set_frame = (ref self {}, int x, int y, int width, int height) {
|
|
89
89
|
```
|
|
90
90
|
#arch: c
|
|
91
91
|
#platform: macos
|
|
@@ -18,7 +18,7 @@ pub struct Rgb {
|
|
|
18
18
|
* Components travel as 0-255 ints; the platform stores 0-1 doubles, so the
|
|
19
19
|
* round trip is exact to ±1 (the getters round).
|
|
20
20
|
**/
|
|
21
|
-
pub mv struct ColorPicker
|
|
21
|
+
pub mv struct ColorPicker: Control {
|
|
22
22
|
var uint64 handle = 0
|
|
23
23
|
|
|
24
24
|
pub func #init = (self, Window window) {
|
|
@@ -80,7 +80,7 @@ pub mv struct ColorPicker : Control {
|
|
|
80
80
|
```
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
pub func set_frame = (ref self, int x, int y, int width, int height) {
|
|
83
|
+
pub func set_frame = (ref self {}, int x, int y, int width, int height) {
|
|
84
84
|
```
|
|
85
85
|
#arch: c
|
|
86
86
|
#platform: macos
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* macOS-only (NSComboBox has no iOS counterpart — see GUI_PLAN Tier 2; the
|
|
13
13
|
* iOS blocks are TODO stubs).
|
|
14
14
|
**/
|
|
15
|
-
pub mv struct ComboBox
|
|
15
|
+
pub mv struct ComboBox: Control {
|
|
16
16
|
var uint64 handle = 0
|
|
17
17
|
|
|
18
18
|
pub func #init = (self, Window window) {
|
|
@@ -63,7 +63,7 @@ pub mv struct ComboBox : Control {
|
|
|
63
63
|
```
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
pub func set_frame = (ref self, int x, int y, int width, int height) {
|
|
66
|
+
pub func set_frame = (ref self {}, int x, int y, int width, int height) {
|
|
67
67
|
```
|
|
68
68
|
#arch: c
|
|
69
69
|
#platform: macos
|